|
@@ -124,7 +124,7 @@ export class VoiceGenerator {
|
|
|
// this.voice.Parent.HasLyrics = true;
|
|
|
//}
|
|
|
let hasTupletCommand: boolean = false;
|
|
|
- let notationNode: IXmlElement = noteNode.element("notations");
|
|
|
+ const notationNode: IXmlElement = noteNode.element("notations");
|
|
|
if (notationNode !== undefined) {
|
|
|
// let articNode: IXmlElement = undefined;
|
|
|
// (*)
|
|
@@ -136,7 +136,7 @@ export class VoiceGenerator {
|
|
|
//if (this.slurReader !== undefined && (slurNodes = notationNode.elements("slur")))
|
|
|
// this.slurReader.addSlur(slurNodes, this.currentNote);
|
|
|
// check for Tuplets
|
|
|
- let tupletNodeList: IXmlElement[] = notationNode.elements("tuplet");
|
|
|
+ const tupletNodeList: IXmlElement[] = notationNode.elements("tuplet");
|
|
|
if (tupletNodeList.length > 0) {
|
|
|
this.openTupletNumber = this.addTuplet(noteNode, tupletNodeList);
|
|
|
hasTupletCommand = true;
|
|
@@ -146,17 +146,17 @@ export class VoiceGenerator {
|
|
|
this.currentVoiceEntry.ArpeggiosNotesIndices.push(this.currentVoiceEntry.Notes.indexOf(this.currentNote));
|
|
|
}
|
|
|
// check for Ties - must be the last check
|
|
|
- let tiedNodeList: IXmlElement[] = notationNode.elements("tied");
|
|
|
+ const tiedNodeList: IXmlElement[] = notationNode.elements("tied");
|
|
|
if (tiedNodeList.length > 0) {
|
|
|
this.addTie(tiedNodeList, measureStartAbsoluteTimestamp, maxTieNoteFraction);
|
|
|
}
|
|
|
|
|
|
// remove open ties, if there is already a gap between the last tie note and now.
|
|
|
- let openTieDict: { [_: number]: Tie; } = this.openTieDict;
|
|
|
- for (let key in openTieDict) {
|
|
|
+ const openTieDict: { [_: number]: Tie; } = this.openTieDict;
|
|
|
+ for (const key in openTieDict) {
|
|
|
if (openTieDict.hasOwnProperty(key)) {
|
|
|
- let tie: Tie = openTieDict[key];
|
|
|
- if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length).lt(this.currentStaffEntry.Timestamp)) {
|
|
|
+ const tie: Tie = openTieDict[key];
|
|
|
+ if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length).lt(this.currentStaffEntry.Timestamp)) {
|
|
|
delete openTieDict[key];
|
|
|
}
|
|
|
}
|
|
@@ -168,10 +168,10 @@ export class VoiceGenerator {
|
|
|
this.handleTimeModificationNode(noteNode);
|
|
|
}
|
|
|
} catch (err) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NoteError", "Ignored erroneous Note."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
}
|
|
|
|
|
|
return this.currentNote;
|
|
@@ -188,19 +188,19 @@ export class VoiceGenerator {
|
|
|
&& this.currentVoiceEntry.graceVoiceEntriesBefore !== undefined
|
|
|
&& this.currentVoiceEntry.graceVoiceEntriesBefore.length > 0
|
|
|
) {
|
|
|
- let voice: Voice = this.currentVoiceEntry.ParentVoice;
|
|
|
- let horizontalIndex: number = this.currentMeasure.VerticalSourceStaffEntryContainers.indexOf(this.currentStaffEntry.VerticalContainerParent);
|
|
|
- let verticalIndex: number = this.currentStaffEntry.VerticalContainerParent.StaffEntries.indexOf(this.currentStaffEntry);
|
|
|
- let previousStaffEntry: SourceStaffEntry = this.currentMeasure.getPreviousSourceStaffEntryFromIndex(verticalIndex, horizontalIndex);
|
|
|
- if (previousStaffEntry !== undefined) {
|
|
|
+ const voice: Voice = this.currentVoiceEntry.ParentVoice;
|
|
|
+ const horizontalIndex: number = this.currentMeasure.VerticalSourceStaffEntryContainers.indexOf(this.currentStaffEntry.VerticalContainerParent);
|
|
|
+ const verticalIndex: number = this.currentStaffEntry.VerticalContainerParent.StaffEntries.indexOf(this.currentStaffEntry);
|
|
|
+ const previousStaffEntry: SourceStaffEntry = this.currentMeasure.getPreviousSourceStaffEntryFromIndex(verticalIndex, horizontalIndex);
|
|
|
+ if (previousStaffEntry !== undefined) {
|
|
|
let previousVoiceEntry: VoiceEntry = undefined;
|
|
|
for (let idx: number = 0, len: number = previousStaffEntry.VoiceEntries.length; idx < len; ++idx) {
|
|
|
- let voiceEntry: VoiceEntry = previousStaffEntry.VoiceEntries[idx];
|
|
|
+ const voiceEntry: VoiceEntry = previousStaffEntry.VoiceEntries[idx];
|
|
|
if (voiceEntry.ParentVoice === voice) {
|
|
|
previousVoiceEntry = voiceEntry;
|
|
|
previousVoiceEntry.graceVoiceEntriesAfter = [];
|
|
|
for (let idx2: number = 0, len2: number = this.currentVoiceEntry.graceVoiceEntriesBefore.length; idx2 < len2; ++idx2) {
|
|
|
- let graceVoiceEntry: VoiceEntry = this.currentVoiceEntry.graceVoiceEntriesBefore[idx2];
|
|
|
+ const graceVoiceEntry: VoiceEntry = this.currentVoiceEntry.graceVoiceEntriesBefore[idx2];
|
|
|
previousVoiceEntry.graceVoiceEntriesAfter.push(graceVoiceEntry);
|
|
|
}
|
|
|
this.currentVoiceEntry.graceVoiceEntriesBefore = [];
|
|
@@ -221,11 +221,11 @@ export class VoiceGenerator {
|
|
|
* @returns {SourceStaffEntry}
|
|
|
*/
|
|
|
public checkForStaffEntryLink(index: number, currentStaff: Staff, currentStaffEntry: SourceStaffEntry, currentMeasure: SourceMeasure): SourceStaffEntry {
|
|
|
- let staffEntryLink: StaffEntryLink = new StaffEntryLink(this.currentVoiceEntry);
|
|
|
+ const staffEntryLink: StaffEntryLink = new StaffEntryLink(this.currentVoiceEntry);
|
|
|
staffEntryLink.LinkStaffEntries.push(currentStaffEntry);
|
|
|
currentStaffEntry.Link = staffEntryLink;
|
|
|
- let linkMusicTimestamp: Fraction = this.currentVoiceEntry.Timestamp.clone();
|
|
|
- let verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = currentMeasure.getVerticalContainerByTimestamp(linkMusicTimestamp);
|
|
|
+ const linkMusicTimestamp: Fraction = this.currentVoiceEntry.Timestamp.clone();
|
|
|
+ const verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = currentMeasure.getVerticalContainerByTimestamp(linkMusicTimestamp);
|
|
|
currentStaffEntry = verticalSourceStaffEntryContainer.StaffEntries[index];
|
|
|
if (currentStaffEntry === undefined) {
|
|
|
currentStaffEntry = new SourceStaffEntry(verticalSourceStaffEntryContainer, currentStaff);
|
|
@@ -244,11 +244,11 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
|
|
|
public checkOpenTies(): void {
|
|
|
- let openTieDict: { [key: number]: Tie } = this.openTieDict;
|
|
|
- for (let key in openTieDict) {
|
|
|
+ const openTieDict: {[key: number]: Tie} = this.openTieDict;
|
|
|
+ for (const key in openTieDict) {
|
|
|
if (openTieDict.hasOwnProperty(key)) {
|
|
|
- let tie: Tie = openTieDict[key];
|
|
|
- if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length)
|
|
|
+ const tie: Tie = openTieDict[key];
|
|
|
+ if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length)
|
|
|
.lt(tie.Start.ParentStaffEntry.VerticalContainerParent.ParentMeasure.Duration)) {
|
|
|
delete openTieDict[key];
|
|
|
}
|
|
@@ -297,28 +297,28 @@ export class VoiceGenerator {
|
|
|
case "maxima":
|
|
|
return new Fraction(8, 1);
|
|
|
default: {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NoteDurationError", "Invalid note duration."
|
|
|
);
|
|
|
- throw new MusicSheetReadingException(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private readArticulations(notationNode: IXmlElement, currentVoiceEntry: VoiceEntry): void {
|
|
|
- let articNode: IXmlElement = notationNode.element("articulations");
|
|
|
+ const articNode: IXmlElement = notationNode.element("articulations");
|
|
|
if (articNode !== undefined) {
|
|
|
this.articulationReader.addArticulationExpression(articNode, currentVoiceEntry);
|
|
|
}
|
|
|
- let fermaNode: IXmlElement = notationNode.element("fermata");
|
|
|
+ const fermaNode: IXmlElement = notationNode.element("fermata");
|
|
|
if (fermaNode !== undefined) {
|
|
|
this.articulationReader.addFermata(fermaNode, currentVoiceEntry);
|
|
|
}
|
|
|
- let tecNode: IXmlElement = notationNode.element("technical");
|
|
|
+ const tecNode: IXmlElement = notationNode.element("technical");
|
|
|
if (tecNode !== undefined) {
|
|
|
this.articulationReader.addTechnicalArticulations(tecNode, currentVoiceEntry);
|
|
|
}
|
|
|
- let ornaNode: IXmlElement = notationNode.element("ornaments");
|
|
|
+ const ornaNode: IXmlElement = notationNode.element("ornaments");
|
|
|
if (ornaNode !== undefined) {
|
|
|
this.articulationReader.addOrnament(ornaNode, currentVoiceEntry);
|
|
|
}
|
|
@@ -340,39 +340,39 @@ export class VoiceGenerator {
|
|
|
let noteStep: NoteEnum = NoteEnum.C;
|
|
|
let noteOctave: number = 0;
|
|
|
let playbackInstrumentId: string = undefined;
|
|
|
- let xmlnodeElementsArr: IXmlElement[] = node.elements();
|
|
|
+ const xmlnodeElementsArr: IXmlElement[] = node.elements();
|
|
|
for (let idx: number = 0, len: number = xmlnodeElementsArr.length; idx < len; ++idx) {
|
|
|
- let noteElement: IXmlElement = xmlnodeElementsArr[idx];
|
|
|
+ const noteElement: IXmlElement = xmlnodeElementsArr[idx];
|
|
|
try {
|
|
|
if (noteElement.name === "pitch") {
|
|
|
- let noteElementsArr: IXmlElement[] = noteElement.elements();
|
|
|
+ const noteElementsArr: IXmlElement[] = noteElement.elements();
|
|
|
for (let idx2: number = 0, len2: number = noteElementsArr.length; idx2 < len2; ++idx2) {
|
|
|
- let pitchElement: IXmlElement = noteElementsArr[idx2];
|
|
|
+ const pitchElement: IXmlElement = noteElementsArr[idx2];
|
|
|
try {
|
|
|
if (pitchElement.name === "step") {
|
|
|
noteStep = NoteEnum[pitchElement.value];
|
|
|
if (noteStep === undefined) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NotePitchError",
|
|
|
"Invalid pitch while reading note."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
}
|
|
|
} else if (pitchElement.name === "alter") {
|
|
|
noteAlter = parseInt(pitchElement.value, 10);
|
|
|
if (isNaN(noteAlter)) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NoteAlterationError", "Invalid alteration while reading note."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
}
|
|
|
|
|
|
} else if (pitchElement.name === "octave") {
|
|
|
noteOctave = parseInt(pitchElement.value, 10);
|
|
|
if (isNaN(noteOctave)) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NoteOctaveError", "Invalid octave value while reading note."
|
|
|
);
|
|
|
this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
@@ -385,11 +385,11 @@ export class VoiceGenerator {
|
|
|
|
|
|
}
|
|
|
} else if (noteElement.name === "unpitched") {
|
|
|
- let displayStep: IXmlElement = noteElement.element("display-step");
|
|
|
+ const displayStep: IXmlElement = noteElement.element("display-step");
|
|
|
if (displayStep !== undefined) {
|
|
|
noteStep = NoteEnum[displayStep.value.toUpperCase()];
|
|
|
}
|
|
|
- let octave: IXmlElement = noteElement.element("display-octave");
|
|
|
+ const octave: IXmlElement = noteElement.element("display-octave");
|
|
|
if (octave !== undefined) {
|
|
|
noteOctave = parseInt(octave.value, 10);
|
|
|
if (guitarPro) {
|
|
@@ -407,9 +407,9 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
|
|
|
noteOctave -= Pitch.OctaveXmlDifference;
|
|
|
- let pitch: Pitch = new Pitch(noteStep, noteOctave, noteAlter);
|
|
|
- let noteLength: Fraction = Fraction.createFromFraction(noteDuration);
|
|
|
- let note: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, noteLength, pitch);
|
|
|
+ const pitch: Pitch = new Pitch(noteStep, noteOctave, noteAlter);
|
|
|
+ const noteLength: Fraction = Fraction.createFromFraction(noteDuration);
|
|
|
+ const note: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, noteLength, pitch);
|
|
|
note.PlaybackInstrumentId = playbackInstrumentId;
|
|
|
if (!graceNote) {
|
|
|
this.currentVoiceEntry.Notes.push(note);
|
|
@@ -429,8 +429,8 @@ export class VoiceGenerator {
|
|
|
* @returns {Note}
|
|
|
*/
|
|
|
private addRestNote(noteDuration: Fraction): Note {
|
|
|
- let restFraction: Fraction = Fraction.createFromFraction(noteDuration);
|
|
|
- let restNote: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, restFraction, undefined);
|
|
|
+ const restFraction: Fraction = Fraction.createFromFraction(noteDuration);
|
|
|
+ const restNote: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, restFraction, undefined);
|
|
|
this.currentVoiceEntry.Notes.push(restNote);
|
|
|
if (this.openBeam !== undefined) {
|
|
|
this.openBeam.ExtendedNoteList.push(restNote);
|
|
@@ -446,15 +446,15 @@ export class VoiceGenerator {
|
|
|
*/
|
|
|
private createBeam(node: IXmlElement, note: Note, grace: boolean): void {
|
|
|
try {
|
|
|
- let beamNode: IXmlElement = node.element("beam");
|
|
|
+ const beamNode: IXmlElement = node.element("beam");
|
|
|
let beamAttr: IXmlAttribute = undefined;
|
|
|
if (beamNode !== undefined && beamNode.hasAttributes) {
|
|
|
beamAttr = beamNode.attribute("number");
|
|
|
}
|
|
|
if (beamAttr !== undefined) {
|
|
|
- let beamNumber: number = parseInt(beamAttr.value, 10);
|
|
|
- let mainBeamNode: IXmlElement[] = node.elements("beam");
|
|
|
- let currentBeamTag: string = mainBeamNode[0].value;
|
|
|
+ const beamNumber: number = parseInt(beamAttr.value, 10);
|
|
|
+ const mainBeamNode: IXmlElement[] = node.elements("beam");
|
|
|
+ const currentBeamTag: string = mainBeamNode[0].value;
|
|
|
if (beamNumber === 1 && mainBeamNode !== undefined) {
|
|
|
if (currentBeamTag === "begin" && this.lastBeamTag !== currentBeamTag) {
|
|
|
if (grace) {
|
|
@@ -477,7 +477,7 @@ export class VoiceGenerator {
|
|
|
return;
|
|
|
}
|
|
|
for (let idx: number = 0, len: number = this.openGraceBeam.Notes.length; idx < len; ++idx) {
|
|
|
- let beamNote: Note = this.openGraceBeam.Notes[idx];
|
|
|
+ const beamNote: Note = this.openGraceBeam.Notes[idx];
|
|
|
if (this.currentVoiceEntry === beamNote.ParentVoiceEntry) {
|
|
|
sameVoiceEntry = true;
|
|
|
}
|
|
@@ -493,7 +493,7 @@ export class VoiceGenerator {
|
|
|
return;
|
|
|
}
|
|
|
for (let idx: number = 0, len: number = this.openBeam.Notes.length; idx < len; ++idx) {
|
|
|
- let beamNote: Note = this.openBeam.Notes[idx];
|
|
|
+ const beamNote: Note = this.openBeam.Notes[idx];
|
|
|
if (this.currentVoiceEntry === beamNote.ParentVoiceEntry) {
|
|
|
sameVoiceEntry = true;
|
|
|
}
|
|
@@ -507,7 +507,7 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/BeamError", "Error while reading beam."
|
|
|
);
|
|
|
this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
@@ -521,7 +521,7 @@ export class VoiceGenerator {
|
|
|
*/
|
|
|
private handleOpenBeam(): void {
|
|
|
if (this.openBeam.Notes.length === 1) {
|
|
|
- let beamNote: Note = this.openBeam.Notes[0];
|
|
|
+ const beamNote: Note = this.openBeam.Notes[0];
|
|
|
beamNote.NoteBeam = undefined;
|
|
|
this.openBeam = undefined;
|
|
|
return;
|
|
@@ -529,17 +529,19 @@ export class VoiceGenerator {
|
|
|
if (this.currentNote === CollectionUtil.last(this.openBeam.Notes)) {
|
|
|
this.openBeam = undefined;
|
|
|
} else {
|
|
|
- let beamLastNote: Note = CollectionUtil.last(this.openBeam.Notes);
|
|
|
- let beamLastNoteStaffEntry: SourceStaffEntry = beamLastNote.ParentStaffEntry;
|
|
|
- let horizontalIndex: number = this.currentMeasure.getVerticalContainerIndexByTimestamp(beamLastNoteStaffEntry.Timestamp);
|
|
|
- let verticalIndex: number = beamLastNoteStaffEntry.VerticalContainerParent.StaffEntries.indexOf(beamLastNoteStaffEntry);
|
|
|
+ const beamLastNote: Note = CollectionUtil.last(this.openBeam.Notes);
|
|
|
+ const beamLastNoteStaffEntry: SourceStaffEntry = beamLastNote.ParentStaffEntry;
|
|
|
+ const horizontalIndex: number = this.currentMeasure.getVerticalContainerIndexByTimestamp(beamLastNoteStaffEntry.Timestamp);
|
|
|
+ const verticalIndex: number = beamLastNoteStaffEntry.VerticalContainerParent.StaffEntries.indexOf(beamLastNoteStaffEntry);
|
|
|
if (horizontalIndex < this.currentMeasure.VerticalSourceStaffEntryContainers.length - 1) {
|
|
|
- let nextStaffEntry: SourceStaffEntry = this.currentMeasure.VerticalSourceStaffEntryContainers[horizontalIndex + 1].StaffEntries[verticalIndex];
|
|
|
+ const nextStaffEntry: SourceStaffEntry = this.currentMeasure
|
|
|
+ .VerticalSourceStaffEntryContainers[horizontalIndex + 1]
|
|
|
+ .StaffEntries[verticalIndex];
|
|
|
if (nextStaffEntry !== undefined) {
|
|
|
for (let idx: number = 0, len: number = nextStaffEntry.VoiceEntries.length; idx < len; ++idx) {
|
|
|
- let voiceEntry: VoiceEntry = nextStaffEntry.VoiceEntries[idx];
|
|
|
+ const voiceEntry: VoiceEntry = nextStaffEntry.VoiceEntries[idx];
|
|
|
if (voiceEntry.ParentVoice === this.voice) {
|
|
|
- let candidateNote: Note = voiceEntry.Notes[0];
|
|
|
+ const candidateNote: Note = voiceEntry.Notes[0];
|
|
|
if (candidateNote.Length.lte(new Fraction(1, 8))) {
|
|
|
this.openBeam.addNoteToBeam(candidateNote);
|
|
|
this.openBeam = undefined;
|
|
@@ -559,27 +561,27 @@ export class VoiceGenerator {
|
|
|
let graceChord: boolean = false;
|
|
|
let type: string = "";
|
|
|
if (node.elements("type")) {
|
|
|
- let typeNode: IXmlElement[] = node.elements("type");
|
|
|
+ const typeNode: IXmlElement[] = node.elements("type");
|
|
|
if (typeNode) {
|
|
|
type = typeNode[0].value;
|
|
|
try {
|
|
|
note.Length = this.getNoteDurationFromType(type);
|
|
|
note.Length.Numerator = 1;
|
|
|
} catch (e) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/NoteDurationError", "Invalid note duration."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException(errorMsg, e);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg, e);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- let graceNode: IXmlElement = node.element("grace");
|
|
|
+ const graceNode: IXmlElement = node.element("grace");
|
|
|
if (graceNode !== undefined && graceNode.attributes()) {
|
|
|
if (graceNode.attribute("slash")) {
|
|
|
- let slash: string = graceNode.attribute("slash").value;
|
|
|
- if (slash === "yes") {
|
|
|
+ const slash: string = graceNode.attribute("slash").value;
|
|
|
+ if (slash === "yes") {
|
|
|
note.GraceNoteSlash = true;
|
|
|
}
|
|
|
}
|
|
@@ -622,12 +624,12 @@ export class VoiceGenerator {
|
|
|
if (timeModNode !== undefined) {
|
|
|
timeModNode = timeModNode.element("actual-notes");
|
|
|
}
|
|
|
- let tupletNodeListArr: IXmlElement[] = tupletNodeList;
|
|
|
+ const tupletNodeListArr: IXmlElement[] = tupletNodeList;
|
|
|
for (let idx: number = 0, len: number = tupletNodeListArr.length; idx < len; ++idx) {
|
|
|
- let tupletNode: IXmlElement = tupletNodeListArr[idx];
|
|
|
- if (tupletNode !== undefined && tupletNode.attributes()) {
|
|
|
- let type: string = tupletNode.attribute("type").value;
|
|
|
- if (type === "start") {
|
|
|
+ const tupletNode: IXmlElement = tupletNodeListArr[idx];
|
|
|
+ if (tupletNode !== undefined && tupletNode.attributes()) {
|
|
|
+ const type: string = tupletNode.attribute("type").value;
|
|
|
+ if (type === "start") {
|
|
|
let tupletNumber: number = 1;
|
|
|
if (tupletNode.attribute("number")) {
|
|
|
tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
|
|
@@ -636,15 +638,15 @@ export class VoiceGenerator {
|
|
|
if (timeModNode !== undefined) {
|
|
|
tupletLabelNumber = parseInt(timeModNode.value, 10);
|
|
|
if (isNaN(tupletLabelNumber)) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg, undefined);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- let tuplet: Tuplet = new Tuplet(tupletLabelNumber);
|
|
|
+ const tuplet: Tuplet = new Tuplet(tupletLabelNumber);
|
|
|
if (this.tupletDict[tupletNumber] !== undefined) {
|
|
|
delete this.tupletDict[tupletNumber];
|
|
|
if (Object.keys(this.tupletDict).length === 0) {
|
|
@@ -654,7 +656,7 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
}
|
|
|
this.tupletDict[tupletNumber] = tuplet;
|
|
|
- let subnotelist: Note[] = [];
|
|
|
+ const subnotelist: Note[] = [];
|
|
|
subnotelist.push(this.currentNote);
|
|
|
tuplet.Notes.push(subnotelist);
|
|
|
tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
@@ -665,15 +667,15 @@ export class VoiceGenerator {
|
|
|
if (tupletNode.attribute("number")) {
|
|
|
tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
|
|
|
}
|
|
|
- let tuplet: Tuplet = this.tupletDict[tupletNumber];
|
|
|
+ const tuplet: Tuplet = this.tupletDict[tupletNumber];
|
|
|
if (tuplet !== undefined) {
|
|
|
- let subnotelist: Note[] = [];
|
|
|
- subnotelist.push(this.currentNote);
|
|
|
- tuplet.Notes.push(subnotelist);
|
|
|
- tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
|
- this.currentNote.NoteTuplet = tuplet;
|
|
|
- delete this.tupletDict[tupletNumber];
|
|
|
- if (Object.keys(this.tupletDict).length === 0) {
|
|
|
+ const subnotelist: Note[] = [];
|
|
|
+ subnotelist.push(this.currentNote);
|
|
|
+ tuplet.Notes.push(subnotelist);
|
|
|
+ tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
|
+ this.currentNote.NoteTuplet = tuplet;
|
|
|
+ delete this.tupletDict[tupletNumber];
|
|
|
+ if (Object.keys(this.tupletDict).length === 0) {
|
|
|
this.openTupletNumber = 0;
|
|
|
} else if (Object.keys(this.tupletDict).length > 1) {
|
|
|
this.openTupletNumber--;
|
|
@@ -683,16 +685,16 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
}
|
|
|
} else if (tupletNodeList[0] !== undefined) {
|
|
|
- let n: IXmlElement = tupletNodeList[0];
|
|
|
- if (n.hasAttributes) {
|
|
|
- let type: string = n.attribute("type").value;
|
|
|
- let tupletnumber: number = 1;
|
|
|
- if (n.attribute("number")) {
|
|
|
+ const n: IXmlElement = tupletNodeList[0];
|
|
|
+ if (n.hasAttributes) {
|
|
|
+ const type: string = n.attribute("type").value;
|
|
|
+ let tupletnumber: number = 1;
|
|
|
+ if (n.attribute("number")) {
|
|
|
tupletnumber = parseInt(n.attribute("number").value, 10);
|
|
|
}
|
|
|
- let noTupletNumbering: boolean = isNaN(tupletnumber);
|
|
|
+ const noTupletNumbering: boolean = isNaN(tupletnumber);
|
|
|
|
|
|
- if (type === "start") {
|
|
|
+ if (type === "start") {
|
|
|
let tupletLabelNumber: number = 0;
|
|
|
let timeModNode: IXmlElement = node.element("time-modification");
|
|
|
if (timeModNode !== undefined) {
|
|
@@ -701,11 +703,11 @@ export class VoiceGenerator {
|
|
|
if (timeModNode !== undefined) {
|
|
|
tupletLabelNumber = parseInt(timeModNode.value, 10);
|
|
|
if (isNaN(tupletLabelNumber)) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException(errorMsg);
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException(errorMsg);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -717,7 +719,7 @@ export class VoiceGenerator {
|
|
|
if (tuplet === undefined) {
|
|
|
tuplet = this.tupletDict[tupletnumber] = new Tuplet(tupletLabelNumber);
|
|
|
}
|
|
|
- let subnotelist: Note[] = [];
|
|
|
+ const subnotelist: Note[] = [];
|
|
|
subnotelist.push(this.currentNote);
|
|
|
tuplet.Notes.push(subnotelist);
|
|
|
tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
@@ -727,19 +729,19 @@ export class VoiceGenerator {
|
|
|
if (noTupletNumbering) {
|
|
|
tupletnumber = this.openTupletNumber;
|
|
|
}
|
|
|
- let tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
|
|
|
+ const tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
|
|
|
if (tuplet !== undefined) {
|
|
|
- let subnotelist: Note[] = [];
|
|
|
- subnotelist.push(this.currentNote);
|
|
|
- tuplet.Notes.push(subnotelist);
|
|
|
- tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
|
- this.currentNote.NoteTuplet = tuplet;
|
|
|
- if (Object.keys(this.tupletDict).length === 0) {
|
|
|
+ const subnotelist: Note[] = [];
|
|
|
+ subnotelist.push(this.currentNote);
|
|
|
+ tuplet.Notes.push(subnotelist);
|
|
|
+ tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
|
|
|
+ this.currentNote.NoteTuplet = tuplet;
|
|
|
+ if (Object.keys(this.tupletDict).length === 0) {
|
|
|
this.openTupletNumber = 0;
|
|
|
} else if (Object.keys(this.tupletDict).length > 1) {
|
|
|
this.openTupletNumber--;
|
|
|
}
|
|
|
- delete this.tupletDict[tupletnumber];
|
|
|
+ delete this.tupletDict[tupletnumber];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -755,34 +757,34 @@ export class VoiceGenerator {
|
|
|
if (this.tupletDict[this.openTupletNumber] !== undefined) {
|
|
|
try {
|
|
|
// Tuplet should already be created
|
|
|
- let tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
|
|
|
- let notes: Note[] = CollectionUtil.last(tuplet.Notes);
|
|
|
- let lastTupletVoiceEntry: VoiceEntry = notes[0].ParentVoiceEntry;
|
|
|
- let noteList: Note[];
|
|
|
- if (lastTupletVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)) {
|
|
|
+ const tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
|
|
|
+ const notes: Note[] = CollectionUtil.last(tuplet.Notes);
|
|
|
+ const lastTupletVoiceEntry: VoiceEntry = notes[0].ParentVoiceEntry;
|
|
|
+ let noteList: Note[];
|
|
|
+ if (lastTupletVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)) {
|
|
|
noteList = notes;
|
|
|
} else {
|
|
|
noteList = [];
|
|
|
tuplet.Notes.push(noteList);
|
|
|
tuplet.Fractions.push(this.getTupletNoteDurationFromType(noteNode));
|
|
|
}
|
|
|
- noteList.push(this.currentNote);
|
|
|
- this.currentNote.NoteTuplet = tuplet;
|
|
|
+ noteList.push(this.currentNote);
|
|
|
+ this.currentNote.NoteTuplet = tuplet;
|
|
|
} catch (ex) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText(
|
|
|
+ const errorMsg: string = ITextTranslation.translateText(
|
|
|
"ReaderErrorMessages/TupletNumberError", "Invalid tuplet number."
|
|
|
);
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw ex;
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw ex;
|
|
|
}
|
|
|
|
|
|
} else if (this.currentVoiceEntry.Notes.length > 0) {
|
|
|
- let firstNote: Note = this.currentVoiceEntry.Notes[0];
|
|
|
- if (firstNote.NoteTuplet !== undefined) {
|
|
|
- let tuplet: Tuplet = firstNote.NoteTuplet;
|
|
|
- let notes: Note[] = CollectionUtil.last(tuplet.Notes);
|
|
|
- notes.push(this.currentNote);
|
|
|
- this.currentNote.NoteTuplet = tuplet;
|
|
|
+ const firstNote: Note = this.currentVoiceEntry.Notes[0];
|
|
|
+ if (firstNote.NoteTuplet !== undefined) {
|
|
|
+ const tuplet: Tuplet = firstNote.NoteTuplet;
|
|
|
+ const notes: Note[] = CollectionUtil.last(tuplet.Notes);
|
|
|
+ notes.push(this.currentNote);
|
|
|
+ this.currentNote.NoteTuplet = tuplet;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -790,25 +792,25 @@ export class VoiceGenerator {
|
|
|
private addTie(tieNodeList: IXmlElement[], measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction): void {
|
|
|
if (tieNodeList !== undefined) {
|
|
|
if (tieNodeList.length === 1) {
|
|
|
- let tieNode: IXmlElement = tieNodeList[0];
|
|
|
- if (tieNode !== undefined && tieNode.attributes()) {
|
|
|
- let type: string = tieNode.attribute("type").value;
|
|
|
- try {
|
|
|
+ const tieNode: IXmlElement = tieNodeList[0];
|
|
|
+ if (tieNode !== undefined && tieNode.attributes()) {
|
|
|
+ const type: string = tieNode.attribute("type").value;
|
|
|
+ try {
|
|
|
if (type === "start") {
|
|
|
- let num: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
- if (num < 0) {
|
|
|
+ const num: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
+ if (num < 0) {
|
|
|
delete this.openTieDict[num];
|
|
|
}
|
|
|
- let newTieNumber: number = this.getNextAvailableNumberForTie();
|
|
|
- let tie: Tie = new Tie(this.currentNote);
|
|
|
- this.openTieDict[newTieNumber] = tie;
|
|
|
- if (this.currentNote.NoteBeam !== undefined) {
|
|
|
+ const newTieNumber: number = this.getNextAvailableNumberForTie();
|
|
|
+ const tie: Tie = new Tie(this.currentNote);
|
|
|
+ this.openTieDict[newTieNumber] = tie;
|
|
|
+ if (this.currentNote.NoteBeam !== undefined) {
|
|
|
if (this.currentNote.NoteBeam.Notes[0] === this.currentNote) {
|
|
|
tie.BeamStartTimestamp = Fraction.plus(measureStartAbsoluteTimestamp, this.currentVoiceEntry.Timestamp);
|
|
|
} else {
|
|
|
for (let idx: number = 0, len: number = this.currentNote.NoteBeam.Notes.length; idx < len; ++idx) {
|
|
|
- let note: Note = this.currentNote.NoteBeam.Notes[idx];
|
|
|
- if (note.NoteTie !== undefined && note.NoteTie !== tie && note.NoteTie.BeamStartTimestamp !== undefined) {
|
|
|
+ const note: Note = this.currentNote.NoteBeam.Notes[idx];
|
|
|
+ if (note.NoteTie !== undefined && note.NoteTie !== tie && note.NoteTie.BeamStartTimestamp !== undefined) {
|
|
|
tie.BeamStartTimestamp = note.NoteTie.BeamStartTimestamp;
|
|
|
break;
|
|
|
}
|
|
@@ -819,113 +821,113 @@ export class VoiceGenerator {
|
|
|
}
|
|
|
}
|
|
|
} else if (type === "stop") {
|
|
|
- let tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
- let tie: Tie = this.openTieDict[tieNumber];
|
|
|
- if (tie !== undefined) {
|
|
|
- let tieStartNote: Note = tie.Start;
|
|
|
- tieStartNote.NoteTie = tie;
|
|
|
- tieStartNote.Length.Add(this.currentNote.Length);
|
|
|
- tie.Fractions.push(this.currentNote.Length);
|
|
|
- if (maxTieNoteFraction.lt(Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length))) {
|
|
|
+ const tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
+ const tie: Tie = this.openTieDict[tieNumber];
|
|
|
+ if (tie !== undefined) {
|
|
|
+ const tieStartNote: Note = tie.Start;
|
|
|
+ tieStartNote.NoteTie = tie;
|
|
|
+ tieStartNote.Length.Add(this.currentNote.Length);
|
|
|
+ tie.Fractions.push(this.currentNote.Length);
|
|
|
+ if (maxTieNoteFraction.lt(Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length))) {
|
|
|
maxTieNoteFraction = Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length);
|
|
|
}
|
|
|
- let i: number = this.currentVoiceEntry.Notes.indexOf(this.currentNote);
|
|
|
- if (i !== -1) {
|
|
|
+ const i: number = this.currentVoiceEntry.Notes.indexOf(this.currentNote);
|
|
|
+ if (i !== -1) {
|
|
|
this.currentVoiceEntry.Notes.splice(i, 1);
|
|
|
}
|
|
|
- if (
|
|
|
+ if (
|
|
|
this.currentVoiceEntry.Articulations.length === 1
|
|
|
&& this.currentVoiceEntry.Articulations[0] === ArticulationEnum.fermata
|
|
|
&& tieStartNote.ParentVoiceEntry.Articulations[ArticulationEnum.fermata] === undefined
|
|
|
) {
|
|
|
tieStartNote.ParentVoiceEntry.Articulations.push(ArticulationEnum.fermata);
|
|
|
}
|
|
|
- if (this.currentNote.NoteBeam !== undefined) {
|
|
|
- let noteBeamIndex: number = this.currentNote.NoteBeam.Notes.indexOf(this.currentNote);
|
|
|
- if (noteBeamIndex === 0 && tie.BeamStartTimestamp === undefined) {
|
|
|
+ if (this.currentNote.NoteBeam !== undefined) {
|
|
|
+ const noteBeamIndex: number = this.currentNote.NoteBeam.Notes.indexOf(this.currentNote);
|
|
|
+ if (noteBeamIndex === 0 && tie.BeamStartTimestamp === undefined) {
|
|
|
tie.BeamStartTimestamp = Fraction.plus(measureStartAbsoluteTimestamp, this.currentVoiceEntry.Timestamp);
|
|
|
}
|
|
|
- let noteBeam: Beam = this.currentNote.NoteBeam;
|
|
|
- noteBeam.Notes[noteBeamIndex] = tieStartNote;
|
|
|
- tie.TieBeam = noteBeam;
|
|
|
+ const noteBeam: Beam = this.currentNote.NoteBeam;
|
|
|
+ noteBeam.Notes[noteBeamIndex] = tieStartNote;
|
|
|
+ tie.TieBeam = noteBeam;
|
|
|
}
|
|
|
- if (this.currentNote.NoteTuplet !== undefined) {
|
|
|
- let noteTupletIndex: number = this.currentNote.NoteTuplet.getNoteIndex(this.currentNote);
|
|
|
- let index: number = this.currentNote.NoteTuplet.Notes[noteTupletIndex].indexOf(this.currentNote);
|
|
|
- let noteTuplet: Tuplet = this.currentNote.NoteTuplet;
|
|
|
- noteTuplet.Notes[noteTupletIndex][index] = tieStartNote;
|
|
|
- tie.TieTuplet = noteTuplet;
|
|
|
+ if (this.currentNote.NoteTuplet !== undefined) {
|
|
|
+ const noteTupletIndex: number = this.currentNote.NoteTuplet.getNoteIndex(this.currentNote);
|
|
|
+ const index: number = this.currentNote.NoteTuplet.Notes[noteTupletIndex].indexOf(this.currentNote);
|
|
|
+ const noteTuplet: Tuplet = this.currentNote.NoteTuplet;
|
|
|
+ noteTuplet.Notes[noteTupletIndex][index] = tieStartNote;
|
|
|
+ tie.TieTuplet = noteTuplet;
|
|
|
}
|
|
|
- for (let idx: number = 0, len: number = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
|
|
|
- let slur: Slur = this.currentNote.NoteSlurs[idx];
|
|
|
- if (slur.StartNote === this.currentNote) {
|
|
|
+ for (let idx: number = 0, len: number = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
|
|
|
+ const slur: Slur = this.currentNote.NoteSlurs[idx];
|
|
|
+ if (slur.StartNote === this.currentNote) {
|
|
|
slur.StartNote = tie.Start;
|
|
|
slur.StartNote.NoteSlurs.push(slur);
|
|
|
}
|
|
|
- if (slur.EndNote === this.currentNote) {
|
|
|
+ if (slur.EndNote === this.currentNote) {
|
|
|
slur.EndNote = tie.Start;
|
|
|
slur.EndNote.NoteSlurs.push(slur);
|
|
|
}
|
|
|
}
|
|
|
- let lyricsEntries: Dictionary<number, LyricsEntry> = this.currentVoiceEntry.LyricsEntries;
|
|
|
- for (let lyricsEntry in lyricsEntries) {
|
|
|
+ const lyricsEntries: Dictionary<number, LyricsEntry> = this.currentVoiceEntry.LyricsEntries;
|
|
|
+ for (const lyricsEntry in lyricsEntries) {
|
|
|
if (lyricsEntries.hasOwnProperty(lyricsEntry)) {
|
|
|
- let val: LyricsEntry = this.currentVoiceEntry.LyricsEntries[lyricsEntry];
|
|
|
- if (!tieStartNote.ParentVoiceEntry.LyricsEntries.hasOwnProperty(lyricsEntry)) {
|
|
|
+ const val: LyricsEntry = this.currentVoiceEntry.LyricsEntries[lyricsEntry];
|
|
|
+ if (!tieStartNote.ParentVoiceEntry.LyricsEntries.hasOwnProperty(lyricsEntry)) {
|
|
|
tieStartNote.ParentVoiceEntry.LyricsEntries[lyricsEntry] = val;
|
|
|
val.Parent = tieStartNote.ParentVoiceEntry;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- delete this.openTieDict[tieNumber];
|
|
|
+ delete this.openTieDict[tieNumber];
|
|
|
}
|
|
|
}
|
|
|
} catch (err) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TieError", "Error while reading tie.");
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ const errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TieError", "Error while reading tie.");
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} else if (tieNodeList.length === 2) {
|
|
|
- let tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
- if (tieNumber >= 0) {
|
|
|
- let tie: Tie = this.openTieDict[tieNumber];
|
|
|
- let tieStartNote: Note = tie.Start;
|
|
|
- tieStartNote.Length.Add(this.currentNote.Length);
|
|
|
- tie.Fractions.push(this.currentNote.Length);
|
|
|
- if (this.currentNote.NoteBeam !== undefined) {
|
|
|
- let noteBeamIndex: number = this.currentNote.NoteBeam.Notes.indexOf(this.currentNote);
|
|
|
- if (noteBeamIndex === 0 && tie.BeamStartTimestamp === undefined) {
|
|
|
+ const tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
|
|
|
+ if (tieNumber >= 0) {
|
|
|
+ const tie: Tie = this.openTieDict[tieNumber];
|
|
|
+ const tieStartNote: Note = tie.Start;
|
|
|
+ tieStartNote.Length.Add(this.currentNote.Length);
|
|
|
+ tie.Fractions.push(this.currentNote.Length);
|
|
|
+ if (this.currentNote.NoteBeam !== undefined) {
|
|
|
+ const noteBeamIndex: number = this.currentNote.NoteBeam.Notes.indexOf(this.currentNote);
|
|
|
+ if (noteBeamIndex === 0 && tie.BeamStartTimestamp === undefined) {
|
|
|
tie.BeamStartTimestamp = Fraction.plus(measureStartAbsoluteTimestamp, this.currentVoiceEntry.Timestamp);
|
|
|
}
|
|
|
- let noteBeam: Beam = this.currentNote.NoteBeam;
|
|
|
- noteBeam.Notes[noteBeamIndex] = tieStartNote;
|
|
|
- tie.TieBeam = noteBeam;
|
|
|
+ const noteBeam: Beam = this.currentNote.NoteBeam;
|
|
|
+ noteBeam.Notes[noteBeamIndex] = tieStartNote;
|
|
|
+ tie.TieBeam = noteBeam;
|
|
|
}
|
|
|
- for (let idx: number = 0, len: number = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
|
|
|
- let slur: Slur = this.currentNote.NoteSlurs[idx];
|
|
|
- if (slur.StartNote === this.currentNote) {
|
|
|
+ for (let idx: number = 0, len: number = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
|
|
|
+ const slur: Slur = this.currentNote.NoteSlurs[idx];
|
|
|
+ if (slur.StartNote === this.currentNote) {
|
|
|
slur.StartNote = tie.Start;
|
|
|
slur.StartNote.NoteSlurs.push(slur);
|
|
|
}
|
|
|
- if (slur.EndNote === this.currentNote) {
|
|
|
+ if (slur.EndNote === this.currentNote) {
|
|
|
slur.EndNote = tie.Start;
|
|
|
slur.EndNote.NoteSlurs.push(slur);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.currentVoiceEntry.LyricsEntries.forEach((key: number, value: LyricsEntry): void => {
|
|
|
+ this.currentVoiceEntry.LyricsEntries.forEach((key: number, value: LyricsEntry): void => {
|
|
|
if (!tieStartNote.ParentVoiceEntry.LyricsEntries.containsKey(key)) {
|
|
|
tieStartNote.ParentVoiceEntry.LyricsEntries.setValue(key, value);
|
|
|
value.Parent = tieStartNote.ParentVoiceEntry;
|
|
|
}
|
|
|
});
|
|
|
- if (maxTieNoteFraction.lt(Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length))) {
|
|
|
+ if (maxTieNoteFraction.lt(Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length))) {
|
|
|
maxTieNoteFraction = Fraction.plus(this.currentStaffEntry.Timestamp, this.currentNote.Length);
|
|
|
}
|
|
|
// delete currentNote from Notes:
|
|
|
- let i: number = this.currentVoiceEntry.Notes.indexOf(this.currentNote);
|
|
|
- if (i !== -1) {
|
|
|
+ const i: number = this.currentVoiceEntry.Notes.indexOf(this.currentNote);
|
|
|
+ if (i !== -1) {
|
|
|
this.currentVoiceEntry.Notes.splice(i, 1);
|
|
|
}
|
|
|
}
|
|
@@ -938,17 +940,17 @@ export class VoiceGenerator {
|
|
|
* @returns {number}
|
|
|
*/
|
|
|
private getNextAvailableNumberForTie(): number {
|
|
|
- let keys: string[] = Object.keys(this.openTieDict);
|
|
|
- if (keys.length === 0) {
|
|
|
+ const keys: string[] = Object.keys(this.openTieDict);
|
|
|
+ if (keys.length === 0) {
|
|
|
return 1;
|
|
|
}
|
|
|
- keys.sort((a, b) => (+a - +b)); // FIXME Andrea: test
|
|
|
- for (let i: number = 0; i < keys.length; i++) {
|
|
|
+ keys.sort((a, b) => (+a - +b)); // FIXME Andrea: test
|
|
|
+ for (let i: number = 0; i < keys.length; i++) {
|
|
|
if ("" + (i + 1) !== keys[i]) {
|
|
|
return i + 1;
|
|
|
}
|
|
|
}
|
|
|
- return +(keys[keys.length - 1]) + 1;
|
|
|
+ return +(keys[keys.length - 1]) + 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -957,16 +959,16 @@ export class VoiceGenerator {
|
|
|
* @returns {number}
|
|
|
*/
|
|
|
private findCurrentNoteInTieDict(candidateNote: Note): number {
|
|
|
- let openTieDict: { [_: number]: Tie; } = this.openTieDict;
|
|
|
- for (let key in openTieDict) {
|
|
|
+ const openTieDict: { [_: number]: Tie; } = this.openTieDict;
|
|
|
+ for (const key in openTieDict) {
|
|
|
if (openTieDict.hasOwnProperty(key)) {
|
|
|
- let tie: Tie = openTieDict[key];
|
|
|
- if (tie.Start.Pitch.FundamentalNote === candidateNote.Pitch.FundamentalNote && tie.Start.Pitch.Octave === candidateNote.Pitch.Octave) {
|
|
|
+ const tie: Tie = openTieDict[key];
|
|
|
+ if (tie.Start.Pitch.FundamentalNote === candidateNote.Pitch.FundamentalNote && tie.Start.Pitch.Octave === candidateNote.Pitch.Octave) {
|
|
|
return +key;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return -1;
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -976,15 +978,15 @@ export class VoiceGenerator {
|
|
|
*/
|
|
|
private getTupletNoteDurationFromType(xmlNode: IXmlElement): Fraction {
|
|
|
if (xmlNode.element("type") !== undefined) {
|
|
|
- let typeNode: IXmlElement = xmlNode.element("type");
|
|
|
- if (typeNode !== undefined) {
|
|
|
- let type: string = typeNode.value;
|
|
|
- try {
|
|
|
+ const typeNode: IXmlElement = xmlNode.element("type");
|
|
|
+ if (typeNode !== undefined) {
|
|
|
+ const type: string = typeNode.value;
|
|
|
+ try {
|
|
|
return this.getNoteDurationFromType(type);
|
|
|
} catch (e) {
|
|
|
- let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid note duration.");
|
|
|
- this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
- throw new MusicSheetReadingException("", e);
|
|
|
+ const errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid note duration.");
|
|
|
+ this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
|
|
|
+ throw new MusicSheetReadingException("", e);
|
|
|
}
|
|
|
|
|
|
}
|