UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

50 lines (49 loc) 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Voice = void 0; const note_1 = require("./note"); const rest_1 = require("./rest"); class Voice { config; log; document; voiceRender; entries; constructor(config, log, document, voiceRender, entries) { this.config = config; this.log = log; this.document = document; this.voiceRender = voiceRender; this.entries = entries; } static create(config, log, document, voiceRender) { const entries = voiceRender.entryRenders .map((entryRender) => { switch (entryRender.type) { case 'note': return note_1.Note.create(config, log, document, entryRender); case 'rest': return rest_1.Rest.create(config, log, document, entryRender); default: return null; } }) .filter((entry) => entry !== null); return new Voice(config, log, document, voiceRender, entries); } /** The name of the element, which can be used as a type discriminant. */ name = 'voice'; /** Returns the bounding box of the element. */ rect() { return this.voiceRender.rect; } /** Returns the entries of the voice. */ getEntries() { return this.entries; } /** Returns the start measure beat for the voice. */ getStartMeasureBeat() { return this.voiceRender.startMeasureBeat; } } exports.Voice = Voice;