UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

57 lines (56 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Wedge = void 0; class Wedge { phase; wedgeType; placement; constructor(phase, wedgeType, placement) { this.phase = phase; this.wedgeType = wedgeType; this.placement = placement; } static create(musicXML) { let phase; switch (musicXML.wedge.getType()) { case 'crescendo': phase = 'start'; break; case 'diminuendo': phase = 'start'; break; case 'stop': phase = 'stop'; break; default: phase = 'continue'; break; } let wedgeType; switch (musicXML.wedge.getType()) { case 'crescendo': wedgeType = 'crescendo'; break; case 'diminuendo': wedgeType = 'diminuendo'; break; default: wedgeType = 'crescendo'; break; } const placement = musicXML.direction.getPlacement() ?? 'below'; return new Wedge(phase, wedgeType, placement); } getPhase() { return this.phase; } parse(voiceCtx) { if (this.phase === 'start') { voiceCtx.beginWedge(this.placement, this.wedgeType); } if (this.phase === 'stop') { voiceCtx.closeWedge(); } } } exports.Wedge = Wedge;