Browse Source

Linting ScoreIO

Andrea Condoluci 9 năm trước cách đây
mục cha
commit
c8853053fc

+ 78 - 74
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -17,10 +17,8 @@ import {RhythmSymbolEnum} from "../VoiceData/Instructions/RhythmInstruction";
 import {KeyEnum} from "../VoiceData/Instructions/KeyInstruction";
 import {IXmlAttribute} from "../../Common/FileIO/Xml";
 import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
-import {Slur} from "../VoiceData/Expressions/ContinuousExpressions/Slur";
 import {logging} from "../../Common/logging";
 import {MidiInstrument} from "../VoiceData/Instructions/ClefInstruction";
-import {VoiceEntry} from "../VoiceData/VoiceEntry";
 
 
 // FIXME: The following classes are missing
@@ -48,7 +46,7 @@ import {VoiceEntry} from "../VoiceData/VoiceEntry";
 type repetitionInstructionReader = any;
 
 export class InstrumentReader {
-  constructor(repetitionInstructionReader: repetitionInstructionReader, xmlMeasureList: IXmlElement[]/* FIXME IEnumerable<IXmlElement>*/, instrument: Instrument) {
+  constructor(repetitionInstructionReader: repetitionInstructionReader, xmlMeasureList: IXmlElement[], instrument: Instrument) {
     // (*) this.repetitionInstructionReader = repetitionInstructionReader;
     this.xmlMeasureList = xmlMeasureList.slice(); // FIXME .ToArray();
     this.musicSheet = instrument.GetMusicSheet;
@@ -124,7 +122,7 @@ export class InstrumentReader {
           if (this.instrument.Staves.length > 1) {
             try {
               if (xmlNode.element("staff") !== undefined) {
-                noteStaff = parseInt(xmlNode.element("staff").value);
+                noteStaff = parseInt(xmlNode.element("staff").value, 10);
               }
             } catch (ex) {
               logging.debug("InstrumentReader.readNextXmlMeasure.get staff number", ex);
@@ -135,7 +133,7 @@ export class InstrumentReader {
           this.currentStaff = this.instrument.Staves[noteStaff - 1];
           let isChord: boolean = xmlNode.element("chord") !== undefined;
           if (xmlNode.element("voice") !== undefined) {
-            let noteVoice: number = parseInt(xmlNode.element("voice").value);
+            let noteVoice: number = parseInt(xmlNode.element("voice").value, 10);
             this.currentVoiceGenerator = this.getOrCreateVoiceGenerator(noteVoice, noteStaff - 1);
           } else {
             if (!isChord || this.currentVoiceGenerator === undefined) {
@@ -147,7 +145,7 @@ export class InstrumentReader {
           let isTuplet: boolean = false;
           if (xmlNode.element("duration") !== undefined) {
             try {
-              noteDivisions = parseInt(xmlNode.element("duration").value);
+              noteDivisions = parseInt(xmlNode.element("duration").value, 10);
               noteDuration = new Fraction(noteDivisions, 4 * this.divisions);
               if (noteDivisions === 0) {
                 noteDuration = this.getNoteDurationFromTypeNode(xmlNode);
@@ -176,7 +174,7 @@ export class InstrumentReader {
             this.currentStaff
           );
           this.currentStaffEntry = out.staffEntry;
-          let newContainerCreated: boolean = out.createdNewContainer;
+          //let newContainerCreated: boolean = out.createdNewContainer;
 
           if (!this.currentVoiceGenerator.hasVoiceEntry() || !isChord && !isGraceNote && !lastNoteWasGrace || !lastNoteWasGrace && isGraceNote) {
             this.currentVoiceGenerator.createVoiceEntry(musicTimestamp, this.currentStaffEntry, !restNote);
@@ -241,7 +239,7 @@ export class InstrumentReader {
           let divisionsNode: IXmlElement = xmlNode.element("divisions");
           if (divisionsNode !== undefined) {
             try {
-              this.divisions = parseInt(divisionsNode.value);
+              this.divisions = parseInt(divisionsNode.value, 10);
             } catch (e) {
               let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/DivisionError", "Invalid divisions value at Instrument: ");
               logging.debug("InstrumentReader.readNextXmlMeasure", errorMsg, e.toString());
@@ -277,10 +275,10 @@ export class InstrumentReader {
             this.saveClefInstructionAtEndOfMeasure();
           }
         } else if (xmlNode.name === "forward") {
-          let forFraction: number = parseInt(xmlNode.element("duration").value);
+          let forFraction: number = parseInt(xmlNode.element("duration").value, 10);
           currentFraction.Add(new Fraction(forFraction, 4 * this.divisions));
         } else if (xmlNode.name === "backup") {
-          let backFraction: number = parseInt(xmlNode.element("duration").value);
+          let backFraction: number = parseInt(xmlNode.element("duration").value, 10);
           currentFraction.Sub(new Fraction(backFraction, 4 * this.divisions));
           if (currentFraction.Numerator < 0) {
             currentFraction = new Fraction(0, 1);
@@ -290,13 +288,13 @@ export class InstrumentReader {
             previousFraction = new Fraction(0, 1);
           }
         } else if (xmlNode.name === "direction") {
-          let directionTypeNode: IXmlElement = xmlNode.element("direction-type");
+          // unused let directionTypeNode: IXmlElement = xmlNode.element("direction-type");
           // (*) MetronomeReader.readMetronomeInstructions(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
           let relativePositionInMeasure: number = Math.min(1, currentFraction.RealValue);
           if (this.activeRhythm !== undefined && this.activeRhythm.Rhythm !== undefined) {
             relativePositionInMeasure /= this.activeRhythm.Rhythm.RealValue;
           }
-          let handeled: boolean = false;
+          // unused: let handeled: boolean = false;
           // (*) if (this.repetitionInstructionReader !== undefined) {
           //  handeled = this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(directionTypeNode, relativePositionInMeasure);
           //}
@@ -336,9 +334,11 @@ export class InstrumentReader {
         }
       }
       for (let j in this.voiceGeneratorsDict) {
-        let voiceGenerator: VoiceGenerator = this.voiceGeneratorsDict[j];
-        voiceGenerator.checkForOpenBeam();
-        voiceGenerator.checkForOpenGraceNotes();
+        if (this.voiceGeneratorsDict.hasOwnProperty(j)) {
+          let voiceGenerator: VoiceGenerator = this.voiceGeneratorsDict[j];
+          voiceGenerator.checkForOpenBeam();
+          voiceGenerator.checkForOpenGraceNotes();
+        }
       }
       if (this.currentXmlMeasureIndex === this.xmlMeasureList.length - 1) {
         for (let i: number = 0; i < this.instrument.Staves.length; i++) {
@@ -371,7 +371,9 @@ export class InstrumentReader {
   }
   public doCalculationsAfterDurationHasBeenSet(): void {
     for (let j in this.voiceGeneratorsDict) {
-      this.voiceGeneratorsDict[j].checkOpenTies();
+      if (this.voiceGeneratorsDict.hasOwnProperty(j)) {
+        this.voiceGeneratorsDict[j].checkOpenTies();
+      }
     }
   }
   private getOrCreateVoiceGenerator(voiceId: number, staffId: number): VoiceGenerator {
@@ -394,17 +396,17 @@ export class InstrumentReader {
         this.staffMainVoiceGeneratorDict[staffId] = voiceGenerator;
       }
     }
-    return voiceGenerator
+    return voiceGenerator;
   }
 
 
-  private createExpressionGenerators(numberOfStaves: number): void {
-    // (*)
-    //this.expressionReaders = new Array(numberOfStaves);
-    //for (let i: number = 0; i < numberOfStaves; i++) {
-    //  this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
-    //}
-  }
+  //private createExpressionGenerators(numberOfStaves: number): void {
+  //  // (*)
+  //  //this.expressionReaders = new Array(numberOfStaves);
+  //  //for (let i: number = 0; i < numberOfStaves; i++) {
+  //  //  this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
+  //  //}
+  //}
 
 
   private createDefaultClefInstruction(staffIndex: number): void {
@@ -504,7 +506,7 @@ export class InstrumentReader {
     if (transposeNode !== undefined) {
       let chromaticNode: IXmlElement = transposeNode.element("chromatic");
       if (chromaticNode !== undefined) {
-        this.instrument.PlaybackTranspose = parseInt(chromaticNode.value);
+        this.instrument.PlaybackTranspose = parseInt(chromaticNode.value, 10);
       }
     }
     let clefList: IXmlElement[] = node.elements("clef");
@@ -519,7 +521,7 @@ export class InstrumentReader {
         let lineNode: IXmlElement = nodeList.element("line");
         if (lineNode !== undefined) {
           try {
-            line = parseInt(lineNode.value);
+            line = parseInt(lineNode.value, 10);
           } catch (ex) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefLineError",
@@ -562,7 +564,7 @@ export class InstrumentReader {
         let clefOctaveNode: IXmlElement = nodeList.element("clef-octave-change");
         if (clefOctaveNode !== undefined) {
           try {
-            clefOctaveOffset = parseInt(clefOctaveNode.value);
+            clefOctaveOffset = parseInt(clefOctaveNode.value, 10);
           } catch (e) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefOctaveError",
@@ -575,7 +577,7 @@ export class InstrumentReader {
         }
         if (nodeList.hasAttributes && nodeList.attributes()[0].name === "number") {
           try {
-            staffNumber = parseInt(nodeList.attributes()[0].value);
+            staffNumber = parseInt(nodeList.attributes()[0].value, 10);
           } catch (err) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefError",
@@ -595,9 +597,9 @@ export class InstrumentReader {
       let keyNode: IXmlElement = node.element("key").element("fifths");
       if (keyNode !== undefined) {
         try {
-          key = <number>parseInt(keyNode.value);
+          key = parseInt(keyNode.value, 10);
         } catch (ex) {
-          let errorMsg: string = ITextTranslation.translateText(
+          errorMsg = ITextTranslation.translateText(
             "ReaderErrorMessages/KeyError",
             "Invalid key found -> set to default."
           );
@@ -668,12 +670,12 @@ export class InstrumentReader {
               if (s.indexOf("+") !== -1) {
                 let numbers: string[] = s.split("+");
                 for (let idx: number = 0, len: number = numbers.length; idx < len; ++idx) {
-                  n += parseInt(numbers[idx]);
+                  n += parseInt(numbers[idx], 10);
                 }
               } else {
-                n = parseInt(s);
+                n = parseInt(s, 10);
               }
-              d = parseInt(typeList[i].value);
+              d = parseInt(typeList[i].value, 10);
               maxDenom = Math.max(maxDenom, d);
               fractions[i] = new Fraction(n, d, false);
             }
@@ -686,8 +688,8 @@ export class InstrumentReader {
             }
             denom = maxDenom;
           } else {
-            num = parseInt(node.element("time").element("beats").value);
-            denom = parseInt(node.element("time").element("beat-type").value);
+            num = parseInt(node.element("time").element("beats").value, 10);
+            denom = parseInt(node.element("time").element("beat-type").value, 10);
           }
         } catch (ex) {
           errorMsg = ITextTranslation.translateText("ReaderErrorMessages/RhythmError", "Invalid rhythm found -> set to default.");
@@ -851,22 +853,24 @@ export class InstrumentReader {
   */
   private saveClefInstructionAtEndOfMeasure(): void {
     for (let key in this.abstractInstructions) {
-      let value = this.abstractInstructions[key];
-      if (value instanceof ClefInstruction) {
-        let clefInstruction: ClefInstruction = <ClefInstruction>value;
-        if (
-          (this.activeClefs[+key - 1] === undefined) ||
-          (clefInstruction.ClefType !== this.activeClefs[+key - 1].ClefType || (
-            clefInstruction.ClefType === this.activeClefs[+key - 1].ClefType &&
-            clefInstruction.Line !== this.activeClefs[+key - 1].Line
-          ))) {
-          let lastStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
-          this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + (+key) - 1] = lastStaffEntry;
-          let newClefInstruction: ClefInstruction = clefInstruction;
-          newClefInstruction.Parent = lastStaffEntry;
-          lastStaffEntry.Instructions.push(newClefInstruction);
-          this.activeClefs[+key - 1] = clefInstruction;
-          delete this.abstractInstructions[+key]; // FIXME Andrea: might hurt performance?
+      if (this.abstractInstructions.hasOwnProperty(key)) {
+        let value: { [n: number]: AbstractNotationInstruction; } = this.abstractInstructions[key];
+        if (value instanceof ClefInstruction) {
+          let clefInstruction: ClefInstruction = <ClefInstruction>value;
+          if (
+            (this.activeClefs[+key - 1] === undefined) ||
+            (clefInstruction.ClefType !== this.activeClefs[+key - 1].ClefType || (
+              clefInstruction.ClefType === this.activeClefs[+key - 1].ClefType &&
+              clefInstruction.Line !== this.activeClefs[+key - 1].Line
+            ))) {
+            let lastStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
+            this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + (+key) - 1] = lastStaffEntry;
+            let newClefInstruction: ClefInstruction = clefInstruction;
+            newClefInstruction.Parent = lastStaffEntry;
+            lastStaffEntry.Instructions.push(newClefInstruction);
+            this.activeClefs[+key - 1] = clefInstruction;
+            delete this.abstractInstructions[+key]; // FIXME Andrea: might hurt performance?
+          }
         }
       }
     }
@@ -881,8 +885,8 @@ export class InstrumentReader {
           let actualNotes: IXmlElement = time.element("actual-notes");
           let normalNotes: IXmlElement = time.element("normal-notes");
           if (actualNotes !== undefined && normalNotes !== undefined) {
-            let actual: number = parseInt(actualNotes.value);
-            let normal: number = parseInt(normalNotes.value);
+            let actual: number = parseInt(actualNotes.value, 10);
+            let normal: number = parseInt(normalNotes.value, 10);
             duration = new Fraction(normal * typeDuration.Numerator, actual * typeDuration.Denominator);
           }
         }
@@ -890,26 +894,26 @@ export class InstrumentReader {
     }
     return duration;
   }
-  private readExpressionStaffNumber(xmlNode: IXmlElement): number {
-    let directionStaffNumber: number = 1;
-    if (xmlNode.element("staff") !== undefined) {
-      let staffNode: IXmlElement = xmlNode.element("staff");
-      if (staffNode !== undefined) {
-        try {
-          directionStaffNumber = parseInt(staffNode.value);
-        } catch (ex) {
-          let errorMsg: string = ITextTranslation.translateText(
-            "ReaderErrorMessages/ExpressionStaffError", "Invalid Expression staff number -> set to default."
-          );
-          this.musicSheet.SheetErrors.pushTemp(errorMsg);
-          directionStaffNumber = 1;
-          logging.debug("InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
-        }
-
-      }
-    }
-    return directionStaffNumber;
-  }
+  //private readExpressionStaffNumber(xmlNode: IXmlElement): number {
+  //  let directionStaffNumber: number = 1;
+  //  if (xmlNode.element("staff") !== undefined) {
+  //    let staffNode: IXmlElement = xmlNode.element("staff");
+  //    if (staffNode !== undefined) {
+  //      try {
+  //        directionStaffNumber = parseInt(staffNode.value, 10);
+  //      } catch (ex) {
+  //        let errorMsg: string = ITextTranslation.translateText(
+  //          "ReaderErrorMessages/ExpressionStaffError", "Invalid Expression staff number -> set to default."
+  //        );
+  //        this.musicSheet.SheetErrors.pushTemp(errorMsg);
+  //        directionStaffNumber = 1;
+  //        logging.debug("InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
+  //      }
+  //
+  //    }
+  //  }
+  //  return directionStaffNumber;
+  //}
   private readDivisionsFromNotes(): number {
     let divisionsFromNote: number = 0;
     let xmlMeasureIndex: number = this.currentXmlMeasureIndex;
@@ -926,7 +930,7 @@ export class InstrumentReader {
               let type: string = typeNode.value;
               let noteDuration: number = 0;
               try {
-                noteDuration = parseInt(durationNode.value);
+                noteDuration = parseInt(durationNode.value, 10);
               } catch (ex) {
                 logging.debug("InstrumentReader.readDivisionsFromNotes", ex);
                 continue;

+ 215 - 209
src/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -12,7 +12,6 @@ import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
 import {RhythmSymbolEnum} from "../VoiceData/Instructions/RhythmInstruction";
 import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
 import {VoiceEntry} from "../VoiceData/VoiceEntry";
-import {Label} from "../Label";
 import {InstrumentalGroup} from "../InstrumentalGroup";
 import {SubInstrument} from "../SubInstrument";
 import {MidiInstrument} from "../VoiceData/Instructions/ClefInstruction";
@@ -88,7 +87,7 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
   //  return this.createMusicSheet(root, path);
   //}
 
-  private _removeFromArray(list: any[], elem: any) {
+  private _removeFromArray(list: any[], elem: any): void {
     let i: number = list.indexOf(elem);
     if (i !== -1) {
       list.splice(i, 1);
@@ -170,18 +169,18 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
   }
 
   // Trim from a string also newlines
-  private trimString(str: string): string {
-    return str.replace(/^\s+|\s+$/g, "");
-  }
+  //private trimString(str: string): string {
+  //  return str.replace(/^\s+|\s+$/g, "");
+  //}
 
   private _lastElement<T>(list: T[]): T {
-    return list[list.length -1];
+    return list[list.length - 1];
   }
 
   private initializeReading(
     partList: IXmlElement[], partInst: IXmlElement[], instrumentReaders: InstrumentReader[]
   ): void {
-    let instrumentDict: { [_:string]: Instrument; } = this.createInstrumentGroups(partList);
+    let instrumentDict: { [_: string]: Instrument; } = this.createInstrumentGroups(partList);
     this.completeNumberOfStaves = this.getCompleteNumberOfStavesFromXml(partInst);
     if (partInst.length !== 0) {
       // (*) this.repetitionInstructionReader.MusicSheet = this.musicSheet;
@@ -226,7 +225,9 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
     let rhythmInstructions: RhythmInstruction[] = [];
     for (let i: number = 0; i < this.completeNumberOfStaves; i++) {
       if (this.currentMeasure.FirstInstructionsStaffEntries[i] !== undefined) {
-        let last = this.currentMeasure.FirstInstructionsStaffEntries[i].Instructions[this.currentMeasure.FirstInstructionsStaffEntries[i].Instructions.length - 1];
+        let last: AbstractNotationInstruction = this.currentMeasure.FirstInstructionsStaffEntries[i].Instructions[
+          this.currentMeasure.FirstInstructionsStaffEntries[i].Instructions.length - 1
+        ];
         if (last instanceof RhythmInstruction) {
           rhythmInstructions.push(<RhythmInstruction>last);
         }
@@ -280,9 +281,12 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
     for (let idx: number = 0, len: number = rhythmInstructions.length; idx < len; ++idx) {
       let rhythmInstruction: RhythmInstruction = rhythmInstructions[idx];
       if (rhythmInstruction.Rhythm.RealValue < maxRhythmValue) {
-        if (this._lastElement(this.currentMeasure.FirstInstructionsStaffEntries[rhythmInstructions.indexOf(rhythmInstruction)].Instructions) instanceof RhythmInstruction) {
+        if (this._lastElement(
+                this.currentMeasure.FirstInstructionsStaffEntries[rhythmInstructions.indexOf(rhythmInstruction)].Instructions
+            ) instanceof RhythmInstruction) {
           // TODO Test correctness
-          let instrs: AbstractNotationInstruction[] = this.currentMeasure.FirstInstructionsStaffEntries[rhythmInstructions.indexOf(rhythmInstruction)].Instructions;
+          let instrs: AbstractNotationInstruction[] =
+              this.currentMeasure.FirstInstructionsStaffEntries[rhythmInstructions.indexOf(rhythmInstruction)].Instructions;
           instrs[instrs.length - 1] = rhythmInstructions[index].clone();
         }
       }
@@ -416,194 +420,196 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
       }
     }
   }
-  private addSheetLabels(root: IXmlElement, filePath: string): void {
-    this.readComposer(root);
-    this.readTitle(root);
-    if (this.musicSheet.Title === undefined || this.musicSheet.Composer === undefined) {
-      this.readTitleAndComposerFromCredits(root);
-    }
-    if (this.musicSheet.Title === undefined) {
-      try {
-        let bar_i: number = Math.max(
-          0, filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")
-        );
-        let filename: string = filePath.substr(bar_i);
-        let filenameSplits: string[] = filename.split(".", 1);
-        this.musicSheet.Title = new Label(filenameSplits[0]);
-      } catch (ex) {
-        logging.log("MusicSheetReader.pushSheetLabels: ", ex);
-      }
-
-    }
-  }
+  //private addSheetLabels(root: IXmlElement, filePath: string): void {
+  //  this.readComposer(root);
+  //  this.readTitle(root);
+  //  if (this.musicSheet.Title === undefined || this.musicSheet.Composer === undefined) {
+  //    this.readTitleAndComposerFromCredits(root);
+  //  }
+  //  if (this.musicSheet.Title === undefined) {
+  //    try {
+  //      let bar_i: number = Math.max(
+  //        0, filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")
+  //      );
+  //      let filename: string = filePath.substr(bar_i);
+  //      let filenameSplits: string[] = filename.split(".", 1);
+  //      this.musicSheet.Title = new Label(filenameSplits[0]);
+  //    } catch (ex) {
+  //      logging.log("MusicSheetReader.pushSheetLabels: ", ex);
+  //    }
+  //
+  //  }
+  //}
   // Checks whether _elem_ has an attribute with value _val_.
-  private presentAttrsWithValue(elem: IXmlElement, val: string): boolean {
-    for (let attr of elem.attributes()) {
-      if (attr.value === val) { return true; }
-    }
-    return false;
-  }
+  //private presentAttrsWithValue(elem: IXmlElement, val: string): boolean {
+  //  for (let attr of elem.attributes()) {
+  //    if (attr.value === val) { return true; }
+  //  }
+  //  return false;
+  //}
 
-  private readComposer(root: IXmlElement): void {
-    let identificationNode: IXmlElement = root.element("identification");
-    if (identificationNode !== undefined) {
-      let creators: IXmlElement[] = identificationNode.elements("creator");
-      for (let idx: number = 0, len: number = creators.length; idx < len; ++idx) {
-        let creator: IXmlElement = creators[idx];
-        if (creator.hasAttributes) {
-          if (this.presentAttrsWithValue(creator, "composer")) {
-            this.musicSheet.Composer = new Label(this.trimString(creator.value));
-            continue;
-          }
-          if (this.presentAttrsWithValue(creator, "lyricist") || this.presentAttrsWithValue(creator, "poet")) {
-            this.musicSheet.Lyricist = new Label(this.trimString(creator.value));
-          }
-        }
-      }
-    }
-  }
-  private readTitleAndComposerFromCredits(root: IXmlElement): void {
-    let systemYCoordinates: number = this.computeSystemYCoordinates(root);
-    if (systemYCoordinates === 0) { return; }
-    let largestTitleCreditSize: number = 1;
-    let finalTitle: string = undefined;
-    let largestCreditYInfo: number = 0;
-    let finalSubtitle: string = undefined;
-    let possibleTitle: string = undefined;
-    let creditElements: IXmlElement[] = root.elements("credit");
-    for (let idx: number = 0, len: number = creditElements.length; idx < len; ++idx) {
-      let credit: IXmlElement = creditElements[idx];
-      if (credit.attribute("page") === undefined) { return; }
-      if (credit.attribute("page").value === "1") {
-        let creditChild: IXmlElement = undefined;
-        if (credit !== undefined) {
-          creditChild = credit.element("credit-words");
-          if (creditChild.attribute("justify") === undefined) {
-            break;
-          }
-          let creditJustify: string = creditChild.attribute("justify").value;
-          let creditY: string = creditChild.attribute("default-y").value;
-          let creditYInfo: number = parseFloat(creditY);
-          if (creditYInfo > systemYCoordinates) {
-            if (this.musicSheet.Title === undefined) {
-              let creditSize: string = creditChild.attribute("font-size").value;
-              let titleCreditSizeInt: number = parseFloat(creditSize);
-              if (largestTitleCreditSize < titleCreditSizeInt) {
-                largestTitleCreditSize = titleCreditSizeInt;
-                finalTitle = creditChild.value;
-              }
-            }
-            if (this.musicSheet.Subtitle === undefined) {
-              if (creditJustify !== "right" && creditJustify !== "left") {
-                if (largestCreditYInfo < creditYInfo) {
-                  largestCreditYInfo = creditYInfo;
-                  if (possibleTitle) {
-                    finalSubtitle = possibleTitle;
-                    possibleTitle = creditChild.value;
-                  } else {
-                    possibleTitle = creditChild.value;
-                  }
-                }
-              }
-            }
-            if (!(this.musicSheet.Composer !== undefined && this.musicSheet.Lyricist !== undefined)) {
-              switch (creditJustify) {
-                case "right":
-                  this.musicSheet.Composer = new Label(this.trimString(creditChild.value));
-                  break;
-                case "left":
-                  this.musicSheet.Lyricist = new Label(this.trimString(creditChild.value));
-                  break;
-                default: break;
-              }
-            }
-          }
-        }
-      }
-    }
-    if (this.musicSheet.Title === undefined && finalTitle) {
-      this.musicSheet.Title = new Label(this.trimString(finalTitle));
-    }
-    if (this.musicSheet.Subtitle === undefined && finalSubtitle) {
-      this.musicSheet.Subtitle = new Label(this.trimString(finalSubtitle));
-    }
-  }
-  private computeSystemYCoordinates(root: IXmlElement): number {
-    if (root.element("defaults") === undefined) {
-      return 0;
-    }
-    let paperHeight: number = 0;
-    let topSystemDistance: number = 0;
-    let defi: string = root.element("defaults").element("page-layout").element("page-height").value;
-    paperHeight = parseFloat(defi);
-    let found: boolean = false;
-    let parts: IXmlElement[] = root.elements("part");
-    for (let idx: number = 0, len: number = parts.length; idx < len; ++idx) {
-      let measures: IXmlElement[] = parts[idx].elements("measure");
-      for (let idx2: number = 0, len2: number = measures.length; idx2 < len2; ++idx2) {
-        let measure: IXmlElement = measures[idx2];
-        if (measure.element("print") !== undefined) {
-          let systemLayouts: IXmlElement[] = measure.element("print").elements("system-layout");
-          for (let idx3: number = 0, len3: number = systemLayouts.length; idx3 < len3; ++idx3) {
-            let syslab: IXmlElement = systemLayouts[idx3];
-            if (syslab.element("top-system-distance") !== undefined) {
-              let topSystemDistanceString: string = syslab.element("top-system-distance").value;
-              topSystemDistance = parseFloat(topSystemDistanceString);
-              found = true;
-              break;
-            }
-          }
-          break;
-        }
-      }
-      if (found) { break; }
-    }
-    if (root.element("defaults").element("system-layout") !== undefined) {
-      let syslay: IXmlElement = root.element("defaults").element("system-layout");
-      if (syslay.element("top-system-distance") !== undefined) {
-        let topSystemDistanceString: string = root.element("defaults").element("system-layout").element("top-system-distance").value;
-        topSystemDistance = parseFloat(topSystemDistanceString);
-      }
-    }
-    if (topSystemDistance === 0) { return 0; }
-    return paperHeight - topSystemDistance;
-  }
-  private readTitle(root: IXmlElement): void {
-    let titleNode: IXmlElement = root.element("work");
-    let titleNodeChild: IXmlElement = undefined;
-    if (titleNode !== undefined) {
-      titleNodeChild = titleNode.element("work-title");
-      if (titleNodeChild !== undefined && titleNodeChild.value) {
-        this.musicSheet.Title = new Label(this.trimString(titleNodeChild.value));
-      }
-    }
-    let movementNode: IXmlElement = root.element("movement-title");
-    let finalSubTitle: string = "";
-    if (movementNode !== undefined) {
-      if (this.musicSheet.Title === undefined) {
-        this.musicSheet.Title = new Label(this.trimString(movementNode.value));
-      } else {
-        finalSubTitle = this.trimString(movementNode.value);
-      }
-    }
-    if (titleNode !== undefined) {
-      let subtitleNodeChild: IXmlElement = titleNode.element("work-number");
-      if (subtitleNodeChild !== undefined) {
-        let workNumber: string = subtitleNodeChild.value;
-        if (workNumber) {
-          if (finalSubTitle) {
-            finalSubTitle = workNumber;
-          } else {
-            finalSubTitle = finalSubTitle + ", " + workNumber;
-          }
-        }
-      }
-    }
-    if (finalSubTitle
-    ) {
-      this.musicSheet.Subtitle = new Label(finalSubTitle);
-    }
-  }
+  //private readComposer(root: IXmlElement): void {
+  //  let identificationNode: IXmlElement = root.element("identification");
+  //  if (identificationNode !== undefined) {
+  //    let creators: IXmlElement[] = identificationNode.elements("creator");
+  //    for (let idx: number = 0, len: number = creators.length; idx < len; ++idx) {
+  //      let creator: IXmlElement = creators[idx];
+  //      if (creator.hasAttributes) {
+  //        if (this.presentAttrsWithValue(creator, "composer")) {
+  //          this.musicSheet.Composer = new Label(this.trimString(creator.value));
+  //          continue;
+  //        }
+  //        if (this.presentAttrsWithValue(creator, "lyricist") || this.presentAttrsWithValue(creator, "poet")) {
+  //          this.musicSheet.Lyricist = new Label(this.trimString(creator.value));
+  //        }
+  //      }
+  //    }
+  //  }
+  //}
+
+  //private readTitleAndComposerFromCredits(root: IXmlElement): void {
+  //  let systemYCoordinates: number = this.computeSystemYCoordinates(root);
+  //  if (systemYCoordinates === 0) { return; }
+  //  let largestTitleCreditSize: number = 1;
+  //  let finalTitle: string = undefined;
+  //  let largestCreditYInfo: number = 0;
+  //  let finalSubtitle: string = undefined;
+  //  let possibleTitle: string = undefined;
+  //  let creditElements: IXmlElement[] = root.elements("credit");
+  //  for (let idx: number = 0, len: number = creditElements.length; idx < len; ++idx) {
+  //    let credit: IXmlElement = creditElements[idx];
+  //    if (credit.attribute("page") === undefined) { return; }
+  //    if (credit.attribute("page").value === "1") {
+  //      let creditChild: IXmlElement = undefined;
+  //      if (credit !== undefined) {
+  //        creditChild = credit.element("credit-words");
+  //        if (creditChild.attribute("justify") === undefined) {
+  //          break;
+  //        }
+  //        let creditJustify: string = creditChild.attribute("justify").value;
+  //        let creditY: string = creditChild.attribute("default-y").value;
+  //        let creditYInfo: number = parseFloat(creditY);
+  //        if (creditYInfo > systemYCoordinates) {
+  //          if (this.musicSheet.Title === undefined) {
+  //            let creditSize: string = creditChild.attribute("font-size").value;
+  //            let titleCreditSizeInt: number = parseFloat(creditSize);
+  //            if (largestTitleCreditSize < titleCreditSizeInt) {
+  //              largestTitleCreditSize = titleCreditSizeInt;
+  //              finalTitle = creditChild.value;
+  //            }
+  //          }
+  //          if (this.musicSheet.Subtitle === undefined) {
+  //            if (creditJustify !== "right" && creditJustify !== "left") {
+  //              if (largestCreditYInfo < creditYInfo) {
+  //                largestCreditYInfo = creditYInfo;
+  //                if (possibleTitle) {
+  //                  finalSubtitle = possibleTitle;
+  //                  possibleTitle = creditChild.value;
+  //                } else {
+  //                  possibleTitle = creditChild.value;
+  //                }
+  //              }
+  //            }
+  //          }
+  //          if (!(this.musicSheet.Composer !== undefined && this.musicSheet.Lyricist !== undefined)) {
+  //            switch (creditJustify) {
+  //              case "right":
+  //                this.musicSheet.Composer = new Label(this.trimString(creditChild.value));
+  //                break;
+  //              case "left":
+  //                this.musicSheet.Lyricist = new Label(this.trimString(creditChild.value));
+  //                break;
+  //              default: break;
+  //            }
+  //          }
+  //        }
+  //      }
+  //    }
+  //  }
+  //  if (this.musicSheet.Title === undefined && finalTitle) {
+  //    this.musicSheet.Title = new Label(this.trimString(finalTitle));
+  //  }
+  //  if (this.musicSheet.Subtitle === undefined && finalSubtitle) {
+  //    this.musicSheet.Subtitle = new Label(this.trimString(finalSubtitle));
+  //  }
+  //}
+
+  //private computeSystemYCoordinates(root: IXmlElement): number {
+  //  if (root.element("defaults") === undefined) {
+  //    return 0;
+  //  }
+  //  let paperHeight: number = 0;
+  //  let topSystemDistance: number = 0;
+  //  let defi: string = root.element("defaults").element("page-layout").element("page-height").value;
+  //  paperHeight = parseFloat(defi);
+  //  let found: boolean = false;
+  //  let parts: IXmlElement[] = root.elements("part");
+  //  for (let idx: number = 0, len: number = parts.length; idx < len; ++idx) {
+  //    let measures: IXmlElement[] = parts[idx].elements("measure");
+  //    for (let idx2: number = 0, len2: number = measures.length; idx2 < len2; ++idx2) {
+  //      let measure: IXmlElement = measures[idx2];
+  //      if (measure.element("print") !== undefined) {
+  //        let systemLayouts: IXmlElement[] = measure.element("print").elements("system-layout");
+  //        for (let idx3: number = 0, len3: number = systemLayouts.length; idx3 < len3; ++idx3) {
+  //          let syslab: IXmlElement = systemLayouts[idx3];
+  //          if (syslab.element("top-system-distance") !== undefined) {
+  //            let topSystemDistanceString: string = syslab.element("top-system-distance").value;
+  //            topSystemDistance = parseFloat(topSystemDistanceString);
+  //            found = true;
+  //            break;
+  //          }
+  //        }
+  //        break;
+  //      }
+  //    }
+  //    if (found) { break; }
+  //  }
+  //  if (root.element("defaults").element("system-layout") !== undefined) {
+  //    let syslay: IXmlElement = root.element("defaults").element("system-layout");
+  //    if (syslay.element("top-system-distance") !== undefined) {
+  //      let topSystemDistanceString: string = root.element("defaults").element("system-layout").element("top-system-distance").value;
+  //      topSystemDistance = parseFloat(topSystemDistanceString);
+  //    }
+  //  }
+  //  if (topSystemDistance === 0) { return 0; }
+  //  return paperHeight - topSystemDistance;
+  //}
+  //private readTitle(root: IXmlElement): void {
+  //  let titleNode: IXmlElement = root.element("work");
+  //  let titleNodeChild: IXmlElement = undefined;
+  //  if (titleNode !== undefined) {
+  //    titleNodeChild = titleNode.element("work-title");
+  //    if (titleNodeChild !== undefined && titleNodeChild.value) {
+  //      this.musicSheet.Title = new Label(this.trimString(titleNodeChild.value));
+  //    }
+  //  }
+  //  let movementNode: IXmlElement = root.element("movement-title");
+  //  let finalSubTitle: string = "";
+  //  if (movementNode !== undefined) {
+  //    if (this.musicSheet.Title === undefined) {
+  //      this.musicSheet.Title = new Label(this.trimString(movementNode.value));
+  //    } else {
+  //      finalSubTitle = this.trimString(movementNode.value);
+  //    }
+  //  }
+  //  if (titleNode !== undefined) {
+  //    let subtitleNodeChild: IXmlElement = titleNode.element("work-number");
+  //    if (subtitleNodeChild !== undefined) {
+  //      let workNumber: string = subtitleNodeChild.value;
+  //      if (workNumber) {
+  //        if (finalSubTitle) {
+  //          finalSubTitle = workNumber;
+  //        } else {
+  //          finalSubTitle = finalSubTitle + ", " + workNumber;
+  //        }
+  //      }
+  //    }
+  //  }
+  //  if (finalSubTitle
+  //  ) {
+  //    this.musicSheet.Subtitle = new Label(finalSubTitle);
+  //  }
+  //}
   private createInstrumentGroups(entryList: IXmlElement[]): { [_: string]: Instrument; } {
     let instrumentId: number = 0;
     let instrumentDict: { [_: string]: Instrument; } = {};
@@ -645,15 +651,15 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
                   let instrumentElement: IXmlElement = instrumentElements[idx3];
                   try {
                     if (instrumentElement.name === "midi-channel") {
-                      if (parseInt(instrumentElement.value) === 10) {
+                      if (parseInt(instrumentElement.value, 10) === 10) {
                         instrument.MidiInstrumentId = MidiInstrument.Percussion;
                       }
                     } else if (instrumentElement.name === "midi-program") {
                       if (instrument.SubInstruments.length > 0 && instrument.MidiInstrumentId !== MidiInstrument.Percussion) {
-                        subInstrument.midiInstrumentID = <MidiInstrument>Math.max(0, parseInt(instrumentElement.value) - 1);
+                        subInstrument.midiInstrumentID = <MidiInstrument>Math.max(0, parseInt(instrumentElement.value, 10) - 1);
                       }
                     } else if (instrumentElement.name === "midi-unpitched") {
-                      subInstrument.fixedKey = Math.max(0, parseInt(instrumentElement.value));
+                      subInstrument.fixedKey = Math.max(0, parseInt(instrumentElement.value, 10));
                     } else if (instrumentElement.name === "volume") {
                       try {
                         let result: number = <number>parseFloat(instrumentElement.value);
@@ -738,7 +744,7 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
     return instrumentDict;
   }
   private getCompleteNumberOfStavesFromXml(partInst: IXmlElement[]): number {
-    let number: number = 0;
+    let num: number = 0;
     let partInstArr: IXmlElement[] = partInst;
     for (let idx: number = 0, len: number = partInstArr.length; idx < len; ++idx) {
       let partNode: IXmlElement = partInstArr[idx];
@@ -751,23 +757,23 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
             stavesNode = stavesNode.element("staves");
           }
           if (stavesNode === undefined) {
-            number++;
+            num++;
           } else {
-            number += parseInt(stavesNode.value);
+            num += parseInt(stavesNode.value, 10);
           }
         }
       }
     }
-    if (number <= 0) {
+    if (num <= 0) {
       let errorMsg: string = ITextTranslation.translateText(
         "ReaderErrorMessages/StaffError", "Invalid number of staves."
       );
       throw new MusicSheetReadingException(errorMsg);
     }
-    return number;
+    return num;
   }
   private getInstrumentNumberOfStavesFromXml(partNode: IXmlElement): number {
-    let number: number = 0;
+    let num: number = 0;
     let xmlMeasure: IXmlElement = partNode.element("measure");
     if (xmlMeasure !== undefined) {
       let attributes: IXmlElement = xmlMeasure.element("attributes");
@@ -776,17 +782,17 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
         staves = attributes.element("staves");
       }
       if (attributes === undefined || staves === undefined) {
-        number = 1;
+        num = 1;
       } else {
-        number = parseInt(staves.value);
+        num = parseInt(staves.value, 10);
       }
     }
-    if (number <= 0) {
+    if (num <= 0) {
       let errorMsg: string = ITextTranslation.translateText(
         "ReaderErrorMessages/StaffError", "Invalid number of Staves."
       );
       throw new MusicSheetReadingException(errorMsg);
     }
-    return number;
+    return num;
   }
 }

+ 204 - 214
src/MusicalScore/ScoreIO/VoiceGenerator.ts

@@ -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);

+ 8 - 7
src/MusicalScore/VoiceData/Expressions/abstractExpression.ts

@@ -1,12 +1,13 @@
 export class AbstractExpression {
-    constructor() {
-
-    }
+    //constructor() {
+    //
+    //}
     protected static isStringInStringList(stringList: Array<string>, inputString: string): boolean {
-        for (var idx: number = 0, len = stringList.length; idx < len; ++idx) {
-            var s: string = stringList[idx];
-            if (inputString.toLowerCase() === s.toLowerCase().trim())
+        for (let idx: number = 0, len: number = stringList.length; idx < len; ++idx) {
+            let s: string = stringList[idx];
+            if (inputString.toLowerCase() === s.toLowerCase().trim()) {
                 return true;
+            }
         }
         return false;
     }
@@ -16,4 +17,4 @@ export enum PlacementEnum {
     Above = 0,
     Below = 1,
     NotYetDefined = 2
-}
+}

+ 13 - 13
src/MusicalScore/VoiceData/Expressions/instantaniousDynamicExpression.ts

@@ -1,7 +1,7 @@
 import {PlacementEnum, AbstractExpression} from "./abstractExpression";
 import {MultiExpression} from "./multiExpression";
 import {DynamicExpressionSymbolEnum} from "./dynamicExpressionSymbolEnum";
-import {ArgumentOutOfRangeException} from "../../Exceptions";
+//import {ArgumentOutOfRangeException} from "../../Exceptions";
 import {InvalidEnumArgumentException} from "../../Exceptions";
 import {logging} from "../../../Common/logging";
 
@@ -36,14 +36,14 @@ export class InstantaniousDynamicExpression extends AbstractExpression {
         "rfz": 0.5,
         "sfz": 0.5,
         "sffz": 0.5,
-        "fz": 0.5
+        "fz": 0.5,
     };
 
-    private static weight: number;
+    //private static weight: number;
     private static listInstantaniousDynamics: string[] =  [
         "pppppp", "ppppp", "pppp", "ppp", "pp", "p",
         "ffffff", "fffff", "ffff", "fff", "ff", "f",
-        "mf", "mp", "sf", "sp", "spp", "fp", "rf", "rfz", "sfz", "sffz", "fz"
+        "mf", "mp", "sf", "sp", "spp", "fp", "rf", "rfz", "sfz", "sffz", "fz",
     ];
 
     private multiExpression: MultiExpression;
@@ -92,8 +92,8 @@ export class InstantaniousDynamicExpression extends AbstractExpression {
     public get MidiVolume(): number {
         return InstantaniousDynamicExpression.dynamicToRelativeVolumeDict[this.dynamicEnum] * 127;
     }
-    public static isInputStringInstantaniousDynamic(inputString:string): boolean {
-        if (inputString === null) { return false; }
+    public static isInputStringInstantaniousDynamic(inputString: string): boolean {
+        if (inputString === undefined) { return false; }
         return InstantaniousDynamicExpression.isStringInStringList(InstantaniousDynamicExpression.listInstantaniousDynamics, inputString);
     }
 
@@ -115,19 +115,19 @@ export class InstantaniousDynamicExpression extends AbstractExpression {
     //            throw new ArgumentOutOfRangeException("expressionSymbolEnum");
     //    }
     //}
-    public getDynamicExpressionSymbol(c:string): DynamicExpressionSymbolEnum  {
+    public getDynamicExpressionSymbol(c: string): DynamicExpressionSymbolEnum  {
         switch (c) {
-            case 'p':
+            case "p":
                 return DynamicExpressionSymbolEnum.p;
-            case 'f':
+            case "f":
                 return DynamicExpressionSymbolEnum.f;
-            case 's':
+            case "s":
                 return DynamicExpressionSymbolEnum.s;
-            case 'z':
+            case "z":
                 return DynamicExpressionSymbolEnum.z;
-            case 'm':
+            case "m":
                 return DynamicExpressionSymbolEnum.m;
-            case 'r':
+            case "r":
                 return DynamicExpressionSymbolEnum.r;
             default:
                 throw new InvalidEnumArgumentException("unknown DynamicExpressionSymbolEnum: " + c);

+ 128 - 109
src/MusicalScore/VoiceData/Expressions/instantaniousTempoExpression.ts

@@ -9,64 +9,31 @@ export class InstantaniousTempoExpression extends AbstractTempoExpression {
         super(label, placement, staffNumber, parentMultiTempoExpression);
         this.setTempoAndTempoType(soundTempo);
     }
-    
-    private tempoEnum: TempoEnum;
-    private tempoInBpm: number;
-
-    // Must refactor: In c# use 'out' arguments
-    //private findTempoEnum(inputString: string, pre: string, post: string): TempoEnum {
-    //    let result: TempoEnum = this.splitStringAfterInstructionWord(inputString, InstantaniousTempoExpression.listInstantaniousTempoLarghissimo, TempoEnum.larghissimo, pre,
-    //        post);
-    //    if (result !== TempoEnum.none)
-    //        return result;
-    //    result = this.splitStringAfterInstructionWord(inputString, InstantaniousTempoExpression.listInstantaniousTempoGrave, TempoEnum.grave, pre,
-    //        post);
-    //    if (result !== TempoEnum.none)
-    //        return result;
-    //    return TempoEnum.none;
-    //}
-    //private splitStringAfterInstructionWord(inputString: string, instruction: string[], value: TempoEnum, pre: string, post: string): TempoEnum {
-    //    pre = undefined;
-    //    post = undefined;
-    //    for (let idx: number = 0, len = instruction.length; idx < len; ++idx) {
-    //        let instructionWord: string = instruction[idx];
-    //        let separators: string[] = [" " + instructionWord, instructionWord + " ", "," + instructionWord, instructionWord + ","];
-    //        for (let j: number = 0; j < 4; j++) {
-    //            let splits:string[] = inputString.split(separators[j], 2);
-    //            if (splits.length > 1) {
-    //                pre = splits[0];
-    //                post = splits[1];
-    //                return value;
-    //            }
-    //        }
-    //    }
-    //    return TempoEnum.none;
-    //}
-    private static listInstantaniousTempoLarghissimo: string[] = ["Larghissimo","Sehr breit","very, very slow"]; // }), TempoEnum.larghissimo);
-    private static listInstantaniousTempoGrave: string[] = ["Grave","Schwer","slow and solemn"]; //  }), TempoEnum.grave);
-    private static listInstantaniousTempoLento: string[] = ["Lento","Lent","Langsam","slowly"]; //  }), TempoEnum.lento);
-    private static listInstantaniousTempoLargo: string[] = ["Largo","Breit","broadly"]; //  }), TempoEnum.largo);
-    private static listInstantaniousTempoLarghetto: string[] = ["Larghetto","Etwas breit","rather broadly"]; //  }), TempoEnum.larghetto);
-    private static listInstantaniousTempoAdagio: string[] = ["Adagio","Langsam","Ruhig","slow and stately"]; // }), TempoEnum.adagio);
-    private static listInstantaniousTempoAdagietto: string[] = ["Adagietto","Ziemlich ruhig","Ziemlich langsam","rather slow"]; //  }), TempoEnum.adagietto);
+    private static listInstantaniousTempoLarghissimo: string[] = ["Larghissimo", "Sehr breit", "very, very slow"]; // }), TempoEnum.larghissimo);
+    private static listInstantaniousTempoGrave: string[] = ["Grave", "Schwer", "slow and solemn"]; //  }), TempoEnum.grave);
+    private static listInstantaniousTempoLento: string[] = ["Lento", "Lent", "Langsam", "slowly"]; //  }), TempoEnum.lento);
+    private static listInstantaniousTempoLargo: string[] = ["Largo", "Breit", "broadly"]; //  }), TempoEnum.largo);
+    private static listInstantaniousTempoLarghetto: string[] = ["Larghetto", "Etwas breit", "rather broadly"]; //  }), TempoEnum.larghetto);
+    private static listInstantaniousTempoAdagio: string[] = ["Adagio", "Langsam", "Ruhig", "slow and stately"]; // }), TempoEnum.adagio);
+    private static listInstantaniousTempoAdagietto: string[] = ["Adagietto", "Ziemlich ruhig", "Ziemlich langsam", "rather slow"]; //  }), TempoEnum.adagietto);
     private static listInstantaniousTempoAndanteModerato: string[] = ["Andante moderato"]; //  }), TempoEnum.andanteModerato);
-    private static listInstantaniousTempoAndante: string[] = ["Andante","Gehend","Schreitend","at a walking pace"]; //  }), TempoEnum.andante);
+    private static listInstantaniousTempoAndante: string[] = ["Andante", "Gehend", "Schreitend", "at a walking pace"]; //  }), TempoEnum.andante);
     private static listInstantaniousTempoAndantino: string[] = ["Andantino"]; //  }), TempoEnum.andantino);
-    private static listInstantaniousTempoModerato: string[] = ["Moderato","M��ig","Mod�r�","moderately"]; //  }), TempoEnum.moderato);
-    private static listInstantaniousTempoAllegretto: string[] = ["Allegretto","fast"]; //  }), TempoEnum.allegretto);
+    private static listInstantaniousTempoModerato: string[] = ["Moderato", "M��ig", "Mod�r�", "moderately"]; //  }), TempoEnum.moderato);
+    private static listInstantaniousTempoAllegretto: string[] = ["Allegretto", "fast"]; //  }), TempoEnum.allegretto);
     private static listInstantaniousTempoAllegroModerato: string[] = ["Allegro moderato"]; //  }), TempoEnum.allegroModerato);
-    private static listInstantaniousTempoAllegro: string[] = ["Allegro","Rapide","Vite","Rasch","Schnell","Fr�hlich"]; //  }), TempoEnum.allegro);
-    private static listInstantaniousTempoVivace: string[] = ["Vivace","Lebhaft","Lebendig","lively and fast"]; //  }), TempoEnum.vivace);
-    private static listInstantaniousTempoVivacissimo: string[] = ["Vivacissimo","Sehr lebhaft","Sehr lebendig"]; //  }), TempoEnum.vivacissimo);
-    private static listInstantaniousTempoAllegrissimo: string[] = ["Allegrissimo","very fast"]; //  }), TempoEnum.allegrissimo);
-    private static listInstantaniousTempoPresto: string[] = ["Presto","Sehr schnell","Geschwind"]; //  }), TempoEnum.presto);
-    private static listInstantaniousTempoPrestissimo: string[] = ["Prestissimo","�u�erst schnell"]; //  }), TempoEnum.prestissimo);
+    private static listInstantaniousTempoAllegro: string[] = ["Allegro", "Rapide", "Vite", "Rasch", "Schnell", "Fr�hlich"]; //  }), TempoEnum.allegro);
+    private static listInstantaniousTempoVivace: string[] = ["Vivace", "Lebhaft", "Lebendig", "lively and fast"]; //  }), TempoEnum.vivace);
+    private static listInstantaniousTempoVivacissimo: string[] = ["Vivacissimo", "Sehr lebhaft", "Sehr lebendig"]; //  }), TempoEnum.vivacissimo);
+    private static listInstantaniousTempoAllegrissimo: string[] = ["Allegrissimo", "very fast"]; //  }), TempoEnum.allegrissimo);
+    private static listInstantaniousTempoPresto: string[] = ["Presto", "Sehr schnell", "Geschwind"]; //  }), TempoEnum.presto);
+    private static listInstantaniousTempoPrestissimo: string[] = ["Prestissimo", "�u�erst schnell"]; //  }), TempoEnum.prestissimo);
     private static listInstantaniousTempoChangesGeneral: string[] = [
         "tempo primo",
         "a tempo",
         "tempo i",
         "rubato",
-        "doppio movimento"
+        "doppio movimento",
     ];
     private static listInstantaniousTempoAddons: string[] = [
         "assai",
@@ -150,45 +117,42 @@ export class InstantaniousTempoExpression extends AbstractTempoExpression {
         "ein wenig",
         "alla marcia",
         "ad libitum",
-        "alla breve"
+        "alla breve",
     ];
-    
-    public get Label(): string {
-        return this.label;
-    }
-    public set Label(value: string) {
-        this.label = value;
-    }
-    public get Placement(): PlacementEnum {
-        return this.placement;
-    }
-    public set Placement(value: PlacementEnum) {
-        this.placement = value;
-    }
-    public get StaffNumber(): number {
-        return this.staffNumber;
-    }
-    public set StaffNumber(value: number) {
-        this.staffNumber = value;
-    }
-    public get Enum(): TempoEnum {
-        return this.tempoEnum;
-    }
-    public get TempoInBpm(): number {
-        return this.tempoInBpm;
-    }
-    public set TempoInBpm(value: number) {
-        this.tempoInBpm = value;
-    }
-    public get ParentMultiTempoExpression(): MultiTempoExpression {
-        return this.parentMultiTempoExpression;
-    }
-    public getAbsoluteTimestamp(): Fraction {
-        return Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp, this.ParentMultiTempoExpression.Timestamp);
-    }
-    public getAbsoluteFloatTimestamp(): number {
-        return Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp, this.ParentMultiTempoExpression.Timestamp).RealValue;
-    }
+
+    private tempoEnum: TempoEnum;
+    private tempoInBpm: number;
+
+    // Must refactor: In c# use 'out' arguments
+    //private findTempoEnum(inputString: string, pre: string, post: string): TempoEnum {
+    //    let result: TempoEnum = this.splitStringAfterInstructionWord(inputString,
+    // InstantaniousTempoExpression.listInstantaniousTempoLarghissimo, TempoEnum.larghissimo, pre,
+    //        post);
+    //    if (result !== TempoEnum.none)
+    //        return result;
+    //    result = this.splitStringAfterInstructionWord(inputString, InstantaniousTempoExpression.listInstantaniousTempoGrave, TempoEnum.grave, pre,
+    //        post);
+    //    if (result !== TempoEnum.none)
+    //        return result;
+    //    return TempoEnum.none;
+    //}
+    //private splitStringAfterInstructionWord(inputString: string, instruction: string[], value: TempoEnum, pre: string, post: string): TempoEnum {
+    //    pre = undefined;
+    //    post = undefined;
+    //    for (let idx: number = 0, len = instruction.length; idx < len; ++idx) {
+    //        let instructionWord: string = instruction[idx];
+    //        let separators: string[] = [" " + instructionWord, instructionWord + " ", "," + instructionWord, instructionWord + ","];
+    //        for (let j: number = 0; j < 4; j++) {
+    //            let splits:string[] = inputString.split(separators[j], 2);
+    //            if (splits.length > 1) {
+    //                pre = splits[0];
+    //                post = splits[1];
+    //                return value;
+    //            }
+    //        }
+    //    }
+    //    return TempoEnum.none;
+    //}
     public static getDefaultValueForTempoType(tempoEnum: TempoEnum): number {
         switch (tempoEnum) {
             case TempoEnum.larghissimo:
@@ -234,8 +198,7 @@ export class InstantaniousTempoExpression extends AbstractTempoExpression {
         }
     }
     public static isInputStringInstantaniousTempo(inputString: string): boolean {
-        if (inputString === undefined)
-            return false;
+        if (inputString === undefined) { return false; }
         return (
             (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoLarghissimo, inputString))
             || (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoGrave, inputString))
@@ -259,136 +222,192 @@ export class InstantaniousTempoExpression extends AbstractTempoExpression {
             || (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoChangesGeneral, inputString))
         );
     }
+
+    public get Label(): string {
+        return this.label;
+    }
+    public set Label(value: string) {
+        this.label = value;
+    }
+    public get Placement(): PlacementEnum {
+        return this.placement;
+    }
+    public set Placement(value: PlacementEnum) {
+        this.placement = value;
+    }
+    public get StaffNumber(): number {
+        return this.staffNumber;
+    }
+    public set StaffNumber(value: number) {
+        this.staffNumber = value;
+    }
+    public get Enum(): TempoEnum {
+        return this.tempoEnum;
+    }
+    public get TempoInBpm(): number {
+        return this.tempoInBpm;
+    }
+    public set TempoInBpm(value: number) {
+        this.tempoInBpm = value;
+    }
+    public get ParentMultiTempoExpression(): MultiTempoExpression {
+        return this.parentMultiTempoExpression;
+    }
+    public getAbsoluteTimestamp(): Fraction {
+        return Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp, this.ParentMultiTempoExpression.Timestamp);
+    }
+    public getAbsoluteFloatTimestamp(): number {
+        return Fraction.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp, this.ParentMultiTempoExpression.Timestamp).RealValue;
+    }
     private setTempoAndTempoType(soundTempo: number): void {
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoLarghissimo, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.larghissimo);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.larghissimo;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoGrave, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.grave);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.grave;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoLento, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.lento);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.lento;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoLargo, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.largo);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.largo;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoLarghetto, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.larghetto);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.larghetto;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAdagio, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.adagio);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.adagio;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAdagietto, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.adagietto);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.adagietto;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAndanteModerato, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.andanteModerato);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.andanteModerato;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAndante, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.andante);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.andante;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAndantino, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.andantino);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.andantino;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoModerato, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.moderato);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.moderato;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAllegretto, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.allegretto);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.allegretto;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAllegroModerato, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.allegroModerato);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.allegroModerato;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAllegro, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.allegro);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.allegro;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoVivace, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.vivace);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.vivace;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoVivacissimo, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.vivacissimo);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.vivacissimo;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoAllegrissimo, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.allegrissimo);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.allegrissimo;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoPresto, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.presto);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.presto;
             return;
         }
         if (InstantaniousTempoExpression.isStringInStringList(InstantaniousTempoExpression.listInstantaniousTempoPrestissimo, this.label)) {
-            if (soundTempo === 0)
+            if (soundTempo === 0) {
                 soundTempo = InstantaniousTempoExpression.getDefaultValueForTempoType(TempoEnum.prestissimo);
+            }
             this.tempoInBpm = soundTempo;
             this.tempoEnum = TempoEnum.prestissimo;
             return;

+ 84 - 113
src/MusicalScore/VoiceData/Expressions/moodExpression.ts

@@ -8,15 +8,11 @@ export class MoodExpression extends AbstractExpression {
         this.staffNumber = staffNumber;
         this.setMoodType();
     }
-    
-    private moodType: MoodEnum;
-    private label: string;
-    private staffNumber: number;
-    private placement: PlacementEnum;
+
     private static listMoodAffettuoso: string[] = ["affettuoso"];
     private static listMoodAgitato: string[] = ["agitato"];
     private static listMoodAppassionato: string[] = ["appassionato"];
-    private static listMoodAnimato: string[] = ["animato","lively"];
+    private static listMoodAnimato: string[] = ["animato", "lively"];
     private static listMoodBrillante: string[] = ["brillante"];
     private static listMoodCantabile: string[] = ["cantabile"];
     private static listMoodDolce: string[] = ["dolce"];
@@ -48,6 +44,53 @@ export class MoodExpression extends AbstractExpression {
     private static listMoodTranquillamente: string[] = ["tranquillamente"];
     private static listMoodTrionfante: string[] = ["trionfante"];
 
+    private moodType: MoodEnum;
+    private label: string;
+    private staffNumber: number;
+    private placement: PlacementEnum;
+
+    public static isInputStringMood(inputString: string): boolean {
+        if (inputString === undefined) {
+            return false;
+        }
+        return (
+            MoodExpression.isStringInStringList(MoodExpression.listMoodAffettuoso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodAgitato, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodAnimato, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodAppassionato, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodBrillante, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodCantabile, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodDolce, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodEnergico, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodEroico, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodEspressivo, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodFurioso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodGiocoso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodGioioso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodGrandioso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodGrazioso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodLacrimoso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodLeggiero, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMaestoso, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMalinconico, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMarcato, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMarziale, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMesto, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodMorendo, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodNobilmente, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodPatetico, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodPesante, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodSaltando, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodSautille, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodScherzando, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodSostenuto, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodSpiccato, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodTenerezza, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodTranquillamente, inputString)
+            || MoodExpression.isStringInStringList(MoodExpression.listMoodTrionfante, inputString)
+        );
+    }
+
     public get Label(): string {
         return this.label;
     }
@@ -73,148 +116,76 @@ export class MoodExpression extends AbstractExpression {
         this.placement = value;
     }
 
-    public static isInputStringMood(inputString: string): boolean {
-        if (inputString == null)
-            return false;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAffettuoso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAgitato, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAnimato, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAppassionato, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodBrillante, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodCantabile, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodDolce, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEnergico, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEroico, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEspressivo, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodFurioso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGiocoso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGioioso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrandioso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrazioso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodLacrimoso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodLeggiero, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMaestoso, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMalinconico, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarcato, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarziale, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMesto, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMorendo, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodNobilmente, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodPatetico, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodPesante, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSaltando, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSautille, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodScherzando, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSostenuto, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSpiccato, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTenerezza, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTranquillamente, inputString))
-            return true;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTrionfante, inputString))
-            return true;
-        return false;
-    }
     private setMoodType(): void {
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAffettuoso, this.label))
+        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAffettuoso, this.label)) {
             this.moodType = MoodEnum.Affettuoso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAgitato, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodAgitato, this.label)) {
             this.moodType = MoodEnum.Agitato;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAnimato, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodAnimato, this.label)) {
             this.moodType = MoodEnum.Animato;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodAppassionato, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodAppassionato, this.label)) {
             this.moodType = MoodEnum.Appassionato;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodBrillante, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodBrillante, this.label)) {
             this.moodType = MoodEnum.Brillante;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodCantabile, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodCantabile, this.label)) {
             this.moodType = MoodEnum.Cantabile;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodDolce, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodDolce, this.label)) {
             this.moodType = MoodEnum.Dolce;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEnergico, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodEnergico, this.label)) {
             this.moodType = MoodEnum.Energico;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEroico, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodEroico, this.label)) {
             this.moodType = MoodEnum.Eroico;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodEspressivo, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodEspressivo, this.label)) {
             this.moodType = MoodEnum.Espressivo;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodFurioso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodFurioso, this.label)) {
             this.moodType = MoodEnum.Furioso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGiocoso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodGiocoso, this.label)) {
             this.moodType = MoodEnum.Giocoso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGioioso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodGioioso, this.label)) {
             this.moodType = MoodEnum.Gioioso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrandioso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrandioso, this.label)) {
             this.moodType = MoodEnum.Grandioso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrazioso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodGrazioso, this.label)) {
             this.moodType = MoodEnum.Grazioso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodLacrimoso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodLacrimoso, this.label)) {
             this.moodType = MoodEnum.Lacrimoso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodLeggiero, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodLeggiero, this.label)) {
             this.moodType = MoodEnum.Leggiero;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMaestoso, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMaestoso, this.label)) {
             this.moodType = MoodEnum.Maestoso;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMalinconico, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMalinconico, this.label)) {
             this.moodType = MoodEnum.Malinconico;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarcato, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarcato, this.label)) {
             this.moodType = MoodEnum.Marcato;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarziale, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMarziale, this.label)) {
             this.moodType = MoodEnum.Marziale;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMesto, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMesto, this.label)) {
             this.moodType = MoodEnum.Mesto;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodMorendo, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodMorendo, this.label)) {
             this.moodType = MoodEnum.Morendo;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodNobilmente, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodNobilmente, this.label)) {
             this.moodType = MoodEnum.Nobilmente;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodPatetico, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodPatetico, this.label)) {
             this.moodType = MoodEnum.Patetico;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodPesante, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodPesante, this.label)) {
             this.moodType = MoodEnum.Pesante;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSaltando, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodSaltando, this.label)) {
             this.moodType = MoodEnum.Saltando;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSautille, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodSautille, this.label)) {
             this.moodType = MoodEnum.Sautille;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodScherzando, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodScherzando, this.label)) {
             this.moodType = MoodEnum.Scherzando;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSostenuto, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodSostenuto, this.label)) {
             this.moodType = MoodEnum.Sostenuto;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodSpiccato, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodSpiccato, this.label)) {
             this.moodType = MoodEnum.Spiccato;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTenerezza, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodTenerezza, this.label)) {
             this.moodType = MoodEnum.Tenerezza;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTranquillamente, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodTranquillamente, this.label)) {
             this.moodType = MoodEnum.Tranquillamente;
-        if (MoodExpression.isStringInStringList(MoodExpression.listMoodTrionfante, this.label))
+        } else if (MoodExpression.isStringInStringList(MoodExpression.listMoodTrionfante, this.label)) {
             this.moodType = MoodEnum.Trionfante;
+        }
     }
 }
 

