UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

46 lines (45 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OctaveShift = void 0; 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(); } } } exports.OctaveShift = OctaveShift;