|
@@ -5,6 +5,7 @@ import {TechnicalInstruction, TechnicalInstructionType} from "../../VoiceData/In
|
|
|
import {OrnamentContainer, OrnamentEnum} from "../../VoiceData/OrnamentContainer";
|
|
|
import {PlacementEnum} from "../../VoiceData/Expressions/AbstractExpression";
|
|
|
import {AccidentalEnum} from "../../../Common/DataObjects/Pitch";
|
|
|
+import { Articulation } from "../../VoiceData/Articulation";
|
|
|
export class ArticulationReader {
|
|
|
|
|
|
private getAccEnumFromString(input: string): AccidentalEnum {
|
|
@@ -50,25 +51,30 @@ export class ArticulationReader {
|
|
|
name = name.replace("-", "");
|
|
|
let articulationEnum: ArticulationEnum = ArticulationEnum[name];
|
|
|
if (VoiceEntry.isSupportedArticulation(articulationEnum)) {
|
|
|
+ let placement: PlacementEnum = PlacementEnum.Above;
|
|
|
+ if (childNode.attribute("placement")?.value === "below") {
|
|
|
+ placement = PlacementEnum.Below;
|
|
|
+ }
|
|
|
+ const newArticulation: Articulation = new Articulation(articulationEnum, placement);
|
|
|
// staccato should be first // necessary?
|
|
|
if (name === "staccato") {
|
|
|
if (currentVoiceEntry.Articulations.length > 0 &&
|
|
|
- currentVoiceEntry.Articulations[0] !== ArticulationEnum.staccato) {
|
|
|
- currentVoiceEntry.Articulations.splice(0, 0, articulationEnum); // TODO can't this overwrite another articulation?
|
|
|
+ currentVoiceEntry.Articulations[0].articulationEnum !== ArticulationEnum.staccato) {
|
|
|
+ currentVoiceEntry.Articulations.splice(0, 0, newArticulation); // TODO can't this overwrite another articulation?
|
|
|
}
|
|
|
}
|
|
|
if (name === "strongaccent") { // see name.replace("-", "") above
|
|
|
const marcatoType: string = childNode?.attribute("type")?.value;
|
|
|
if (marcatoType === "up") {
|
|
|
- articulationEnum = ArticulationEnum.marcatoup;
|
|
|
+ newArticulation.articulationEnum = ArticulationEnum.marcatoup;
|
|
|
} else if (marcatoType === "down") {
|
|
|
- articulationEnum = ArticulationEnum.marcatodown;
|
|
|
+ newArticulation.articulationEnum = ArticulationEnum.marcatodown;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// don't add the same articulation twice
|
|
|
- if (currentVoiceEntry.Articulations.indexOf(articulationEnum) === -1) {
|
|
|
- currentVoiceEntry.Articulations.push(articulationEnum);
|
|
|
+ if (!currentVoiceEntry.hasArticulation(newArticulation)) {
|
|
|
+ currentVoiceEntry.Articulations.push(newArticulation);
|
|
|
}
|
|
|
}
|
|
|
} catch (ex) {
|
|
@@ -93,8 +99,12 @@ export class ArticulationReader {
|
|
|
articulationEnum = ArticulationEnum.invertedfermata;
|
|
|
}
|
|
|
}
|
|
|
+ let placement: PlacementEnum = PlacementEnum.Above;
|
|
|
+ if (xmlNode.attribute("placement")?.value === "below") {
|
|
|
+ placement = PlacementEnum.Below;
|
|
|
+ }
|
|
|
// add to VoiceEntry
|
|
|
- currentVoiceEntry.Articulations.push(articulationEnum);
|
|
|
+ currentVoiceEntry.Articulations.push(new Articulation(articulationEnum, placement));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -123,8 +133,13 @@ export class ArticulationReader {
|
|
|
const articulationEnum: ArticulationEnum = xmlElementToArticulationEnum[xmlArticulation];
|
|
|
const node: IXmlElement = xmlNode.element(xmlArticulation);
|
|
|
if (node) {
|
|
|
- if (currentVoiceEntry.Articulations.indexOf(articulationEnum) === -1) {
|
|
|
- currentVoiceEntry.Articulations.push(articulationEnum);
|
|
|
+ let placement: PlacementEnum = PlacementEnum.Above;
|
|
|
+ if (node.attribute("placement").value === "below") {
|
|
|
+ placement = PlacementEnum.Below;
|
|
|
+ }
|
|
|
+ const newArticulation: Articulation = new Articulation(articulationEnum, placement);
|
|
|
+ if (!currentVoiceEntry.hasArticulation(newArticulation)) {
|
|
|
+ currentVoiceEntry.Articulations.push(newArticulation);
|
|
|
}
|
|
|
}
|
|
|
}
|