Browse Source

Added logging, SheetErrors and fixed InstrumentReader

Andrea Condoluci 9 years ago
parent
commit
28f6038d63

+ 16 - 0
src/Common/DataObjects/MusicSheetErrors.ts

@@ -0,0 +1,16 @@
+// skeleton by Andrea
+
+export class MusicSheetErrors {
+    public Errors: string[];
+    public TempErrors: string[];
+    public MeasureErrors: { [n: number]: string[] };
+
+    // Add an error message to the temporary errors list
+    public pushTemp(errorMsg: string) {
+        this.TempErrors.push(errorMsg);
+    }
+
+    public push(errorMsg: string) {
+        this.Errors.push(errorMsg);
+    }
+}

+ 3 - 0
src/Common/DataObjects/fraction.ts

@@ -164,6 +164,9 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     public lt(frac: Fraction): boolean {
         return (this.numerator * frac.Denominator - this.denominator * frac.Numerator) < 0;
     }
+    public lte(frac: Fraction): boolean {
+        return (this.numerator * frac.Denominator - this.denominator * frac.Numerator) <= 0;
+    }
 
     //public Equals(f: Fraction): boolean {
     //    if (ReferenceEquals(this, f))

+ 10 - 0
src/Common/logging.ts

@@ -0,0 +1,10 @@
+/**
+ * Created by acondolu on 26/04/16.
+ */
+
+
+export class logging {
+    public static debug(...arguments: any[]) {
+        console.log("[OSMD] DEBUG: ", arguments.join(" "));
+    }
+}

+ 2 - 1
src/MusicalScore/Label.ts

