UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

34 lines (33 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Part = void 0; const stave_1 = require("./stave"); const contexts_1 = require("./contexts"); class Part { id; signature; staves; constructor(config, log, id, signature, staves) { this.id = id; this.signature = signature; this.staves = staves; } static create(config, log, id, signature, events) { const staves = new Array(); const staveCount = signature.getStaveCount(id).getValue(); for (let staveNumber = 1; staveNumber <= staveCount; staveNumber++) { const stave = stave_1.Stave.create(config, log, staveNumber, id, signature, events.filter((e) => e.staveNumber === staveNumber)); staves.push(stave); } return new Part(config, log, id, signature, staves); } parse(fragmentCtx) { const partCtx = new contexts_1.PartContext(fragmentCtx, this.id); return { type: 'part', signature: this.signature.asPartSignature(this.id).parse(), staves: this.staves.map((stave) => stave.parse(partCtx)), }; } } exports.Part = Part;