Преглед на файлове

Fixing types & imports pt.6

Andrea Condoluci преди 9 години
родител
ревизия
c1f0714272

+ 10 - 11
src/Common/DataObjects/fraction.ts

@@ -139,12 +139,9 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
         return upTestFraction;
     }
 
-    //public Equals(obj: Object): boolean {
-    //    if (ReferenceEquals(obj, null)) {
-    //        return false;
-    //    }
-    //    return this.Equals(__as__<Fraction>(obj, Fraction));
-    //}
+    public Equals(obj: Fraction): boolean {
+        return this.RealValue == obj.RealValue;
+    }
 
     //public Equals(f: Fraction): boolean {
     //    if (ReferenceEquals(this, f))
@@ -229,11 +226,13 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //        return f1;
     //    else return f2;
     //}
-    //public static fractionMax(f1: Fraction, f2: Fraction): Fraction {
-    //    if (f1 > f2)
-    //        return f1;
-    //    else return f2;
-    //}
+    public static max(f1: Fraction, f2: Fraction): Fraction {
+        if (f1.RealValue > f2.RealValue) {
+            return f1;
+        } else {
+            return f2;
+        }
+    }
     //public static GetMaxValue(): Fraction {
     //    return new Fraction(Fraction.maximumAllowedNumber, 1);
     //}

+ 1 - 1
src/Common/FileIO/Xml.ts

@@ -56,7 +56,7 @@ export class IXmlElement {
     return this.Elements(elementName)[0];
   }
 
-  public Elements(nodeName: string): IXmlElement[] {
+  public Elements(nodeName?: string): IXmlElement[] {
     let nodes: NodeList = this._elem.childNodes;
     let ret: IXmlElement[] = new Array();
     let nameUnset: boolean = typeof nodeName === "undefined";

+ 18 - 0
src/MusicalScore/Exceptions.ts

@@ -0,0 +1,18 @@
+export class MusicSheetReadingException implements Error {
+    public name: string;
+    public message: string;
+    constructor(message: string, exitCode: number) {
+        //super(message);
+        this.message = message;
+    }
+}
+
+
+export class ArgumentOutOfRangeException implements Error {
+    public name: string;
+    public message: string;
+    constructor(message: string) {
+        //super(message);
+        this.message = message;
+    }
+}

+ 1 - 1
src/MusicalScore/Instrument.ts

@@ -4,10 +4,10 @@ import { MusicSheet } from "./MusicSheet"
 import { Voice } from "./VoiceData/Voice"
 import { Staff } from "./VoiceData/Staff"
 import { SubInstrument } from "./SubInstrument"
+import {MidiInstrument} from "./VoiceData/Instructions/ClefInstruction";
 
 // FIXME
 type IPhonicScoreInterface = any;
-type MidiInstrument = any;
 type InstrumentParameters = any;
 type InstrumentParameterChangedDelegate = any;
 

+ 13 - 0
src/MusicalScore/Interfaces/ITextTranslation.ts

@@ -0,0 +1,13 @@
+export class ITextTranslation {
+    public static DefaultTextTranslation: ITextTranslation;
+
+    public static translateText(tag: string, text: string): string {
+        if (this.DefaultTextTranslation == undefined) {
+            return text;
+        }
+
+        //return this.DefaultTextTranslation.translate(tag, text);
+    }
+
+    //declare public translate(tag: string, text: string): string;
+}

+ 21 - 22
src/MusicalScore/MusicSheet.ts

@@ -34,7 +34,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         } catch (ex) {
             console.log("MusicSheet Error: EngravingRules"); // FIXME
         }
-        this.playbackSettings = undefined // FIXME this.SheetPlaybackSetting = new PlaybackSettings(new Fraction(4, 4, false), 100);
+        this.playbackSettings = undefined; // FIXME this.SheetPlaybackSetting = new PlaybackSettings(new Fraction(4, 4, false), 100);
         this.UserStartTempoInBPM = 100;
         this.PageWidth = 120;
         this.MusicPartManager = new MusicPartManager(this);
@@ -44,24 +44,24 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public PageWidth: number;
 
     private idString: string = "kjgdfuilhsda�oihfsvjh";
-    private sourceMeasures: SourceMeasure[] = new Array();
-    private repetitions: Repetition[] = new Array();
-    private dynListStaves: DynamicsContainer[][] = new Array();
-    private timestampSortedDynamicExpressionsList: DynamicsContainer[] = new Array();
-    private timestampSortedTempoExpressionsList: MultiTempoExpression[] = new Array();
-    private instrumentalGroups: InstrumentalGroup[] = new Array();
-    private instruments: Instrument[] = new Array();
+    private sourceMeasures: SourceMeasure[] = [];
+    private repetitions: Repetition[] = [];
+    private dynListStaves: DynamicsContainer[][] = [];
+    private timestampSortedDynamicExpressionsList: DynamicsContainer[] = [];
+    private timestampSortedTempoExpressionsList: MultiTempoExpression[] = [];
+    private instrumentalGroups: InstrumentalGroup[] = [];
+    private instruments: Instrument[] = [];
     private playbackSettings: PlaybackSettings;
     private path: string;
     private title: Label;
     private subtitle: Label;
     private composer: Label;
     private lyricist: Label;
-    // private languages: Language[] = new Array();
+    // private languages: Language[] = [];
     // private activeLanguage: Language;
     private musicPartManager: MusicPartManager = undefined;
     private musicSheetErrors: MusicSheetErrors = undefined; // FIXME new MusicSheetErrors();
-    private staves: Staff[] = new Array();
+    private staves: Staff[] = [];
     private selectionStart: Fraction;
     private selectionEnd: Fraction;
     private transpose: number = 0;
@@ -247,7 +247,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
             return undefined;
         }
     }
-    public getIndexFromStaff(staff: Staff): number {
+    public static getIndexFromStaff(staff: Staff): number {
         return staff.IdInMusicSheet;
     }
     public fillStaffList(): void {
@@ -277,7 +277,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return number;
     }
     public getListOfMeasuresFromIndeces(start: number, end: number): SourceMeasure[] {
-        let measures: SourceMeasure[] = new Array();
+        let measures: SourceMeasure[] = [];
         for (let i: number = start; i <= end; i++) {
             measures.push(this.sourceMeasures[i]);
         }
@@ -303,7 +303,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
                 let voiceEntry: VoiceEntry = iterator.CurrentVoiceEntries[idx];
                 for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
                     let note: Note = voiceEntry.Notes[idx2];
-                    note.State = undefined // FIXME NoteState.Normal;
+                    note.State = undefined; // FIXME NoteState.Normal;
                 }
             }
             iterator.moveToNext();
