UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

42 lines (41 loc) 1.09 kB
export class OctaveShift { config; log; phase; size; constructor(config, log, phase, size) { this.config = config; this.log = log; this.phase = phase; this.size = size; } static create(config, log, musicXML) { const type = musicXML.octaveShift.getType(); const factor = type === 'down' ? -1 : 1; const size = factor * musicXML.octaveShift.getSize(); let phase; switch (type) { case 'down': phase = 'start'; break; case 'up': phase = 'start'; break; case 'stop': phase = 'stop'; break; default: phase = 'continue'; break; } return new OctaveShift(config, log, phase, size); } parse(voiceCtx) { if (this.phase === 'start') { voiceCtx.beginOctaveShift(this.size); } if (this.phase === 'stop') { voiceCtx.closeOctaveShift(); } } }