UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

53 lines (52 loc) 1.41 kB
export 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(); } } }