@@ -4,7 +4,8 @@ import {OSMDFonts} from "../Common/Enums/osmdFonts";
 import {OSMDFontStyles} from "../Common/Enums/osmdFontStyles";
 
 export class Label {
-  constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: OSMDTextAlignment) {
+    // FIXME contructor
+    constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: OSMDTextAlignment) {
       //if (arg1 instanceof string) {
       this.text = <string>arg1;
       //} else if (arg1 instanceof FontInfo.MusicFontSymbol) {

+ 158 - 158
src/MusicalScore/MusicSheet.ts

@@ -13,45 +13,49 @@ import {MusicPartManagerIterator} from "./MusicParts/MusicPartManagerIterator";
 import {PartListEntry} from "./MusicSource/PartListEntry";
 import {VerticalSourceStaffEntryContainer} from "./VoiceData/VerticalSourceStaffEntryContainer";
 import {Voice} from "./VoiceData/Voice";
+import {MusicSheetErrors} from "../Common/DataObjects/MusicSheetErrors";
 
 // FIXME
-type MusicSheetParameters = any;
-type MultiTempoExpression = any;
-type PlaybackSettings = any;
-type MusicSheetParameterObject = any;
-type EngravingRules = any;
-type MusicSheetErrors = any;
-type IPhonicScoreInterface = any;
-type MusicSheetParameterChangedDelegate = any;
-type IInstrument = any;
-type ISettableInstrument = any;
-type IRepetition = any;
+//type MusicSheetParameters = any;
+//type MultiTempoExpression = any;
+//type PlaybackSettings = any;
+//type MusicSheetParameterObject = any;
+//type EngravingRules = any;
+//type MusicSheetErrors = any;
+//type IPhonicScoreInterface = any;
+//type MusicSheetParameterChangedDelegate = any;
+//type IInstrument = any;
+//type ISettableInstrument = any;
+//type IRepetition = any;
+
+// FIXME Andrea: Commented out some things, have a look at (*)
 
 export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet>*/ {
     constructor() {
-        try {
-            this.Rules = undefined; // FIXME: EngravingRules.Rules;
-        } catch (ex) {
-            console.log("MusicSheet Error: EngravingRules"); // FIXME
-        }
-        this.playbackSettings = undefined; // FIXME this.SheetPlaybackSetting = new PlaybackSettings(new Fraction(4, 4, false), 100);
+        // (*) try {
+        //    this.Rules = EngravingRules.Rules;
+        // } catch (ex) {
+        //     console.log("MusicSheet Error: EngravingRules");
+        // }
+        // (*) this.playbackSettings = new PlaybackSettings(new Fraction(4, 4, false), 100);
         this.UserStartTempoInBPM = 100;
         this.PageWidth = 120;
         this.MusicPartManager = new MusicPartManager(this);
     }
     public static defaultTitle: string = "[kein Titel]";
+
     public UserStartTempoInBPM: number;
     public PageWidth: number;
 
-    private idString: string = "kjgdfuilhsda�oihfsvjh";
+    //private idString: string = "kjgdfuilhsda�oihfsvjh";
     private sourceMeasures: SourceMeasure[] = [];
     private repetitions: Repetition[] = [];
     private dynListStaves: DynamicsContainer[][] = [];
     private timestampSortedDynamicExpressionsList: DynamicsContainer[] = [];
-    private timestampSortedTempoExpressionsList: MultiTempoExpression[] = [];
+    // (*) private timestampSortedTempoExpressionsList: MultiTempoExpression[] = [];
     private instrumentalGroups: InstrumentalGroup[] = [];
     private instruments: Instrument[] = [];
-    private playbackSettings: PlaybackSettings;
+    // (*) private playbackSettings: PlaybackSettings;
     private path: string;
     private title: Label;
     private subtitle: Label;
@@ -60,7 +64,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     // private languages: Language[] = [];
     // private activeLanguage: Language;
     private musicPartManager: MusicPartManager = undefined;
-    private musicSheetErrors: MusicSheetErrors = undefined; // FIXME new MusicSheetErrors();
+    private musicSheetErrors: MusicSheetErrors = new MusicSheetErrors();
     private staves: Staff[] = [];
     private selectionStart: Fraction;
     private selectionEnd: Fraction;
@@ -69,17 +73,17 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     private drawErroneousMeasures: boolean = false;
     private hasBeenOpenedForTheFirstTime: boolean = false;
     private currentEnrolledPosition: Fraction = new Fraction(0, 1);
-    private musicSheetParameterObject: MusicSheetParameterObject = undefined;
-    private engravingRules: EngravingRules;
-    private phonicScoreInterface: IPhonicScoreInterface;
-    private musicSheetParameterChangedDelegate: MusicSheetParameterChangedDelegate;
+    // (*) private musicSheetParameterObject: MusicSheetParameterObject = undefined;
+    // (*) private engravingRules: EngravingRules;
+    // (*) private phonicScoreInterface: IPhonicScoreInterface;
+    // (*) private musicSheetParameterChangedDelegate: MusicSheetParameterChangedDelegate;
 
-    public get PhonicScoreInterface(): IPhonicScoreInterface {
-        return this.phonicScoreInterface;
-    }
-    public set PhonicScoreInterface(value: IPhonicScoreInterface) {
-        this.phonicScoreInterface = value;
-    }
+    // (*) public get PhonicScoreInterface(): IPhonicScoreInterface {
+    //     return this.phonicScoreInterface;
+    // }
+    // public set PhonicScoreInterface(value: IPhonicScoreInterface) {
+    //     this.phonicScoreInterface = value;
+    // }
     public get SourceMeasures(): SourceMeasure[] {
         return this.sourceMeasures;
     }
@@ -95,9 +99,10 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public get DynListStaves(): DynamicsContainer[][] {
         return this.dynListStaves;
     }
-    public get TimestampSortedTempoExpressionsList(): MultiTempoExpression[] {
-        return this.timestampSortedTempoExpressionsList;
-    }
+    // (*)
+    //public get TimestampSortedTempoExpressionsList(): MultiTempoExpression[] {
+    //    return this.timestampSortedTempoExpressionsList;
+    //}
     public get TimestampSortedDynamicExpressionsList(): DynamicsContainer[] {
         return this.timestampSortedDynamicExpressionsList;
     }
@@ -107,12 +112,12 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public get Instruments(): Instrument[] {
         return this.instruments;
     }
-    public get SheetPlaybackSetting(): PlaybackSettings {
-        return this.playbackSettings;
-    }
-    public set SheetPlaybackSetting(value: PlaybackSettings) {
-        this.playbackSettings = value;
-    }
+    // (*) public get SheetPlaybackSetting(): PlaybackSettings {
+    //    return this.playbackSettings;
+    //}
+    // (*) public set SheetPlaybackSetting(value: PlaybackSettings) {
+    //    this.playbackSettings = value;
+    //}
     public get DrawErroneousMeasures(): boolean {
         return this.drawErroneousMeasures;
     }
@@ -126,7 +131,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         this.hasBeenOpenedForTheFirstTime = value;
     }
     public InitializeStartTempoInBPM(startTempo: number): void {
-        this.playbackSettings.BeatsPerMinute = startTempo;
+        // (*) this.playbackSettings.BeatsPerMinute = startTempo;
         this.UserStartTempoInBPM = startTempo;
     }
     public get DefaultStartTempoInBpm(): number {
@@ -197,12 +202,12 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public set Lyricist(value: Label) {
         this.lyricist = value;
     }
-    public get Rules(): EngravingRules {
-        return this.engravingRules;
-    }
-    public set Rules(value: EngravingRules) {
-        this.engravingRules = value;
-    }
+    // (*) public get Rules(): EngravingRules {
+    //    return this.engravingRules;
+    //}
+    // (*) public set Rules(value: EngravingRules) {
+    //    this.engravingRules = value;
+    //}
     public get SheetErrors(): MusicSheetErrors {
         return this.musicSheetErrors;
     }
@@ -210,8 +215,8 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return this.selectionStart;
     }
     public set SelectionStart(value: Fraction) {
-        this.selectionStart = value;
-        this.currentEnrolledPosition = Fraction.CreateFractionFromFraction(this.selectionStart);
+        this.selectionStart = value.clone();
+        this.currentEnrolledPosition = value.clone();
     }
     public get SelectionEnd(): Fraction {
         return this.selectionEnd;
@@ -219,14 +224,14 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public set SelectionEnd(value: Fraction) {
         this.selectionEnd = value;
     }
-    public get MusicSheetParameterObject(): MusicSheetParameterObject {
-        return this.musicSheetParameterObject;
-    }
-    public set MusicSheetParameterObject(value: MusicSheetParameterObject) {
-        this.musicSheetParameterObject = value;
-        this.Title = new Label(this.musicSheetParameterObject.Title);
-        this.Composer = new Label(this.musicSheetParameterObject.Composer);
-    }
+    // (*) public get MusicSheetParameterObject(): MusicSheetParameterObject {
+    //    return this.musicSheetParameterObject;
+    //}
+    // (*) public set MusicSheetParameterObject(value: MusicSheetParameterObject) {
+    //    this.musicSheetParameterObject = value;
+    //    this.Title = new Label(this.musicSheetParameterObject.Title);
+    //    this.Composer = new Label(this.musicSheetParameterObject.Composer);
+    //}
     public addMeasure(measure: SourceMeasure): void {
         this.SourceMeasures.push(measure);
         measure.MeasureListIndex = this.SourceMeasures.length - 1;
@@ -296,19 +301,19 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public getLastSourceMeasure(): SourceMeasure {
         return this.sourceMeasures[this.sourceMeasures.length - 1];
     }
-    public resetAllNoteStates(): void {
-        let iterator: MusicPartManagerIterator = this.MusicPartManager.getIterator();
-        while (!iterator.EndReached && iterator.CurrentVoiceEntries !== undefined) {
-            for (let idx: number = 0, len: number = iterator.CurrentVoiceEntries.length; idx < len; ++idx) {
-                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;
-                }
-            }
-            iterator.moveToNext();
-        }
-    }
+    // (*) public resetAllNoteStates(): void {
+    //    let iterator: MusicPartManagerIterator = this.MusicPartManager.getIterator();
+    //    while (!iterator.EndReached && iterator.CurrentVoiceEntries !== undefined) {
+    //        for (let idx: number = 0, len: number = iterator.CurrentVoiceEntries.length; idx < len; ++idx) {
+    //            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 = NoteState.Normal;
+    //            }
+    //        }
+    //        iterator.moveToNext();
+    //    }
+    //}
     public getMusicSheetInstrumentIndex(instrument: Instrument): number {
         return this.Instruments.indexOf(instrument);
     }
@@ -348,47 +353,42 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public CompareTo(other: MusicSheet): number {
         return this.Title.Text.localeCompare(other.Title.Text);
     }
-    public get IInstruments(): IInstrument[] {
-        return this.instruments.slice()
-    }
-    public get IInitializableInstruments(): ISettableInstrument[] {
-        return this.instruments.slice();
-    }
-    public get IRepetitions(): IRepetition[] {
-        try {
-            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) {
-                    repetitions.push(<Repetition>partListEntry);
-                }
-            }
-            return repetitions;
-        } catch (ex) {
-            console.log(/*Logger.DefaultLogger.LogError(LogLevel.NORMAL, FIXME */ "MusicSheet.IRepetitions get: ", ex);
-            return undefined;
-        }
-
-    }
-    public GetExpressionsStartTempoInBPM(): number {
-        if (this.TimestampSortedTempoExpressionsList.length > 0) {
-            let me: MultiTempoExpression = this.TimestampSortedTempoExpressionsList[0];
-            if (me.InstantaniousTempo !== undefined) {
-                return me.InstantaniousTempo.TempoInBpm;
-            } else if (me.ContinuousTempo !== undefined) {
-                return me.ContinuousTempo.StartTempo;
-            }
-        }
-        return this.UserStartTempoInBPM;
-    }
+    // (*)
+    //public get IInstruments(): IInstrument[] {
+    //    return this.instruments.slice()
+    //}
+    //public get IInitializableInstruments(): ISettableInstrument[] {
+    //    return this.instruments.slice();
+    //}
+    //public get IRepetitions(): IRepetition[] {
+    //    try {
+    //        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) {
+    //                repetitions.push(<Repetition>partListEntry);
+    //            }
+    //        }
+    //        return repetitions;
+    //    } catch (ex) {
+    //        console.log(/*Logger.DefaultLogger.LogError(LogLevel.NORMAL, FIXME */ "MusicSheet.IRepetitions get: ", ex);
+    //        return undefined;
+    //    }
+    //
+    //}
+    //public GetExpressionsStartTempoInBPM(): number {
+    //    if (this.TimestampSortedTempoExpressionsList.length > 0) {
+    //        let me: MultiTempoExpression = this.TimestampSortedTempoExpressionsList[0];
+    //        if (me.InstantaniousTempo !== undefined) {
+    //            return me.InstantaniousTempo.TempoInBpm;
+    //        } else if (me.ContinuousTempo !== undefined) {
+    //            return me.ContinuousTempo.StartTempo;
+    //        }
+    //    }
+    //    return this.UserStartTempoInBPM;
+    //}
     public get Errors(): { [n: number]: string[]; } {
-        try {
-            return this.musicSheetErrors.MeasureErrors;
-        } catch (ex) {
-            console.log(/* FIXME LogLevel.NORMAL, */ "MusicSheet.Errors get: ", ex);
-            return undefined;
-        }
-
+        return this.musicSheetErrors.MeasureErrors;
     }
     public get FirstMeasureNumber(): number {
         try {
@@ -420,49 +420,50 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public set Transpose(value: number) {
         this.transpose = value;
     }
-    public SetMusicSheetParameter(parameter: MusicSheetParameters, value: Object): void {
-        if (this.PhonicScoreInterface !== undefined) {
-            this.PhonicScoreInterface.RequestMusicSheetParameter(parameter, value);
-        } else {
-            let oldValue: Object = 0;
-            if (parameter === undefined) { // FIXME MusicSheetParameters.MusicSheetTranspose) {
-                oldValue = this.Transpose;
-                this.Transpose = <number>value;
-            }
-            if (parameter === undefined) { // FIXME MusicSheetParameters.StartTempoInBPM) {
-                oldValue = this.UserStartTempoInBPM;
-                this.UserStartTempoInBPM = <number>value;
-            }
-            if (parameter === undefined) { // FIXME MusicSheetParameters.HighlightErrors) {
-                oldValue = value;
-            }
-            if (this.MusicSheetParameterChanged !== undefined) {
-                this.musicSheetParameterChangedDelegate(undefined, parameter, value, oldValue);
-            }
-        }
-    }
-    public get MusicSheetParameterChanged(): MusicSheetParameterChangedDelegate {
-        return this.musicSheetParameterChangedDelegate;
-    }
-    public set MusicSheetParameterChanged(value: MusicSheetParameterChangedDelegate) {
-        this.musicSheetParameterChangedDelegate = value;
-    }
-    public get FullNameString(): string {
-        return this.ComposerString + " " + this.TitleString;
-    }
-    public get IdString(): string {
-        return this.idString;
-    }
-    public set IdString(value: string) {
-        this.idString = value;
-    }
-    public Dispose(): void {
-        this.MusicSheetParameterChanged = undefined;
-        for (let idx: number = 0, len: number = this.IInstruments.length; idx < len; ++idx) {
-            let instrument: IInstrument = this.IInstruments[idx];
-            instrument.Dispose(); // FIXME
-        }
-    }
+    // (*)
+    //public SetMusicSheetParameter(parameter: MusicSheetParameters, value: Object): void {
+    //    if (this.PhonicScoreInterface !== undefined) {
+    //        this.PhonicScoreInterface.RequestMusicSheetParameter(parameter, value);
+    //    } else {
+    //        let oldValue: Object = 0;
+    //        if (parameter === undefined) { // FIXME MusicSheetParameters.MusicSheetTranspose) {
+    //            oldValue = this.Transpose;
+    //            this.Transpose = <number>value;
+    //        }
+    //        if (parameter === undefined) { // FIXME MusicSheetParameters.StartTempoInBPM) {
+    //            oldValue = this.UserStartTempoInBPM;
+    //            this.UserStartTempoInBPM = <number>value;
+    //        }
+    //        if (parameter === undefined) { // FIXME MusicSheetParameters.HighlightErrors) {
+    //            oldValue = value;
+    //        }
+    //        if (this.MusicSheetParameterChanged !== undefined) {
+    //            this.musicSheetParameterChangedDelegate(undefined, parameter, value, oldValue);
+    //        }
+    //    }
+    //}
+    //public get MusicSheetParameterChanged(): MusicSheetParameterChangedDelegate {
+    //    return this.musicSheetParameterChangedDelegate;
+    //}
+    //public set MusicSheetParameterChanged(value: MusicSheetParameterChangedDelegate) {
+    //    this.musicSheetParameterChangedDelegate = value;
+    //}
+    //public get FullNameString(): string {
+    //    return this.ComposerString + " " + this.TitleString;
+    //}
+    //public get IdString(): string {
+    //    return this.idString;
+    //}
+    //public set IdString(value: string) {
+    //    this.idString = value;
+    //}
+    //public Dispose(): void {
+    //    this.MusicSheetParameterChanged = undefined;
+    //    for (let idx: number = 0, len: number = this.IInstruments.length; idx < len; ++idx) {
+    //        let instrument: IInstrument = this.IInstruments[idx];
+    //        instrument.Dispose(); // FIXME
+    //    }
+    //}
     public getEnrolledSelectionStartTimeStampWorkaround(): Fraction {
         let iter: MusicPartManagerIterator = this.MusicPartManager.getIterator(this.SelectionStart);
         return Fraction.CreateFractionFromFraction(iter.CurrentEnrolledTimestamp);
@@ -476,7 +477,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
             let sm: SourceMeasure = this.SourceMeasures[idx];
             for (let idx2: number = 0, len2: number = sm.VerticalSourceStaffEntryContainers.length; idx2 < len2; ++idx2) {
                 let vssec: VerticalSourceStaffEntryContainer = sm.VerticalSourceStaffEntryContainers[idx2];
-                if (timeStamp === vssec.getAbsoluteTimestamp()) {
+                if (Fraction.Equal(timeStamp, vssec.getAbsoluteTimestamp())) {
                     return sm;
                 }
             }
@@ -484,12 +485,11 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return this.findSourceMeasureFromTimeStamp(timeStamp);
     }
     public findSourceMeasureFromTimeStamp(timeStamp: Fraction): SourceMeasure {
-        for (let idx: number = 0, len: number = this.SourceMeasures.length; idx < len; ++idx) {
-            let sm: SourceMeasure = this.SourceMeasures[idx];
-            if (sm.AbsoluteTimestamp >= timeStamp && timeStamp < Fraction.plus(sm.AbsoluteTimestamp, sm.Duration)) {
+        for (let sm of this.SourceMeasures) {
+            // FIXME: bug?
+            if (timeStamp.lte(sm.AbsoluteTimestamp) && timeStamp.lt(Fraction.plus(sm.AbsoluteTimestamp, sm.Duration))) {
                 return sm;
             }
         }
-        return undefined;
     }
 }

+ 132 - 126
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -16,35 +16,39 @@ import {ClefEnum} from "../VoiceData/Instructions/ClefInstruction";
 import {RhythmSymbolEnum} from "../VoiceData/Instructions/RhythmInstruction";
 import {KeyEnum} from "../VoiceData/Instructions/KeyInstruction";
 import {IXmlAttribute} from "../../Common/FileIO/Xml";
+import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
+import {Slur} from "../VoiceData/Expressions/ContinuousExpressions/Slur";
+import {logging} from "../../Common/logging";
+import {MidiInstrument} from "../VoiceData/Instructions/ClefInstruction";
+import {VoiceEntry} from "../VoiceData/VoiceEntry";
 
 
-// FIXME
-type repetitionInstructionReader = any;
-type ChordSymbolContainer = any;
-type SlurReader = any;
-type RepetitionInstructionReader = any;
-type ExpressionReader = any;
+// FIXME: The following classes are missing
+//type repetitionInstructionReader = any;
+//type ChordSymbolContainer = any;
+//type SlurReader = any;
+//type RepetitionInstructionReader = any;
+//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 {
+//  }
+//}
 
-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;
+  constructor(/*repetitionInstructionReader: repetitionInstructionReader, */ xmlMeasureList: IXmlElement[]/* FIXME IEnumerable<IXmlElement>*/, instrument: Instrument) {
+    // (*) this.repetitionInstructionReader = repetitionInstructionReader;
     this.xmlMeasureList = xmlMeasureList.slice(); // FIXME .ToArray();
     this.musicSheet = instrument.GetMusicSheet;
     this.instrument = instrument;
@@ -54,12 +58,12 @@ export class InstrumentReader {
       this.activeClefsHaveBeenInitialized[i] = false;
     }
     // FIXME createExpressionGenerators(instrument.Staves.length);
-    this.slurReader = MusicSymbolModuleFactory.createSlurReader(this.musicSheet);
+    // (*) this.slurReader = MusicSymbolModuleFactory.createSlurReader(this.musicSheet);
   }
-  private repetitionInstructionReader: RepetitionInstructionReader;
+  // (*) private repetitionInstructionReader: RepetitionInstructionReader;
   private xmlMeasureList: IXmlElement[];
   private musicSheet: MusicSheet;
-  private slurReader: SlurReader;
+  private slurReader: any; // (*) SlurReader;
   private instrument: Instrument;
   private voiceGeneratorsDict: { [n: number]: VoiceGenerator; } = {};
   private staffMainVoiceGeneratorDict: { [staffId: number]: VoiceGenerator } = {};
@@ -77,9 +81,9 @@ export class InstrumentReader {
   private activeKeyHasBeenInitialized: boolean = false;
   private abstractInstructions: { [n: number]: AbstractNotationInstruction; } = {};
   private openChordSymbolContainer: ChordSymbolContainer;
-  private expressionReaders: ExpressionReader[];
+  // (*) private expressionReaders: ExpressionReader[];
   private currentVoiceGenerator: VoiceGenerator;
-  // private openSlurDict: Dictionary<number, Slur> = new Dictionary<number, Slur>();
+  //private openSlurDict: { [n: number]: Slur; } = {};
   private maxTieNoteFraction: Fraction;
   public get ActiveKey(): KeyInstruction {
     return this.activeKey;
@@ -99,16 +103,16 @@ export class InstrumentReader {
     }
     this.currentMeasure = currentMeasure;
     this.inSourceMeasureInstrumentIndex = this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument);
-    if (this.repetitionInstructionReader !== undefined) {
-      this.repetitionInstructionReader.prepareReadingMeasure(currentMeasure, this.currentXmlMeasureIndex);
-    }
+    // (*) if (this.repetitionInstructionReader !== undefined) {
+    //  this.repetitionInstructionReader.prepareReadingMeasure(currentMeasure, this.currentXmlMeasureIndex);
+    //}
     let currentFraction: Fraction = new Fraction(0, 1);
     let previousFraction: Fraction = new Fraction(0, 1);
     let divisionsException: boolean = false;
     this.maxTieNoteFraction = new Fraction(0, 1);
     let lastNoteWasGrace: boolean = false;
     try {
-      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[this.currentXmlMeasureIndex].Elements().slice();
+      let xmlMeasureListArr: IXmlElement[] = this.xmlMeasureList[this.currentXmlMeasureIndex].Elements();
       for (let idx: number = 0, len: number = xmlMeasureListArr.length; idx < len; ++idx) {
         let xmlNode: IXmlElement = xmlMeasureListArr[idx];
         if (xmlNode.Name === "note") {
@@ -122,7 +126,7 @@ export class InstrumentReader {
                 noteStaff = parseInt(xmlNode.Element("staff").Value);
               }
             } catch (ex) {
-              // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure.get staff number", ex);
+              logging.debug("InstrumentReader.readNextXmlMeasure.get staff number", ex);
               noteStaff = 1;
             }
 
@@ -153,8 +157,8 @@ export class InstrumentReader {
               }
             } catch (ex) {
               let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid Note Duration.");
-              this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-              // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure", errorMsg, ex);
+              this.musicSheet.SheetErrors.pushTemp(errorMsg);
+              logging.debug("InstrumentReader.readNextXmlMeasure", errorMsg, ex);
               continue;
             }
 
@@ -165,13 +169,14 @@ export class InstrumentReader {
           if (isChord) {
             musicTimestamp = Fraction.CreateFractionFromFraction(previousFraction);
           }
-          let newContainerCreated: boolean;
-          this.currentStaffEntry = this.currentMeasure.findOrCreateStaffEntry(
+          let out: {createdNewContainer: boolean, staffEntry: SourceStaffEntry} = this.currentMeasure.findOrCreateStaffEntry(
             musicTimestamp,
             this.inSourceMeasureInstrumentIndex + noteStaff - 1,
-            this.currentStaff,
-            newContainerCreated
+            this.currentStaff
           );
+          this.currentStaffEntry = out.staffEntry;
+          let newContainerCreated: boolean = out.createdNewContainer;
+
           if (!this.currentVoiceGenerator.hasVoiceEntry() || !isChord && !isGraceNote && !lastNoteWasGrace || !lastNoteWasGrace && isGraceNote) {
             this.currentVoiceGenerator.createVoiceEntry(musicTimestamp, this.currentStaffEntry, !restNote);
           }
@@ -200,7 +205,7 @@ export class InstrumentReader {
             this.openChordSymbolContainer = undefined;
           }
           if (this.activeRhythm !== undefined) {
-            this.musicSheet.SheetPlaybackSetting.Rhythm = this.activeRhythm.Rhythm;
+            // (*) this.musicSheet.SheetPlaybackSetting.Rhythm = this.activeRhythm.Rhythm;
           }
           if (isTuplet) {
             this.currentVoiceGenerator.read(
@@ -220,15 +225,15 @@ export class InstrumentReader {
           }
           let notationsNode: IXmlElement = xmlNode.Element("notations");
           if (notationsNode !== undefined && notationsNode.Element("dynamics") !== undefined) {
-            let expressionReader: ExpressionReader = this.expressionReaders[this.readExpressionStaffNumber(xmlNode) - 1];
-            if (expressionReader !== undefined) {
-              expressionReader.readExpressionParameters(
-                xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, false
-              );
-              expressionReader.read(
-                xmlNode, this.currentMeasure, previousFraction
-              );
-            }
+            // (*) let expressionReader: ExpressionReader = this.expressionReaders[this.readExpressionStaffNumber(xmlNode) - 1];
+            //if (expressionReader !== undefined) {
+            //  expressionReader.readExpressionParameters(
+            //    xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, false
+            //  );
+            //  expressionReader.read(
+            //    xmlNode, this.currentMeasure, previousFraction
+            //  );
+            //}
           }
           lastNoteWasGrace = isGraceNote;
         } else if (xmlNode.Name === "attributes") {
@@ -257,7 +262,7 @@ export class InstrumentReader {
             let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/DivisionError", "Invalid divisions value at Instrument: ");
             this.divisions = this.readDivisionsFromNotes();
             if (this.divisions > 0) {
-              this.musicSheet.SheetErrors.Errors.Add(errorMsg + this.instrument.Name);
+              this.musicSheet.SheetErrors.push(errorMsg + this.instrument.Name);
             } else {
               divisionsException = true;
               throw new MusicSheetReadingException(errorMsg + this.instrument.Name, 0);
@@ -285,47 +290,48 @@ export class InstrumentReader {
           }
         } else if (xmlNode.Name === "direction") {
           let directionTypeNode: IXmlElement = xmlNode.Element("direction-type");
-          MetronomeReader.readMetronomeInstructions(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
+          // (*) MetronomeReader.readMetronomeInstructions(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
           let relativePositionInMeasure: number = Math.min(1, currentFraction.RealValue);
           if (this.activeRhythm !== undefined && this.activeRhythm.Rhythm !== undefined) {
             relativePositionInMeasure /= this.activeRhythm.Rhythm.RealValue;
           }
           let handeled: boolean = false;
-          if (this.repetitionInstructionReader !== undefined) {
-            handeled = this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(directionTypeNode, relativePositionInMeasure);
-          }
-          if (!handeled) {
-            let expressionReader: ExpressionReader = this.expressionReaders[0];
-            let staffIndex: number = this.readExpressionStaffNumber(xmlNode) - 1;
-            if (staffIndex < this.expressionReaders.length) {
-              expressionReader = this.expressionReaders[staffIndex];
-            }
-            if (expressionReader !== undefined) {
-              if (directionTypeNode.Element("octave-shift") !== undefined) {
-                expressionReader.readExpressionParameters(
-                  xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, true
-                );
-                expressionReader.addOctaveShift(xmlNode, this.currentMeasure, Fraction.CreateFractionFromFraction(previousFraction));
-              }
-              expressionReader.readExpressionParameters(
-                xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, false
-              );
-              expressionReader.read(xmlNode, this.currentMeasure, currentFraction);
-            }
-          }
+          // (*) if (this.repetitionInstructionReader !== undefined) {
+          //  handeled = this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(directionTypeNode, relativePositionInMeasure);
+          //}
+          //if (!handeled) {
+          //  let expressionReader: ExpressionReader = this.expressionReaders[0];
+          //  let staffIndex: number = this.readExpressionStaffNumber(xmlNode) - 1;
+          //  if (staffIndex < this.expressionReaders.length) {
+          //    expressionReader = this.expressionReaders[staffIndex];
+          //  }
+          //  if (expressionReader !== undefined) {
+          //    if (directionTypeNode.Element("octave-shift") !== undefined) {
+          //      expressionReader.readExpressionParameters(
+          //        xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, true
+          //      );
+          //      expressionReader.addOctaveShift(xmlNode, this.currentMeasure, Fraction.CreateFractionFromFraction(previousFraction));
+          //    }
+          //    expressionReader.readExpressionParameters(
+          //      xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, false
+          //    );
+          //    expressionReader.read(xmlNode, this.currentMeasure, currentFraction);
+          //  }
+          //}
         } else if (xmlNode.Name === "barline") {
-          if (this.repetitionInstructionReader !== undefined) {
-            let measureEndsSystem: boolean = false;
-            this.repetitionInstructionReader.handleLineRepetitionInstructions(xmlNode, measureEndsSystem);
-            if (measureEndsSystem) {
-              this.currentMeasure.BreakSystemAfter = true;
-              this.currentMeasure.EndsPiece = true;
-            }
-          }
+          // (*)
+          //if (this.repetitionInstructionReader !== undefined) {
+          //  let measureEndsSystem: boolean = false;
+          //  this.repetitionInstructionReader.handleLineRepetitionInstructions(xmlNode, measureEndsSystem);
+          //  if (measureEndsSystem) {
+          //    this.currentMeasure.BreakSystemAfter = true;
+          //    this.currentMeasure.EndsPiece = true;
+          //  }
+          //}
         } else if (xmlNode.Name === "sound") {
-          MetronomeReader.readTempoInstruction(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
+          // (*) MetronomeReader.readTempoInstruction(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
         } else if (xmlNode.Name === "harmony") {
-          this.openChordSymbolContainer = ChordSymbolReader.readChordSymbol(xmlNode, this.musicSheet, this.activeKey);
+          // (*) this.openChordSymbolContainer = ChordSymbolReader.readChordSymbol(xmlNode, this.musicSheet, this.activeKey);
         }
       }
       for (let j in this.voiceGeneratorsDict) {
@@ -341,20 +347,21 @@ export class InstrumentReader {
         if (!this.activeKeyHasBeenInitialized) {
           this.createDefaultKeyInstruction();
         }
-        for (let i: number = 0; i < this.expressionReaders.length; i++) {
-          let reader: ExpressionReader = this.expressionReaders[i];
-          if (reader !== undefined) {
-            reader.checkForOpenExpressions(this.currentMeasure, currentFraction);
-          }
-        }
+        // (*)
+        //for (let i: number = 0; i < this.expressionReaders.length; i++) {
+        //  let reader: ExpressionReader = this.expressionReaders[i];
+        //  if (reader !== undefined) {
+        //    reader.checkForOpenExpressions(this.currentMeasure, currentFraction);
+        //  }
+        //}
       }
     } catch (e) {
       if (divisionsException) {
         throw new MusicSheetReadingException(e.Message, 0);
       }
       let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/MeasureError", "Error while reading Measure.");
-      this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-      // FIXME console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readNextXmlMeasure", errorMsg, e);
+      this.musicSheet.SheetErrors.pushTemp(errorMsg);
+      logging.debug("InstrumentReader.readNextXmlMeasure", errorMsg, e);
     }
 
     this.previousMeasure = this.currentMeasure;
@@ -391,10 +398,11 @@ export class InstrumentReader {
 
 
   private createExpressionGenerators(numberOfStaves: number): void {
-    this.expressionReaders = new Array(numberOfStaves);
-    for (let i: number = 0; i < numberOfStaves; i++) {
-      this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
-    }
+    // (*)
+    //this.expressionReaders = new Array(numberOfStaves);
+    //for (let i: number = 0; i < numberOfStaves; i++) {
+    //  this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
+    //}
   }
 
 
@@ -522,16 +530,16 @@ export class InstrumentReader {
               "ReaderErrorMessages/ClefLineError",
               "Invalid clef line given -> using default clef line."
             );
-            this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+            this.musicSheet.SheetErrors.pushTemp(errorMsg);
             line = 2;
-            console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+            logging.debug("InstrumentReader.addAbstractInstruction", errorMsg, ex);
           }
 
         }
         let signNode: IXmlElement = nodeList.Element("sign");
         if (signNode !== undefined) {
           try {
-            clefEnum = <ClefEnum>Enum.Parse(/*typeof*/ClefEnum, signNode.Value);
+            // (*) clefEnum = <ClefEnum>Enum.Parse(/*typeof*/ClefEnum, signNode.Value);
             if (!ClefInstruction.isSupportedClef(clefEnum)) {
               if (clefEnum === ClefEnum.TAB && guitarPro) {
                 clefOctaveOffset = -1;
@@ -540,7 +548,7 @@ export class InstrumentReader {
                 "ReaderErrorMessages/ClefError",
                 "Unsupported clef found -> using default clef."
               );
-              this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+              this.musicSheet.SheetErrors.pushTemp(errorMsg);
               clefEnum = ClefEnum.G;
               line = 2;
             }
@@ -549,10 +557,10 @@ export class InstrumentReader {
               "ReaderErrorMessages/ClefError",
               "Invalid clef found -> using default clef."
             );
-            this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+            this.musicSheet.SheetErrors.pushTemp(errorMsg);
             clefEnum = ClefEnum.G;
             line = 2;
-            console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, e);
+            logging.debug("InstrumentReader.addAbstractInstruction", errorMsg, e);
           }
 
         }
@@ -565,7 +573,7 @@ export class InstrumentReader {
               "ReaderErrorMessages/ClefOctaveError",
               "Invalid clef octave found -> using default clef octave."
             );
-            this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+            this.musicSheet.SheetErrors.pushTemp(errorMsg);
             clefOctaveOffset = 0;
           }
 
@@ -578,7 +586,7 @@ export class InstrumentReader {
               "ReaderErrorMessages/ClefError",
               "Invalid clef found -> using default clef."
             );
-            this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+            this.musicSheet.SheetErrors.pushTemp(errorMsg);
             staffNumber = 1;
           }
         }
@@ -587,7 +595,7 @@ export class InstrumentReader {
         this.abstractInstructions[staffNumber] = clefInstruction;
       }
     }
-    if (node.Element("key") !== undefined && this.instrument.MidiInstrumentId !== Common.Enums.MidiInstrument.Percussion) {
+    if (node.Element("key") !== undefined && this.instrument.MidiInstrumentId !== MidiInstrument.Percussion) {
       let key: number = 0;
       let keyNode: IXmlElement = node.Element("key").Element("fifths");
       if (keyNode !== undefined) {
@@ -598,9 +606,9 @@ export class InstrumentReader {
             "ReaderErrorMessages/KeyError",
             "Invalid key found -> set to default."
           );
-          this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+          this.musicSheet.SheetErrors.pushTemp(errorMsg);
           key = 0;
-          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          logging.debug("InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
       }
@@ -609,15 +617,15 @@ export class InstrumentReader {
       if (modeNode !== undefined) { modeNode = modeNode.Element("mode"); }
       if (modeNode !== undefined) {
         try {
-          keyEnum = <KeyEnum>Enum.Parse(/*typeof*/KeyEnum, modeNode.Value);
+          // (*) keyEnum = <KeyEnum>Enum.Parse(/*typeof*/KeyEnum, modeNode.Value);
         } catch (ex) {
           errorMsg = ITextTranslation.translateText(
             "ReaderErrorMessages/KeyError",
             "Invalid key found -> set to default."
           );
-          this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+          this.musicSheet.SheetErrors.pushTemp(errorMsg);
           keyEnum = KeyEnum.major;
-          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          logging.debug("InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
       }
@@ -630,7 +638,7 @@ export class InstrumentReader {
       if (
         timeNode !== undefined &&
         timeNode.HasAttributes &&
-        timeNode.Attributes()[] !== undefined
+        timeNode.Attributes() !== undefined
       ) {
         let firstAttr: IXmlAttribute = timeNode.Attributes()[0];
         if (firstAttr.Name === "symbol") {
@@ -645,8 +653,8 @@ export class InstrumentReader {
       let denom: number = 0;
       let senzaMisura: boolean = (timeNode !== undefined && timeNode.Element("senza-misura") !== undefined);
       let timeList: IXmlElement[] = node.Elements("time");
-      let beatsList: IXmlElement[] = new Array();
-      let typeList: IXmlElement[] = new Array();
+      let beatsList: IXmlElement[] = [];
+      let typeList: IXmlElement[] = [];
       for (let idx: number = 0, len: number = timeList.length; idx < len; ++idx) {
         let xmlNode: IXmlElement = timeList[idx];
         beatsList.push.apply(beatsList, xmlNode.Elements("beats"));
@@ -688,29 +696,27 @@ export class InstrumentReader {
           }
         } catch (ex) {
           errorMsg = ITextTranslation.translateText("ReaderErrorMessages/RhythmError", "Invalid rhythm found -> set to default.");
-          this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+          this.musicSheet.SheetErrors.pushTemp(errorMsg);
           num = 4;
           denom = 4;
-          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.addAbstractInstruction", errorMsg, ex);
+          logging.debug("InstrumentReader.addAbstractInstruction", errorMsg, ex);
         }
 
         if ((num === denom === 4) || (num === denom === 2)) {
           symbolEnum = RhythmSymbolEnum.NONE;
         }
-        let rhythmInstruction: RhythmInstruction = new RhythmInstruction(
-          new Fraction(num, denom, false), num, denom, symbolEnum
+        this.abstractInstructions[1] = new RhythmInstruction(
+            new Fraction(num, denom, false), num, denom, symbolEnum
         );
-        this.abstractInstructions[1] = rhythmInstruction;
       } else {
-        let rhythmInstruction: RhythmInstruction = new RhythmInstruction(new Fraction(4, 4, false), 4, 4, RhythmSymbolEnum.NONE);
-        this.abstractInstructions[1] = rhythmInstruction;
+        this.abstractInstructions[1] = new RhythmInstruction(new Fraction(4, 4, false), 4, 4, RhythmSymbolEnum.NONE);
       }
     }
   }
 
   private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
     // FIXME TODO
-    console.log("saveAbstractInstructionList still to implement! See InstrumentReader.ts");
+    logging.debug("saveAbstractInstructionList still to implement! See InstrumentReader.ts");
   }
 
   /*private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
@@ -849,7 +855,7 @@ export class InstrumentReader {
   }
   */
   private saveClefInstructionAtEndOfMeasure(): void {
-    for (let key in this.abstractInstructions) {
+    for (let key of this.abstractInstructions) {
       let value = this.abstractInstructions[key];
       if (value instanceof ClefInstruction) {
         let clefInstruction: ClefInstruction = <ClefInstruction>value;
@@ -865,7 +871,7 @@ export class InstrumentReader {
           newClefInstruction.Parent = lastStaffEntry;
           lastStaffEntry.Instructions.push(newClefInstruction);
           this.activeClefs[key - 1] = clefInstruction;
-          delete this.abstractInstructions[key]; // FIXME might hurt performance
+          delete this.abstractInstructions[key]; // FIXME Andrea: might hurt performance
         }
       }
     }
@@ -900,9 +906,9 @@ export class InstrumentReader {
           let errorMsg: string = ITextTranslation.translateText(
             "ReaderErrorMessages/ExpressionStaffError", "Invalid Expression staff number -> set to default."
           );
-          this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
+          this.musicSheet.SheetErrors.pushTemp(errorMsg);
           directionStaffNumber = 1;
-          console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
+          logging.debug("InstrumentReader.readExpressionStaffNumber", errorMsg, ex);
         }
 
       }
@@ -927,7 +933,7 @@ export class InstrumentReader {
               try {
                 noteDuration = parseInt(durationNode.Value);
               } catch (ex) {
-                console.log(/*LogLevel.DEBUG, */  "InstrumentReader.readDivisionsFromNotes", ex);
+                logging.debug("InstrumentReader.readDivisionsFromNotes", ex);
                 continue;
               }
 

+ 3 - 0
src/MusicalScore/ScoreIO/VoiceGenerator.ts

@@ -10,6 +10,8 @@ import {Beam} from "../VoiceData/Beam";
 import {Tie} from "../VoiceData/Tie";
 import {Tuplet} from "../VoiceData/Tuplet";
 import {Fraction} from "../../Common/DataObjects/fraction";
+import {MusicSymbolModuleFactory} from "./InstrumentReader";
+import {IXmlElement} from "../../Common/FileIO/Xml";
 
 export class VoiceGenerator {
     constructor(instrument: Instrument, voiceId: number, slurReader: SlurReader, mainVoice: Voice = null) {
@@ -40,6 +42,7 @@ export class VoiceGenerator {
     private currentOctaveShift: number = 0;
     private tupletDict: Dictionary<number, Tuplet> = new Dictionary<number, Tuplet>();
     private openTupletNumber: number = 0;
+
     public get GetVoice(): Voice {
         return this.voice;
     }

+ 2 - 0
src/MusicalScore/VoiceData/Beam.ts

@@ -3,6 +3,7 @@ import {Note} from "./Note";
 export class Beam {
     private notes: Note[] = [];
     private extendedNoteList: Note[] = [];
+
     public get Notes(): Note[] {
         return this.notes;
     }
@@ -15,6 +16,7 @@ export class Beam {
     public set ExtendedNoteList(value: Note[]) {
         this.extendedNoteList = value;
     }
+
     public addNoteToBeam(note: Note): void {
         if (note !== undefined) {
             note.NoteBeam = this;

+ 4 - 6
src/MusicalScore/VoiceData/HelperObjects/DynamicsContainer.ts

@@ -11,9 +11,11 @@ export class DynamicsContainer /*implements IComparable<DynamicsContainer>*/ {
         this.InstantaniousDynamicExpression = instantaniousDynamicExpression;
         this.StaffNumber = staffNumber;
     }
+
     public ContinuousDynamicExpression: ContinuousDynamicExpression;
-    public InstantaniousDynamicExpression: InstantaniousDynamicExpression;
+    public InstantaneousDynamicExpression: InstantaneousDynamicExpression;
     public StaffNumber: number;
+
     public parMultiExpression(): MultiExpression {
         if (this.ContinuousDynamicExpression !== undefined) {
             return this.ContinuousDynamicExpression.StartMultiExpression;
@@ -24,10 +26,6 @@ export class DynamicsContainer /*implements IComparable<DynamicsContainer>*/ {
         return undefined;
     }
     public CompareTo(other: DynamicsContainer): number {
-        let thisTimestamp: number = this.parMultiExpression().AbsoluteTimestamp.RealValue;
-        let otherTimestamp: number = other.parMultiExpression().AbsoluteTimestamp.RealValue;
-        if (thisTimestamp > otherTimestamp) { return 1; }
-        if (thisTimestamp < otherTimestamp) { return -1; }
-        return 0;
+        return this.parMultiExpression().AbsoluteTimestamp.CompareTo(other.parMultiExpression().AbsoluteTimestamp);
     }
 }

+ 8 - 2
src/MusicalScore/VoiceData/Note.ts

@@ -8,7 +8,10 @@ import {Tie} from "./Tie";
 import {Staff} from "./Staff";
 import {Slur} from "./Expressions/ContinuousExpressions/Slur";
 
+import Vex = require("vexflow");
+
 export class Note {
+
     constructor(voiceEntry: VoiceEntry, parentStaffEntry: SourceStaffEntry, length: Fraction, pitch: Pitch) {
         this.voiceEntry = voiceEntry;
         this.parentStaffEntry = parentStaffEntry;
@@ -20,6 +23,7 @@ export class Note {
           this.HalfTone = 0;
         }
     }
+
     public HalfTone: number;
 
     private voiceEntry: VoiceEntry;
@@ -32,6 +36,7 @@ export class Note {
     private slurs: Slur[] = [];
     private graceNoteSlash: boolean = false;
     private playbackInstrumentId: string = undefined;
+
     public get GraceNoteSlash(): boolean {
         return this.graceNoteSlash;
     }
@@ -89,11 +94,11 @@ export class Note {
     public set PlaybackInstrumentId(value: string) {
         this.playbackInstrumentId = value;
     }
+
     public calculateNoteLengthWithoutTie(): Fraction {
         let withoutTieLength: Fraction = this.length.clone();
         if (this.tie !== undefined) {
-            for (let idx: number = 0, len: number = this.tie.Fractions.length; idx < len; ++idx) {
-                let fraction: Fraction = this.tie.Fractions[idx];
+            for (let fraction of this.tie.Fractions) {
                 withoutTieLength.Sub(fraction);
             }
         }
@@ -114,6 +119,7 @@ export class Note {
         return originalLength;
     }
     public calculateNoteLengthWithDots(): Fraction {
+        // FIXME is this function the same as this.calculateNoteLengthWithoutTie?
         if (this.tie !== undefined) {
             return this.calculateNoteLengthWithoutTie();
         }

+ 15 - 14
src/MusicalScore/VoiceData/SourceMeasure.ts

@@ -105,10 +105,12 @@ export class SourceMeasure {
     }
     return undefined;
   }
-  public findOrCreateStaffEntry(inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff): SourceStaffEntry {
-    // FIXME, createdNewContainer: boolean): SourceStaffEntry {
+  public findOrCreateStaffEntry(
+      inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff
+  ): {createdNewContainer: boolean, staffEntry: SourceStaffEntry} {
+    // FIXME Andrea: debug & Test
+    let createdNewContainer: boolean = false;
     let staffEntry: SourceStaffEntry = undefined;
-    //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++) {
@@ -119,14 +121,14 @@ export class SourceMeasure {
     }
     if (existingVerticalSourceStaffEntryContainer !== undefined) {
       if (existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] !== undefined) {
-        return existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex];
+        staffEntry = existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex];
       } else {
         staffEntry = new SourceStaffEntry(existingVerticalSourceStaffEntryContainer, staff);
         existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] = staffEntry;
-        return staffEntry;
       }
+      return {createdNewContainer: createdNewContainer, staffEntry: staffEntry};
     }
-    //createdNewContainer = true;
+    createdNewContainer = true;
     let last: VerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length - 1];
     if (this.verticalSourceStaffEntryContainers.length === 0 || last.Timestamp < inMeasureTimestamp) {
       let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
@@ -147,7 +149,7 @@ export class SourceMeasure {
           this.verticalSourceStaffEntryContainers.splice(i + 1, 0, container);
           staffEntry = new SourceStaffEntry(container, staff);
           container[inSourceMeasureStaffIndex] = staffEntry;
-          return staffEntry;
+          break;
         }
         if (i === 0) {
           let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
@@ -156,14 +158,15 @@ export class SourceMeasure {
           this.verticalSourceStaffEntryContainers.splice(i, 0, container);
           staffEntry = new SourceStaffEntry(container, staff);
           container[inSourceMeasureStaffIndex] = staffEntry;
-          return staffEntry;
+          break;
         }
       }
     }
-    return staffEntry;
+    return {createdNewContainer: createdNewContainer, staffEntry: staffEntry};
   }
-  public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice): VoiceEntry {//, createdNewVoiceEntry: boolean): VoiceEntry {
+  public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice): { createdVoiceEntry: boolean, voiceEntry: VoiceEntry } {
     let ve: VoiceEntry = undefined;
+    let createdNewVoiceEntry: boolean = false;
     for (let voiceEntry: VoiceEntry of sse.VoiceEntries) {
       if (voiceEntry.ParentVoice === voice) {
         ve = voiceEntry;
@@ -173,11 +176,9 @@ export class SourceMeasure {
     if (ve === undefined) {
       ve = new VoiceEntry(sse.Timestamp, voice, sse);
       sse.VoiceEntries.push(ve);
-      // FIXME createdNewVoiceEntry = true;
-    } else {
-      // FIXME createdNewVoiceEntry = false;
+      createdNewVoiceEntry = true;
     }
-    return ve;
+    return { createdVoiceEntry: createdVoiceEntry, voiceEntry: ve };
   }
   public getPreviousSourceStaffEntryFromIndex(
     verticalIndex: number, horizontalIndex: number