|  | @@ -33,15 +33,16 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |      constructor(instrument: Instrument, voiceId: number, slurReader: SlurReader, mainVoice: Voice = undefined) {
 | 
	
		
			
				|  |  |          this.musicSheet = instrument.GetMusicSheet;
 | 
	
		
			
				|  |  |          this.slurReader = slurReader;
 | 
	
		
			
				|  |  | -        if (mainVoice !== undefined)
 | 
	
		
			
				|  |  | +        if (mainVoice !== undefined) {
 | 
	
		
			
				|  |  |              this.voice = new LinkedVoice(instrument, voiceId, mainVoice);
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              this.voice = new Voice(instrument, voiceId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          instrument.Voices.push(this.voice);
 | 
	
		
			
				|  |  |          //this.lyricsReader = MusicSymbolModuleFactory.createLyricsReader(this.musicSheet);
 | 
	
		
			
				|  |  |          //this.articulationReader = MusicSymbolModuleFactory.createArticulationReader();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private slurReader: SlurReader;
 | 
	
		
			
				|  |  |      //private lyricsReader: LyricsReader;
 | 
	
		
			
				|  |  |      //private articulationReader: ArticulationReader;
 | 
	
	
		
			
				|  | @@ -70,18 +71,24 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      public createVoiceEntry(musicTimestamp: Fraction, parentStaffEntry: SourceStaffEntry, addToVoice: boolean): void {
 | 
	
		
			
				|  |  |          this.currentVoiceEntry = new VoiceEntry(musicTimestamp.clone(), this.voice, parentStaffEntry);
 | 
	
		
			
				|  |  | -        if (addToVoice)
 | 
	
		
			
				|  |  | +        if (addToVoice) {
 | 
	
		
			
				|  |  |              this.voice.VoiceEntries.push(this.currentVoiceEntry);
 | 
	
		
			
				|  |  | -        if (parentStaffEntry.VoiceEntries.indexOf(this.currentVoiceEntry) === -1)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (parentStaffEntry.VoiceEntries.indexOf(this.currentVoiceEntry) === -1) {
 | 
	
		
			
				|  |  |              parentStaffEntry.VoiceEntries.push(this.currentVoiceEntry);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public read(noteNode: IXmlElement, noteDuration: number, divisions: number, restNote: boolean, graceNote: boolean,
 | 
	
		
			
				|  |  | +    public read(
 | 
	
		
			
				|  |  | +        noteNode: IXmlElement, noteDuration: number, divisions: number, restNote: boolean, graceNote: boolean,
 | 
	
		
			
				|  |  |          parentStaffEntry: SourceStaffEntry, parentMeasure: SourceMeasure,
 | 
	
		
			
				|  |  | -        measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, chord: boolean, guitarPro: boolean): Note {
 | 
	
		
			
				|  |  | +        measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, chord: boolean, guitarPro: boolean
 | 
	
		
			
				|  |  | +    ): Note {
 | 
	
		
			
				|  |  |          this.currentStaffEntry = parentStaffEntry;
 | 
	
		
			
				|  |  |          this.currentMeasure = parentMeasure;
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  | -            this.currentNote = restNote ? this.addRestNote(noteDuration, divisions) : this.addSingleNote(noteNode, noteDuration, divisions, graceNote, chord, guitarPro);
 | 
	
		
			
				|  |  | +            this.currentNote = restNote
 | 
	
		
			
				|  |  | +                ? this.addRestNote(noteDuration, divisions)
 | 
	
		
			
				|  |  | +                : this.addSingleNote(noteNode, noteDuration, divisions, graceNote, chord, guitarPro);
 | 
	
		
			
				|  |  |              // (*)
 | 
	
		
			
				|  |  |              //if (this.lyricsReader !== undefined && noteNode.element("lyric") !== undefined) {
 | 
	
		
			
				|  |  |              //    this.lyricsReader.addLyricEntry(noteNode, this.currentVoiceEntry);
 | 
	
	
		
			
				|  | @@ -89,7 +96,7 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |              //}
 | 
	
		
			
				|  |  |              let notationNode: IXmlElement = noteNode.element("notations");
 | 
	
		
			
				|  |  |              if (notationNode !== undefined) {
 | 
	
		
			
				|  |  | -                let articNode: IXmlElement = undefined;
 | 
	
		
			
				|  |  | +                // let articNode: IXmlElement = undefined;
 | 
	
		
			
				|  |  |                  // (*)
 | 
	
		
			
				|  |  |                  //if (this.articulationReader !== undefined) {
 | 
	
		
			
				|  |  |                  //    this.readArticulations(notationNode, this.currentVoiceEntry);
 | 
	
	
		
			
				|  | @@ -98,27 +105,30 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  // (*)
 | 
	
		
			
				|  |  |                  //if (this.slurReader !== undefined && (slurNodes = notationNode.elements("slur")))
 | 
	
		
			
				|  |  |                  //    this.slurReader.addSlur(slurNodes, this.currentNote);
 | 
	
		
			
				|  |  | -                let tupletNodeList: IXmlElement[] = undefined;
 | 
	
		
			
				|  |  | -                if ((tupletNodeList = notationNode.elements("tuplet")))
 | 
	
		
			
				|  |  | +                let tupletNodeList: IXmlElement[] = notationNode.elements("tuplet");
 | 
	
		
			
				|  |  | +                if (tupletNodeList) {
 | 
	
		
			
				|  |  |                      this.openTupletNumber = this.addTuplet(noteNode, tupletNodeList);
 | 
	
		
			
				|  |  | -                if (notationNode.element("arpeggiate") !== undefined && !graceNote)
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (notationNode.element("arpeggiate") !== undefined && !graceNote) {
 | 
	
		
			
				|  |  |                      this.currentVoiceEntry.ArpeggiosNotesIndices.push(this.currentVoiceEntry.Notes.indexOf(this.currentNote));
 | 
	
		
			
				|  |  | -                let tiedNodeList: IXmlElement[] = undefined;
 | 
	
		
			
				|  |  | -                if ((tiedNodeList = notationNode.elements("tied")))
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                let tiedNodeList: IXmlElement[] = notationNode.elements("tied");
 | 
	
		
			
				|  |  | +                if (tiedNodeList) {
 | 
	
		
			
				|  |  |                      this.addTie(tiedNodeList, measureStartAbsoluteTimestamp, maxTieNoteFraction);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  let openTieDict: { [_: number]: Tie; } = this.openTieDict;
 | 
	
		
			
				|  |  |                  for (let key in openTieDict) {
 | 
	
		
			
				|  |  |                      let tie: Tie = openTieDict[key];
 | 
	
		
			
				|  |  | -                    if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length).lt(this.currentStaffEntry.Timestamp))
 | 
	
		
			
				|  |  | +                    if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length).lt(this.currentStaffEntry.Timestamp)) {
 | 
	
		
			
				|  |  |                          delete openTieDict[key];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (noteNode.element("time-modification") !== undefined && notationNode === undefined) {
 | 
	
		
			
				|  |  |                  this.handleTimeModificationNode(noteNode);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        catch (err) {
 | 
	
		
			
				|  |  | +        } catch (err) {
 | 
	
		
			
				|  |  |              let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  |                  "ReaderErrorMessages/NoteError", "Ignored erroneous Note."
 | 
	
		
			
				|  |  |              );
 | 
	
	
		
			
				|  | @@ -128,19 +138,24 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |          return this.currentNote;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      public checkForOpenGraceNotes(): void {
 | 
	
		
			
				|  |  | -        if (this.currentStaffEntry !== undefined && this.currentStaffEntry.VoiceEntries.length === 0 && this.currentVoiceEntry.graceVoiceEntriesBefore !== undefined && this.currentVoiceEntry.graceVoiceEntriesBefore.length > 0) {
 | 
	
		
			
				|  |  | +        if (
 | 
	
		
			
				|  |  | +            this.currentStaffEntry !== undefined
 | 
	
		
			
				|  |  | +            && this.currentStaffEntry.VoiceEntries.length === 0
 | 
	
		
			
				|  |  | +            && 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) {
 | 
	
		
			
				|  |  |                  let previousVoiceEntry: VoiceEntry = undefined;
 | 
	
		
			
				|  |  | -                for (let idx: number = 0, len = previousStaffEntry.VoiceEntries.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                for (let idx: number = 0, len: number = previousStaffEntry.VoiceEntries.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  |                      let voiceEntry: VoiceEntry = previousStaffEntry.VoiceEntries[idx];
 | 
	
		
			
				|  |  |                      if (voiceEntry.ParentVoice === voice) {
 | 
	
		
			
				|  |  |                          previousVoiceEntry = voiceEntry;
 | 
	
		
			
				|  |  |                          previousVoiceEntry.graceVoiceEntriesAfter = [];
 | 
	
		
			
				|  |  | -                        for (let idx2: number = 0, len2 = this.currentVoiceEntry.graceVoiceEntriesBefore.length; idx2 < len2; ++idx2) {
 | 
	
		
			
				|  |  | +                        for (let idx2: number = 0, len2: number = this.currentVoiceEntry.graceVoiceEntriesBefore.length; idx2 < len2; ++idx2) {
 | 
	
		
			
				|  |  |                              let graceVoiceEntry: VoiceEntry = this.currentVoiceEntry.graceVoiceEntriesBefore[idx2];
 | 
	
		
			
				|  |  |                              previousVoiceEntry.graceVoiceEntriesAfter.push(graceVoiceEntry);
 | 
	
		
			
				|  |  |                          }
 | 
	
	
		
			
				|  | @@ -152,8 +167,9 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public checkForStaffEntryLink(index: number, currentStaff: Staff, currentStaffEntry: SourceStaffEntry,
 | 
	
		
			
				|  |  | -        currentMeasure: SourceMeasure): SourceStaffEntry {
 | 
	
		
			
				|  |  | +    public checkForStaffEntryLink(
 | 
	
		
			
				|  |  | +        index: number, currentStaff: Staff, currentStaffEntry: SourceStaffEntry, currentMeasure: SourceMeasure
 | 
	
		
			
				|  |  | +    ): SourceStaffEntry {
 | 
	
		
			
				|  |  |          let staffEntryLink: StaffEntryLink = new StaffEntryLink(this.currentVoiceEntry);
 | 
	
		
			
				|  |  |          staffEntryLink.LinkStaffEntries.push(currentStaffEntry);
 | 
	
		
			
				|  |  |          currentStaffEntry.Link = staffEntryLink;
 | 
	
	
		
			
				|  | @@ -170,15 +186,18 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |          return currentStaffEntry;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      public checkForOpenBeam(): void {
 | 
	
		
			
				|  |  | -        if (this.openBeam !== undefined && this.currentNote !== undefined)
 | 
	
		
			
				|  |  | +        if (this.openBeam !== undefined && this.currentNote !== undefined) {
 | 
	
		
			
				|  |  |              this.handleOpenBeam();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      public checkOpenTies(): void {
 | 
	
		
			
				|  |  |          let openTieDict: {[key: number]: Tie} = this.openTieDict;
 | 
	
		
			
				|  |  |          for (let key in openTieDict) {
 | 
	
		
			
				|  |  |              let tie: Tie = openTieDict[key];
 | 
	
		
			
				|  |  | -            if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length).lt(tie.Start.ParentStaffEntry.VerticalContainerParent.ParentMeasure.Duration))
 | 
	
		
			
				|  |  | +            if (Fraction.plus(tie.Start.ParentStaffEntry.Timestamp, tie.Start.Length)
 | 
	
		
			
				|  |  | +                    .lt(tie.Start.ParentStaffEntry.VerticalContainerParent.ParentMeasure.Duration)) {
 | 
	
		
			
				|  |  |                  delete openTieDict[key];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      public hasVoiceEntry(): boolean {
 | 
	
	
		
			
				|  | @@ -238,132 +257,88 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |      //    if ((ornaNode = notationNode.element("ornaments")) !== undefined)
 | 
	
		
			
				|  |  |      //        this.articulationReader.addOrnament(ornaNode, currentVoiceEntry);
 | 
	
		
			
				|  |  |      //}
 | 
	
		
			
				|  |  | -    private addSingleNote(node: IXmlElement, noteDuration: number, divisions: number, graceNote: boolean, chord: boolean,
 | 
	
		
			
				|  |  | -        guitarPro: boolean): Note {
 | 
	
		
			
				|  |  | +    private addSingleNote(
 | 
	
		
			
				|  |  | +        node: IXmlElement, noteDuration: number, divisions: number, graceNote: boolean, chord: boolean, guitarPro: boolean
 | 
	
		
			
				|  |  | +    ): Note {
 | 
	
		
			
				|  |  |          let noteAlter: AccidentalEnum = AccidentalEnum.NONE;
 | 
	
		
			
				|  |  |          let noteStep: NoteEnum = NoteEnum.C;
 | 
	
		
			
				|  |  |          let noteOctave: number = 0;
 | 
	
		
			
				|  |  |          let playbackInstrumentId: string = undefined;
 | 
	
		
			
				|  |  |          let xmlnodeElementsArr: IXmlElement[] = node.elements();
 | 
	
		
			
				|  |  | -        for (let idx: number = 0, len = xmlnodeElementsArr.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +        for (let idx: number = 0, len: number = xmlnodeElementsArr.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  |              let noteElement: IXmlElement = xmlnodeElementsArr[idx];
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  if (noteElement.name === "pitch") {
 | 
	
		
			
				|  |  |                      let noteElementsArr: IXmlElement[] = noteElement.elements();
 | 
	
		
			
				|  |  | -                    for (let idx2: number = 0, len2 = noteElementsArr.length; idx2 < len2; ++idx2) {
 | 
	
		
			
				|  |  | +                    for (let idx2: number = 0, len2: number = noteElementsArr.length; idx2 < len2; ++idx2) {
 | 
	
		
			
				|  |  |                          let pitchElement: IXmlElement = noteElementsArr[idx2];
 | 
	
		
			
				|  |  |                          try {
 | 
	
		
			
				|  |  |                              if (pitchElement.name === "step") {
 | 
	
		
			
				|  |  | -                                try {
 | 
	
		
			
				|  |  | -                                    switch (pitchElement.value) {
 | 
	
		
			
				|  |  | -                                        case "C":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.C;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "D":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.D;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "E":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.E;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "F":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.F;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "G":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.G;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "A":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.A;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                        case "B":
 | 
	
		
			
				|  |  | -                                            {
 | 
	
		
			
				|  |  | -                                                noteStep = NoteEnum.B;
 | 
	
		
			
				|  |  | -                                                break;
 | 
	
		
			
				|  |  | -                                            }
 | 
	
		
			
				|  |  | -                                    }
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                catch (e) {
 | 
	
		
			
				|  |  | +                                noteStep = NoteEnum[pitchElement.value];
 | 
	
		
			
				|  |  | +                                if (noteStep === undefined) {
 | 
	
		
			
				|  |  |                                      let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  |                                          "ReaderErrorMessages/NotePitchError",
 | 
	
		
			
				|  |  |                                          "Invalid pitch while reading note."
 | 
	
		
			
				|  |  |                                      );
 | 
	
		
			
				|  |  |                                      this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  | -                                    throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  | +                                    throw new MusicSheetReadingException(errorMsg, undefined);
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else if (pitchElement.name === "alter") {
 | 
	
		
			
				|  |  | -                                try {
 | 
	
		
			
				|  |  | -                                    noteAlter = parseInt(pitchElement.value);
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                catch (e) {
 | 
	
		
			
				|  |  | +                            } else if (pitchElement.name === "alter") {
 | 
	
		
			
				|  |  | +                                noteAlter = parseInt(pitchElement.value, 10);
 | 
	
		
			
				|  |  | +                                if (noteAlter === undefined) {
 | 
	
		
			
				|  |  |                                      let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteAlterationError",
 | 
	
		
			
				|  |  |                                          "Invalid alteration while reading note.");
 | 
	
		
			
				|  |  |                                      this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  | -                                    throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  | +                                    throw new MusicSheetReadingException(errorMsg, undefined);
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else if (pitchElement.name === "octave") {
 | 
	
		
			
				|  |  | -                                try {
 | 
	
		
			
				|  |  | -                                    noteOctave = parseInt(pitchElement.value);
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                catch (e) {
 | 
	
		
			
				|  |  | -                                    let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteOctaveError",
 | 
	
		
			
				|  |  | -                                        "Invalid octave value while reading note.");
 | 
	
		
			
				|  |  | +                            } else if (pitchElement.name === "octave") {
 | 
	
		
			
				|  |  | +                                noteOctave = parseInt(pitchElement.value, 10);
 | 
	
		
			
				|  |  | +                                if (noteOctave === undefined) {
 | 
	
		
			
				|  |  | +                                    let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  | +                                        "ReaderErrorMessages/NoteOctaveError", "Invalid octave value while reading note."
 | 
	
		
			
				|  |  | +                                    );
 | 
	
		
			
				|  |  |                                      this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  | -                                    throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  | +                                    throw new MusicSheetReadingException(errorMsg, undefined);
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        catch (ex) {
 | 
	
		
			
				|  |  | -                            logging.log("VoiceGenerator.addSingleNote read Step: ", ex);
 | 
	
		
			
				|  |  | +                        } catch (ex) {
 | 
	
		
			
				|  |  | +                            logging.log("VoiceGenerator.addSingleNote read Step: ", ex.message);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else if (noteElement.name === "unpitched") {
 | 
	
		
			
				|  |  | -                    let displayStep: IXmlElement = undefined;
 | 
	
		
			
				|  |  | -                    if ((displayStep = noteElement.element("display-step")) !== undefined) {
 | 
	
		
			
				|  |  | +                } else if (noteElement.name === "unpitched") {
 | 
	
		
			
				|  |  | +                    let displayStep: IXmlElement = noteElement.element("display-step");
 | 
	
		
			
				|  |  | +                    if (displayStep !== undefined) {
 | 
	
		
			
				|  |  |                          noteStep = NoteEnum[displayStep.value.toUpperCase()];
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    let octave: IXmlElement = undefined;
 | 
	
		
			
				|  |  | -                    if ((octave = noteElement.element("display-octave")) !== undefined) {
 | 
	
		
			
				|  |  | -                        noteOctave = parseInt(octave.value);
 | 
	
		
			
				|  |  | -                        if (guitarPro)
 | 
	
		
			
				|  |  | +                    let octave: IXmlElement = noteElement.element("display-octave");
 | 
	
		
			
				|  |  | +                    if (octave !== undefined) {
 | 
	
		
			
				|  |  | +                        noteOctave = parseInt(octave.value, 10);
 | 
	
		
			
				|  |  | +                        if (guitarPro) {
 | 
	
		
			
				|  |  |                              noteOctave += 1;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else if (noteElement.name === "instrument") {
 | 
	
		
			
				|  |  | -                    if (noteElement.firstAttribute !== undefined)
 | 
	
		
			
				|  |  | +                } else if (noteElement.name === "instrument") {
 | 
	
		
			
				|  |  | +                    if (noteElement.firstAttribute !== undefined) {
 | 
	
		
			
				|  |  |                          playbackInstrumentId = noteElement.firstAttribute.value;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (ex) {
 | 
	
		
			
				|  |  | +            } catch (ex) {
 | 
	
		
			
				|  |  |                  logging.log("VoiceGenerator.addSingleNote: ", ex);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          noteOctave -= Pitch.OctaveXmlDifference;
 | 
	
		
			
				|  |  |          let pitch: Pitch = new Pitch(noteStep, noteOctave, noteAlter);
 | 
	
		
			
				|  |  |          let noteLength: Fraction = new Fraction(noteDuration, divisions);
 | 
	
		
			
				|  |  |          let note: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, noteLength, pitch);
 | 
	
		
			
				|  |  |          note.PlaybackInstrumentId = playbackInstrumentId;
 | 
	
		
			
				|  |  | -        if (!graceNote)
 | 
	
		
			
				|  |  | +        if (!graceNote) {
 | 
	
		
			
				|  |  |              this.currentVoiceEntry.Notes.push(note);
 | 
	
		
			
				|  |  | -        else this.handleGraceNote(node, note);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            this.handleGraceNote(node, note);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          if (node.elements("beam") && !chord) {
 | 
	
		
			
				|  |  |              this.createBeam(node, note, graceNote);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -373,30 +348,33 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |          let restFraction: Fraction = new Fraction(noteDuration, divisions);
 | 
	
		
			
				|  |  |          let restNote: Note = new Note(this.currentVoiceEntry, this.currentStaffEntry, restFraction, undefined);
 | 
	
		
			
				|  |  |          this.currentVoiceEntry.Notes.push(restNote);
 | 
	
		
			
				|  |  | -        if (this.openBeam !== undefined)
 | 
	
		
			
				|  |  | +        if (this.openBeam !== undefined) {
 | 
	
		
			
				|  |  |              this.openBeam.ExtendedNoteList.push(restNote);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return restNote;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      private createBeam(node: IXmlElement, note: Note, grace: boolean): void {
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              let beamNode: IXmlElement = node.element("beam");
 | 
	
		
			
				|  |  |              let beamAttr: IXmlAttribute = undefined;
 | 
	
		
			
				|  |  | -            if (beamNode !== undefined && beamNode.hasAttributes)
 | 
	
		
			
				|  |  | +            if (beamNode !== undefined && beamNode.hasAttributes) {
 | 
	
		
			
				|  |  |                  beamAttr = beamNode.attribute("number");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              if (beamAttr !== undefined) {
 | 
	
		
			
				|  |  | -                let beamNumber: number = parseInt(beamAttr.value);
 | 
	
		
			
				|  |  | +                let beamNumber: number = parseInt(beamAttr.value, 10);
 | 
	
		
			
				|  |  |                  let mainBeamNode: IXmlElement[] = node.elements("beam");
 | 
	
		
			
				|  |  |                  let currentBeamTag: string = mainBeamNode[0].value;
 | 
	
		
			
				|  |  |                  if (beamNumber === 1 && mainBeamNode !== undefined) {
 | 
	
		
			
				|  |  |                      if (currentBeamTag === "begin" && this.lastBeamTag !== currentBeamTag) {
 | 
	
		
			
				|  |  |                          if (grace) {
 | 
	
		
			
				|  |  | -                            if (this.openGraceBeam !== undefined)
 | 
	
		
			
				|  |  | +                            if (this.openGraceBeam !== undefined) {
 | 
	
		
			
				|  |  |                                  this.handleOpenBeam();
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                              this.openGraceBeam = new Beam();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else {
 | 
	
		
			
				|  |  | -                            if (this.openBeam !== undefined)
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            if (this.openBeam !== undefined) {
 | 
	
		
			
				|  |  |                                  this.handleOpenBeam();
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                              this.openBeam = new Beam();
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -404,38 +382,39 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  let sameVoiceEntry: boolean = false;
 | 
	
		
			
				|  |  |                  if (grace) {
 | 
	
		
			
				|  |  | -                    if (this.openGraceBeam === undefined)
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    for (let idx: number = 0, len = this.openGraceBeam.Notes.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                    if (this.openGraceBeam === undefined) { return; }
 | 
	
		
			
				|  |  | +                    for (let idx: number = 0, len: number = this.openGraceBeam.Notes.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  |                          let beamNote: Note = this.openGraceBeam.Notes[idx];
 | 
	
		
			
				|  |  | -                        if (this.currentVoiceEntry === beamNote.ParentVoiceEntry)
 | 
	
		
			
				|  |  | +                        if (this.currentVoiceEntry === beamNote.ParentVoiceEntry) {
 | 
	
		
			
				|  |  |                              sameVoiceEntry = true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      if (!sameVoiceEntry) {
 | 
	
		
			
				|  |  |                          this.openGraceBeam.addNoteToBeam(note);
 | 
	
		
			
				|  |  | -                        if (currentBeamTag === "end" && beamNumber === 1)
 | 
	
		
			
				|  |  | +                        if (currentBeamTag === "end" && beamNumber === 1) {
 | 
	
		
			
				|  |  |                              this.openGraceBeam = undefined;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else {
 | 
	
		
			
				|  |  | -                    if (this.openBeam === undefined)
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    for (let idx: number = 0, len = this.openBeam.Notes.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    if (this.openBeam === undefined) { return; }
 | 
	
		
			
				|  |  | +                    for (let idx: number = 0, len: number = this.openBeam.Notes.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  |                          let beamNote: Note = this.openBeam.Notes[idx];
 | 
	
		
			
				|  |  | -                        if (this.currentVoiceEntry === beamNote.ParentVoiceEntry)
 | 
	
		
			
				|  |  | +                        if (this.currentVoiceEntry === beamNote.ParentVoiceEntry) {
 | 
	
		
			
				|  |  |                              sameVoiceEntry = true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      if (!sameVoiceEntry) {
 | 
	
		
			
				|  |  |                          this.openBeam.addNoteToBeam(note);
 | 
	
		
			
				|  |  | -                        if (currentBeamTag === "end" && beamNumber === 1)
 | 
	
		
			
				|  |  | +                        if (currentBeamTag === "end" && beamNumber === 1) {
 | 
	
		
			
				|  |  |                              this.openBeam = undefined;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        catch (e) {
 | 
	
		
			
				|  |  | -            let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/BeamError",
 | 
	
		
			
				|  |  | -                "Error while reading beam.");
 | 
	
		
			
				|  |  | +        } catch (e) {
 | 
	
		
			
				|  |  | +            let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  | +                "ReaderErrorMessages/BeamError", "Error while reading beam."
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  |              this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  |              throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -446,11 +425,11 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |              let beamNote: Note = this.openBeam.Notes[0];
 | 
	
		
			
				|  |  |              beamNote.NoteBeam = undefined;
 | 
	
		
			
				|  |  |              this.openBeam = undefined;
 | 
	
		
			
				|  |  | -            return
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (this.currentNote === CollectionUtil.last(this.openBeam.Notes))
 | 
	
		
			
				|  |  | +        if (this.currentNote === CollectionUtil.last(this.openBeam.Notes)) {
 | 
	
		
			
				|  |  |              this.openBeam = undefined;
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              let beamLastNote: Note = CollectionUtil.last(this.openBeam.Notes);
 | 
	
		
			
				|  |  |              let beamLastNoteStaffEntry: SourceStaffEntry = beamLastNote.ParentStaffEntry;
 | 
	
		
			
				|  |  |              let horizontalIndex: number = this.currentMeasure.getVerticalContainerIndexByTimestamp(beamLastNoteStaffEntry.Timestamp);
 | 
	
	
		
			
				|  | @@ -458,22 +437,20 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |              if (horizontalIndex < this.currentMeasure.VerticalSourceStaffEntryContainers.length - 1) {
 | 
	
		
			
				|  |  |                  let nextStaffEntry: SourceStaffEntry = this.currentMeasure.VerticalSourceStaffEntryContainers[horizontalIndex + 1][verticalIndex];
 | 
	
		
			
				|  |  |                  if (nextStaffEntry !== undefined) {
 | 
	
		
			
				|  |  | -                    for (let idx: number = 0, len = nextStaffEntry.VoiceEntries.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                    for (let idx: number = 0, len: number = nextStaffEntry.VoiceEntries.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  |                          let voiceEntry: VoiceEntry = nextStaffEntry.VoiceEntries[idx];
 | 
	
		
			
				|  |  |                          if (voiceEntry.ParentVoice === this.voice) {
 | 
	
		
			
				|  |  |                              let candidateNote: Note = voiceEntry.Notes[0];
 | 
	
		
			
				|  |  |                              if (candidateNote.Length <= new Fraction(1, 8)) {
 | 
	
		
			
				|  |  |                                  this.openBeam.addNoteToBeam(candidateNote);
 | 
	
		
			
				|  |  |                                  this.openBeam = undefined;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else {
 | 
	
		
			
				|  |  | +                            } else {
 | 
	
		
			
				|  |  |                                  this.openBeam = undefined;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else {
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  |                  this.openBeam = undefined;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -488,12 +465,12 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  try {
 | 
	
		
			
				|  |  |                      note.Length = this.getNoteDurationFromType(type);
 | 
	
		
			
				|  |  |                      note.Length.Numerator = 1;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (e) {
 | 
	
		
			
				|  |  | -                    let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError",
 | 
	
		
			
				|  |  | -                        "Invalid note duration.");
 | 
	
		
			
				|  |  | +                } catch (e) {
 | 
	
		
			
				|  |  | +                    let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  | +                        "ReaderErrorMessages/NoteDurationError", "Invalid note duration."
 | 
	
		
			
				|  |  | +                    );
 | 
	
		
			
				|  |  |                      this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  | -                    throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  | +                    throw new MusicSheetReadingException(errorMsg, e);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -502,24 +479,30 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |          if (graceNode !== undefined && graceNode.attributes()) {
 | 
	
		
			
				|  |  |              if (graceNode.attribute("slash") !== undefined) {
 | 
	
		
			
				|  |  |                  let slash: string = graceNode.attribute("slash").value;
 | 
	
		
			
				|  |  | -                if (slash === "yes")
 | 
	
		
			
				|  |  | +                if (slash === "yes") {
 | 
	
		
			
				|  |  |                      note.GraceNoteSlash = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (node.element("chord") !== undefined)
 | 
	
		
			
				|  |  | +        if (node.element("chord") !== undefined) {
 | 
	
		
			
				|  |  |              graceChord = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          let graceVoiceEntry: VoiceEntry = undefined;
 | 
	
		
			
				|  |  |          if (!graceChord) {
 | 
	
		
			
				|  |  |              graceVoiceEntry = new VoiceEntry(
 | 
	
		
			
				|  |  |                  new Fraction(0, 1), this.currentVoiceEntry.ParentVoice, this.currentStaffEntry
 | 
	
		
			
				|  |  |              );
 | 
	
		
			
				|  |  | -            if (this.currentVoiceEntry.graceVoiceEntriesBefore === undefined)
 | 
	
		
			
				|  |  | +            if (this.currentVoiceEntry.graceVoiceEntriesBefore === undefined) {
 | 
	
		
			
				|  |  |                  this.currentVoiceEntry.graceVoiceEntriesBefore = [];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              this.currentVoiceEntry.graceVoiceEntriesBefore.push(graceVoiceEntry);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            if (this.currentVoiceEntry.graceVoiceEntriesBefore !== undefined && this.currentVoiceEntry.graceVoiceEntriesBefore.length > 0)
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            if (
 | 
	
		
			
				|  |  | +                this.currentVoiceEntry.graceVoiceEntriesBefore !== undefined
 | 
	
		
			
				|  |  | +                && this.currentVoiceEntry.graceVoiceEntriesBefore.length > 0
 | 
	
		
			
				|  |  | +            ) {
 | 
	
		
			
				|  |  |                  graceVoiceEntry = CollectionUtil.last(this.currentVoiceEntry.graceVoiceEntriesBefore);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (graceVoiceEntry !== undefined) {
 | 
	
		
			
				|  |  |              graceVoiceEntry.Notes.push(note);
 | 
	
	
		
			
				|  | @@ -529,37 +512,39 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |      private addTuplet(node: IXmlElement, tupletNodeList: IXmlElement[]): number {
 | 
	
		
			
				|  |  |          if (tupletNodeList !== undefined && tupletNodeList.length > 1) {
 | 
	
		
			
				|  |  |              let timeModNode: IXmlElement = node.element("time-modification");
 | 
	
		
			
				|  |  | -            if (timeModNode !== undefined)
 | 
	
		
			
				|  |  | +            if (timeModNode !== undefined) {
 | 
	
		
			
				|  |  |                  timeModNode = timeModNode.element("actual-notes");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              let tupletNodeListArr: IXmlElement[] = tupletNodeList;
 | 
	
		
			
				|  |  | -            for (let idx: number = 0, len = tupletNodeListArr.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +            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") {
 | 
	
		
			
				|  |  |                          let tupletNumber: number = 1;
 | 
	
		
			
				|  |  | -                        if (tupletNode.attribute("nummber") !== undefined)
 | 
	
		
			
				|  |  | -                            tupletNumber = parseInt(tupletNode.attribute("number").value);
 | 
	
		
			
				|  |  | +                        if (tupletNode.attribute("nummber") !== undefined) {
 | 
	
		
			
				|  |  | +                            tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                          let tupletLabelNumber: number = 0;
 | 
	
		
			
				|  |  |                          if (timeModNode !== undefined) {
 | 
	
		
			
				|  |  | -                            try {
 | 
	
		
			
				|  |  | -                                tupletLabelNumber = parseInt(timeModNode.value);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            catch (e) {
 | 
	
		
			
				|  |  | -                                let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError",
 | 
	
		
			
				|  |  | -                                    "Invalid tuplet note duration.");
 | 
	
		
			
				|  |  | +                            tupletLabelNumber = parseInt(timeModNode.value, 10);
 | 
	
		
			
				|  |  | +                            if (tupletLabelNumber === undefined) {
 | 
	
		
			
				|  |  | +                                let errorMsg: string = ITextTranslation.translateText(
 | 
	
		
			
				|  |  | +                                    "ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
 | 
	
		
			
				|  |  | +                                );
 | 
	
		
			
				|  |  |                                  this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  | -                                throw new MusicSheetReadingException("", e);
 | 
	
		
			
				|  |  | +                                throw new MusicSheetReadingException(errorMsg, undefined);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          let tuplet: Tuplet = new Tuplet(tupletLabelNumber);
 | 
	
		
			
				|  |  |                          if (this.tupletDict[tupletNumber] !== undefined) {
 | 
	
		
			
				|  |  |                              delete this.tupletDict[tupletNumber];
 | 
	
		
			
				|  |  | -                            if (Object.keys(this.tupletDict).length === 0)
 | 
	
		
			
				|  |  | +                            if (Object.keys(this.tupletDict).length === 0) {
 | 
	
		
			
				|  |  |                                  this.openTupletNumber = 0;
 | 
	
		
			
				|  |  | -                            else if (Object.keys(this.tupletDict).length > 1)
 | 
	
		
			
				|  |  | +                            } else if (Object.keys(this.tupletDict).length > 1) {
 | 
	
		
			
				|  |  |                                  this.openTupletNumber--;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          this.tupletDict[tupletNumber] = tuplet;
 | 
	
		
			
				|  |  |                          let subnotelist: Note[] = [];
 | 
	
	
		
			
				|  | @@ -568,11 +553,11 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                          tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
 | 
	
		
			
				|  |  |                          this.currentNote.NoteTuplet = tuplet;
 | 
	
		
			
				|  |  |                          this.openTupletNumber = tupletNumber;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else if (type === "stop") {
 | 
	
		
			
				|  |  | +                    } else if (type === "stop") {
 | 
	
		
			
				|  |  |                          let tupletNumber: number = 1;
 | 
	
		
			
				|  |  | -                        if (tupletNode.attribute("number") !== undefined)
 | 
	
		
			
				|  |  | -                            tupletNumber = parseInt(tupletNode.attribute("number").value);
 | 
	
		
			
				|  |  | +                        if (tupletNode.attribute("number") !== undefined) {
 | 
	
		
			
				|  |  | +                            tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                          let tuplet: Tuplet = this.tupletDict[tupletNumber];
 | 
	
		
			
				|  |  |                          if (tuplet !== undefined) {
 | 
	
		
			
				|  |  |                              let subnotelist: Note[] = [];
 | 
	
	
		
			
				|  | @@ -581,16 +566,16 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                              tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
 | 
	
		
			
				|  |  |                              this.currentNote.NoteTuplet = tuplet;
 | 
	
		
			
				|  |  |                              delete this.tupletDict[tupletNumber];
 | 
	
		
			
				|  |  | -                            if (Object.keys(this.tupletDict).length === 0)
 | 
	
		
			
				|  |  | +                            if (Object.keys(this.tupletDict).length === 0) {
 | 
	
		
			
				|  |  |                                  this.openTupletNumber = 0;
 | 
	
		
			
				|  |  | -                            else if (Object.keys(this.tupletDict).length > 1)
 | 
	
		
			
				|  |  | +                            } else if (Object.keys(this.tupletDict).length > 1) {
 | 
	
		
			
				|  |  |                                  this.openTupletNumber--;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if (tupletNodeList[0] !== undefined) {
 | 
	
		
			
				|  |  | +        } else if (tupletNodeList[0] !== undefined) {
 | 
	
		
			
				|  |  |              let n: IXmlElement = tupletNodeList[0];
 | 
	
		
			
				|  |  |              if (n.hasAttributes) {
 | 
	
		
			
				|  |  |                  let type: string = n.attribute("type").value;
 | 
	
	
		
			
				|  | @@ -598,22 +583,21 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  let noTupletNumbering: boolean = false;
 | 
	
		
			
				|  |  |                  try {
 | 
	
		
			
				|  |  |                      if (n.attribute("number") !== undefined)
 | 
	
		
			
				|  |  | -                        tupletnumber = parseInt(n.attribute("number").value);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (err) {
 | 
	
		
			
				|  |  | +                        tupletnumber = parseInt(n.attribute("number").value, 10);
 | 
	
		
			
				|  |  | +                } catch (err) {
 | 
	
		
			
				|  |  |                      noTupletNumbering = true;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (type === "start") {
 | 
	
		
			
				|  |  |                      let tupletLabelNumber: number = 0;
 | 
	
		
			
				|  |  |                      let timeModNode: IXmlElement = node.element("time-modification");
 | 
	
		
			
				|  |  | -                    if (timeModNode !== undefined)
 | 
	
		
			
				|  |  | +                    if (timeModNode !== undefined) {
 | 
	
		
			
				|  |  |                          timeModNode = timeModNode.element("actual-notes");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      if (timeModNode !== undefined) {
 | 
	
		
			
				|  |  |                          try {
 | 
	
		
			
				|  |  | -                            tupletLabelNumber = parseInt(timeModNode.value);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        catch (e) {
 | 
	
		
			
				|  |  | +                            tupletLabelNumber = parseInt(timeModNode.value, 10);
 | 
	
		
			
				|  |  | +                        } catch (e) {
 | 
	
		
			
				|  |  |                              let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError",
 | 
	
		
			
				|  |  |                                  "Invalid tuplet note duration.");
 | 
	
		
			
				|  |  |                              this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
	
		
			
				|  | @@ -635,10 +619,10 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                      tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
 | 
	
		
			
				|  |  |                      this.currentNote.NoteTuplet = tuplet;
 | 
	
		
			
				|  |  |                      this.openTupletNumber = tupletnumber;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else if (type === "stop") {
 | 
	
		
			
				|  |  | -                    if (noTupletNumbering)
 | 
	
		
			
				|  |  | +                } else if (type === "stop") {
 | 
	
		
			
				|  |  | +                    if (noTupletNumbering) {
 | 
	
		
			
				|  |  |                          tupletnumber = this.openTupletNumber;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      let tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
 | 
	
		
			
				|  |  |                      if (tuplet !== undefined) {
 | 
	
		
			
				|  |  |                          let subnotelist: Note[] = [];
 | 
	
	
		
			
				|  | @@ -646,10 +630,11 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                          tuplet.Notes.push(subnotelist);
 | 
	
		
			
				|  |  |                          tuplet.Fractions.push(this.getTupletNoteDurationFromType(node));
 | 
	
		
			
				|  |  |                          this.currentNote.NoteTuplet = tuplet;
 | 
	
		
			
				|  |  | -                        if (Object.keys(this.tupletDict).length === 0)
 | 
	
		
			
				|  |  | +                        if (Object.keys(this.tupletDict).length === 0) {
 | 
	
		
			
				|  |  |                              this.openTupletNumber = 0;
 | 
	
		
			
				|  |  | -                        else if (Object.keys(this.tupletDict).length > 1)
 | 
	
		
			
				|  |  | +                        } else if (Object.keys(this.tupletDict).length > 1) {
 | 
	
		
			
				|  |  |                              this.openTupletNumber--;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                          delete this.tupletDict[tupletnumber];
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -664,25 +649,23 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  let notes: Note[] = CollectionUtil.last(tuplet.Notes);
 | 
	
		
			
				|  |  |                  let lastTupletVoiceEntry: VoiceEntry = notes[0].ParentVoiceEntry;
 | 
	
		
			
				|  |  |                  let noteList: Note[];
 | 
	
		
			
				|  |  | -                if (lastTupletVoiceEntry.Timestamp === this.currentVoiceEntry.Timestamp)
 | 
	
		
			
				|  |  | +                if (lastTupletVoiceEntry.Timestamp === this.currentVoiceEntry.Timestamp) {
 | 
	
		
			
				|  |  |                      noteList = notes;
 | 
	
		
			
				|  |  | -                else {
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  |                      noteList = [];
 | 
	
		
			
				|  |  |                      tuplet.Notes.push(noteList);
 | 
	
		
			
				|  |  |                      tuplet.Fractions.push(this.getTupletNoteDurationFromType(noteNode));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  noteList.push(this.currentNote);
 | 
	
		
			
				|  |  |                  this.currentNote.NoteTuplet = tuplet;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (ex) {
 | 
	
		
			
				|  |  | +            } catch (ex) {
 | 
	
		
			
				|  |  |                  let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError",
 | 
	
		
			
				|  |  |                      "Invalid tuplet number.");
 | 
	
		
			
				|  |  |                  this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  |                  throw ex;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if (this.currentVoiceEntry.Notes.length > 0) {
 | 
	
		
			
				|  |  | +        } else if (this.currentVoiceEntry.Notes.length > 0) {
 | 
	
		
			
				|  |  |              let firstNote: Note = this.currentVoiceEntry.Notes[0];
 | 
	
		
			
				|  |  |              if (firstNote.NoteTuplet !== undefined) {
 | 
	
		
			
				|  |  |                  let tuplet: Tuplet = firstNote.NoteTuplet;
 | 
	
	
		
			
				|  | @@ -700,29 +683,30 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                      let type: string = tieNode.attribute("type").value;
 | 
	
		
			
				|  |  |                      try {
 | 
	
		
			
				|  |  |                          if (type === "start") {
 | 
	
		
			
				|  |  | -                            let number: number = this.findCurrentNoteInTieDict(this.currentNote);
 | 
	
		
			
				|  |  | -                            if (number < 0)
 | 
	
		
			
				|  |  | -                                delete this.openTieDict[number];
 | 
	
		
			
				|  |  | +                            let 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)
 | 
	
		
			
				|  |  | +                            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 = this.currentNote.NoteBeam.Notes.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                                } 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) {
 | 
	
		
			
				|  |  |                                              tie.BeamStartTimestamp = note.NoteTie.BeamStartTimestamp;
 | 
	
		
			
				|  |  |                                              break;
 | 
	
		
			
				|  |  |                                          }
 | 
	
		
			
				|  |  |                                      }
 | 
	
		
			
				|  |  | -                                    if (this.currentNote === CollectionUtil.last(this.currentNote.NoteBeam.Notes))
 | 
	
		
			
				|  |  | +                                    if (this.currentNote === CollectionUtil.last(this.currentNote.NoteBeam.Notes)) {
 | 
	
		
			
				|  |  |                                          tie.BeamStartTimestamp = Fraction.plus(measureStartAbsoluteTimestamp, this.currentVoiceEntry.Timestamp);
 | 
	
		
			
				|  |  | +                                    }
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else if (type === "stop") {
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else if (type === "stop") {
 | 
	
		
			
				|  |  |                              let tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
 | 
	
		
			
				|  |  |                              let tie: Tie = this.openTieDict[tieNumber];
 | 
	
		
			
				|  |  |                              if (tie !== undefined) {
 | 
	
	
		
			
				|  | @@ -730,16 +714,23 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                                  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)))
 | 
	
		
			
				|  |  | +                                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) delete this.currentVoiceEntry.Notes[i];
 | 
	
		
			
				|  |  | -                                if (this.currentVoiceEntry.Articulations.length === 1 && this.currentVoiceEntry.Articulations[0] === ArticulationEnum.fermata && tieStartNote.ParentVoiceEntry.Articulations[ArticulationEnum.fermata] === undefined)
 | 
	
		
			
				|  |  | +                                if (i !== -1) { delete this.currentVoiceEntry.Notes[i]; }
 | 
	
		
			
				|  |  | +                                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 (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;
 | 
	
	
		
			
				|  | @@ -751,7 +742,7 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                                      noteTuplet.Notes[noteTupletIndex][index] = tieStartNote;
 | 
	
		
			
				|  |  |                                      tie.TieTuplet = noteTuplet;
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | -                                for (let idx: number = 0, len = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                                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) {
 | 
	
		
			
				|  |  |                                          slur.StartNote = tie.Start;
 | 
	
	
		
			
				|  | @@ -773,15 +764,13 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                                  delete this.openTieDict[tieNumber];
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    catch (err) {
 | 
	
		
			
				|  |  | +                    } catch (err) {
 | 
	
		
			
				|  |  |                          let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/TieError", "Error while reading tie.");
 | 
	
		
			
				|  |  |                          this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else if (tieNodeList.length === 2) {
 | 
	
		
			
				|  |  | +            } else if (tieNodeList.length === 2) {
 | 
	
		
			
				|  |  |                  let tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
 | 
	
		
			
				|  |  |                  if (tieNumber >= 0) {
 | 
	
		
			
				|  |  |                      let tie: Tie = this.openTieDict[tieNumber];
 | 
	
	
		
			
				|  | @@ -790,13 +779,14 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                      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)
 | 
	
		
			
				|  |  | +                        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;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    for (let idx: number = 0, len = this.currentNote.NoteSlurs.length; idx < len; ++idx) {
 | 
	
		
			
				|  |  | +                    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) {
 | 
	
		
			
				|  |  |                              slur.StartNote = tie.Start;
 | 
	
	
		
			
				|  | @@ -815,23 +805,24 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                              lyricsEntry.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) delete this.currentVoiceEntry.Notes[i];
 | 
	
		
			
				|  |  | +                    if (i !== -1) { delete this.currentVoiceEntry.Notes[i]; }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      private getNextAvailableNumberForTie(): number {
 | 
	
		
			
				|  |  |          let keys: string[] = Object.keys(this.openTieDict);
 | 
	
		
			
				|  |  | -        if (keys.length === 0)
 | 
	
		
			
				|  |  | -            return 1;
 | 
	
		
			
				|  |  | +        if (keys.length === 0) { return 1; }
 | 
	
		
			
				|  |  |          keys.sort((a, b) => (+a - +b)); // FIXME Andrea: test
 | 
	
		
			
				|  |  |          for (let i: number = 0; i < keys.length; i++) {
 | 
	
		
			
				|  |  | -            if ("" + (i + 1) !== keys[i])
 | 
	
		
			
				|  |  | +            if ("" + (i + 1) !== keys[i]) {
 | 
	
		
			
				|  |  |                  return i + 1;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return +(keys[keys.length - 1]) + 1;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -852,8 +843,7 @@ export class VoiceGenerator {
 | 
	
		
			
				|  |  |                  let type: string = typeNode.value;
 | 
	
		
			
				|  |  |                  try {
 | 
	
		
			
				|  |  |                      return this.getNoteDurationFromType(type);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (e) {
 | 
	
		
			
				|  |  | +                } catch (e) {
 | 
	
		
			
				|  |  |                      let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid note duration.");
 | 
	
		
			
				|  |  |                      this.musicSheet.SheetErrors.pushTemp(errorMsg);
 | 
	
		
			
				|  |  |                      throw new MusicSheetReadingException("", e);
 |