Explorar el Código

Fixing types & imports pt.7

Andrea Condoluci hace 9 años
padre
commit
c0a4a719c3

+ 24 - 19
src/Common/DataObjects/fraction.ts

@@ -14,6 +14,14 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     private denominator: number = 1;
     private realValue: number;
 
+    public static max(f1: Fraction, f2: Fraction): Fraction {
+        if (f1.RealValue > f2.RealValue) {
+            return f1;
+        } else {
+            return f2;
+        }
+    }
+
     public static Equal(f1: Fraction, f2: Fraction): boolean {
       // FIXME
       return f1.Denominator === f2.Denominator && f1.Numerator === f2.Numerator;
@@ -55,6 +63,10 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
         return a;
     }
 
+    public ToString(): string {
+        return this.numerator + "/" + this.denominator;
+    }
+
     public clone(): Fraction {
         return new Fraction(this.numerator, this.denominator, false);
     }
@@ -140,7 +152,16 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     }
 
     public Equals(obj: Fraction): boolean {
-        return this.RealValue == obj.RealValue;
+        return this.RealValue === obj.RealValue;
+    }
+
+    public CompareTo(obj: Fraction): number {
+        if (this.RealValue > obj.RealValue) {
+            return 1;
+        } else if (this.RealValue < obj.RealValue) {
+            return -1;
+        }
+        return 0;
     }
 
     //public Equals(f: Fraction): boolean {
@@ -209,14 +230,7 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //        return m1;
     //    else return m2;
     //}
-    public CompareTo(obj: Fraction): number {
-        if (this.RealValue > obj.RealValue) {
-            return 1;
-        } else if (this.RealValue < obj.RealValue) {
-            return -1;
-        }
-        return 0;
-    }
+
     //public static getFraction(value: number, denominatorPrecision: number): Fraction {
     //    let numerator: number = <number>Math.round(value / (1.0 / denominatorPrecision));
     //    return new Fraction(numerator, denominatorPrecision);
@@ -226,13 +240,7 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //        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);
     //}
@@ -242,9 +250,6 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //public static get MaxAllowedDenominator(): number {
     //    return Fraction.maximumAllowedNumber;
     //}
-    public ToString(): string {
-        return this.numerator + "/" + this.denominator;
-    }
     //public ToFloatingString(): string {
     //    return this.RealValue.ToString();
     //}

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

