UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

46 lines (45 loc) 1.6 kB
import { Clef } from './clef'; import { Key } from './key'; import { Time } from './time'; import { StaveDetails } from './stavedetails'; import { MeasureStyle } from './measurestyle'; /** * Attributes contains musical information that typically changes each measure, such as key and time signatures, clefs, * transpositions and staving. * * See https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/attributes/ */ export class Attributes { element; constructor(element) { this.element = element; } /** Returns the number of staves. */ getStaveCount() { return this.element.first('staves')?.content().int() ?? null; } /** Returns the stave details. */ getStaveDetails() { return this.element.all('staff-details').map((element) => new StaveDetails(element)); } /** Returns the times. */ getTimes() { return this.element.all('time').map((element) => new Time(element)); } /** Returns the keys. */ getKeys() { return this.element.all('key').map((element) => new Key(element)); } /** Returns the clefs. */ getClefs() { return this.element.all('clef').map((element) => new Clef(element)); } /** Returns the measure styles. */ getMeasureStyles() { return this.element.all('measure-style').map((element) => new MeasureStyle(element)); } /** Returns the how many divisions per quarter note are used to indicate a note's duration. */ getQuarterNoteDivisions() { return this.element.first('divisions')?.content().int() ?? null; } }