@stringsync/vexml
Version:
MusicXML to Vexflow
43 lines (42 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Time = void 0;
const enums_1 = require("./enums");
/**
* Time represents a time signature element.
*
* See https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/time/
*/
class Time {
element;
constructor(element) {
this.element = element;
}
/** Returns the stave number this time belongs to. Defaults to null. */
getStaveNumber() {
return this.element.attr('number').int();
}
/** Returns the beats of the time. */
getBeats() {
return this.element
.all('beats')
.map((beats) => beats.content().str())
.filter((content) => typeof content === 'string');
}
/** Returns the beat types of the time. */
getBeatTypes() {
return this.element
.all('beat-type')
.map((beatType) => beatType.content().str())
.filter((content) => typeof content === 'string');
}
/** Returns whether the time signature is hidden. */
isHidden() {
return !!this.element.first('senza-misura');
}
/** Returns the symbol of the time. */
getSymbol() {
return this.element.attr('symbol').enum(enums_1.TIME_SYMBOLS) ?? null;
}
}
exports.Time = Time;