UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

48 lines (47 loc) 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Score = void 0; const system_1 = require("./system"); const idprovider_1 = require("./idprovider"); const contexts_1 = require("./contexts"); class Score { config; log; idProvider; title; partLabels; systems; constructor(config, log, idProvider, title, partLabels, systems) { this.config = config; this.log = log; this.idProvider = idProvider; this.title = title; this.partLabels = partLabels; this.systems = systems; } static create(config, log, musicXML) { const idProvider = new idprovider_1.IdProvider(); const title = musicXML.scorePartwise.getTitle(); const partLabels = musicXML.scorePartwise.getPartDetails().map((p) => p.name); // When parsing, we'll assume that there is only one system. Pre-rendering determines the minimum needed widths for // each element. We can then use this information to determine the number of systems needed to fit a constrained // width if needed. const systems = [system_1.System.create(config, log, { scorePartwise: musicXML.scorePartwise })]; return new Score(config, log, idProvider, title, partLabels, systems); } parse() { const scoreCtx = new contexts_1.ScoreContext(this.idProvider); return { type: 'score', title: this.title, partLabels: this.partLabels, systems: this.systems.map((s) => s.parse(scoreCtx)), curves: scoreCtx.getCurves(), wedges: scoreCtx.getWedges(), pedals: scoreCtx.getPedals(), octaveShifts: scoreCtx.getOctaveShifts(), vibratos: scoreCtx.getVibratos(), }; } } exports.Score = Score;