+ 39 - 34
src/MusicalScore/VoiceData/Expressions/multiExpression.ts

@@ -25,7 +25,7 @@ export class MultiExpression /*implements IComparable<MultiExpression>*/ {
     private combinedExpressionsText: string;
     private octaveShiftStart: OctaveShift;
     private octaveShiftEnd: OctaveShift;
-    
+
     public get SourceMeasureParent(): SourceMeasure {
         return this.sourceMeasure;
     }
@@ -93,22 +93,23 @@ export class MultiExpression /*implements IComparable<MultiExpression>*/ {
         this.combinedExpressionsText = value;
     }
     public getPlacementOfFirstEntry(): PlacementEnum {
-        var placement: PlacementEnum = PlacementEnum.Above;
+        let placement: PlacementEnum = PlacementEnum.Above;
         if (this.expressions.length > 0) {
-            if (this.expressions[0].expression instanceof InstantaniousDynamicExpression)
+            if (this.expressions[0].expression instanceof InstantaniousDynamicExpression) {
                 placement = (<InstantaniousDynamicExpression>(this.expressions[0].expression)).Placement;
-            else if (this.expressions[0].expression instanceof ContinuousDynamicExpression)
+            } else if (this.expressions[0].expression instanceof ContinuousDynamicExpression) {
                 placement = (<ContinuousDynamicExpression>(this.expressions[0].expression)).Placement;
-            else if (this.expressions[0].expression instanceof MoodExpression)
+            } else if (this.expressions[0].expression instanceof MoodExpression) {
                 placement = (<MoodExpression>(this.expressions[0].expression)).Placement;
-            else if (this.expressions[0].expression instanceof UnknownExpression)
+            } else if (this.expressions[0].expression instanceof UnknownExpression) {
                 placement = (<UnknownExpression>(this.expressions[0].expression)).Placement;
+            }
         }
         return placement;
     }
     // (*)
     //public getFontstyleOfFirstEntry(): PSFontStyles {
-    //    var fontStyle: PSFontStyles = PSFontStyles.Regular;
+    //    let fontStyle: PSFontStyles = PSFontStyles.Regular;
     //    if (this.expressions.length > 0) {
     //        if (this.expressions[0].expression instanceof ContinuousDynamicExpression)
     //            fontStyle = PSFontStyles.Italic;
@@ -120,76 +121,80 @@ export class MultiExpression /*implements IComparable<MultiExpression>*/ {
     //    return fontStyle;
     //}
     //public getFirstEntry(staffLine: StaffLine, graphLabel: GraphicalLabel): AbstractGraphicalExpression {
-    //    var indexOfFirstNotInstDynExpr: number = 0;
+    //    let indexOfFirstNotInstDynExpr: number = 0;
     //    if (this.expressions[0].expression instanceof InstantaniousDynamicExpression)
     //        indexOfFirstNotInstDynExpr = 1;
     //    if (this.expressions.length > 0) {
     //        if (this.expressions[indexOfFirstNotInstDynExpr].expression instanceof ContinuousDynamicExpression)
-    //            return new GraphicalContinuousDynamicExpression(<ContinuousDynamicExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphLabel);
+    //            return new GraphicalContinuousDynamicExpression(
+    // <ContinuousDynamicExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphLabel);
     //        else if (this.expressions[indexOfFirstNotInstDynExpr].expression instanceof MoodExpression)
     //            return new GraphicalMoodExpression(<MoodExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphLabel);
     //        else if (this.expressions[indexOfFirstNotInstDynExpr].expression instanceof UnknownExpression)
     //            return new GraphicalUnknownExpression(<UnknownExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphLabel);
-    //        else return null;
+    //        else return undefined;
     //    }
-    //    else return null;
+    //    else return undefined;
     //}
     public addExpression(abstractExpression: AbstractExpression, prefix: string): void {
         if (abstractExpression instanceof InstantaniousDynamicExpression) {
-            if (this.instantaniousDynamic != null)
+            if (this.instantaniousDynamic !== undefined) {
                 this.removeExpressionFromEntryList(this.InstantaniousDynamic);
+            }
             this.instantaniousDynamic = <InstantaniousDynamicExpression>abstractExpression;
             this.instantaniousDynamic.ParentMultiExpression = this;
-        }
-        else if (abstractExpression instanceof ContinuousDynamicExpression) {
+        } else if (abstractExpression instanceof ContinuousDynamicExpression) {
             this.startingContinuousDynamic = <ContinuousDynamicExpression>abstractExpression;
-        }
-        else if (abstractExpression instanceof MoodExpression) {
+        } else if (abstractExpression instanceof MoodExpression) {
             this.moodList.push(<MoodExpression>abstractExpression);
-        }
-        else if (abstractExpression instanceof UnknownExpression) {
+        } else if (abstractExpression instanceof UnknownExpression) {
             this.unknownList.push(<UnknownExpression>abstractExpression);
         }
         this.addExpressionToEntryList(abstractExpression, prefix);
     }
     public CompareTo(other: MultiExpression): number {
-        if (this.SourceMeasureParent.MeasureNumber > other.SourceMeasureParent.MeasureNumber)
+        if (this.SourceMeasureParent.MeasureNumber > other.SourceMeasureParent.MeasureNumber) {
             return 1;
-        if (this.SourceMeasureParent.MeasureNumber < other.SourceMeasureParent.MeasureNumber)
+        }
+        if (this.SourceMeasureParent.MeasureNumber < other.SourceMeasureParent.MeasureNumber) {
             return -1;
-        else {
-            if (this.Timestamp.RealValue > other.Timestamp.RealValue)
-                return 1;
-            if (this.Timestamp.RealValue < other.Timestamp.RealValue)
+        } else {
+            if (this.Timestamp.RealValue > other.Timestamp.RealValue) { return 1; }
+            if (this.Timestamp.RealValue < other.Timestamp.RealValue) {
                 return -1;
-            else return 0;
+            } else {
+                return 0;
+            }
         }
     }
     private addExpressionToEntryList(expression: AbstractExpression, prefix: string): void {
-        var multiExpressionEntry: MultiExpressionEntry = new MultiExpressionEntry();
+        let multiExpressionEntry: MultiExpressionEntry = new MultiExpressionEntry();
         multiExpressionEntry.prefix = prefix;
         multiExpressionEntry.expression = expression;
-        if (expression instanceof ContinuousDynamicExpression)
+        if (expression instanceof ContinuousDynamicExpression) {
             multiExpressionEntry.label = (<ContinuousDynamicExpression>(expression)).Label;
-        else if (expression instanceof MoodExpression)
+        } else if (expression instanceof MoodExpression) {
             multiExpressionEntry.label = (<MoodExpression>(expression)).Label;
-        else if (expression instanceof UnknownExpression)
+        } else if (expression instanceof UnknownExpression) {
             multiExpressionEntry.label = (<UnknownExpression>(expression)).Label;
-        else multiExpressionEntry.label = "";
+        } else {
+            multiExpressionEntry.label = "";
+        }
         this.expressions.push(multiExpressionEntry);
     }
     private removeExpressionFromEntryList(expression: AbstractExpression): void {
-        for (var idx: number = 0, len = this.expressions.length; idx < len; ++idx) {
-            var entry: MultiExpressionEntry = this.expressions[idx];
-            if (entry.expression == expression) {
+        for (let idx: number = 0, len: number = this.expressions.length; idx < len; ++idx) {
+            let entry: MultiExpressionEntry = this.expressions[idx];
+            if (entry.expression === expression) {
                 this.expressions.splice(idx, 1);
                 break;
             }
         }
     }
 }
+
 export class MultiExpressionEntry {
     public prefix: string;
     public expression: AbstractExpression;
     public label: string;
-}
+}

+ 31 - 25
src/MusicalScore/VoiceData/Expressions/multiTempoExpression.ts

@@ -14,10 +14,11 @@ export class MultiTempoExpression /*implements IComparable<MultiTempoExpression>
 
     private timestamp: Fraction;
     private sourceMeasure: SourceMeasure;
-    private instantaniousTempo: InstantaniousTempoExpression;
+    private instantaneousTempo: InstantaniousTempoExpression;
     private continuousTempo: ContinuousTempoExpression;
-    private expressions: Array<TempoExpressionEntry> = [];
+    private expressions: TempoExpressionEntry[] = [];
     private combinedExpressionsText: string;
+
     public get Timestamp(): Fraction {
         return this.timestamp;
     }
@@ -31,12 +32,12 @@ export class MultiTempoExpression /*implements IComparable<MultiTempoExpression>
         this.sourceMeasure = value;
     }
     public get InstantaniousTempo(): InstantaniousTempoExpression {
-        return this.instantaniousTempo;
+        return this.instantaneousTempo;
     }
     public get ContinuousTempo(): ContinuousTempoExpression {
         return this.continuousTempo;
     }
-    public get EntriesList(): Array<TempoExpressionEntry> {
+    public get EntriesList(): TempoExpressionEntry[] {
         return this.expressions;
     }
     public get CombinedExpressionsText(): string {
@@ -46,63 +47,68 @@ export class MultiTempoExpression /*implements IComparable<MultiTempoExpression>
         this.combinedExpressionsText = value;
     }
     public getPlacementOfFirstEntry(): PlacementEnum {
-        var placement: PlacementEnum = PlacementEnum.Above;
+        let placement: PlacementEnum = PlacementEnum.Above;
         if (this.expressions.length > 0) {
-            if (this.expressions[0].expression instanceof InstantaniousTempoExpression)
+            if (this.expressions[0].expression instanceof InstantaniousTempoExpression) {
                 placement = (<InstantaniousTempoExpression>(this.expressions[0].expression)).Placement;
-            else if (this.expressions[0].expression instanceof ContinuousTempoExpression)
+            } else if (this.expressions[0].expression instanceof ContinuousTempoExpression) {
                 placement = (<ContinuousTempoExpression>(this.expressions[0].expression)).Placement;
+            }
         }
         return placement;
     }
     public getFontstyleOfFirstEntry(): OSMDFontStyles {
-        var fontStyle: OSMDFontStyles = OSMDFontStyles.Regular;
-        if (this.expressions[0].expression instanceof InstantaniousTempoExpression)
+        let fontStyle: OSMDFontStyles = OSMDFontStyles.Regular;
+        if (this.expressions[0].expression instanceof InstantaniousTempoExpression) {
             fontStyle = OSMDFontStyles.Bold;
-        else if (this.expressions[0].expression instanceof ContinuousTempoExpression)
+        } else if (this.expressions[0].expression instanceof ContinuousTempoExpression) {
             fontStyle = OSMDFontStyles.Italic;
+        }
         return fontStyle;
     }
     //public getFirstEntry(graphicalLabel: GraphicalLabel): AbstractGraphicalExpression {
-    //    var indexOfFirstNotInstDynExpr: number = 0;
+    //    let indexOfFirstNotInstDynExpr: number = 0;
     //    if (this.expressions.length > 0) {
     //        if (this.expressions[indexOfFirstNotInstDynExpr].expression instanceof InstantaniousTempoExpression)
-    //            return new GraphicalInstantaniousTempoExpression(<InstantaniousTempoExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphicalLabel);
+    //            return new GraphicalInstantaniousTempoExpression(
+    // <InstantaniousTempoExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphicalLabel);
     //        else if (this.expressions[indexOfFirstNotInstDynExpr].expression instanceof ContinuousTempoExpression)
-    //            return new GraphicalContinuousTempoExpression(<ContinuousTempoExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphicalLabel);
+    //            return new GraphicalContinuousTempoExpression(
+    // <ContinuousTempoExpression>(this.expressions[indexOfFirstNotInstDynExpr].expression), graphicalLabel);
     //        else return null;
     //    }
     //    return null;
     //}
     public addExpression(abstractTempoExpression: AbstractTempoExpression, prefix: string): void {
         if (abstractTempoExpression instanceof InstantaniousTempoExpression) {
-            this.instantaniousTempo = <InstantaniousTempoExpression>abstractTempoExpression;
-        }
-        else if (abstractTempoExpression instanceof ContinuousTempoExpression) {
+            this.instantaneousTempo = <InstantaniousTempoExpression>abstractTempoExpression;
+        } else if (abstractTempoExpression instanceof ContinuousTempoExpression) {
             this.continuousTempo = <ContinuousTempoExpression>abstractTempoExpression;
         }
-        var tempoExpressionEntry: TempoExpressionEntry = new TempoExpressionEntry();
+        let tempoExpressionEntry: TempoExpressionEntry = new TempoExpressionEntry();
         tempoExpressionEntry.prefix = prefix;
         tempoExpressionEntry.expression = abstractTempoExpression;
         tempoExpressionEntry.label = abstractTempoExpression.Label;
         this.expressions.push(tempoExpressionEntry);
     }
     public CompareTo(other: MultiTempoExpression): number {
-        if (this.SourceMeasureParent.MeasureNumber > other.SourceMeasureParent.MeasureNumber)
+        if (this.SourceMeasureParent.MeasureNumber > other.SourceMeasureParent.MeasureNumber) {
             return 1;
-        if (this.SourceMeasureParent.MeasureNumber < other.SourceMeasureParent.MeasureNumber)
+        } else if (this.SourceMeasureParent.MeasureNumber < other.SourceMeasureParent.MeasureNumber) {
             return -1;
-        else {
-            if (this.Timestamp.RealValue > other.Timestamp.RealValue)
-                return 1;
-            if (this.Timestamp.RealValue < other.Timestamp.RealValue)
+        } else {
+            if (this.Timestamp.RealValue > other.Timestamp.RealValue) { return 1; }
+            if (this.Timestamp.RealValue < other.Timestamp.RealValue) {
                 return -1;
-            else return 0;
+            } else {
+                return 0;
+            }
         }
     }
 }
+
 export class TempoExpressionEntry {
     public prefix: string;
     public expression: AbstractTempoExpression;
     public label: string;
-}
+}

+ 4 - 1
src/MusicalScore/VoiceData/Expressions/unknownExpression.ts

@@ -11,7 +11,10 @@ export class UnknownExpression extends AbstractExpression {
         this.label = label;
         this.placement = placementEnum;
         this.staffNumber = staffNumber;
-        this.textAlignment = textAlignment | OSMDTextAlignment.LeftBottom;
+        if (textAlignment === undefined) {
+            textAlignment = OSMDTextAlignment.LeftBottom;
+        }
+        this.textAlignment = textAlignment;
     }
     private label: string;
     private placement: PlacementEnum;

+ 2 - 2
test/Common/FileIO/Xml.ts

@@ -1,7 +1,7 @@
 import { IXmlElement } from "../../../src/Common/FileIO/Xml.ts";
 
 // Test XML simple document
-let xml_test_data: string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
+let xmlTestData: string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 <!DOCTYPE score-partwise PUBLIC \"-//Recordare//DTD MusicXML 2.0 Partwise//EN\" \"http://www.musicxml.org/dtds/partwise.dtd\">\
 <score-partwise>  <identification>    <encoding>      <software>Example Software name</software>      \
 <encoding-date>2016-04-04</encoding-date>      </encoding>    </identification>   <credit page=\"1\"> \
@@ -10,7 +10,7 @@ let xml_test_data: string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 
 describe("XML Unit Tests", () => {
   let parser: DOMParser = new DOMParser();
-  let doc: Document = parser.parseFromString(xml_test_data, "text/xml");
+  let doc: Document = parser.parseFromString(xmlTestData, "text/xml");
   let documentElement: IXmlElement = new IXmlElement(doc.documentElement);
 
   it("IXmlElement Tests", (done: MochaDone) => {

+ 35 - 31
typings/vexflow.d.ts

@@ -2,28 +2,30 @@ declare namespace Vex {
   export module Flow {
 
     export class Formatter {
+      constructor();
+
       public hasMinTotalWidth: boolean;
       public minTotalWidth: number;
 
-      preCalculateMinTotalWidth(voices: Voice[]);
-      constructor();
+      public preCalculateMinTotalWidth(voices: Voice[]): number;
     }
 
     export class BoundingBox {
-      mergeWith(bb: BoundingBox): BoundingBox;
-      getX(): number;
-      getY(): number;
-      getW(): number;
-      getH(): number;
-
       constructor(x: number, y: number, w: number, h: number);
+
+      public mergeWith(bb: BoundingBox): BoundingBox;
+      public getX(): number;
+      public getY(): number;
+      public getW(): number;
+      public getH(): number;
     }
 
     export class Voice {
-      getBoundingBox(): BoundingBox;
-      setStave(stave: Stave): Voice;
-      addTickables(notes: StaveNote[]): Voice;
       constructor(time: any);
+
+      public getBoundingBox(): BoundingBox;
+      public setStave(stave: Stave): Voice;
+      public addTickables(notes: StaveNote[]): Voice;
     }
 
     export class StaveNote {
@@ -31,24 +33,24 @@ declare namespace Vex {
     }
 
     export class Stave {
-      x: number;
-      start_x: number;
-      end_x: number;
-
-      getYForGlyphs(): number;
-      getWidth(): number;
-      setWidth(width: number): Stave;
-      getNoteStartX(): number;
-      format(): void;
-      getSpacingBetweenLines(): number;
-      getNumLines(): number;
-      getLineForY(y: number): number;
-      getModifiers(pos: any, cat: any): Vex.Flow.Clef[]; // FIXME
-      setContext(ctx: any);
-      addModifier(mod: any, pos: any);
-      draw(): void;
-
       constructor(x: number, y: number, width: number);
+
+      public x: number;
+      public start_x: number;
+      public end_x: number;
+
+      public getYForGlyphs(): number;
+      public getWidth(): number;
+      public setWidth(width: number): Stave;
+      public getNoteStartX(): number;
+      public format(): void;
+      public getSpacingBetweenLines(): number;
+      public getNumLines(): number;
+      public getLineForY(y: number): number;
+      public getModifiers(pos: any, cat: any): Vex.Flow.Clef[]; // FIXME
+      public setContext(ctx: any): void;
+      public addModifier(mod: any, pos: any): void;
+      public draw(): void;
     }
 
     export class StaveModifier {
@@ -56,6 +58,8 @@ declare namespace Vex {
     }
 
     export class Clef {
+      constructor(type: any);
+
       public static category: string;
       public static types: { [type: string]: any; } ;
       public glyph: any;
@@ -64,14 +68,14 @@ declare namespace Vex {
 
       public getBoundingBox(): Vex.Flow.BoundingBox;
       public setStave(stave: Vex.Flow.Stave): void;
-      constructor(type: any);
     }
 
     export class Renderer {
       constructor(canvas: HTMLCanvasElement, backend: any);
-      public resize(a: number, b:number);
-      public getContext(): any;
+
       public static Backends: any;
+      public resize(a: number, b: number): void;
+      public getContext(): any;
     }
 
     //export class