@stringsync/vexml
Version:
MusicXML to Vexflow
25 lines (24 loc) • 717 B
JavaScript
import { KEY_MODES } from './enums';
/**
* Key represents a key signature.
*
* See https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/key/
*/
export class Key {
element;
constructor(element) {
this.element = element;
}
/** Returns the fifths count of the key. Defaults to 0. */
getFifthsCount() {
return this.element.first('fifths')?.content().int() ?? 0;
}
/** Returns the mode of the key. Defaults to 'none'. */
getMode() {
return this.element.first('mode')?.content().enum(KEY_MODES) ?? 'none';
}
/** Returns the stave number this key belongs to. */
getStaveNumber() {
return this.element.attr('number').int();
}
}