@stringsync/vexml
Version:
MusicXML to Vexflow
56 lines (55 loc) • 2.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Barline = void 0;
const enums_1 = require("./enums");
/**
* Barline includes information about repeats, endings, and graphical bar styles.
*
* See https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/barline/
*/
class Barline {
element;
constructor(element) {
this.element = element;
}
/** Returns the bar style of the barline. Defaults to 'regular'. */
getBarStyle() {
return this.element.first('bar-style')?.content().enum(enums_1.BAR_STYLES) ?? 'regular';
}
/** Whether or not the barline is a repeat. Defaults to false. */
isRepeat() {
return this.element.all('repeat').length > 0;
}
/** Returns the number of times the repeat should be played. Defaults to null. */
getRepeatTimes() {
return this.element.first('repeat')?.attr('times').int() ?? null;
}
/** Returns the repeat direction. Defaults to null. */
getRepeatDirection() {
return this.element.first('repeat')?.attr('direction').enum(enums_1.REPEAT_DIRECTIONS) ?? null;
}
/** Returns the location of the barline. Defaults to 'right'. */
getLocation() {
return this.element
.attr('location')
.withDefault('right')
.enum(enums_1.BARLINE_LOCATIONS);
}
/** Whether or not the barline is an ending */
isEnding() {
return this.element.all('ending').length > 0;
}
/** Returns the ending text. Defaults to empty string. */
getEndingText() {
return this.element.first('ending')?.content().str() ?? '';
}
/** Returns the ending number. Defaults to '1'. */
getEndingNumber() {
return this.element.first('ending')?.attr('number').str() ?? '1';
}
/** Returns the ending type. Defaults to 'start'. */
getEndingType() {
return this.element.first('ending')?.attr('type').enum(enums_1.START_STOP_DISCONTINUE) ?? 'start';
}
}
exports.Barline = Barline;