UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

30 lines (29 loc) 1.05 kB
import { Stave } from './stave'; import { PartContext } from './contexts'; export 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.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 PartContext(fragmentCtx, this.id); return { type: 'part', signature: this.signature.asPartSignature(this.id).parse(), staves: this.staves.map((stave) => stave.parse(partCtx)), }; } }