@stringsync/vexml
Version:
MusicXML to Vexflow
31 lines (30 loc) • 894 B
JavaScript
import * as util from '../util';
import * as vexflow from 'vexflow';
import { Rect } from '../spatial';
export class Beam {
config;
log;
document;
key;
registry;
constructor(config, log, document, key, registry) {
this.config = config;
this.log = log;
this.document = document;
this.key = key;
this.registry = registry;
}
render() {
const beam = this.document.getBeam(this.key);
const vexflowStemmableNotes = this.registry.get(beam.id);
util.assertDefined(vexflowStemmableNotes);
util.assert(vexflowStemmableNotes.length > 1, 'Beam must have more than one voice entry');
const vexflowBeams = [new vexflow.Beam(vexflowStemmableNotes)];
return {
type: 'beam',
rect: Rect.empty(),
key: this.key,
vexflowBeams,
};
}
}