@stringsync/vexml
Version:
MusicXML to Vexflow
29 lines (28 loc) • 966 B
JavaScript
import { CLEF_SIGNS } from './enums';
/**
* A symbol placed at the left-hand end of the stave, indicating the pitch of the notes written.
*
* See https://www.w3.org/2021/06/musicxml40/musicxml-reference/data-types/clef-sign/
*/
export class Clef {
element;
constructor(element) {
this.element = element;
}
/** Returns the stave number this clef belongs to. */
getStaveNumber() {
return this.element.attr('number').withDefault(1).int();
}
/** Returns the clef sign. Defaults to null. */
getSign() {
return this.element.first('sign')?.content().enum(CLEF_SIGNS) ?? null;
}
/** Returns the line of the clef. Defaults to null. */
getLine() {
return this.element.first('line')?.content().int() ?? null;
}
/** Returns the octave change of the clef. Defaults to null. */
getOctaveChange() {
return this.element.first('clef-octave-change')?.content().int() ?? null;
}
}