@@ -323,9 +323,9 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public setRepetitionNewUserNumberOfRepetitions(index: number, value: number): void {
         let repIndex: number = 0;
         for (let i: number = 0; i < this.repetitions.length; i++) {
-            if (this.repetitions[i] instanceof Repetition) {
+            if (this.repetitions[i] instanceof Repetition) { // FIXME
                 if (index === repIndex) {
-                    (<Repetition>this.repetitions[i]).UserNumberOfRepetitions = value;
+                    this.repetitions[i].UserNumberOfRepetitions = value;
                     break;
                 } else {
                     repIndex++;
@@ -356,7 +356,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     }
     public get IRepetitions(): IRepetition[] {
         try {
-            let repetitions: IRepetition[] = new Array();
+            let repetitions: IRepetition[] = [];
             for (let idx: number = 0, len: number = this.repetitions.length; idx < len; ++idx) {
                 let partListEntry: PartListEntry = this.repetitions[idx];
                 if (partListEntry instanceof Repetition) {
@@ -365,8 +365,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
             }
             return repetitions;
         } catch (ex) {
-            //Logger.DefaultLogger.LogError(LogLevel.NORMAL, "MusicSheet.IRepetitions get: ", ex);
-            // FIXME logger
+            console.log(/*Logger.DefaultLogger.LogError(LogLevel.NORMAL, FIXME */ "MusicSheet.IRepetitions get: ", ex);
             return undefined;
         }
 
@@ -386,7 +385,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         try {
             return this.musicSheetErrors.MeasureErrors;
         } catch (ex) {
-            // FIXME Logger.DefaultLogger.LogError(LogLevel.NORMAL, "MusicSheet.Errors get: ", ex);
+            console.log(/* FIXME LogLevel.NORMAL, */ "MusicSheet.Errors get: ", ex);
             return undefined;
         }
 
@@ -395,7 +394,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         try {
             return this.getFirstSourceMeasure().MeasureNumber;
         } catch (ex) {
-            // Logger.DefaultLogger.LogError(LogLevel.NORMAL, "MusicSheet.FirstMeasureNumber: ", ex); // FIXME
+            console.log(/* FIXME LogLevel.NORMAL, */ "MusicSheet.FirstMeasureNumber: ", ex);
             return 0;
         }
 
@@ -404,7 +403,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         try {
             return this.getLastSourceMeasure().MeasureNumber;
         } catch (ex) {
-            // Logger.DefaultLogger.LogError(LogLevel.NORMAL, "MusicSheet.LastMeasureNumber: ", ex); // FIXME
+            console.log(/* FIXME LogLevel.NORMAL, */ "MusicSheet.LastMeasureNumber: ", ex);
             return 0;
         }
 
@@ -461,7 +460,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         this.MusicSheetParameterChanged = undefined;
         for (let idx: number = 0, len: number = this.IInstruments.length; idx < len; ++idx) {
             let instrument: IInstrument = this.IInstruments[idx];
-            instrument.Dispose();
+            instrument.Dispose(); // FIXME
         }
     }
     public getEnrolledSelectionStartTimeStampWorkaround(): Fraction {

+ 107 - 80
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -10,6 +10,12 @@ import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
 import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
 import {Fraction} from "../../Common/DataObjects/fraction";
 import {IXmlElement} from "../../Common/FileIO/Xml";
+import {ITextTranslation} from "../Interfaces/ITextTranslation";
+import {MusicSheetReadingException} from "../Exceptions";
+import {ClefEnum} from "../VoiceData/Instructions/ClefInstruction";
+import {RhythmSymbolEnum} from "../VoiceData/Instructions/RhythmInstruction";
+import {KeyEnum} from "../VoiceData/Instructions/KeyInstruction";
+import {IXmlAttribute} from "../../Common/FileIO/Xml";
 
 
 // FIXME
@@ -21,12 +27,25 @@ type ExpressionReader = any;
 
 declare class MusicSymbolModuleFactory {
   public static createSlurReader(x: any): any;
+  public static createExpressionGenerator(musicSheet: MusicSheet, instrument: Instrument, n: number);
 }
 
+class MetronomeReader {
+  public static addMetronomeSettings(xmlNode: IXmlElement, musicSheet: MusicSheet): void { }
+  public static readMetronomeInstructions(xmlNode: IXmlElement, musicSheet: MusicSheet, currentXmlMeasureIndex: number): void { }
+  public static readTempoInstruction(soundNode: IXmlElement, musicSheet: MusicSheet, currentXmlMeasureIndex: number): void { }
+}
+
+class ChordSymbolReader {
+  public static readChordSymbol(xmlNode:IXmlElement, musicSheet:MusicSheet, activeKey:any): void {
+  }
+}
+////////////
+
 export class InstrumentReader {
   constructor(repetitionInstructionReader: repetitionInstructionReader, xmlMeasureList: IXmlElement[]/* FIXME IEnumerable<IXmlElement>*/, instrument: Instrument) {
     this.repetitionInstructionReader = repetitionInstructionReader;
-    this.xmlMeasureList = xmlMeasureList; // FIXME .ToArray();
+    this.xmlMeasureList = xmlMeasureList.slice(); // FIXME .ToArray();
     this.musicSheet = instrument.GetMusicSheet;
     this.instrument = instrument;
     this.activeClefs = new Array(instrument.Staves.length);
@@ -43,7 +62,7 @@ export class InstrumentReader {
   private slurReader: SlurReader;
   private instrument: Instrument;
   private voiceGeneratorsDict: { [n: number]: VoiceGenerator; } = {};
-  private staffMainVoiceGeneratorDict: Dictionary<Staff, VoiceGenerator> = new Dictionary<Staff, VoiceGenerator>();
+  private staffMainVoiceGeneratorDict: { [staffId: number]: VoiceGenerator } = {};
   private inSourceMeasureInstrumentIndex: number;
   private divisions: number = 0;
   private currentMeasure: SourceMeasure;
@@ -89,7 +108,7 @@ export class InstrumentReader {
     this.maxTieNoteFraction = new Fraction(0, 1);
     let lastNoteWasGrace: boolean = false;
     try {
-      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[this.currentXmlMeasureIndex].Elements().ToArray();
+      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[this.currentXmlMeasureIndex].Elements().slice();
       for (let idx: number = 0, len: number = xmlMeasureListArr.length; idx < len; ++idx) {
         let xmlNode: IXmlElement = xmlMeasureListArr[idx];
         if (xmlNode.Name === "note") {
@@ -103,7 +122,7 @@ export class InstrumentReader {
                 noteStaff = parseInt(xmlNode.Element("staff").Value);
               }
             } catch (ex) {
-              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure.get staff number", ex);
+              // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure.get staff number", ex);
               noteStaff = 1;
             }
 
@@ -133,9 +152,9 @@ export class InstrumentReader {
                 isTuplet = true;
               }
             } catch (ex) {
-              let errorMsg: string = "FIXME Instrument Reader"; // FIXME ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid Note Duration.");
+              let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid Note Duration.");
               this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, ex);
+              // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure", errorMsg, ex);
               continue;
             }
 
@@ -151,7 +170,7 @@ export class InstrumentReader {
             musicTimestamp,
             this.inSourceMeasureInstrumentIndex + noteStaff - 1,
             this.currentStaff,
-            newContainerCreated,
+            newContainerCreated
           );
           if (!this.currentVoiceGenerator.hasVoiceEntry() || !isChord && !isGraceNote && !lastNoteWasGrace || !lastNoteWasGrace && isGraceNote) {
             this.currentVoiceGenerator.createVoiceEntry(musicTimestamp, this.currentStaffEntry, !restNote);
@@ -172,10 +191,10 @@ export class InstrumentReader {
           let beginOfMeasure: boolean = (
             this.currentStaffEntry !== undefined &&
             this.currentStaffEntry.Timestamp !== undefined &&
-            this.currentStaffEntry.Timestamp === new Fraction(0, 1) &&
+            this.currentStaffEntry.Timestamp.Equals(new Fraction(0, 1)) &&
             !this.currentStaffEntry.hasNotes()
           );
-          saveAbstractInstructionList(this.instrument.Staves.length, beginOfMeasure);
+          this.saveAbstractInstructionList(this.instrument.Staves.length, beginOfMeasure);
           if (this.openChordSymbolContainer !== undefined) {
             this.currentStaffEntry.ChordContainer = this.openChordSymbolContainer;
             this.openChordSymbolContainer = undefined;
@@ -219,7 +238,7 @@ export class InstrumentReader {
               this.divisions = parseInt(divisionsNode.Value);
             } catch (e) {
               let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/DivisionError", "Invalid divisions value at Instrument: ");
-              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
+              console.log(/*LogLevel.DEBUG, */"InstrumentReader.readNextXmlMeasure", errorMsg, e);
               this.divisions = this.readDivisionsFromNotes();
               if (this.divisions > 0) {
                 this.musicSheet.SheetErrors.Errors.push(errorMsg + this.instrument.Name);
@@ -245,8 +264,8 @@ export class InstrumentReader {
             }
           }
           this.addAbstractInstruction(xmlNode, guitarPro);
-          if (currentFraction === new Fraction(0, 1) && this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex], xmlNode)) {
-            saveAbstractInstructionList(this.instrument.Staves.length, true);
+          if (currentFraction.Equals(new Fraction(0, 1)) && this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex], xmlNode)) {
+            this.saveAbstractInstructionList(this.instrument.Staves.length, true);
           }
           if (this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex], xmlNode)) {
             this.saveClefInstructionAtEndOfMeasure();
@@ -317,7 +336,7 @@ export class InstrumentReader {
       if (this.currentXmlMeasureIndex === this.xmlMeasureList.length - 1) {
         for (let i: number = 0; i < this.instrument.Staves.length; i++) {
           if (!this.activeClefsHaveBeenInitialized[i]) {
-            createDefaultClefInstruction(this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument) + i);
+            this.createDefaultClefInstruction(this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument) + i);
         }}
         if (!this.activeKeyHasBeenInitialized) {
           this.createDefaultKeyInstruction();
@@ -331,11 +350,11 @@ export class InstrumentReader {
       }
     } catch (e) {
       if (divisionsException) {
-        throw new MusicSheetReadingException(e.Message, e, 0);
+        throw new MusicSheetReadingException(e.Message, 0);
       }
       let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/MeasureError", "Error while reading Measure.");
       this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-      // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
+      // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure", errorMsg, e);
     }
 
     this.previousMeasure = this.currentMeasure;
@@ -355,8 +374,8 @@ export class InstrumentReader {
         staff.Voices.push(voiceGenerator.GetVoice);
       }
     } else {
-      if (this.staffMainVoiceGeneratorDict[staff] !== undefined) {
-        let mainVoiceGenerator: VoiceGenerator = this.staffMainVoiceGeneratorDict[staff];
+      let mainVoiceGenerator: VoiceGenerator = this.staffMainVoiceGeneratorDict[staffId];
+      if (mainVoiceGenerator !== undefined) {
         voiceGenerator = new VoiceGenerator(this.instrument, voiceId, this.slurReader, mainVoiceGenerator.GetVoice);
         staff.Voices.push(voiceGenerator.GetVoice);
         this.voiceGeneratorsDict[voiceId] = voiceGenerator;
@@ -364,24 +383,25 @@ export class InstrumentReader {
         voiceGenerator = new VoiceGenerator(this.instrument, voiceId, this.slurReader);
         staff.Voices.push(voiceGenerator.GetVoice);
         this.voiceGeneratorsDict[voiceId] = voiceGenerator;
-        this.staffMainVoiceGeneratorDict[staff] = voiceGenerator;
+        this.staffMainVoiceGeneratorDict[staffId] = 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.musicSheet2, this.instrument, i + 1);
+    for (let i: number = 0; i < numberOfStaves; i++) {
+      this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
+    }
   }
 
 
   private createDefaultClefInstruction(staffIndex: number): void {
     let first: SourceMeasure;
-    if (this.musicSheet2.SourceMeasures.Count > 0) {
-      first = this.musicSheet2.SourceMeasures[0];
+    if (this.musicSheet.SourceMeasures.length > 0) {
+      first = this.musicSheet.SourceMeasures[0];
     } else {
       first = this.currentMeasure;
     }
@@ -395,37 +415,37 @@ export class InstrumentReader {
       firstStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
     }
     clefInstruction.Parent = firstStaffEntry;
-    firstStaffEntry.Instructions.Insert(0, clefInstruction);
+    firstStaffEntry.Instructions.splice(0, 0, clefInstruction);
   }
-*/
+
   private createDefaultKeyInstruction(): void {
     let first: SourceMeasure;
-    if (this.musicSheet.SourceMeasures.Count > 0) {
+    if (this.musicSheet.SourceMeasures.length > 0) {
       first = this.musicSheet.SourceMeasures[0];
     } else {
       first = this.currentMeasure;
     }
-    let keyInstruction: KeyInstruction = new KeyInstruction(0, KeyEnum.major);
-    for (let j: number = this.inSourceMeasureInstrumentIndex; j < this.inSourceMeasureInstrumentIndex + this.instrument.Staves.Count; j++) {
+    let keyInstruction: KeyInstruction = new KeyInstruction(undefined, 0, KeyEnum.major);
+    for (let j: number = this.inSourceMeasureInstrumentIndex; j < this.inSourceMeasureInstrumentIndex + this.instrument.Staves.length; j++) {
       if (first.FirstInstructionsStaffEntries[j] === undefined) {
         let firstStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
         first.FirstInstructionsStaffEntries[j] = firstStaffEntry;
         keyInstruction.Parent = firstStaffEntry;
-        firstStaffEntry.Instructions.Add(keyInstruction);
+        firstStaffEntry.Instructions.push(keyInstruction);
       } else {
         let firstStaffEntry: SourceStaffEntry = first.FirstInstructionsStaffEntries[j];
         keyInstruction.Parent = firstStaffEntry;
         firstStaffEntry.removeFirstInstructionOfType<KeyInstruction>();
         if (firstStaffEntry.Instructions[0] instanceof ClefInstruction) {
-          firstStaffEntry.Instructions.Insert(1, keyInstruction);
+          firstStaffEntry.Instructions.splice(1, 0, keyInstruction);
         } else {
-          firstStaffEntry.Instructions.Insert(0, keyInstruction);
+          firstStaffEntry.Instructions.splice(0, 0, keyInstruction);
         }
       }
     }
   }
   private isAttributesNodeAtBeginOfMeasure(parentNode: IXmlElement, attributesNode: IXmlElement): boolean {
-    let childs: IXmlElement[] = parentNode.Elements().ToArray();
+    let childs: IXmlElement[] = parentNode.Elements().slice();
     let attributesNodeIndex: number = 0;
     for (let i: number = 0; i < childs.length; i++) {
       if (childs[i] === attributesNode) {
@@ -446,7 +466,7 @@ export class InstrumentReader {
     return (attributesNodeIndex < firstNoteNodeIndex && firstNoteNodeIndex > 0) || (firstNoteNodeIndex < 0);
   }
   private isAttributesNodeAtEndOfMeasure(parentNode: IXmlElement, attributesNode: IXmlElement): boolean {
-    let childs: IXmlElement[] = parentNode.Elements().ToArray();
+    let childs: IXmlElement[] = parentNode.Elements().slice();
     let attributesNodeIndex: number = 0;
     for (let i: number = 0; i < childs.length; i++) {
       if (childs[i] === attributesNode) {
@@ -475,7 +495,7 @@ export class InstrumentReader {
   }
   private addAbstractInstruction(node: IXmlElement, guitarPro: boolean): void {
     if (node.Element("divisions") !== undefined) {
-      if (node.Elements().Count() === 1) { return; }
+      if (node.Elements().length === 1) { return; }
     }
     let transposeNode: IXmlElement = node.Element("transpose");
     if (transposeNode !== undefined) {
@@ -484,16 +504,16 @@ export class InstrumentReader {
         this.instrument.PlaybackTranspose = parseInt(chromaticNode.Value);
       }
     }
-    let clefList: IXmlElement[] = node.Elements("clef").ToArray();
+    let clefList: IXmlElement[] = node.Elements("clef");
+    let errorMsg: string;
     if (clefList.length > 0) {
-      for (let idx: number = 0, len: number = clefList.Count(); idx < len; ++idx) {
+      for (let idx: number = 0, len: number = clefList.length; idx < len; ++idx) {
         let nodeList: IXmlElement = clefList[idx];
         let clefEnum: ClefEnum = ClefEnum.G;
         let line: number = 2;
         let staffNumber: number = 1;
         let clefOctaveOffset: number = 0;
         let lineNode: IXmlElement = nodeList.Element("line");
-        let errorMsg: string;
         if (lineNode !== undefined) {
           try {
             line = parseInt(lineNode.Value);
@@ -504,7 +524,7 @@ export class InstrumentReader {
             );
             this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
             line = 2;
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+            console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
           }
 
         }
@@ -532,7 +552,7 @@ export class InstrumentReader {
             this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
             clefEnum = ClefEnum.G;
             line = 2;
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.addAbstractInstruction", errorMsg, e);
+            console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, e);
           }
 
         }
@@ -550,9 +570,9 @@ export class InstrumentReader {
           }
 
         }
-        if (nodeList.HasAttributes && nodeList.Attributes().First().Name === "number") {
+        if (nodeList.HasAttributes && nodeList.Attributes()[0].Name === "number") {
           try {
-            staffNumber = parseInt(nodeList.Attributes().First().Value);
+            staffNumber = parseInt(nodeList.Attributes()[0].Value);
           } catch (err) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefError",
@@ -564,7 +584,7 @@ export class InstrumentReader {
         }
 
         let clefInstruction: ClefInstruction = new ClefInstruction(clefEnum, clefOctaveOffset, line);
-        this.abstractInstructions.Add(new KeyValuePairClass<number, AbstractNotationInstruction>(staffNumber, clefInstruction));
+        this.abstractInstructions[staffNumber] = clefInstruction;
       }
     }
     if (node.Element("key") !== undefined && this.instrument.MidiInstrumentId !== Common.Enums.MidiInstrument.Percussion) {
@@ -580,7 +600,7 @@ export class InstrumentReader {
           );
           this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
           key = 0;
-          Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
       }
@@ -597,12 +617,12 @@ export class InstrumentReader {
           );
           this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
           keyEnum = KeyEnum.major;
-          Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
       }
-      let keyInstruction: KeyInstruction = new KeyInstruction(key, keyEnum);
-      this.abstractInstructions.Add(new KeyValuePairClass<number, AbstractNotationInstruction>(1, keyInstruction));
+      let keyInstruction: KeyInstruction = new KeyInstruction(undefined, key, keyEnum);
+      this.abstractInstructions[1] = keyInstruction;
     }
     if (node.Element("time") !== undefined) {
       let symbolEnum: RhythmSymbolEnum = RhythmSymbolEnum.NONE;
@@ -610,9 +630,9 @@ export class InstrumentReader {
       if (
         timeNode !== undefined &&
         timeNode.HasAttributes &&
-        timeNode.Attributes().First() !== undefined
+        timeNode.Attributes()[] !== undefined
       ) {
-        let firstAttr: IXmlAttribute = timeNode.Attributes().First();
+        let firstAttr: IXmlAttribute = timeNode.Attributes()[0];
         if (firstAttr.Name === "symbol") {
           if (firstAttr.Value === "common") {
             symbolEnum = RhythmSymbolEnum.COMMON;
@@ -624,34 +644,34 @@ export class InstrumentReader {
       let num: number = 0;
       let denom: number = 0;
       let senzaMisura: boolean = (timeNode !== undefined && timeNode.Element("senza-misura") !== undefined);
-      let timeList: IXmlElement[] = node.Elements("time").ToArray();
-      let beatsList: List<IXmlElement> = new List<IXmlElement>();
-      let typeList: List<IXmlElement> = new List<IXmlElement>();
+      let timeList: IXmlElement[] = node.Elements("time");
+      let beatsList: IXmlElement[] = new Array();
+      let typeList: IXmlElement[] = new Array();
       for (let idx: number = 0, len: number = timeList.length; idx < len; ++idx) {
         let xmlNode: IXmlElement = timeList[idx];
-        beatsList.AddRange(xmlNode.Elements("beats"));
-        typeList.AddRange(xmlNode.Elements("beat-type"));
+        beatsList.push.apply(beatsList, xmlNode.Elements("beats"));
+        typeList.push.apply(typeList, xmlNode.Elements("beat-type"));
       }
       if (!senzaMisura) {
         try {
-          if (beatsList !== undefined && beatsList.Count > 0 && typeList !== undefined && beatsList.Count === typeList.Count) {
-            let length: number = beatsList.Count();
+          if (beatsList !== undefined && beatsList.length > 0 && typeList !== undefined && beatsList.length === typeList.length) {
+            let length: number = beatsList.length;
             let fractions: Fraction[] = new Array(length);
             let maxDenom: number = 0;
             for (let i: number = 0; i < length; i++) {
               let s: string = beatsList[i].Value;
               let n: number = 0;
               let d: number = 0;
-              if (s.IndexOf("+") !== -1) {
-                let numbers: string[] = s.Split("+");
-                for (let idx: number = 0, len: number = numbers.Count(); idx < len; ++idx) {
+              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]);
                 }
               } else {
                 n = parseInt(s);
               }
               d = parseInt(typeList[i].Value);
-              maxDenom = Math.Max(maxDenom, d);
+              maxDenom = Math.max(maxDenom, d);
               fractions[i] = new Fraction(n, d, false);
             }
             for (let i: number = 0; i < length; i++) {
@@ -671,7 +691,7 @@ export class InstrumentReader {
           this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
           num = 4;
           denom = 4;
-          Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
         if ((num === denom === 4) || (num === denom === 2)) {
@@ -680,15 +700,21 @@ export class InstrumentReader {
         let rhythmInstruction: RhythmInstruction = new RhythmInstruction(
           new Fraction(num, denom, false), num, denom, symbolEnum
         );
-        this.abstractInstructions.Add(new KeyValuePairClass<number, AbstractNotationInstruction>(1, rhythmInstruction));
+        this.abstractInstructions[1] = rhythmInstruction;
       } else {
         let rhythmInstruction: RhythmInstruction = new RhythmInstruction(new Fraction(4, 4, false), 4, 4, RhythmSymbolEnum.NONE);
-        this.abstractInstructions.Add(new KeyValuePairClass<number, AbstractNotationInstruction>(1, rhythmInstruction));
+        this.abstractInstructions[1] = rhythmInstruction;
       }
     }
   }
+
+  private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
+    // FIXME TODO
+    console.log("saveAbstractInstructionList still to implement! See InstrumentReader.ts");
+  }
+
   /*private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
-    for (let i: number = this.abstractInstructions.Count - 1; i >= 0; i--) {
+    for (let i: number = this.abstractInstructions.length - 1; i >= 0; i--) {
       let keyValuePair: KeyValuePairClass<number, AbstractNotationInstruction> = this.abstractInstructions[i];
       if (keyValuePair.value instanceof ClefInstruction) {
         let clefInstruction: ClefInstruction = <ClefInstruction>keyValuePair.value;
@@ -780,7 +806,7 @@ export class InstrumentReader {
                 firstStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[j];
                 newKeyInstruction.Parent = firstStaffEntry;
                 firstStaffEntry.removeFirstInstructionOfType<KeyInstruction>();
-                if (firstStaffEntry.Instructions.Count === 0) {
+                if (firstStaffEntry.Instructions.length === 0) {
                   firstStaffEntry.Instructions.Add(newKeyInstruction);
                 } else {
                   if (firstStaffEntry.Instructions[0] instanceof ClefInstruction) {
@@ -823,23 +849,23 @@ export class InstrumentReader {
   }
   */
   private saveClefInstructionAtEndOfMeasure(): void {
-    for (let i: number = this.abstractInstructions.Count - 1; i >= 0; i--) {
-      let keyValuePair: KeyValuePairClass<number, AbstractNotationInstruction> = this.abstractInstructions[i];
-      if (keyValuePair.value instanceof ClefInstruction) {
-        let clefInstruction: ClefInstruction = __as__<ClefInstruction>(keyValuePair.value, ClefInstruction);
+    for (let key in this.abstractInstructions) {
+      let value = this.abstractInstructions[key];
+      if (value instanceof ClefInstruction) {
+        let clefInstruction: ClefInstruction = <ClefInstruction>value;
         if (
-          (this.activeClefs[keyValuePair.key - 1] === undefined) ||
-          (clefInstruction.ClefType !== this.activeClefs[keyValuePair.key - 1].ClefType || (
-            clefInstruction.ClefType === this.activeClefs[keyValuePair.key - 1].ClefType &&
-            clefInstruction.Line !== this.activeClefs[keyValuePair.key - 1].Line
+          (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 + keyValuePair.key - 1] = lastStaffEntry;
+          this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] = lastStaffEntry;
           let newClefInstruction: ClefInstruction = clefInstruction;
           newClefInstruction.Parent = lastStaffEntry;
-          lastStaffEntry.Instructions.Add(newClefInstruction);
-          this.activeClefs[keyValuePair.key - 1] = clefInstruction;
-          this.abstractInstructions.Remove(keyValuePair);
+          lastStaffEntry.Instructions.push(newClefInstruction);
+          this.activeClefs[key - 1] = clefInstruction;
+          delete this.abstractInstructions[key]; // FIXME might hurt performance
         }
       }
     }
@@ -876,7 +902,7 @@ export class InstrumentReader {
           );
           this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
           directionStaffNumber = 1;
-          Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
+          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
         }
 
       }
@@ -888,7 +914,7 @@ export class InstrumentReader {
     let xmlMeasureIndex: number = this.currentXmlMeasureIndex;
     let read: boolean = false;
     while (!read) {
-      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[xmlMeasureIndex].Elements().ToArray();
+      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[xmlMeasureIndex].Elements();
       for (let idx: number = 0, len: number = xmlMeasureListArr.length; idx < len; ++idx) {
         let xmlNode: IXmlElement = xmlMeasureListArr[idx];
         if (xmlNode.Name === "note" && xmlNode.Element("time-modification") === undefined) {
@@ -901,7 +927,7 @@ export class InstrumentReader {
               try {
                 noteDuration = parseInt(durationNode.Value);
               } catch (ex) {
-                Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readDivisionsFromNotes", ex);
+                console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readDivisionsFromNotes", ex);
                 continue;
               }
 
@@ -970,7 +996,7 @@ export class InstrumentReader {
   }
 }
 
-
+/*
 class KeyValuePairClass<T, TU> {
   constructor(key: T, value: TU) {
     this.key = key;
@@ -979,3 +1005,4 @@ class KeyValuePairClass<T, TU> {
   public key: T;
   public value: TU;
 }
+*/

+ 11 - 8
src/MusicalScore/VoiceData/Beam.ts

@@ -1,26 +1,29 @@
+import {Note} from "./Note";
+
 export class Beam {
-    private notes: List<Note> = new List<Note>();
-    private extendedNoteList: List<Note> = new List<Note>();
-    public get Notes(): List<Note> {
+    private notes: Note[] = [];
+    private extendedNoteList: Note[] = [];
+    public get Notes(): Note[] {
         return this.notes;
     }
-    public set Notes(value: List<Note>) {
+    public set Notes(value: Note[]) {
         this.notes = value;
     }
-    public get ExtendedNoteList(): List<Note> {
+    public get ExtendedNoteList(): Note[] {
         return this.extendedNoteList;
     }
-    public set ExtendedNoteList(value: List<Note>) {
+    public set ExtendedNoteList(value: Note[]) {
         this.extendedNoteList = value;
     }
     public addNoteToBeam(note: Note): void {
         if (note !== undefined) {
             note.NoteBeam = this;
-            this.notes.Add(note);
-            this.extendedNoteList.Add(note);
+            this.notes.push(note);
+            this.extendedNoteList.push(note);
         }
     }
 }
+
 export enum BeamEnum {
     BeamNone = -1,
     BeamBegin = 0,

+ 2 - 0
src/MusicalScore/VoiceData/Instructions/AbstractNotationInstruction.ts

@@ -1,3 +1,5 @@
+import {SourceStaffEntry} from "../SourceStaffEntry";
+
 export class AbstractNotationInstruction {
     constructor(parent: SourceStaffEntry) {
         this.parent = parent;

+ 151 - 20
src/MusicalScore/VoiceData/Instructions/ClefInstruction.ts

@@ -1,7 +1,12 @@
 import {Pitch} from "../../../Common/DataObjects/pitch";
+import {AbstractNotationInstruction} from "./AbstractNotationInstruction";
+import {NoteEnum} from "../../../Common/DataObjects/pitch";
+import {AccidentalEnum} from "../../../Common/DataObjects/pitch";
+import {ArgumentOutOfRangeException} from "../../Exceptions";
 
 export class ClefInstruction extends AbstractNotationInstruction {
   constructor(clefType: ClefEnum, octaveOffset: number, line: number) {
+    super(undefined); // FIXME? Missing SourceStaffEntry!
     this.line = line;
     this.clefType = clefType;
     this.octaveOffset = octaveOffset;
@@ -37,15 +42,15 @@ export class ClefInstruction extends AbstractNotationInstruction {
         return new ClefInstruction(ClefEnum.G, 0, 2);
     }
   }
-  public static getAllPossibleClefs(): List<ClefInstruction> {
-    let clefList: List<ClefInstruction> = new List<ClefInstruction>();
+  public static getAllPossibleClefs(): ClefInstruction[] {
+    let clefList: ClefInstruction[] = new Array();
     for (let i: number = 0; i <= 2; i++) {
       let clefInstructionG: ClefInstruction = new ClefInstruction(ClefEnum.G, i, 2);
-      clefList.Add(clefInstructionG);
+      clefList.push(clefInstructionG);
     }
     for (let j: number = -2; j <= 0; j++) {
       let clefInstructionF: ClefInstruction = new ClefInstruction(ClefEnum.F, j, 4);
-      clefList.Add(clefInstructionF);
+      clefList.push(clefInstructionF);
     }
     return clefList;
   }
@@ -91,23 +96,18 @@ export class ClefInstruction extends AbstractNotationInstruction {
   public set ReferenceCyPosition(value: number) {
     this.referenceCyPosition = value;
   }
-  public OperatorEquals(clef2: ClefInstruction): boolean {
-    let clef1: ClefInstruction = this;
-    if (ReferenceEquals(clef1, clef2)) {
-      return true;
-    }
-    if (clef1 === undefined || clef2 === undefined) {
-      return false;
-    }
-    return (clef1.ClefPitch === clef2.ClefPitch && clef1.Line === clef2.Line);
+  public Equals(other: ClefInstruction): boolean {
+    if (this === other) { return true; }
+    if (this === undefined || other === undefined) { return false; }
+    return (this.ClefPitch === other.ClefPitch && this.Line === other.Line);
   }
 
-  public OperatorNotEqual(clef2: ClefInstruction): boolean {
-    return this !== clef2;
+  public NotEqual(clef2: ClefInstruction): boolean {
+    return ! this.Equals(clef2);
   }
 
   public ToString(): string {
-    return "ClefType: " + this.clefType.ToString();
+    return "ClefType: " + this.clefType;
   }
   private calcParameters(): void {
     switch (this.clefType) {
@@ -132,14 +132,145 @@ export class ClefInstruction extends AbstractNotationInstruction {
     }
   }
 }
+
 export enum ClefEnum {
   G = 0,
-
   F = 1,
-
   C = 2,
-
   percussion = 3,
-
   TAB = 4
 }
+
+
+export enum MidiInstrument {
+  None = -1,
+  Acoustic_Grand_Piano,
+  Bright_Acoustic_Piano,
+  Electric_Grand_Piano,
+  Honky_tonk_Piano,
+  Electric_Piano_1,
+  Electric_Piano_2,
+  Harpsichord,
+  Clavinet,
+  Celesta,
+  Glockenspiel,
+  Music_Box,
+  Vibraphone,
+  Marimba,
+  Xylophone,
+  Tubular_Bells,
+  Dulcimer,
+  Drawbar_Organ,
+  Percussive_Organ,
+  Rock_Organ,
+  Church_Organ,
+  Reed_Organ,
+  Accordion,
+  Harmonica,
+  Tango_Accordion,
+  Acoustic_Guitar_nylon,
+  Acoustic_Guitar_steel,
+  Electric_Guitar_jazz,
+  Electric_Guitar_clean,
+  Electric_Guitar_muted,
+  Overdriven_Guitar,
+  Distortion_Guitar,
+  Guitar_harmonics,
+  Acoustic_Bass,
+  Electric_Bass_finger,
+  Electric_Bass_pick,
+  Fretless_Bass,
+  Slap_Bass_1,
+  Slap_Bass_2,
+  Synth_Bass_1,
+  Synth_Bass_2,
+  Violin,
+  Viola,
+  Cello,
+  Contrabass,
+  Tremolo_Strings,
+  Pizzicato_Strings,
+  Orchestral_Harp,
+  Timpani,
+  String_Ensemble_1,
+  String_Ensemble_2,
+  Synth_Strings_1,
+  Synth_Strings_2,
+  Choir_Aahs,
+  Voice_Oohs,
+  Synth_Voice,
+  Orchestra_Hit,
+  Trumpet,
+  Trombone,
+  Tuba,
+  Muted_Trumpet,
+  French_Horn,
+  Brass_Section,
+  Synth_Brass_1,
+  Synth_Brass_2,
+  Soprano_Sax,
+  Alto_Sax,
+  Tenor_Sax,
+  Baritone_Sax,
+  Oboe,
+  English_Horn,
+  Bassoon,
+  Clarinet,
+  Piccolo,
+  Flute,
+  Recorder,
+  Pan_Flute,
+  Blown_Bottle,
+  Shakuhachi,
+  Whistle,
+  Ocarina,
+  Lead_1_square,
+  Lead_2_sawtooth,
+  Lead_3_calliope,
+  Lead_4_chiff,
+  Lead_5_charang,
+  Lead_6_voice,
+  Lead_7_fifths,
+  Lead_8_bass_lead,
+  Pad_1_new_age,
+  Pad_2_warm,
+  Pad_3_polysynth,
+  Pad_4_choir,
+  Pad_5_bowed,
+  Pad_6_metallic,
+  Pad_7_halo,
+  Pad_8_sweep,
+  FX_1_rain,
+  FX_2_soundtrack,
+  FX_3_crystal,
+  FX_4_atmosphere,
+  FX_5_brightness,
+  FX_6_goblins,
+  FX_7_echoes,
+  FX_8_scifi,
+  Sitar,
+  Banjo,
+  Shamisen,
+  Koto,
+  Kalimba,
+  Bag_pipe,
+  Fiddle,
+  Shanai,
+  Tinkle_Bell,
+  Agogo,
+  Steel_Drums,
+  Woodblock,
+  Taiko_Drum,
+  Melodic_Tom,
+  Synth_Drum,
+  Reverse_Cymbal,
+  Guitar_Fret_Noise,
+  Breath_Noise,
+  Seashore,
+  Bird_Tweet,
+  Telephone_Ring,
+  Helicopter,
+  Applause,
+  Gunshot,
+  Percussion = 128
+}

+ 43 - 30
src/MusicalScore/VoiceData/Instructions/KeyInstruction.ts

@@ -1,18 +1,31 @@
+import {AbstractNotationInstruction} from "./AbstractNotationInstruction";
+import {SourceStaffEntry} from "../SourceStaffEntry";
+import {NoteEnum} from "../../../Common/DataObjects/pitch";
+import {AccidentalEnum} from "../../../Common/DataObjects/pitch";
+import {Pitch} from "../../../Common/DataObjects/pitch";
+
+
 export class KeyInstruction extends AbstractNotationInstruction {
-  constructor(key: number, mode: KeyEnum) {
-    super();
-    this.Key = key;
-    this.mode = mode;
-  }
-  constructor(parent: SourceStaffEntry, key: number, mode: KeyEnum) {
-    super(parent);
-    this.Key = key;
-    this.mode = mode;
-  }
-  constructor(keyInstruction: KeyInstruction) {
-    this(keyInstruction.parent, keyInstruction.keyType, keyInstruction.mode);
-    this.keyType = keyInstruction.keyType;
-    this.mode = keyInstruction.mode;
+  constructor(first: SourceStaffEntry|KeyInstruction, key?: number, mode?: KeyEnum) {
+    if (first === undefined) {
+      super(undefined); // FIXME check
+      this.Key = key;
+      this.mode = mode;
+    }
+    if (first instanceof SourceStaffEntry) {
+      let parent: SourceStaffEntry = <SourceStaffEntry> first;
+      super(parent);
+      this.Key = key;
+      this.mode = mode;
+    }
+    if (first instanceof KeyInstruction) {
+      let keyInstruction: KeyInstruction = <KeyInstruction> first;
+      super(undefined); // FIXME check
+      this(keyInstruction.parent, keyInstruction.keyType, keyInstruction.mode);
+      this.keyType = keyInstruction.keyType;
+      this.mode = keyInstruction.mode;
+    }
+
   }
 
   private static sharpPositionList: NoteEnum[] = [NoteEnum.F, NoteEnum.C, NoteEnum.G, NoteEnum.D, NoteEnum.A, NoteEnum.E, NoteEnum.B];
@@ -21,16 +34,16 @@ export class KeyInstruction extends AbstractNotationInstruction {
   private keyType: number;
   private mode: KeyEnum;
 
-  public static getNoteEnumList(instruction: KeyInstruction): List<NoteEnum> {
-    let enums: List<NoteEnum> = new List<NoteEnum>();
+  public static getNoteEnumList(instruction: KeyInstruction): NoteEnum[] {
+    let enums: NoteEnum[] = new Array();
     if (instruction.keyType > 0) {
       for (let i: number = 0; i < instruction.keyType; i++) {
-        enums.Add(KeyInstruction.sharpPositionList[i]);
+        enums.push(KeyInstruction.sharpPositionList[i]);
       }
     }
     if (instruction.keyType < 0) {
-      for (let i: number = 0; i < Math.Abs(instruction.keyType); i++) {
-        enums.Add(KeyInstruction.flatPositionList[i]);
+      for (let i: number = 0; i < Math.abs(instruction.keyType); i++) {
+        enums.push(KeyInstruction.flatPositionList[i]);
       }
     }
     return enums;
@@ -39,8 +52,8 @@ export class KeyInstruction extends AbstractNotationInstruction {
   public static getAllPossibleMajorKeyInstructions(): KeyInstruction[] {
     let keyInstructionList: KeyInstruction[] = new Array();
     for (let keyType: number = -7; keyType < 7; keyType++) {
-      let currentKeyInstruction: KeyInstruction = new KeyInstruction(keyType, KeyEnum.major);
-      keyInstructionList.Add(currentKeyInstruction);
+      let currentKeyInstruction: KeyInstruction = new KeyInstruction(undefined, keyType, KeyEnum.major);
+      keyInstructionList.push(currentKeyInstruction);
     }
     return keyInstructionList;
   }
@@ -56,36 +69,36 @@ export class KeyInstruction extends AbstractNotationInstruction {
   public set Mode(value: KeyEnum) {
     this.mode = value;
   }
-  public getFundamentalNotesOfAccidentals(): List<NoteEnum> {
-    let noteList: List<NoteEnum> = new List<NoteEnum>();
+  public getFundamentalNotesOfAccidentals(): NoteEnum[] {
+    let noteList: NoteEnum[] = new Array();
     if (this.keyType > 0) {
       for (let i: number = 0; i < this.keyType; i++) {
-        noteList.Add(KeyInstruction.sharpPositionList[i]);
+        noteList.push(KeyInstruction.sharpPositionList[i]);
       }
     } else if (this.keyType < 0) {
       for (let i: number = 0; i < -this.keyType; i++) {
-        noteList.Add(KeyInstruction.flatPositionList[i]);
+        noteList.push(KeyInstruction.flatPositionList[i]);
       }
     }
     return noteList;
   }
   public getAlterationForPitch(pitch: Pitch): AccidentalEnum {
-    if (this.keyType > 0 && Array.IndexOf(KeyInstruction.sharpPositionList, pitch.FundamentalNote) <= this.keyType) {
+    if (this.keyType > 0 && KeyInstruction.sharpPositionList.indexOf(pitch.FundamentalNote) <= this.keyType) {
       return AccidentalEnum.SHARP;
-    } else if (this.keyType < 0 && Array.IndexOf(KeyInstruction.flatPositionList, pitch.FundamentalNote) <= Math.Abs(this.keyType)) {
+    } else if (this.keyType < 0 && KeyInstruction.flatPositionList.indexOf(pitch.FundamentalNote) <= Math.abs(this.keyType)) {
       return AccidentalEnum.FLAT;
     }
     return AccidentalEnum.NONE;
   }
   public ToString(): string {
-    return "Key: " + this.keyType.ToString() + this.mode.ToString();
+    return "Key: " + this.keyType + "" + this.mode;
   }
   public OperatorEquals(key2: KeyInstruction): boolean {
     let key1: KeyInstruction = this;
-    if (ReferenceEquals(key1, key2)) {
+    if (key1 === key2) {
       return true;
     }
-    if ((<Object>key1 === undefined) || (<Object>key2 === undefined)) {
+    if ((key1 === undefined) || (key2 === undefined)) {
       return false;
     }
     return (key1.Key === key2.Key && key1.Mode === key2.Mode);

+ 3 - 0
src/MusicalScore/VoiceData/LinkedVoice.ts

@@ -1,3 +1,6 @@
+import {Voice} from "./Voice";
+import {Instrument} from "../Instrument";
+
 export class LinkedVoice extends Voice {
     constructor(parent: Instrument, voiceId: number, master: Voice) {
         super(parent, voiceId);

+ 1 - 1
src/MusicalScore/VoiceData/Note.ts

@@ -154,7 +154,7 @@ export class Note {
         return absolute;
     }
     public checkForDoubleSlur(slur: Slur): boolean {
-        for (let idx: number = 0, len: number = this.slurs.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.slurs.length; idx < len; ++idx) {
             let noteSlur: Slur = this.slurs[idx];
             if (
               noteSlur.StartNote !== undefined &&

+ 9 - 6
src/MusicalScore/VoiceData/OrnamentContainer.ts

@@ -1,26 +1,29 @@
+import {AccidentalEnum} from "../../Common/DataObjects/pitch";
+
 export class OrnamentContainer {
     constructor(ornament: OrnamentEnum) {
         this.ornament = ornament;
     }
     private ornament: OrnamentEnum;
-    private accidentalAbove: AccEnum = AccEnum.NONE;
-    private accidentalBelow: AccEnum = AccEnum.NONE;
+    private accidentalAbove: AccidentalEnum = AccidentalEnum.NONE;
+    private accidentalBelow: AccidentalEnum = AccidentalEnum.NONE;
     public get GetOrnament(): OrnamentEnum {
         return this.ornament;
     }
-    public get AccidentalAbove(): AccEnum {
+    public get AccidentalAbove(): AccidentalEnum {
         return this.accidentalAbove;
     }
-    public set AccidentalAbove(value: AccEnum) {
+    public set AccidentalAbove(value: AccidentalEnum) {
         this.accidentalAbove = value;
     }
-    public get AccidentalBelow(): AccEnum {
+    public get AccidentalBelow(): AccidentalEnum {
         return this.accidentalBelow;
     }
-    public set AccidentalBelow(value: AccEnum) {
+    public set AccidentalBelow(value: AccidentalEnum) {
         this.accidentalBelow = value;
     }
 }
+
 export enum OrnamentEnum {
     Trill,
     Turn,

+ 46 - 35
src/MusicalScore/VoiceData/SourceMeasure.ts

@@ -6,6 +6,10 @@ import {Staff} from "./Staff";
 import {VoiceEntry} from "./VoiceEntry";
 import {Voice} from "./Voice";
 import {MusicSheet} from "../MusicSheet";
+
+type MultiExpression = any;
+type MultiTempoExpression = any;
+
 export class SourceMeasure {
   constructor(completeNumberOfStaves: number) {
     this.completeNumberOfStaves = completeNumberOfStaves;
@@ -19,16 +23,16 @@ export class SourceMeasure {
   private absoluteTimestamp: Fraction;
   private completeNumberOfStaves: number;
   private duration: Fraction;
-  private staffLinkedExpressions: MultiExpression[] = new Array();
-  private tempoExpressions: MultiTempoExpression[] = new Array();
-  private verticalSourceStaffEntryContainers: VerticalSourceStaffEntryContainer[] = new Array();
+  private staffLinkedExpressions: MultiExpression[] = [];
+  private tempoExpressions: MultiTempoExpression[] = [];
+  private verticalSourceStaffEntryContainers: VerticalSourceStaffEntryContainer[] = [];
   private implicitMeasure: boolean;
   private breakSystemAfter: boolean;
-  private staffMeasureErrors: boolean[] = new Array();
-  private firstInstructionsStaffEntries: SourceStaffEntry[] = new Array();
-  private lastInstructionsStaffEntries: SourceStaffEntry[] = new Array();
-  private firstRepetitionInstructions: RepetitionInstruction[] = new Array();
-  private lastRepetitionInstructions: RepetitionInstruction[] = new Array();
+  private staffMeasureErrors: boolean[] = [];
+  private firstInstructionsStaffEntries: SourceStaffEntry[] = [];
+  private lastInstructionsStaffEntries: SourceStaffEntry[] = [];
+  private firstRepetitionInstructions: RepetitionInstruction[] = [];
+  private lastRepetitionInstructions: RepetitionInstruction[] = [];
   public get MeasureNumber(): number {
     return this.measureNumber;
   }
@@ -101,12 +105,18 @@ export class SourceMeasure {
     }
     return undefined;
   }
-  public findOrCreateStaffEntry(inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff, createdNewContainer: boolean): SourceStaffEntry {
+  public findOrCreateStaffEntry(inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff): SourceStaffEntry {
+    // FIXME, createdNewContainer: boolean): SourceStaffEntry {
     let staffEntry: SourceStaffEntry = undefined;
-    createdNewContainer = false;
-    let existingVerticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers.Find(
-      o => o.Timestamp === inMeasureTimestamp
-    );
+    //createdNewContainer = false; FIXME! The original C# version uses a "out" argument!
+    // Find:
+    let existingVerticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = undefined;
+    for (let k: number = 0; k < this.verticalSourceStaffEntryContainers.length; k++) {
+      if (this.verticalSourceStaffEntryContainers[k].Timestamp === inMeasureTimestamp) {
+        existingVerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers[k];
+        break;
+      }
+    }
     if (existingVerticalSourceStaffEntryContainer !== undefined) {
       if (existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] !== undefined) {
         return existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex];
@@ -116,10 +126,11 @@ export class SourceMeasure {
         return staffEntry;
       }
     }
-    createdNewContainer = true;
-    if (this.verticalSourceStaffEntryContainers.Count === 0 || this.verticalSourceStaffEntryContainers.Last().Timestamp < inMeasureTimestamp) {
+    //createdNewContainer = true;
+    let last: VerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length - 1];
+    if (this.verticalSourceStaffEntryContainers.length === 0 || last.Timestamp < inMeasureTimestamp) {
       let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
-        this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+        this, Fraction.CreateFractionFromFraction(inMeasureTimestamp), this.completeNumberOfStaves
       );
       this.verticalSourceStaffEntryContainers.push(container);
       staffEntry = new SourceStaffEntry(container, staff);
@@ -131,18 +142,18 @@ export class SourceMeasure {
       ) {
         if (this.verticalSourceStaffEntryContainers[i].Timestamp < inMeasureTimestamp) {
           let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
-            this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+            this, Fraction.CreateFractionFromFraction(inMeasureTimestamp), this.completeNumberOfStaves
           );
-          this.verticalSourceStaffEntryContainers.Insert(i + 1, container);
+          this.verticalSourceStaffEntryContainers.splice(i + 1, 0, container);
           staffEntry = new SourceStaffEntry(container, staff);
           container[inSourceMeasureStaffIndex] = staffEntry;
           return staffEntry;
         }
         if (i === 0) {
           let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
-            this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+            this, Fraction.CreateFractionFromFraction(inMeasureTimestamp), this.completeNumberOfStaves
           );
-          this.verticalSourceStaffEntryContainers.Insert(i, container);
+          this.verticalSourceStaffEntryContainers.splice(i, 0, container);
           staffEntry = new SourceStaffEntry(container, staff);
           container[inSourceMeasureStaffIndex] = staffEntry;
           return staffEntry;
@@ -151,7 +162,7 @@ export class SourceMeasure {
     }
     return staffEntry;
   }
-  public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice, createdNewVoiceEntry: boolean): VoiceEntry {
+  public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice): VoiceEntry {//, createdNewVoiceEntry: boolean): VoiceEntry {
     let ve: VoiceEntry = undefined;
     for (let voiceEntry: VoiceEntry of sse.VoiceEntries) {
       if (voiceEntry.ParentVoice === voice) {
@@ -162,9 +173,9 @@ export class SourceMeasure {
     if (ve === undefined) {
       ve = new VoiceEntry(sse.Timestamp, voice, sse);
       sse.VoiceEntries.push(ve);
-      createdNewVoiceEntry = true;
+      // FIXME createdNewVoiceEntry = true;
     } else {
-      createdNewVoiceEntry = false;
+      // FIXME createdNewVoiceEntry = false;
     }
     return ve;
   }
@@ -180,16 +191,16 @@ export class SourceMeasure {
   }
   public getVerticalContainerIndexByTimestamp(musicTimestamp: Fraction): number {
     let index: number = -1;
-    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.length; idx < len; ++idx) {
       let verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
       if (verticalSourceStaffEntryContainer.Timestamp === musicTimestamp) {
-        return this.verticalSourceStaffEntryContainers.IndexOf(verticalSourceStaffEntryContainer);
+        return this.verticalSourceStaffEntryContainers.indexOf(verticalSourceStaffEntryContainer);
       }
     }
     return index;
   }
   public getVerticalContainerByTimestamp(musicTimestamp: Fraction): VerticalSourceStaffEntryContainer {
-    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.length; idx < len; ++idx) {
       let verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
       if (verticalSourceStaffEntryContainer.Timestamp === musicTimestamp) {
         return verticalSourceStaffEntryContainer;
@@ -205,16 +216,16 @@ export class SourceMeasure {
       }
     }
     if (undefinedCounter === this.completeNumberOfStaves) {
-      this.verticalSourceStaffEntryContainers.Remove(this.verticalSourceStaffEntryContainers[index]);
+      this.verticalSourceStaffEntryContainers.splice(index, 1);
     }
   }
   public reverseCheck(musicSheet: MusicSheet, maxInstDuration: Fraction): Fraction {
     let maxDuration: Fraction = new Fraction(0, 1);
-    let instrumentsDurations: Fraction[] = new Array();
+    let instrumentsDurations: Fraction[] = [];
     for (let i: number = 0; i < musicSheet.Instruments.length; i++) {
       let instrumentDuration: Fraction = new Fraction(0, 1);
       let inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
-      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
+      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.length; j++) {
         let lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
         if (lastStaffEntry !== undefined && !lastStaffEntry.hasTie()) {
           let verticalContainerIndex: number = this.verticalSourceStaffEntryContainers.indexOf(lastStaffEntry.VerticalContainerParent);
@@ -229,22 +240,22 @@ export class SourceMeasure {
           }
         }
       }
-      instrumentsDurations.Add(instrumentDuration);
+      instrumentsDurations.push(instrumentDuration);
     }
-    for (let idx: number = 0, len: number = instrumentsDurations.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = instrumentsDurations.length; idx < len; ++idx) {
       let instrumentsDuration: Fraction = instrumentsDurations[idx];
       if (maxDuration < instrumentsDuration) {
         maxDuration = instrumentsDuration;
       }
     }
-    return Math.max(maxDuration, maxInstDuration);
+    return Fraction.max(maxDuration, maxInstDuration);
   }
   public calculateInstrumentsDuration(musicSheet: MusicSheet, instrumentMaxTieNoteFractions: Fraction[]): Fraction[] {
-    let instrumentsDurations: Fraction[] = new Array();
+    let instrumentsDurations: Fraction[] = [];
     for (let i: number = 0; i < musicSheet.Instruments.length; i++) {
       let instrumentDuration: Fraction = new Fraction(0, 1);
       let inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
-      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
+      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.length; j++) {
         let lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
         if (lastStaffEntry !== undefined && lastStaffEntry.Timestamp !== undefined) {
           if (instrumentDuration < lastStaffEntry.Timestamp + lastStaffEntry.calculateMaxNoteLength()) {
@@ -260,7 +271,7 @@ export class SourceMeasure {
     return instrumentsDurations;
   }
   public getEntriesPerStaff(staffIndex: number): SourceStaffEntry[] {
-    let sourceStaffEntries: SourceStaffEntry[] = new Array();
+    let sourceStaffEntries: SourceStaffEntry[] = [];
     for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.length; idx < len; ++idx) {
       let container: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
       let sse: SourceStaffEntry = container[staffIndex];

+ 4 - 4
src/MusicalScore/VoiceData/SourceStaffEntry.ts

@@ -17,11 +17,11 @@ export class SourceStaffEntry {
   }
   private parentStaff: Staff;
   private verticalContainerParent: VerticalSourceStaffEntryContainer;
-  private voiceEntries: VoiceEntry[] = new Array();
+  private voiceEntries: VoiceEntry[] = [];
   private staffEntryLink: StaffEntryLink;
-  private instructions: AbstractNotationInstruction[] = new Array();
-  //private graceVoiceEntriesBefore: VoiceEntry[] = new Array();
-  //private graceVoiceEntriesAfter: VoiceEntry[] = new Array();
+  private instructions: AbstractNotationInstruction[] = [];
+  //private graceVoiceEntriesBefore: VoiceEntry[] = [];
+  //private graceVoiceEntriesAfter: VoiceEntry[] = [];
   private chordSymbolContainer: ChordSymbolContainer;
   public get ParentStaff(): Staff {
     return this.parentStaff;

+ 1 - 2
src/MusicalScore/VoiceData/Staff.ts

@@ -1,7 +1,6 @@
 import {Voice} from "./Voice";
 import {Instrument} from "../Instrument";
 
-
 export class Staff {
     constructor(parentInstrument: Instrument, instrumentStaffId: number) {
         this.parentInstrument = parentInstrument;
@@ -15,7 +14,7 @@ export class Staff {
     public Following: boolean;
 
     private parentInstrument: Instrument;
-    private voices: Voice[] = new Array();
+    private voices: Voice[] = [];
     private volume: number = 1;
     private id: number;
 

+ 4 - 1
src/MusicalScore/VoiceData/StaffEntryLink.ts

@@ -1,9 +1,12 @@
+import {VoiceEntry} from "./VoiceEntry";
+import {SourceStaffEntry} from "./SourceStaffEntry";
+
 export class StaffEntryLink {
     constructor(voiceEntry: VoiceEntry) {
         this.voiceEntry = voiceEntry;
     }
     private voiceEntry: VoiceEntry;
-    private linkStaffEntries: SourceStaffEntry[] = new Array();
+    private linkStaffEntries: SourceStaffEntry[] = [];
     public get GetVoiceEntry(): VoiceEntry {
         return this.voiceEntry;
     }

+ 19 - 12
src/MusicalScore/VoiceData/Tie.ts

@@ -1,3 +1,11 @@
+import {Note} from "./Note";
+import {Beam} from "./Beam";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {Tuplet} from "./Tuplet";
+
+// FIXME: Missing Slur class
+type Slur = any;
+
 export class Tie {
     constructor(note: Note) {
         this.start = note;
@@ -8,8 +16,8 @@ export class Tie {
     private tieTuplet: Tuplet;
     private tieEndingSlur: Slur;
     private tieStartingSlur: Slur;
-    private fractions: List<Fraction> = new List<Fraction>();
-    private noteHasBeenCreated: List<boolean> = new List<boolean>();
+    private fractions: Fraction[] = [];
+    private noteHasBeenCreated: boolean[] = [];
     private baseNoteYPosition: number;
     public get Start(): Note {
         return this.start;
@@ -47,16 +55,16 @@ export class Tie {
     public set TieStartingSlur(value: Slur) {
         this.tieStartingSlur = value;
     }
-    public get Fractions(): List<Fraction> {
+    public get Fractions(): Fraction[] {
         return this.fractions;
     }
-    public set Fractions(value: List<Fraction>) {
+    public set Fractions(value: Fraction[]) {
         this.fractions = value;
     }
-    public get NoteHasBeenCreated(): List<boolean> {
+    public get NoteHasBeenCreated(): boolean[] {
         return this.noteHasBeenCreated;
     }
-    public set NoteHasBeenCreated(value: List<boolean>) {
+    public set NoteHasBeenCreated(value: boolean[]) {
         this.noteHasBeenCreated = value;
     }
     public get BaseNoteYPosition(): number {
@@ -66,16 +74,15 @@ export class Tie {
         this.baseNoteYPosition = value;
     }
     public initializeBoolList(): void {
-        this.noteHasBeenCreated.Clear();
-        for (let idx: number = 0, len: number = this.fractions.Count; idx < len; ++idx) {
+        this.noteHasBeenCreated = [];
+        for (let idx: number = 0, len: number = this.fractions.length; idx < len; ++idx) {
             // let fraction: Fraction = this.fractions[idx];
-            this.noteHasBeenCreated.Add(false);
+            this.noteHasBeenCreated.push(false);
         }
     }
     public allGraphicalNotesHaveBeenCreated(): boolean {
-        for (let idx: number = 0, len: number = this.noteHasBeenCreated.Count; idx < len; ++idx) {
-            let b: boolean = this.noteHasBeenCreated[idx];
-            if (!b) { return false; }
+        for (let idx: number = 0, len: number = this.noteHasBeenCreated.length; idx < len; ++idx) {
+            if (!this.noteHasBeenCreated[idx]) { return false; }
         }
         return true;
     }

+ 5 - 2
src/MusicalScore/VoiceData/Tuplet.ts

@@ -1,10 +1,13 @@
+import {Note} from "./Note";
+import {Fraction} from "../../Common/DataObjects/fraction";
+
 export class Tuplet {
   constructor(tupletLabelNumber: number) {
     this.tupletLabelNumber = tupletLabelNumber;
   }
   private tupletLabelNumber: number;
-  private notes: Note[][] = new Array();
-  private fractions: Fraction[] = new Array();
+  private notes: Note[][] = [];
+  private fractions: Fraction[] = [];
   public get TupletLabelNumber(): number {
     return this.tupletLabelNumber;
   }

+ 7 - 3
src/MusicalScore/VoiceData/VerticalSourceStaffEntryContainer.ts

@@ -1,3 +1,7 @@
+import {SourceMeasure} from "./SourceMeasure";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {SourceStaffEntry} from "./SourceStaffEntry";
+
 export class VerticalSourceStaffEntryContainer {
     constructor(parentMeasure: SourceMeasure, timestamp: Fraction, size: number) {
         this.timestamp = timestamp;
@@ -7,8 +11,8 @@ export class VerticalSourceStaffEntryContainer {
     }
     private timestamp: Fraction;
     private size: number;
-    private staffEntries: SourceStaffEntry[] = new Array();
-    private comments: Comment[] = new Array();
+    private staffEntries: SourceStaffEntry[] = [];
+    private comments: Comment[] = [];
     private parentMeasure: SourceMeasure;
 
     public $get$(index: number): SourceStaffEntry {
@@ -46,7 +50,7 @@ export class VerticalSourceStaffEntryContainer {
     }
     private initialize(): void {
         for (let i: number = 0; i < this.size; i++) {
-            this.staffEntries.Add();
+            this.staffEntries.push(undefined);
         }
     }
 }

+ 3 - 0
src/MusicalScore/VoiceData/Voice.ts

@@ -1,3 +1,6 @@
+import {Instrument} from "../Instrument";
+import {VoiceEntry} from "./VoiceEntry";
+
 export class Voice {
     constructor(parent: Instrument, voiceId: number) {
         this.parent = parent;

+ 23 - 22
src/MusicalScore/VoiceData/VoiceEntry.ts

@@ -22,11 +22,11 @@ export class VoiceEntry {
   private parentVoice: Voice;
   private parentSourceStaffEntry: SourceStaffEntry;
   private timestamp: Fraction;
-  private notes: Note[] = new Array();
-  private articulations: ArticulationEnum[] = new Array();
-  private technicalInstructions: TechnicalInstruction[] = new Array();
+  private notes: Note[] = [];
+  private articulations: ArticulationEnum[] = [];
+  private technicalInstructions: TechnicalInstruction[] = [];
   private lyricsEntries: { [n: number]: LyricsEntry; } = {};
-  private arpeggiosNotesIndices: number[] = new Array();
+  private arpeggiosNotesIndices: number[] = [];
   private ornamentContainer: OrnamentContainer;
   public get ParentSourceStaffEntry(): SourceStaffEntry {
     return this.parentSourceStaffEntry;
@@ -121,10 +121,13 @@ export class VoiceEntry {
     return false;
   }
   public getVerseNumberForLyricEntry(lyricsEntry: LyricsEntry): number {
-    for (let key in this.lyricsEntries) {
-      if (lyricsEntry === this.lyricsEntries[key]) {
-        return key;
-      } // FIXME
+    let lyricsEntries: { [n: number]: LyricsEntry; } = this.lyricsEntries;
+    for (let key in lyricsEntries) {
+      if (lyricsEntries.hasOwnProperty(key)) { // FIXME check has own property
+          if (lyricsEntry === this.lyricsEntries[key]) {
+              return key;
+          }
+      }
     }
     return 1;
   }
@@ -132,7 +135,7 @@ export class VoiceEntry {
     return this.createVoiceEntriesForOrnament(this, activeKey);
   }
   public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): VoiceEntry[] {
-    let voiceEntries: VoiceEntry[] = new Array();
+    let voiceEntries: VoiceEntry[] = [];
     if (voiceEntryWithOrnament.ornamentContainer === undefined) {
       return;
     }
@@ -144,27 +147,24 @@ export class VoiceEntry {
     //let length: Fraction;
     switch (voiceEntryWithOrnament.ornamentContainer.GetOrnament) {
       case OrnamentEnum.Trill: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 8);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 8);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           if (voiceEntryWithOrnament.OrnamentContainer.AccidentalAbove !== AccidentalEnum.NONE) {
             alteration = <AccidentalEnum><number>voiceEntryWithOrnament.ornamentContainer.AccidentalAbove;
           }
           for (let i: number = 0; i < 8; i++) {
+            currentTimestamp = Fraction.plus(baseTimestamp, new Fraction(i * length.Numerator, length.Denominator));
             if ((i % 2) === 0) {
-              currentTimestamp = Fraction.plus(baseTimestamp, new Fraction(i * length.Numerator, length.Denominator));
               this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
             } else {
-              currentTimestamp = Fraction.plus(baseTimestamp, new Fraction(i * length.Numerator, length.Denominator));
-              this.createAlteratedVoiceEntry(
-                currentTimestamp, length, baseVoice, higherPitch, alteration, voiceEntries
-              );
+              this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, alteration, voiceEntries);
             }
           }
         }
         break;
       case OrnamentEnum.Turn: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
@@ -183,7 +183,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.InvertedTurn: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
@@ -202,7 +202,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.DelayedTurn: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 2);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
@@ -220,7 +220,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.DelayedInvertedTurn: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 2);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
@@ -238,7 +238,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.Mordent: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
@@ -250,7 +250,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.InvertedMordent: {
-          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
@@ -276,7 +276,8 @@ export class VoiceEntry {
     voiceEntries.push(voiceEntry);
   }
   private createAlteratedVoiceEntry(
-    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, higherPitch: Pitch, alteration: AccidentalEnum, voiceEntries: VoiceEntry[]
+    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, higherPitch: Pitch,
+    alteration: AccidentalEnum, voiceEntries: VoiceEntry[]
   ): void {
     let voiceEntry: VoiceEntry = new VoiceEntry(currentTimestamp, baseVoice, undefined);
     let pitch: Pitch = new Pitch(higherPitch.FundamentalNote, higherPitch.Octave, alteration);