@@ -43,7 +43,7 @@ export class IXmlElement {
   public Attributes(): IXmlAttribute[] {
     if (typeof this._attrs === "undefined") {
       let attributes: NamedNodeMap = this._elem.attributes;
-      let attrs: IXmlAttribute[] = new Array();
+      let attrs: IXmlAttribute[] = [];
       for (let i: number = 0; i < attributes.length; i += 1) {
         attrs.push(new IXmlAttribute(attributes[i]));
       }
@@ -58,7 +58,7 @@ export class IXmlElement {
 
   public Elements(nodeName?: string): IXmlElement[] {
     let nodes: NodeList = this._elem.childNodes;
-    let ret: IXmlElement[] = new Array();
+    let ret: IXmlElement[] = [];
     let nameUnset: boolean = typeof nodeName === "undefined";
     for (let i: number = 0; i < nodes.length; i += 1) {
       let node: Node = nodes[i];

+ 9 - 9
src/MusicalScore/Instrument.ts

@@ -1,10 +1,10 @@
 import { InstrumentalGroup } from "./InstrumentalGroup";
 import { Label } from "./Label";
-import { MusicSheet } from "./MusicSheet"
-import { Voice } from "./VoiceData/Voice"
-import { Staff } from "./VoiceData/Staff"
-import { SubInstrument } from "./SubInstrument"
-import {MidiInstrument} from "./VoiceData/Instructions/ClefInstruction";
+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;
@@ -26,8 +26,8 @@ export class Instrument extends InstrumentalGroup /*implements ISettableInstrume
     public InstrumentParameterChanged: InstrumentParameterChangedDelegate;
 
     private phonicScoreInterface: IPhonicScoreInterface;
-    private voices: Voice[] = new Array();
-    private staves: Staff[] = new Array();
+    private voices: Voice[] = [];
+    private staves: Staff[] = [];
     private nameLabel: Label;
     // private range: ToneRange;
     private idString: string;
@@ -36,8 +36,8 @@ export class Instrument extends InstrumentalGroup /*implements ISettableInstrume
     private hasChordSymbols: boolean = false;
     private playbackTranspose: number;
 
-    private lyricVersesNumbers: number[] = new Array();
-    private subInstruments: SubInstrument[] = new Array();
+    private lyricVersesNumbers: number[] = [];
+    private subInstruments: SubInstrument[] = [];
     public get Voices(): Voice[] {
         return this.voices;
     }

+ 2 - 2
src/MusicalScore/InstrumentalGroup.ts

@@ -1,4 +1,4 @@
-import { MusicSheet } from "./MusicSheet"
+import { MusicSheet } from "./MusicSheet";
 
 export class InstrumentalGroup {
     constructor(name: string, musicSheet: MusicSheet, parent: InstrumentalGroup) {
@@ -9,7 +9,7 @@ export class InstrumentalGroup {
     private name: string;
     private musicSheet: MusicSheet;
     private parent: InstrumentalGroup;
-    private instrumentalGroups: InstrumentalGroup[] = new Array();
+    private instrumentalGroups: InstrumentalGroup[] = [];
     //private instruments: List<Instrument> = new List<Instrument>();
     public get InstrumentalGroups(): InstrumentalGroup[] {
         return this.instrumentalGroups;

+ 6 - 6
src/MusicalScore/MusicParts/MusicPartManager.ts

@@ -1,8 +1,8 @@
-import { MusicSheet } from "../MusicSheet"
-import { PartListEntry } from "../MusicSource/PartListEntry"
-import { Repetition } from "../MusicSource/Repetition"
-import { Fraction } from "../../Common/DataObjects/fraction"
-import { MusicPartManagerIterator } from "./MusicPartManagerIterator"
+import { MusicSheet } from "../MusicSheet";
+import { PartListEntry } from "../MusicSource/PartListEntry";
+import { Repetition } from "../MusicSource/Repetition";
+import { Fraction } from "../../Common/DataObjects/fraction";
+import { MusicPartManagerIterator } from "./MusicPartManagerIterator";
 
 export class MusicPartManager /*implements ISelectionListener*/ {
     constructor(musicSheet: MusicSheet) {
@@ -60,7 +60,7 @@ export class MusicPartManager /*implements ISelectionListener*/ {
         this.musicSheet.SelectionEnd = end === undefined ? this.sheetEnd : end;
     }
     private calcMapping(): void {
-        let timestamps: TimestampTransform[] = new Array();
+        let timestamps: TimestampTransform[] = [];
         let iterator: MusicPartManagerIterator = this.getIterator();
         let currentRepetition: Repetition = iterator.CurrentRepetition;
         let curTimestampTransform: TimestampTransform = new TimestampTransform(

+ 14 - 16
src/MusicalScore/MusicParts/MusicPartManagerIterator.ts

@@ -6,16 +6,15 @@ import {MappingSourceMusicPart} from "../MusicSource/MappingSourceMusicPart";
 import {SourceMeasure} from "../VoiceData/SourceMeasure";
 import {VoiceEntry} from "../VoiceData/VoiceEntry";
 import {Instrument} from "../Instrument";
-import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
 import {VerticalSourceStaffEntryContainer} from "../VoiceData/VerticalSourceStaffEntryContainer";
 import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
 import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
 import {RepetitionInstruction} from "../VoiceData/Instructions/RepetitionInstruction";
 
 // FIXME:
-type ContinuousDynamicExpression = AbstractExpression;
-type InstantaniousDynamicExpression = AbstractExpression;
 type MultiTempoExpression = any;
+type ContinuousDynamicExpression = any;
+type InstantaniousDynamicExpression = any;
 type AbstractExpression = any;
 
 export class MusicPartManagerIterator {
@@ -66,7 +65,7 @@ export class MusicPartManagerIterator {
     private currentDynamicEntryIndex: number = 0;
     private currentTempoEntryIndex: number = 0;
     private currentVoiceEntries: VoiceEntry[];
-    private currentDynamicChangingExpressions: DynamicsContainer[] = new Array();
+    private currentDynamicChangingExpressions: DynamicsContainer[] = [];
     private currentTempoChangingExpression: MultiTempoExpression;
     // FIXME: replace these two with a real Dictionary!
     private repetitionIterationCountDictKeys: Repetition[];
@@ -78,7 +77,7 @@ export class MusicPartManagerIterator {
     private currentEnrolledMeasureTimestamp: Fraction = new Fraction(0, 1);
     private currentVerticalContainerInMeasureTimestamp: Fraction = new Fraction(0, 1);
     private jumpResponsibleRepetition: Repetition = undefined;
-    private activeDynamicExpressions: AbstractExpression[] = new Array();
+    private activeDynamicExpressions: AbstractExpression[] = [];
     private activeTempoExpression: MultiTempoExpression;
     public get EndReached(): boolean {
         return this.endReached;
@@ -94,7 +93,7 @@ export class MusicPartManagerIterator {
     }
     public get CurrentRepetitionIteration(): number {
         if (this.CurrentRepetition !== undefined) {
-            return this.getRepetitionIterationCount(this.CurrentRepetition)
+            return this.getRepetitionIterationCount(this.CurrentRepetition);
         }
         return 0;
     }
@@ -143,7 +142,7 @@ export class MusicPartManagerIterator {
     }
 
     public CurrentVisibleVoiceEntries(instrument?: Instrument): VoiceEntry[] {
-        let voiceEntries: VoiceEntry[] = new Array();
+        let voiceEntries: VoiceEntry[] = [];
         if (this.currentVoiceEntries === undefined) {
             return voiceEntries;
         }
@@ -163,7 +162,7 @@ export class MusicPartManagerIterator {
     }
 
     public CurrentAudibleVoiceEntries(instrument?: Instrument): VoiceEntry[] {
-        let voiceEntries: VoiceEntry[] = new Array();
+        let voiceEntries: VoiceEntry[] = [];
         if (this.currentVoiceEntries === undefined) {
             return voiceEntries;
         }
@@ -187,7 +186,7 @@ export class MusicPartManagerIterator {
     }
 
     public CurrentScoreFollowingVoiceEntries(instrument?: Instrument): VoiceEntry[] {
-        let voiceEntries: VoiceEntry[] = new Array();
+        let voiceEntries: VoiceEntry[] = [];
         if (this.currentVoiceEntries === undefined) {
             return voiceEntries;
         }
@@ -239,7 +238,7 @@ export class MusicPartManagerIterator {
     }
     private setRepetitionIterationCount(repetition: Repetition, iterationCount: number): number {
         let i: number = this.repetitionIterationCountDictKeys.indexOf(repetition);
-        if (i == -1) {
+        if (i === -1) {
             this.repetitionIterationCountDictKeys.push(repetition);
             this.repetitionIterationCountDictValues.push(iterationCount);
         } else {
@@ -249,7 +248,7 @@ export class MusicPartManagerIterator {
     }
     private getRepetitionIterationCount(rep: Repetition): number {
         let i: number = this.repetitionIterationCountDictKeys.indexOf(rep);
-        if (i != -1) {
+        if (i !== -1) {
             return this.repetitionIterationCountDictValues[i];
         }
     }
@@ -300,8 +299,7 @@ export class MusicPartManagerIterator {
     private handleRepetitionsAtMeasureBegin(): void {
         for (let idx: number = 0, len: number = this.currentMeasure.FirstRepetitionInstructions.length; idx < len; ++idx) {
             let repetitionInstruction: RepetitionInstruction = this.currentMeasure.FirstRepetitionInstructions[idx];
-            if (repetitionInstruction.ParentRepetition === undefined)
-                continue;
+            if (repetitionInstruction.ParentRepetition === undefined) { continue; }
             let currentRepetition: Repetition = repetitionInstruction.ParentRepetition;
             this.currentRepetition = currentRepetition;
             if (currentRepetition.StartIndex === this.currentMeasureIndex) {
@@ -418,7 +416,7 @@ export class MusicPartManagerIterator {
             if (this.activeDynamicExpressions[staffIndex] !== undefined) {
                 let startTime: Fraction;
                 let endTime: Fraction;
-                /*if (this.activeDynamicExpressions[staffIndex] instanceof ContinuousDynamicExpression) {
+                if (this.activeDynamicExpressions[staffIndex] instanceof ContinuousDynamicExpression) {
                     let continuousDynamic: ContinuousDynamicExpression = <ContinuousDynamicExpression>this.activeDynamicExpressions[staffIndex];
                     startTime = continuousDynamic.StartMultiExpression.AbsoluteTimestamp;
                     endTime = continuousDynamic.EndMultiExpression.AbsoluteTimestamp;
@@ -430,7 +428,7 @@ export class MusicPartManagerIterator {
                     if (this.CurrentSourceTimestamp === instantaniousDynamic.ParentMultiExpression.AbsoluteTimestamp) {
                         this.currentDynamicChangingExpressions.push(new DynamicsContainer(instantaniousDynamic, staffIndex));
                     }
-                }*/ // FIXME COMMENTED OUT, missing classes
+                }
             }
         }
         let timeSortedTempoExpressions: MultiTempoExpression[] = this.manager.MusicSheet.TimestampSortedTempoExpressionsList;
@@ -527,7 +525,7 @@ export class MusicPartManagerIterator {
         }
     }
     private getVoiceEntries(container: VerticalSourceStaffEntryContainer): VoiceEntry[] {
-        let entries: VoiceEntry[] = new Array();
+        let entries: VoiceEntry[] = [];
         for (let sourceStaffEntry of container.StaffEntries) {
             if (sourceStaffEntry === undefined) { continue; }
             for (let voiceEntry of sourceStaffEntry.VoiceEntries) {

+ 8 - 3
src/MusicalScore/MusicSource/MappingSourceMusicPart.ts

@@ -4,20 +4,25 @@ import {Repetition} from "./Repetition";
 import {PartListEntry} from "./PartListEntry";
 
 export class MappingSourceMusicPart /* implements IComparable, IComparable<MappingSourceMusicPart>*/ {
-    constructor(sourceMusicPart: SourceMusicPart, startTimestamp: Fraction, parentPartListEntry?: Repetition, repetitionRun: number = -1, isEnding: boolean = false) {
+    constructor(
+        sourceMusicPart: SourceMusicPart, startTimestamp: Fraction, parentPartListEntry?: Repetition,
+        repetitionRun: number = -1, isEnding: boolean = false,
+    ) {
         this.sourceMusicPart = sourceMusicPart;
         this.parentPartListEntry = parentPartListEntry;
-        this.startTimestamp = Fraction.CreateFractionFromFraction(startTimestamp);
+        this.startTimestamp = startTimestamp.clone();
         this.repetitionRun = repetitionRun;
-        this.parentRepetition = <Repetition>parentPartListEntry;
+        this.parentRepetition = parentPartListEntry;
         this.isEnding = isEnding;
     }
+
     private sourceMusicPart: SourceMusicPart;
     private parentRepetition: Repetition;
     private parentPartListEntry: PartListEntry;
     private startTimestamp: Fraction;
     private repetitionRun: number = -1;
     private isEnding: boolean;
+
     public get IsRepetition(): boolean {
         return this.parentRepetition !== undefined;
     }

+ 1 - 1
src/MusicalScore/MusicSource/PartListEntry.ts

@@ -11,7 +11,7 @@ export class PartListEntry {
     public StartIndex: number;
     public EndIndex: number;
 
-    protected enrolledTimestamps: Fraction[] = new Array();
+    protected enrolledTimestamps: Fraction[] = [];
     protected visible: boolean = true;
 
     private musicSheet: MusicSheet;

+ 7 - 8
src/MusicalScore/MusicSource/Repetition.ts

@@ -1,5 +1,4 @@
 import {SourceMusicPart} from "./SourceMusicPart";
-import {VoiceEntry} from "../VoiceData/VoiceEntry";
 import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
 import {SourceMeasure} from "../VoiceData/SourceMeasure";
 import {Fraction} from "../../Common/DataObjects/fraction";
@@ -18,21 +17,21 @@ export class Repetition extends PartListEntry /*implements IRepetition*/ {
     public EndMarker: RepetitionInstruction;
     public ForwardJumpInstruction: RepetitionInstruction;
 
-    private backwardJumpInstructions: RepetitionInstruction[] = new Array();
-    private endingParts: RepetitionEndingPart[] = new Array();
-    private endingIndexDict: { [_: number] : RepetitionEndingPart; } = {};
+    private backwardJumpInstructions: RepetitionInstruction[] = [];
+    private endingParts: RepetitionEndingPart[] = [];
+    private endingIndexDict: { [_: number]: RepetitionEndingPart; } = {};
     private userNumberOfRepetitions: number = 0;
-    private visibles: boolean[] = new Array();
+    private visibles: boolean[] = [];
     private fromWords: boolean = false;
     private musicSheet2: MusicSheet;
-    private repetitonIterationOrder: number[] = new Array();
+    private repetitonIterationOrder: number[] = [];
     private numberOfEndings: number = 1;
     private virtualOverallRepetition: boolean;
 
     public get BackwardJumpInstructions(): RepetitionInstruction[] {
         return this.backwardJumpInstructions;
     }
-    public get EndingIndexDict(): { [_: number] : RepetitionEndingPart; } {
+    public get EndingIndexDict(): { [_: number]: RepetitionEndingPart; } {
         return this.endingIndexDict;
     }
     public get EndingParts(): RepetitionEndingPart[] {
@@ -164,7 +163,7 @@ export class RepetitionEndingPart {
         this.part = endingPart;
     }
     public part: SourceMusicPart;
-    public endingIndices: number[] = new Array();
+    public endingIndices: number[] = [];
     public ToString(): string {
       return this.endingIndices.join(", ");
     }

+ 72 - 73
src/MusicalScore/SubInstrument.ts

@@ -1,65 +1,68 @@
+import {Instrument} from "./Instrument";
+import {MidiInstrument} from "./VoiceData/Instructions/ClefInstruction";
+
 export class SubInstrument {
     constructor(parentInstrument: Instrument) {
         this.parentInstrument = parentInstrument;
         this.FixedKey = -1;
-        this.MidiInstrumentId = parseMidiInstrument(this.parentInstrument.Name);
-        this.Name = this.MidiInstrumentId.ToString();
+        this.MidiInstrumentId = this.parseMidiInstrument(this.parentInstrument.Name);
+        this.Name = SubInstrument.midiInstrument[this.MidiInstrumentId];
         this.Volume = 1.0;
     }
-    /*private static midiInstrument: Dictionary<string, MidiInstrument> = __init(new Dictionary<string, MidiInstrument>(), {
-        { "cello", MidiInstrument.Cello },
-        { "violon-c", MidiInstrument.Cello },
-        { "contrabass", MidiInstrument.Contrabass },
-        { "kontrabass", MidiInstrument.Contrabass },
-        { "clarinet", MidiInstrument.Clarinet },
-        { "klarinette", MidiInstrument.Clarinet },
-        { "flute", MidiInstrument.Flute },
-        { "fl�te", MidiInstrument.Flute },
-        { "frenchhorn", MidiInstrument.French_Horn },
-        { "guitar", MidiInstrument.Acoustic_Guitar_nylon },
-        { "gitarre", MidiInstrument.Acoustic_Guitar_nylon },
-        { "harp", MidiInstrument.Orchestral_Harp },
-        { "harfe", MidiInstrument.Orchestral_Harp },
-        { "oboe", MidiInstrument.Oboe },
-        { "organ", MidiInstrument.Church_Organ },
-        { "orgue", MidiInstrument.Church_Organ },
-        { "orgel", MidiInstrument.Church_Organ },
-        { "piano", MidiInstrument.Acoustic_Grand_Piano },
-        { "klavier", MidiInstrument.Acoustic_Grand_Piano },
-        { "piccolo", MidiInstrument.Piccolo },
-        { "strings", MidiInstrument.String_Ensemble_1 },
-        { "streicher", MidiInstrument.String_Ensemble_1 },
-        { "steeldrum", MidiInstrument.Steel_Drums },
-        { "trombone", MidiInstrument.Trombone },
-        { "posaune", MidiInstrument.Trombone },
-        { "brass", MidiInstrument.Trombone },
-        { "trumpet", MidiInstrument.Trumpet },
-        { "trompete", MidiInstrument.Trumpet },
-        { "tpt", MidiInstrument.Trumpet },
-        { "tuba", MidiInstrument.Tuba },
-        { "sax", MidiInstrument.Tenor_Sax },
-        { "viola", MidiInstrument.Viola },
-        { "bratsche", MidiInstrument.Viola },
-        { "violin", MidiInstrument.Violin },
-        { "violon.", MidiInstrument.Violin },
-        { "woodblock", MidiInstrument.Woodblock },
-        { "alt", MidiInstrument.Synth_Voice },
-        { "alto", MidiInstrument.Synth_Voice },
-        { "tenor", MidiInstrument.Synth_Voice },
-        { "bariton", MidiInstrument.Synth_Voice },
-        { "baritone", MidiInstrument.Synth_Voice },
-        { "bass", MidiInstrument.Synth_Voice },
-        { "sopran", MidiInstrument.Synth_Voice },
-        { "voice", MidiInstrument.Synth_Voice },
-        { "recorder", MidiInstrument.Recorder },
-        { "blockfl�te", MidiInstrument.Recorder },
-        { "banjo", MidiInstrument.Banjo },
-        { "drums", MidiInstrument.Percussion },
-        { "percussion", MidiInstrument.Percussion },
-        { "schlagzeug", MidiInstrument.Percussion },
-        { "schlagwerk", MidiInstrument.Percussion },
-        { "unnamed", MidiInstrument.Acoustic_Grand_Piano },
-});*/
+    private static midiInstrument: { [key: string]: MidiInstrument; } = {
+        "cello": MidiInstrument.Cello,
+        "violon-c": MidiInstrument.Cello,
+        "contrabass": MidiInstrument.Contrabass,
+        "kontrabass": MidiInstrument.Contrabass,
+        "clarinet": MidiInstrument.Clarinet,
+        "klarinette": MidiInstrument.Clarinet,
+        "flute": MidiInstrument.Flute,
+        "fl�te": MidiInstrument.Flute,
+        "frenchhorn": MidiInstrument.French_Horn,
+        "guitar": MidiInstrument.Acoustic_Guitar_nylon,
+        "gitarre": MidiInstrument.Acoustic_Guitar_nylon,
+        "harp": MidiInstrument.Orchestral_Harp,
+        "harfe": MidiInstrument.Orchestral_Harp,
+        "oboe": MidiInstrument.Oboe,
+        "organ": MidiInstrument.Church_Organ,
+        "orgue": MidiInstrument.Church_Organ,
+        "orgel": MidiInstrument.Church_Organ,
+        "piano": MidiInstrument.Acoustic_Grand_Piano,
+        "klavier": MidiInstrument.Acoustic_Grand_Piano,
+        "piccolo": MidiInstrument.Piccolo,
+        "strings": MidiInstrument.String_Ensemble_1,
+        "streicher": MidiInstrument.String_Ensemble_1,
+        "steeldrum": MidiInstrument.Steel_Drums,
+        "trombone": MidiInstrument.Trombone,
+        "posaune": MidiInstrument.Trombone,
+        "brass": MidiInstrument.Trombone,
+        "trumpet": MidiInstrument.Trumpet,
+        "trompete": MidiInstrument.Trumpet,
+        "tpt": MidiInstrument.Trumpet,
+        "tuba": MidiInstrument.Tuba,
+        "sax": MidiInstrument.Tenor_Sax,
+        "viola": MidiInstrument.Viola,
+        "bratsche": MidiInstrument.Viola,
+        "violin": MidiInstrument.Violin,
+        "violon.": MidiInstrument.Violin,
+        "woodblock": MidiInstrument.Woodblock,
+        "alt": MidiInstrument.Synth_Voice,
+        "alto": MidiInstrument.Synth_Voice,
+        "tenor": MidiInstrument.Synth_Voice,
+        "bariton": MidiInstrument.Synth_Voice,
+        "baritone": MidiInstrument.Synth_Voice,
+        "bass": MidiInstrument.Synth_Voice,
+        "sopran": MidiInstrument.Synth_Voice,
+        "voice": MidiInstrument.Synth_Voice,
+        "recorder": MidiInstrument.Recorder,
+        "blockfl�te": MidiInstrument.Recorder,
+        "banjo": MidiInstrument.Banjo,
+        "drums": MidiInstrument.Percussion,
+        "percussion": MidiInstrument.Percussion,
+        "schlagzeug": MidiInstrument.Percussion,
+        "schlagwerk": MidiInstrument.Percussion,
+        "unnamed": MidiInstrument.Acoustic_Grand_Piano,
+    };
 
     public IdString: string;
     public MidiInstrumentId: MidiInstrument;
@@ -84,31 +87,27 @@ export class SubInstrument {
         this.MidiInstrumentId = this.parseMidiInstrument(instrumentType);
     }
     private parseMidiInstrument(instrumentType: string): MidiInstrument {
+        // FIXME: test this function
         try {
-            if (!string.IsNullOrEmpty(instrumentType)) {
-                let tmpName: string = instrumentType.ToLower().Trim();
-                let midiInstrumentArr: KeyValuePair<string, MidiInstrument>[] = SubInstrument.midiInstrument.ToArray();
-                for (let idx: number = 0, len: number = midiInstrumentArr.length; idx < len; ++idx) {
-                    let keyValuePair: KeyValuePair<string, MidiInstrument> = midiInstrumentArr[idx];
-                    if (tmpName.Contains(keyValuePair.Key)) {
-                        return keyValuePair.Value;
+            if (instrumentType) {
+                let tmpName: string = instrumentType.toLowerCase().trim();
+                for (let key in SubInstrument.midiInstrument) {
+                    if (tmpName.indexOf(key) !== -1) {
+                        return SubInstrument.midiInstrument[key];
                     }
                 }
             }
-            if (!string.IsNullOrEmpty(this.parentInstrument.Name)) {
-                let tmpName: string = this.parentInstrument.Name.ToLower().Trim();
-                let midiInstrumentArr: KeyValuePair<string, MidiInstrument>[] = SubInstrument.midiInstrument.ToArray();
-                for (let idx: number = 0, len: number = midiInstrumentArr.length; idx < len; ++idx) {
-                    let keyValuePair: KeyValuePair<string, MidiInstrument> = midiInstrumentArr[idx];
-                    if (tmpName.Contains(keyValuePair.Key)) {
-                        return keyValuePair.Value;
+            if (this.parentInstrument.Name) {
+                let tmpName: string = this.parentInstrument.Name.toLowerCase().trim();
+                for (let key in SubInstrument.midiInstrument) {
+                    if (tmpName.indexOf(key) !== -1) {
+                        return SubInstrument.midiInstrument[key];
                     }
                 }
             }
-            return MidiInstrument.Acoustic_Grand_Piano;
         } catch (e) {
-            return MidiInstrument.Acoustic_Grand_Piano;
+            console.log("Error parsing MIDI Instrument. Default to Grand Piano."); // FIXME
         }
-
+        return MidiInstrument.Acoustic_Grand_Piano;
     }
 }

+ 5 - 1
src/MusicalScore/VoiceData/HelperObjects/DynamicsContainer.ts

@@ -1,4 +1,8 @@
-export class DynamicsContainer implements IComparable<DynamicsContainer> {
+type ContinuousDynamicExpression = any;
+type InstantaniousDynamicExpression = any;
+type MultiExpression = any;
+
+export class DynamicsContainer /*implements IComparable<DynamicsContainer>*/ {
     constructor(continuousDynamicExpression: ContinuousDynamicExpression, staffNumber: number) {
         this.ContinuousDynamicExpression = continuousDynamicExpression;
         this.StaffNumber = staffNumber;

+ 5 - 5
src/MusicalScore/VoiceData/Instructions/ClefInstruction.ts

@@ -43,7 +43,7 @@ export class ClefInstruction extends AbstractNotationInstruction {
     }
   }
   public static getAllPossibleClefs(): ClefInstruction[] {
-    let clefList: ClefInstruction[] = new Array();
+    let clefList: ClefInstruction[] = [];
     for (let i: number = 0; i <= 2; i++) {
       let clefInstructionG: ClefInstruction = new ClefInstruction(ClefEnum.G, i, 2);
       clefList.push(clefInstructionG);
@@ -112,15 +112,15 @@ export class ClefInstruction extends AbstractNotationInstruction {
   private calcParameters(): void {
     switch (this.clefType) {
       case ClefEnum.G:
-        this.clefPitch = new Pitch(NoteEnum.G, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
+        this.clefPitch = new Pitch(NoteEnum.G, 1 + this.octaveOffset, AccidentalEnum.NONE);
         this.referenceCyPosition = (5 - this.line) + 2;
         break;
       case ClefEnum.F:
-        this.clefPitch = new Pitch(NoteEnum.F, <number>(0 + this.octaveOffset), AccidentalEnum.NONE);
+        this.clefPitch = new Pitch(NoteEnum.F, 0 + this.octaveOffset, AccidentalEnum.NONE);
         this.referenceCyPosition = (5 - this.line) + 1.5;
         break;
       case ClefEnum.C:
-        this.clefPitch = new Pitch(NoteEnum.C, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
+        this.clefPitch = new Pitch(NoteEnum.C, 1 + this.octaveOffset, AccidentalEnum.NONE);
         this.referenceCyPosition = (5 - this.line);
         break;
       case ClefEnum.percussion:
@@ -273,4 +273,4 @@ export enum MidiInstrument {
   Applause,
   Gunshot,
   Percussion = 128
-}
+}

+ 10 - 14
src/MusicalScore/VoiceData/Instructions/KeyInstruction.ts

@@ -35,7 +35,7 @@ export class KeyInstruction extends AbstractNotationInstruction {
   private mode: KeyEnum;
 
   public static getNoteEnumList(instruction: KeyInstruction): NoteEnum[] {
-    let enums: NoteEnum[] = new Array();
+    let enums: NoteEnum[] = [];
     if (instruction.keyType > 0) {
       for (let i: number = 0; i < instruction.keyType; i++) {
         enums.push(KeyInstruction.sharpPositionList[i]);
@@ -50,7 +50,7 @@ export class KeyInstruction extends AbstractNotationInstruction {
   }
 
   public static getAllPossibleMajorKeyInstructions(): KeyInstruction[] {
-    let keyInstructionList: KeyInstruction[] = new Array();
+    let keyInstructionList: KeyInstruction[] = [];
     for (let keyType: number = -7; keyType < 7; keyType++) {
       let currentKeyInstruction: KeyInstruction = new KeyInstruction(undefined, keyType, KeyEnum.major);
       keyInstructionList.push(currentKeyInstruction);
@@ -70,7 +70,7 @@ export class KeyInstruction extends AbstractNotationInstruction {
     this.mode = value;
   }
   public getFundamentalNotesOfAccidentals(): NoteEnum[] {
-    let noteList: NoteEnum[] = new Array();
+    let noteList: NoteEnum[] = [];
     if (this.keyType > 0) {
       for (let i: number = 0; i < this.keyType; i++) {
         noteList.push(KeyInstruction.sharpPositionList[i]);
@@ -105,21 +105,17 @@ export class KeyInstruction extends AbstractNotationInstruction {
   }
 
   public OperatorNotEqual(key2: KeyInstruction): boolean {
-    let key1: KeyInstruction = this;
-    return !(key1 === key2);
+    return !(this.OperatorEquals(key2));
   }
 }
 
-export module KeyInstruction {
-  export class NoteEnumToHalfToneLink {
-    constructor(note: NoteEnum, halftone: number) {
-      this.note = note;
-      this.halfTone = halftone;
-    }
-    public note: NoteEnum;
-    public halfTone: number;
+export class NoteEnumToHalfToneLink {
+  constructor(note: NoteEnum, halftone: number) {
+    this.note = note;
+    this.halfTone = halftone;
   }
-
+  public note: NoteEnum;
+  public halfTone: number;
 }
 
 export enum KeyEnum {

+ 40 - 37
src/MusicalScore/VoiceData/Instructions/RepetitionInstruction.ts

@@ -1,27 +1,7 @@
-export enum RepetitionInstructionEnum {
-  StartLine,
-  ForwardJump,
-  BackJumpLine,
-  Ending,
-  DaCapo,
-  DalSegno,
-  Fine,
-  ToCoda,
-  DalSegnoAlFine,
-  DaCapoAlFine,
-  DalSegnoAlCoda,
-  DaCapoAlCoda,
-  Coda,
-  Segno,
-  None,
-}
-export enum AlignmentType {
-  Begin,
-  End,
-}
+import {Repetition} from "../../MusicSource/Repetition";
 
-export class RepetitionInstructionComparer implements IComparer<RepetitionInstruction> {
-  public Compare(x: RepetitionInstruction, y: RepetitionInstruction): number {
+export class RepetitionInstructionComparer /*implements IComparer<RepetitionInstruction>*/ {
+  public static Compare(x: RepetitionInstruction, y: RepetitionInstruction): number {
     if (x.ParentRepetition !== undefined && y.ParentRepetition !== undefined) {
       if (x.Alignment === AlignmentType.End && y.Alignment === AlignmentType.End) {
         if (x.ParentRepetition.StartIndex < y.ParentRepetition.StartIndex) { return 1; }
@@ -35,34 +15,34 @@ export class RepetitionInstructionComparer implements IComparer<RepetitionInstru
     return 0;
   }
 }
-export class RepetitionInstruction implements IComparable {
+
+export class RepetitionInstruction /*implements IComparable*/ {
+  /* FIXME: Check constructor calling from other classes
   constructor(measureIndex: number, type: RepetitionInstructionEnum) {
-    this(measureIndex, new List<number>(), type, AlignmentType.End, undefined);
+    this(measureIndex, [], type, AlignmentType.End, undefined);
     if (type === RepetitionInstructionEnum.StartLine || type === RepetitionInstructionEnum.Segno || type === RepetitionInstructionEnum.Coda) {
       this.Alignment = AlignmentType.Begin;
     }
   }
   constructor(measureIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
-    this(measureIndex, new List<number>(), type, alignment, parentRepetition);
+    this(measureIndex, [], type, alignment, parentRepetition);
 
   }
   constructor(measureIndex: number, endingIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
-    this(measureIndex, __init(new List<number>(), { endingIndex }), type, alignment, parentRepetition);
+    this(measureIndex, [endingIndex], type, alignment, parentRepetition);
 
   }
-  constructor(measureIndex: number, endingIndices: List<number>, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
+  */
+  constructor(measureIndex: number, endingIndices: number[], type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
     this.MeasureIndex = measureIndex;
-    this.EndingIndices = new List<number>();
-    for (let idx: number = 0, len: number = endingIndices.Count; idx < len; ++idx) {
-      let endingIndex: number = endingIndices[idx];
-      this.EndingIndices.Add(endingIndex);
-    }
+    this.EndingIndices = endingIndices.slice();
     this.Type = type;
     this.Alignment = alignment;
     this.ParentRepetition = parentRepetition;
   }
+
   public MeasureIndex: number;
-  public EndingIndices: List<number>;
+  public EndingIndices: number[];
   public Type: RepetitionInstructionEnum;
   public Alignment: AlignmentType;
   public ParentRepetition: Repetition;
@@ -122,16 +102,39 @@ export class RepetitionInstruction implements IComparable {
     }
     return 0;
   }
-  public isIdenticalTo(other: RepetitionInstruction): boolean {
+  public equals(other: RepetitionInstruction): boolean {
     if (
       this.MeasureIndex !== other.MeasureIndex
       || this.Type !== other.Type
       || this.Alignment !== other.Alignment
-      || this.EndingIndices.Count !== other.EndingIndices.Count
+      || this.EndingIndices.length !== other.EndingIndices.length
     ) { return false; }
-    for (let i: number = 0; i < this.EndingIndices.Count; i++) {
+    for (let i: number = 0; i < this.EndingIndices.length; i++) {
       if (this.EndingIndices[i] !== other.EndingIndices[i]) { return false; }
     }
     return true;
   }
 }
+
+export enum RepetitionInstructionEnum {
+  StartLine,
+  ForwardJump,
+  BackJumpLine,
+  Ending,
+  DaCapo,
+  DalSegno,
+  Fine,
+  ToCoda,
+  DalSegnoAlFine,
+  DaCapoAlFine,
+  DalSegnoAlCoda,
+  DaCapoAlCoda,
+  Coda,
+  Segno,
+  None,
+}
+
+export enum AlignmentType {
+  Begin,
+  End,
+}

+ 1 - 1
src/MusicalScore/VoiceData/Instructions/RhythmInstruction.ts

@@ -3,7 +3,7 @@ import {Fraction} from "../../../Common/DataObjects/fraction";
 
 export class RhythmInstruction extends AbstractNotationInstruction {
     constructor(rhythm: Fraction, numerator: number, denominator: number, rhythmSymbolEnum: RhythmSymbolEnum) {
-        super();
+        super(undefined); // FIXME no parent SourceStaffEntry
         this.rhythm = rhythm;
         this.numerator = numerator;
         this.denominator = denominator;

+ 2 - 0
src/MusicalScore/VoiceData/Lyrics/LyricsEntry.ts

@@ -1,4 +1,5 @@
 import {LyricWord} from "./LyricsWord";
+import {VoiceEntry} from "../VoiceEntry";
 
 export class LyricsEntry {
     constructor(text: string, word: LyricWord, parent: VoiceEntry) {
@@ -9,6 +10,7 @@ export class LyricsEntry {
     private _text: string;
     private _word: LyricWord;
     private _parent: VoiceEntry;
+
     public get Text(): string {
         return this._text;
     }

+ 2 - 2
src/MusicalScore/VoiceData/Lyrics/LyricsWord.ts

@@ -1,7 +1,8 @@
 import {LyricsEntry} from "./LyricsEntry";
+import {VoiceEntry} from "../VoiceEntry";
 
 export class LyricWord {
-    private _syllabels: LyricsEntry[] = new Array();
+    private _syllabels: LyricsEntry[] = [];
     public get Syllabels(): LyricsEntry[] {
         return this._syllabels;
     }
@@ -21,6 +22,5 @@ export class LyricWord {
                 return lyricsEntry;
             }
         }
-        return undefined;
     }
 }