UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

31 lines (30 loc) 1 kB
import { TextStateMachine } from './textstatemachine'; export class Annotation { config; log; text; horizontalJustification; verticalJustification; constructor(config, log, text, horizontalJustification, verticalJustification) { this.config = config; this.log = log; this.text = text; this.horizontalJustification = horizontalJustification; this.verticalJustification = verticalJustification; } static fromLyric(config, log, musicXML) { const machine = new TextStateMachine(); for (const component of musicXML.lyric.getComponents()) { machine.process(component); } return new Annotation(config, log, machine.getText(), 'center', 'bottom'); } parse() { return { type: 'annotation', text: this.text, horizontalJustification: this.horizontalJustification, verticalJustification: this.verticalJustification, }; } }