@stringsync/vexml
Version:
MusicXML to Vexflow
35 lines (34 loc) • 972 B
JavaScript
/**
* The `<harmonic>` element indicates natural and artificial harmonics.
*
* See https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/harmonic/
*/
export class Harmonic {
element;
constructor(element) {
this.element = element;
}
/** Returns the type of harmonic. Defaults to 'unspecified'. */
getType() {
if (this.element.first('natural')) {
return 'natural';
}
if (this.element.first('artificial')) {
return 'artificial';
}
return 'unspecified';
}
/** Returns the pitch type of the harmonic. Defaults to 'unspecified'. */
getPitchType() {
if (this.element.first('base-pitch')) {
return 'base';
}
if (this.element.first('touching-pitch')) {
return 'touching';
}
if (this.element.first('sounding-pitch')) {
return 'sounding';
}
return 'unspecified';
}
}