Browse Source

Fixing types & imports pt.5

Andrea Condoluci 9 years ago
parent
commit
8648bee0a5

+ 8 - 7
src/Common/DataObjects/fraction.ts

@@ -212,13 +212,14 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //        return m1;
     //    else return m2;
     //}
-    //public CompareTo(obj: Object): number {
-    //    if (this > <Fraction>obj)
-    //        return 1;
-    //    else if (this <<Fraction>obj)
-    //        return -1;
-    //    return 0;
-    //}
+    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);

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

@@ -1,4 +1,4 @@
-export class XmlAttribute {
+export class IXmlAttribute {
   public Name: string;
   public Value: string;
 
@@ -8,14 +8,14 @@ export class XmlAttribute {
   };
 }
 
-export class XmlElement {
+export class IXmlElement {
   public Name: string;
   public Value: string;
   public HasAttributes: boolean = false;
-  public FirstAttribute: XmlAttribute;
+  public FirstAttribute: IXmlAttribute;
   public HasElements: boolean;
 
-  private _attrs: XmlAttribute[];
+  private _attrs: IXmlAttribute[];
   private _elem: Element;
 
   constructor(elem: Element) {
@@ -24,7 +24,7 @@ export class XmlElement {
 
     if (elem.hasAttributes()) {
       this.HasAttributes = true;
-      this.FirstAttribute = new XmlAttribute(elem.attributes[0]);
+      this.FirstAttribute = new IXmlAttribute(elem.attributes[0]);
       }
     this.HasElements = elem.hasChildNodes();
     // Look for a value
@@ -36,35 +36,35 @@ export class XmlElement {
     }
   }
 
-  public Attribute(attributeName: string): XmlAttribute {
-    return new XmlAttribute(this._elem.attributes.getNamedItem(attributeName));
+  public Attribute(attributeName: string): IXmlAttribute {
+    return new IXmlAttribute(this._elem.attributes.getNamedItem(attributeName));
   }
 
-  public Attributes(): XmlAttribute[] {
+  public Attributes(): IXmlAttribute[] {
     if (typeof this._attrs === "undefined") {
       let attributes: NamedNodeMap = this._elem.attributes;
-      let attrs: XmlAttribute[] = new Array();
+      let attrs: IXmlAttribute[] = new Array();
       for (let i: number = 0; i < attributes.length; i += 1) {
-        attrs.push(new XmlAttribute(attributes[i]));
+        attrs.push(new IXmlAttribute(attributes[i]));
       }
       this._attrs = attrs;
     }
     return this._attrs;
   }
 
-  public Element(elementName: string): XmlElement {
+  public Element(elementName: string): IXmlElement {
     return this.Elements(elementName)[0];
   }
 
-  public Elements(nodeName: string): XmlElement[] {
+  public Elements(nodeName: string): IXmlElement[] {
     let nodes: NodeList = this._elem.childNodes;
-    let ret: XmlElement[] = new Array();
+    let ret: IXmlElement[] = new Array();
     let nameUnset: boolean = typeof nodeName === "undefined";
     for (let i: number = 0; i < nodes.length; i += 1) {
       let node: Node = nodes[i];
       if (node.nodeType === Node.ELEMENT_NODE &&
         (nameUnset || node.nodeName === nodeName)) {
-          ret.push(new XmlElement(<Element> node));
+          ret.push(new IXmlElement(<Element> node));
         }
     }
     return ret;

+ 29 - 24
src/MusicalScore/MusicSheet.ts

@@ -12,14 +12,29 @@ import {VoiceEntry} from "./VoiceData/VoiceEntry";
 import {MusicPartManagerIterator} from "./MusicParts/MusicPartManagerIterator";
 import {PartListEntry} from "./MusicSource/PartListEntry";
 import {VerticalSourceStaffEntryContainer} from "./VoiceData/VerticalSourceStaffEntryContainer";
+import {Voice} from "./VoiceData/Voice";
+
+// 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;
+
 export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet>*/ {
     constructor() {
         try {
-            this.Rules = EngravingRules.Rules;
+            this.Rules = undefined; // FIXME: EngravingRules.Rules;
         } catch (ex) {
             console.log("MusicSheet Error: EngravingRules"); // FIXME
         }
-        this.playbackSettings = this.SheetPlaybackSetting = new PlaybackSettings(new Fraction(4, 4, false), 100);
+        this.playbackSettings = undefined // FIXME this.SheetPlaybackSetting = new PlaybackSettings(new Fraction(4, 4, false), 100);
         this.UserStartTempoInBPM = 100;
         this.PageWidth = 120;
         this.MusicPartManager = new MusicPartManager(this);
@@ -45,7 +60,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     // private languages: Language[] = new Array();
     // private activeLanguage: Language;
     private musicPartManager: MusicPartManager = undefined;
-    private musicSheetErrors: MusicSheetErrors = new MusicSheetErrors();
+    private musicSheetErrors: MusicSheetErrors = undefined; // FIXME new MusicSheetErrors();
     private staves: Staff[] = new Array();
     private selectionStart: Fraction;
     private selectionEnd: Fraction;
@@ -269,7 +284,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return measures;
     }
     public getNextSourceMeasure(measure: SourceMeasure): SourceMeasure {
-        let index: number = this.sourceMeasures.IndexOf(measure);
+        let index: number = this.sourceMeasures.indexOf(measure);
         if (index === this.sourceMeasures.length - 1) {
             return measure;
         }
@@ -288,7 +303,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
                 let voiceEntry: VoiceEntry = iterator.CurrentVoiceEntries[idx];
                 for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
                     let note: Note = voiceEntry.Notes[idx2];
-                    note.State = NoteState.Normal;
+                    note.State = undefined // FIXME NoteState.Normal;
                 }
             }
             iterator.moveToNext();
@@ -334,20 +349,10 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return this.Title.Text.localeCompare(other.Title.Text);
     }
     public get IInstruments(): IInstrument[] {
-        let list: IInstrument[] = new Array();
-        for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
-            let instr: Instrument = this.instruments[idx];
-            list.push(instr);
-        }
-        return list;
+        return this.instruments.slice()
     }
     public get IInitializableInstruments(): ISettableInstrument[] {
-        let list: ISettableInstrument[] = new Array();
-        for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
-            let instr: Instrument = this.instruments[idx];
-            list.push(instr);
-        }
-        return list;
+        return this.instruments.slice();
     }
     public get IRepetitions(): IRepetition[] {
         try {
@@ -377,7 +382,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         }
         return this.UserStartTempoInBPM;
     }
-    public get Errors(): Dictionary<number, string[]> {
+    public get Errors(): { [n: number]: string[]; } {
         try {
             return this.musicSheetErrors.MeasureErrors;
         } catch (ex) {
@@ -421,19 +426,19 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
             this.PhonicScoreInterface.RequestMusicSheetParameter(parameter, value);
         } else {
             let oldValue: Object = 0;
-            if (parameter === MusicSheetParameters.MusicSheetTranspose) {
+            if (parameter === undefined) { // FIXME MusicSheetParameters.MusicSheetTranspose) {
                 oldValue = this.Transpose;
                 this.Transpose = <number>value;
             }
-            if (parameter === MusicSheetParameters.StartTempoInBPM) {
+            if (parameter === undefined) { // FIXME MusicSheetParameters.StartTempoInBPM) {
                 oldValue = this.UserStartTempoInBPM;
                 this.UserStartTempoInBPM = <number>value;
             }
-            if (parameter === MusicSheetParameters.HighlightErrors) {
+            if (parameter === undefined) { // FIXME MusicSheetParameters.HighlightErrors) {
                 oldValue = value;
             }
             if (this.MusicSheetParameterChanged !== undefined) {
-                this.MusicSheetParameterChanged(undefined, parameter, value, oldValue);
+                this.musicSheetParameterChangedDelegate(undefined, parameter, value, oldValue);
             }
         }
     }
@@ -465,7 +470,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     }
     public get SheetEndTimestamp(): Fraction {
         let lastMeasure: SourceMeasure = this.getLastSourceMeasure();
-        return lastMeasure.AbsoluteTimestamp + lastMeasure.Duration;
+        return Fraction.plus(lastMeasure.AbsoluteTimestamp, lastMeasure.Duration);
     }
     public getSourceMeasureFromTimeStamp(timeStamp: Fraction): SourceMeasure {
         for (let idx: number = 0, len: number = this.SourceMeasures.length; idx < len; ++idx) {
@@ -482,7 +487,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     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 < sm.AbsoluteTimestamp + sm.Duration) {
+            if (sm.AbsoluteTimestamp >= timeStamp && timeStamp < Fraction.plus(sm.AbsoluteTimestamp, sm.Duration)) {
                 return sm;
             }
         }

+ 13 - 12
src/MusicalScore/MusicSource/MappingSourceMusicPart.ts

@@ -1,14 +1,15 @@
-export class MappingSourceMusicPart implements IComparable, IComparable<MappingSourceMusicPart> {
-    constructor(sourceMusicPart: SourceMusicPart, startTimestamp: Fraction) {
-        this(sourceMusicPart, undefined, startTimestamp, -1, false);
+import {SourceMusicPart} from "./SourceMusicPart";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {Repetition} from "./Repetition";
+import {PartListEntry} from "./PartListEntry";
 
-    }
-    constructor(sourceMusicPart: SourceMusicPart, parentPartListEntry: Repetition, startTimestamp: Fraction, repetitionRun: number, isEnding: boolean) {
+export class MappingSourceMusicPart /* implements IComparable, IComparable<MappingSourceMusicPart>*/ {
+    constructor(sourceMusicPart: SourceMusicPart, startTimestamp: Fraction, parentPartListEntry?: Repetition, repetitionRun: number = -1, isEnding: boolean = false) {
         this.sourceMusicPart = sourceMusicPart;
         this.parentPartListEntry = parentPartListEntry;
-        this.startTimestamp = new Fraction(startTimestamp);
+        this.startTimestamp = Fraction.CreateFractionFromFraction(startTimestamp);
         this.repetitionRun = repetitionRun;
-        this.parentRepetition = __as__<Repetition>(parentPartListEntry, Repetition);
+        this.parentRepetition = <Repetition>parentPartListEntry;
         this.isEnding = isEnding;
     }
     private sourceMusicPart: SourceMusicPart;
@@ -38,13 +39,13 @@ export class MappingSourceMusicPart implements IComparable, IComparable<MappingS
     public get StartTimestamp(): Fraction {
         return this.startTimestamp;
     }
-    public CompareTo(obj: Object): number {
-        let comp: MappingSourceMusicPart = __as__<MappingSourceMusicPart>(obj, MappingSourceMusicPart);
+    public CompareTo(comp: MappingSourceMusicPart): number {
+        //let comp: MappingSourceMusicPart = <MappingSourceMusicPart>(obj, MappingSourceMusicPart);
         if (comp !== undefined) {
             return this.startTimestamp.CompareTo(comp.startTimestamp);
         } else { return 1; }
     }
-    public CompareTo(other: MappingSourceMusicPart): number {
-        return this.CompareTo(<Object>other);
-    }
+    //public CompareTo(other: MappingSourceMusicPart): number {
+    //    return this.CompareTo(<Object>other);
+    //}
 }

+ 12 - 13
src/MusicalScore/MusicSource/Repetition.ts

@@ -77,8 +77,7 @@ export class Repetition extends PartListEntry /*implements IRepetition*/ {
     public SetEndingStartIndex(endingNumbers: number[], startIndex: number): void {
         let part: RepetitionEndingPart = new RepetitionEndingPart(new SourceMusicPart(this.musicSheet2, startIndex, startIndex));
         this.endingParts.push(part);
-        for (let idx: number = 0, len: number = endingNumbers.length; idx < len; ++idx) {
-            let endingNumber: number = endingNumbers[idx];
+        for (let endingNumber of endingNumbers) {
             try {
                 this.endingIndexDict[endingNumber] = part;
                 part.endingIndices.push(endingNumber);
@@ -91,15 +90,15 @@ export class Repetition extends PartListEntry /*implements IRepetition*/ {
 
         }
     }
-    public SetEndingStartIndex(endingNumber: number, startIndex: number): void {
-        let part: RepetitionEndingPart = new RepetitionEndingPart(new SourceMusicPart(this.musicSheet2, startIndex, startIndex));
-        this.endingParts.push(part);
-        this.endingIndexDict[endingNumber] = part;
-        part.endingIndices.push(endingNumber);
-        if (this.numberOfEndings < endingNumber) {
-            this.numberOfEndings = endingNumber;
-        }
-    }
+    //public SetEndingStartIndex(endingNumber: number, startIndex: number): void {
+    //    let part: RepetitionEndingPart = new RepetitionEndingPart(new SourceMusicPart(this.musicSheet2, startIndex, startIndex));
+    //    this.endingParts.push(part);
+    //    this.endingIndexDict[endingNumber] = part;
+    //    part.endingIndices.push(endingNumber);
+    //    if (this.numberOfEndings < endingNumber) {
+    //        this.numberOfEndings = endingNumber;
+    //    }
+    //}
     public setEndingEndIndex(endingNumber: number, endIndex: number): void {
         if (this.endingIndexDict[endingNumber] !== undefined) {
             this.endingIndexDict[endingNumber].part.setEndIndex(endIndex);
@@ -137,11 +136,11 @@ export class Repetition extends PartListEntry /*implements IRepetition*/ {
         for (let measureIndex: number = start; measureIndex <= end; measureIndex++) {
             let sourceMeasure: SourceMeasure = this.musicSheet2.SourceMeasures[measureIndex];
             for (let i: number = 0; i < sourceMeasure.CompleteNumberOfStaves; i++) {
-                for (let sourceStaffEntries: SourceStaffEntry[] of sourceMeasure.VerticalSourceStaffEntryContainers) {
+                for (let sourceStaffEntries of sourceMeasure.VerticalSourceStaffEntryContainers) {
                     if (sourceStaffEntries[i] !== undefined) {
                         let sourceStaffEntry: SourceStaffEntry = sourceStaffEntries[i];
                         let verses: number = 0;
-                        for (let voiceEntry: VoiceEntry of sourceStaffEntry.VoiceEntries) {
+                        for (let voiceEntry of sourceStaffEntry.VoiceEntries) {
                             verses += Object.keys(voiceEntry.LyricsEntries).length;
                         }
                         lyricVerses = Math.max(lyricVerses, verses);

+ 5 - 8
src/MusicalScore/MusicSource/SourceMusicPart.ts

@@ -1,19 +1,16 @@
 import {PartListEntry} from "./PartListEntry";
 import {Repetition} from "./Repetition";
 import {Fraction} from "../../Common/DataObjects/fraction";
+import {MusicSheet} from "../MusicSheet";
 
 export class SourceMusicPart extends PartListEntry {
-    constructor(musicSheet: MusicSheet) {
+    constructor(musicSheet: MusicSheet, startIndex?: number, endIndex?: number) {
         super(musicSheet);
-        this.musicSheet = musicSheet;
-    }
-    constructor(musicSheet: MusicSheet, startIndex: number, endIndex: number) {
-        super(musicSheet);
-        this.musicSheet = musicSheet;
+        this.musicSheet2 = musicSheet;
         this.startIndex = startIndex;
         this.endIndex = endIndex;
     }
-    protected musicSheet: MusicSheet;
+    protected musicSheet2: MusicSheet;
     protected parentRepetition: Repetition;
     private startIndex: number;
     private endIndex: number;
@@ -33,7 +30,7 @@ export class SourceMusicPart extends PartListEntry {
         this.parentRepetition = value;
     }
     public get AbsoluteTimestamp(): Fraction {
-        return new Fraction(this.musicSheet.SourceMeasures[this.startIndex].AbsoluteTimestamp);
+        return Fraction.CreateFractionFromFraction(this.musicSheet2.SourceMeasures[this.startIndex].AbsoluteTimestamp);
     }
     public setStartIndex(startIndex: number): void {
         this.startIndex = startIndex;

+ 99 - 81
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -1,15 +1,40 @@
+import {Instrument} from "../Instrument";
+import {MusicSheet} from "../MusicSheet";
+import {VoiceGenerator} from "./VoiceGenerator";
+import {Staff} from "../VoiceData/Staff";
+import {SourceMeasure} from "../VoiceData/SourceMeasure";
+import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
+import {ClefInstruction} from "../VoiceData/Instructions/ClefInstruction";
+import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
+import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
+import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {IXmlElement} from "../../Common/FileIO/Xml";
+
+
+// FIXME
+type repetitionInstructionReader = any;
+type ChordSymbolContainer = any;
+type SlurReader = any;
+type RepetitionInstructionReader = any;
+type ExpressionReader = any;
+
+declare class MusicSymbolModuleFactory {
+  public static createSlurReader(x: any): any;
+}
+
 export class InstrumentReader {
-  constructor(repetitionInstructionReader: RepetitionInstructionReader, xmlMeasureList: IEnumerable<IXmlElement>, instrument: Instrument) {
+  constructor(repetitionInstructionReader: repetitionInstructionReader, xmlMeasureList: IXmlElement[]/* FIXME IEnumerable<IXmlElement>*/, instrument: Instrument) {
     this.repetitionInstructionReader = repetitionInstructionReader;
-    this.xmlMeasureList = xmlMeasureList.ToArray();
+    this.xmlMeasureList = xmlMeasureList; // FIXME .ToArray();
     this.musicSheet = instrument.GetMusicSheet;
     this.instrument = instrument;
-    this.activeClefs = new Array(instrument.Staves.Count);
-    this.activeClefsHaveBeenInitialized = new Array(instrument.Staves.Count);
-    for (let i: number = 0; i < instrument.Staves.Count; i++) {
+    this.activeClefs = new Array(instrument.Staves.length);
+    this.activeClefsHaveBeenInitialized = new Array(instrument.Staves.length);
+    for (let i: number = 0; i < instrument.Staves.length; i++) {
       this.activeClefsHaveBeenInitialized[i] = false;
     }
-    createExpressionGenerators(instrument.Staves.Count);
+    // FIXME createExpressionGenerators(instrument.Staves.length);
     this.slurReader = MusicSymbolModuleFactory.createSlurReader(this.musicSheet);
   }
   private repetitionInstructionReader: RepetitionInstructionReader;
@@ -17,7 +42,7 @@ export class InstrumentReader {
   private musicSheet: MusicSheet;
   private slurReader: SlurReader;
   private instrument: Instrument;
-  private voiceGeneratorsDict: Dictionary<number, VoiceGenerator> = new Dictionary<number, VoiceGenerator>();
+  private voiceGeneratorsDict: { [n: number]: VoiceGenerator; } = {};
   private staffMainVoiceGeneratorDict: Dictionary<Staff, VoiceGenerator> = new Dictionary<Staff, VoiceGenerator>();
   private inSourceMeasureInstrumentIndex: number;
   private divisions: number = 0;
@@ -31,8 +56,7 @@ export class InstrumentReader {
   private activeRhythm: RhythmInstruction;
   private activeClefsHaveBeenInitialized: boolean[];
   private activeKeyHasBeenInitialized: boolean = false;
-  private abstractInstructions: List<KeyValuePairClass<number, AbstractNotationInstruction>> =
-    new List<KeyValuePairClass<number, AbstractNotationInstruction>>();
+  private abstractInstructions: { [n: number]: AbstractNotationInstruction; } = {};
   private openChordSymbolContainer: ChordSymbolContainer;
   private expressionReaders: ExpressionReader[];
   private currentVoiceGenerator: VoiceGenerator;
@@ -73,13 +97,13 @@ export class InstrumentReader {
             continue;
           }
           let noteStaff: number = 1;
-          if (this.instrument.Staves.Count > 1) {
+          if (this.instrument.Staves.length > 1) {
             try {
               if (xmlNode.Element("staff") !== undefined) {
-                noteStaff = StringToNumberConverter.ToInteger(xmlNode.Element("staff").Value);
+                noteStaff = parseInt(xmlNode.Element("staff").Value);
               }
             } catch (ex) {
-              Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure.get staff number", ex);
+              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure.get staff number", ex);
               noteStaff = 1;
             }
 
@@ -87,7 +111,7 @@ export class InstrumentReader {
           this.currentStaff = this.instrument.Staves[noteStaff - 1];
           let isChord: boolean = xmlNode.Element("chord") !== undefined;
           if (xmlNode.Element("voice") !== undefined) {
-            let noteVoice: number = StringToNumberConverter.ToInteger(xmlNode.Element("voice").Value);
+            let noteVoice: number = parseInt(xmlNode.Element("voice").Value);
             this.currentVoiceGenerator = this.getOrCreateVoiceGenerator(noteVoice, noteStaff - 1);
           } else {
             if (!isChord || this.currentVoiceGenerator === undefined) {
@@ -99,7 +123,7 @@ export class InstrumentReader {
           let isTuplet: boolean = false;
           if (xmlNode.Element("duration") !== undefined) {
             try {
-              noteDivisions = StringToNumberConverter.ToInteger(xmlNode.Element("duration").Value);
+              noteDivisions = parseInt(xmlNode.Element("duration").Value);
               noteDuration = new Fraction(noteDivisions, 4 * this.divisions);
               if (noteDivisions === 0) {
                 noteDuration = this.getNoteDurationFromTypeNode(xmlNode);
@@ -109,18 +133,18 @@ export class InstrumentReader {
                 isTuplet = true;
               }
             } catch (ex) {
-              let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid Note Duration.");
+              let errorMsg: string = "FIXME Instrument Reader"; // FIXME ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid Note Duration.");
               this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-              Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, ex);
+              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, ex);
               continue;
             }
 
           }
           let restNote: boolean = xmlNode.Element("rest") !== undefined;
           let isGraceNote: boolean = xmlNode.Element("grace") !== undefined || noteDivisions === 0 || isChord && lastNoteWasGrace;
-          let musicTimestamp: Fraction = new Fraction(currentFraction);
+          let musicTimestamp: Fraction = Fraction.CreateFractionFromFraction(currentFraction);
           if (isChord) {
-            musicTimestamp = new Fraction(previousFraction);
+            musicTimestamp = Fraction.CreateFractionFromFraction(previousFraction);
           }
           let newContainerCreated: boolean;
           this.currentStaffEntry = this.currentMeasure.findOrCreateStaffEntry(
@@ -133,8 +157,8 @@ export class InstrumentReader {
             this.currentVoiceGenerator.createVoiceEntry(musicTimestamp, this.currentStaffEntry, !restNote);
           }
           if (!isGraceNote && !isChord) {
-            previousFraction = new Fraction(currentFraction);
-            currentFraction.Add(new Fraction(noteDuration));
+            previousFraction = Fraction.CreateFractionFromFraction(currentFraction);
+            currentFraction.Add(Fraction.CreateFractionFromFraction(noteDuration));
           }
           if (
             isChord &&
@@ -151,7 +175,7 @@ export class InstrumentReader {
             this.currentStaffEntry.Timestamp === new Fraction(0, 1) &&
             !this.currentStaffEntry.hasNotes()
           );
-          saveAbstractInstructionList(this.instrument.Staves.Count, beginOfMeasure);
+          saveAbstractInstructionList(this.instrument.Staves.length, beginOfMeasure);
           if (this.openChordSymbolContainer !== undefined) {
             this.currentStaffEntry.ChordContainer = this.openChordSymbolContainer;
             this.openChordSymbolContainer = undefined;
@@ -192,13 +216,13 @@ export class InstrumentReader {
           let divisionsNode: IXmlElement = xmlNode.Element("divisions");
           if (divisionsNode !== undefined) {
             try {
-              this.divisions = StringToNumberConverter.ToInteger(divisionsNode.Value);
+              this.divisions = parseInt(divisionsNode.Value);
             } catch (e) {
               let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/DivisionError", "Invalid divisions value at Instrument: ");
-              Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
+              // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
               this.divisions = this.readDivisionsFromNotes();
               if (this.divisions > 0) {
-                this.musicSheet.SheetErrors.Errors.Add(errorMsg + this.instrument.Name);
+                this.musicSheet.SheetErrors.Errors.push(errorMsg + this.instrument.Name);
               } else {
                 divisionsException = true;
                 throw new MusicSheetReadingException(errorMsg + this.instrument.Name, 0);
@@ -222,16 +246,16 @@ export class InstrumentReader {
           }
           this.addAbstractInstruction(xmlNode, guitarPro);
           if (currentFraction === new Fraction(0, 1) && this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex], xmlNode)) {
-            saveAbstractInstructionList(this.instrument.Staves.Count, true);
+            saveAbstractInstructionList(this.instrument.Staves.length, true);
           }
           if (this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex], xmlNode)) {
             this.saveClefInstructionAtEndOfMeasure();
           }
         } else if (xmlNode.Name === "forward") {
-          let forFraction: number = StringToNumberConverter.ToInteger(xmlNode.Element("duration").Value);
+          let forFraction: number = parseInt(xmlNode.Element("duration").Value);
           currentFraction.Add(new Fraction(forFraction, 4 * this.divisions));
         } else if (xmlNode.Name === "backup") {
-          let backFraction: number = StringToNumberConverter.ToInteger(xmlNode.Element("duration").Value);
+          let backFraction: number = parseInt(xmlNode.Element("duration").Value);
           currentFraction.Sub(new Fraction(backFraction, 4 * this.divisions));
           if (currentFraction.Numerator < 0) {
             currentFraction = new Fraction(0, 1);
@@ -243,7 +267,7 @@ export class InstrumentReader {
         } else if (xmlNode.Name === "direction") {
           let directionTypeNode: IXmlElement = xmlNode.Element("direction-type");
           MetronomeReader.readMetronomeInstructions(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
-          let relativePositionInMeasure: number = Math.Min(1, currentFraction.RealValue);
+          let relativePositionInMeasure: number = Math.min(1, currentFraction.RealValue);
           if (this.activeRhythm !== undefined && this.activeRhythm.Rhythm !== undefined) {
             relativePositionInMeasure /= this.activeRhythm.Rhythm.RealValue;
           }
@@ -254,7 +278,7 @@ export class InstrumentReader {
           if (!handeled) {
             let expressionReader: ExpressionReader = this.expressionReaders[0];
             let staffIndex: number = this.readExpressionStaffNumber(xmlNode) - 1;
-            if (staffIndex < this.expressionReaders.Count()) {
+            if (staffIndex < this.expressionReaders.length) {
               expressionReader = this.expressionReaders[staffIndex];
             }
             if (expressionReader !== undefined) {
@@ -262,7 +286,7 @@ export class InstrumentReader {
                 expressionReader.readExpressionParameters(
                   xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, true
                 );
-                expressionReader.addOctaveShift(xmlNode, this.currentMeasure, new Fraction(previousFraction));
+                expressionReader.addOctaveShift(xmlNode, this.currentMeasure, Fraction.CreateFractionFromFraction(previousFraction));
               }
               expressionReader.readExpressionParameters(
                 xmlNode, this.instrument, this.divisions, currentFraction, previousFraction, this.currentMeasure.MeasureNumber, false
@@ -285,14 +309,13 @@ export class InstrumentReader {
           this.openChordSymbolContainer = ChordSymbolReader.readChordSymbol(xmlNode, this.musicSheet, this.activeKey);
         }
       }
-      for (let j: number = 0; j < this.voiceGeneratorsDict.Count; j++) {
-        let keyValuePair: KeyValuePair<number, VoiceGenerator> = this.voiceGeneratorsDict.ElementAt(j);
-        let voiceGenerator: VoiceGenerator = keyValuePair.Value;
+      for (let j in this.voiceGeneratorsDict) {
+        let voiceGenerator: VoiceGenerator = this.voiceGeneratorsDict[j];
         voiceGenerator.checkForOpenBeam();
         voiceGenerator.checkForOpenGraceNotes();
       }
       if (this.currentXmlMeasureIndex === this.xmlMeasureList.length - 1) {
-        for (let i: number = 0; i < this.instrument.Staves.Count; i++) {
+        for (let i: number = 0; i < this.instrument.Staves.length; i++) {
           if (!this.activeClefsHaveBeenInitialized[i]) {
             createDefaultClefInstruction(this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument) + i);
         }}
@@ -312,7 +335,7 @@ export class InstrumentReader {
       }
       let errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/MeasureError", "Error while reading Measure.");
       this.musicSheet.SheetErrors.AddErrorMessageInTempList(errorMsg);
-      Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
+      // FIXME Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readNextXmlMeasure", errorMsg, e);
     }
 
     this.previousMeasure = this.currentMeasure;
@@ -320,49 +343,45 @@ export class InstrumentReader {
     return true;
   }
   public doCalculationsAfterDurationHasBeenSet(): void {
-    for (let j: number = 0; j < this.voiceGeneratorsDict.Count; j++) {
-      let keyValuePair: KeyValuePair<number, VoiceGenerator> = this.voiceGeneratorsDict.ElementAt(j);
-      let voiceGenerator: VoiceGenerator = keyValuePair.Value;
-      voiceGenerator.checkOpenTies();
+    for (let j in this.voiceGeneratorsDict) {
+      this.voiceGeneratorsDict[j].checkOpenTies();
     }
   }
   private getOrCreateVoiceGenerator(voiceId: number, staffId: number): VoiceGenerator {
-    let voiceGenerator: VoiceGenerator;
     let staff: Staff = this.instrument.Staves[staffId];
-    if (this.voiceGeneratorsDict.ContainsKey(voiceId)) {
-      voiceGenerator = this.voiceGeneratorsDict[voiceId];
-      if (!staff.Voices.Contains(voiceGenerator.GetVoice)) {
-        staff.Voices.Add(voiceGenerator.GetVoice);
+    let voiceGenerator: VoiceGenerator = this.voiceGeneratorsDict[voiceId];
+    if (voiceGenerator !== undefined) {
+      if (staff.Voices.indexOf(voiceGenerator.GetVoice) === -1) {
+        staff.Voices.push(voiceGenerator.GetVoice);
       }
-      return voiceGenerator;
     } else {
-      if (this.staffMainVoiceGeneratorDict.ContainsKey(staff)) {
+      if (this.staffMainVoiceGeneratorDict[staff] !== undefined) {
         let mainVoiceGenerator: VoiceGenerator = this.staffMainVoiceGeneratorDict[staff];
         voiceGenerator = new VoiceGenerator(this.instrument, voiceId, this.slurReader, mainVoiceGenerator.GetVoice);
-        staff.Voices.Add(voiceGenerator.GetVoice);
-        this.voiceGeneratorsDict.Add(voiceId, voiceGenerator);
-        return voiceGenerator;
+        staff.Voices.push(voiceGenerator.GetVoice);
+        this.voiceGeneratorsDict[voiceId] = voiceGenerator;
+      } else {
+        voiceGenerator = new VoiceGenerator(this.instrument, voiceId, this.slurReader);
+        staff.Voices.push(voiceGenerator.GetVoice);
+        this.voiceGeneratorsDict[voiceId] = voiceGenerator;
+        this.staffMainVoiceGeneratorDict[staff] = voiceGenerator;
       }
-      voiceGenerator = new VoiceGenerator(this.instrument, voiceId, this.slurReader);
-      staff.Voices.Add(voiceGenerator.GetVoice);
-      this.voiceGeneratorsDict.Add(voiceId, voiceGenerator);
-      this.staffMainVoiceGeneratorDict.Add(staff, voiceGenerator);
-      return voiceGenerator;
     }
+    return voiceGenerator
   }
 
 /*
   private createExpressionGenerators(numberOfStaves: number): void {
     this.expressionReaders = new Array(numberOfStaves);
     for (let i: number = 0; i < numberOfStaves; i++)
-      this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet, this.instrument, i + 1);
+      this.expressionReaders[i] = MusicSymbolModuleFactory.createExpressionGenerator(this.musicSheet2, this.instrument, i + 1);
   }
 
 
   private createDefaultClefInstruction(staffIndex: number): void {
     let first: SourceMeasure;
-    if (this.musicSheet.SourceMeasures.Count > 0) {
-      first = this.musicSheet.SourceMeasures[0];
+    if (this.musicSheet2.SourceMeasures.Count > 0) {
+      first = this.musicSheet2.SourceMeasures[0];
     } else {
       first = this.currentMeasure;
     }
@@ -462,7 +481,7 @@ export class InstrumentReader {
     if (transposeNode !== undefined) {
       let chromaticNode: IXmlElement = transposeNode.Element("chromatic");
       if (chromaticNode !== undefined) {
-        this.instrument.PlaybackTranspose = StringToNumberConverter.ToInteger(chromaticNode.Value);
+        this.instrument.PlaybackTranspose = parseInt(chromaticNode.Value);
       }
     }
     let clefList: IXmlElement[] = node.Elements("clef").ToArray();
@@ -477,7 +496,7 @@ export class InstrumentReader {
         let errorMsg: string;
         if (lineNode !== undefined) {
           try {
-            line = StringToNumberConverter.ToInteger(lineNode.Value);
+            line = parseInt(lineNode.Value);
           } catch (ex) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefLineError",
@@ -520,7 +539,7 @@ export class InstrumentReader {
         let clefOctaveNode: IXmlElement = nodeList.Element("clef-octave-change");
         if (clefOctaveNode !== undefined) {
           try {
-            clefOctaveOffset = StringToNumberConverter.ToInteger(clefOctaveNode.Value);
+            clefOctaveOffset = parseInt(clefOctaveNode.Value);
           } catch (e) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefOctaveError",
@@ -533,7 +552,7 @@ export class InstrumentReader {
         }
         if (nodeList.HasAttributes && nodeList.Attributes().First().Name === "number") {
           try {
-            staffNumber = StringToNumberConverter.ToInteger(nodeList.Attributes().First().Value);
+            staffNumber = parseInt(nodeList.Attributes().First().Value);
           } catch (err) {
             errorMsg = ITextTranslation.translateText(
               "ReaderErrorMessages/ClefError",
@@ -553,7 +572,7 @@ export class InstrumentReader {
       let keyNode: IXmlElement = node.Element("key").Element("fifths");
       if (keyNode !== undefined) {
         try {
-          key = <number>StringToNumberConverter.ToInteger(keyNode.Value);
+          key = <number>parseInt(keyNode.Value);
         } catch (ex) {
           let errorMsg: string = ITextTranslation.translateText(
             "ReaderErrorMessages/KeyError",
@@ -626,12 +645,12 @@ export class InstrumentReader {
               if (s.IndexOf("+") !== -1) {
                 let numbers: string[] = s.Split("+");
                 for (let idx: number = 0, len: number = numbers.Count(); idx < len; ++idx) {
-                  n += StringToNumberConverter.ToInteger(numbers[idx]);
+                  n += parseInt(numbers[idx]);
                 }
               } else {
-                n = StringToNumberConverter.ToInteger(s);
+                n = parseInt(s);
               }
-              d = StringToNumberConverter.ToInteger(typeList[i].Value);
+              d = parseInt(typeList[i].Value);
               maxDenom = Math.Max(maxDenom, d);
               fractions[i] = new Fraction(n, d, false);
             }
@@ -644,8 +663,8 @@ export class InstrumentReader {
             }
             denom = maxDenom;
           } else {
-            num = StringToNumberConverter.ToInteger(node.Element("time").Element("beats").Value);
-            denom = StringToNumberConverter.ToInteger(node.Element("time").Element("beat-type").Value);
+            num = parseInt(node.Element("time").Element("beats").Value);
+            denom = parseInt(node.Element("time").Element("beat-type").Value);
           }
         } catch (ex) {
           errorMsg = ITextTranslation.translateText("ReaderErrorMessages/RhythmError", "Invalid rhythm found -> set to default.");
@@ -709,7 +728,7 @@ export class InstrumentReader {
                   lastStaffEntry.Instructions.Add(newClefInstruction);
                 }
               } else if (!this.activeClefsHaveBeenInitialized[keyValuePair.key - 1]) {
-                let first: SourceMeasure = this.musicSheet.SourceMeasures[0];
+                let first: SourceMeasure = this.musicSheet2.SourceMeasures[0];
                 if (first.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] === undefined) {
                   firstStaffEntry = new SourceStaffEntry(undefined, undefined);
                 } else {
@@ -742,7 +761,7 @@ export class InstrumentReader {
           if (!this.activeKeyHasBeenInitialized) {
             this.activeKeyHasBeenInitialized = true;
             if (this.currentXmlMeasureIndex > 0) {
-              sourceMeasure = this.musicSheet.SourceMeasures[0];
+              sourceMeasure = this.musicSheet2.SourceMeasures[0];
             } else {
               sourceMeasure = this.currentMeasure;
             }
@@ -835,8 +854,8 @@ export class InstrumentReader {
           let actualNotes: IXmlElement = time.Element("actual-notes");
           let normalNotes: IXmlElement = time.Element("normal-notes");
           if (actualNotes !== undefined && normalNotes !== undefined) {
-            let actual: number = StringToNumberConverter.ToInteger(actualNotes.Value);
-            let normal: number = StringToNumberConverter.ToInteger(normalNotes.Value);
+            let actual: number = parseInt(actualNotes.Value);
+            let normal: number = parseInt(normalNotes.Value);
             duration = new Fraction(normal, actual) * typeDuration;
           }
         }
@@ -850,7 +869,7 @@ export class InstrumentReader {
       let staffNode: IXmlElement = xmlNode.Element("staff");
       if (staffNode !== undefined) {
         try {
-          directionStaffNumber = StringToNumberConverter.ToInteger(staffNode.Value);
+          directionStaffNumber = parseInt(staffNode.Value);
         } catch (ex) {
           let errorMsg: string = ITextTranslation.translateText(
             "ReaderErrorMessages/ExpressionStaffError", "Invalid Expression staff number -> set to default."
@@ -880,7 +899,7 @@ export class InstrumentReader {
               let type: string = typeNode.Value;
               let noteDuration: number = 0;
               try {
-                noteDuration = StringToNumberConverter.ToInteger(durationNode.Value);
+                noteDuration = parseInt(durationNode.Value);
               } catch (ex) {
                 Logger.DefaultLogger.LogError(LogLevel.DEBUG, "InstrumentReader.readDivisionsFromNotes", ex);
                 continue;
@@ -951,13 +970,12 @@ export class InstrumentReader {
   }
 }
 
-export module InstrumentReader {
-  export class KeyValuePairClass<T, TU> {
-    constructor(key: T, value: TU) {
-      this.key = key;
-      this.value = value;
-    }
-    public key: T;
-    public value: TU;
+
+class KeyValuePairClass<T, TU> {
+  constructor(key: T, value: TU) {
+    this.key = key;
+    this.value = value;
   }
+  public key: T;
+  public value: TU;
 }

+ 28 - 18
src/MusicalScore/VoiceData/Note.ts

@@ -1,3 +1,15 @@
+import {VoiceEntry} from "./VoiceEntry";
+import {SourceStaffEntry} from "./SourceStaffEntry";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {Pitch} from "../../Common/DataObjects/pitch";
+import {Beam} from "./Beam";
+import {Tuplet} from "./Tuplet";
+import {Tie} from "./Tie";
+import {Staff} from "./Staff";
+
+type NoteState = any;
+type Slur = any;
+
 export class Note {
     constructor(voiceEntry: VoiceEntry, parentStaffEntry: SourceStaffEntry, length: Fraction, pitch: Pitch) {
         this.voiceEntry = voiceEntry;
@@ -20,7 +32,7 @@ export class Note {
     private beam: Beam;
     private tuplet: Tuplet;
     private tie: Tie;
-    private slurs: List<Slur> = new List<Slur>();
+    private slurs: Slur[] = new Array();
     private graceNoteSlash: boolean = false;
     private playbackInstrumentId: string = undefined;
     public get GraceNoteSlash(): boolean {
@@ -68,10 +80,10 @@ export class Note {
     public set NoteTie(value: Tie) {
         this.tie = value;
     }
-    public get NoteSlurs(): List<Slur> {
+    public get NoteSlurs(): Slur[] {
         return this.slurs;
     }
-    public set NoteSlurs(value: List<Slur>) {
+    public set NoteSlurs(value: Slur[]) {
         this.slurs = value;
     }
     public get PlaybackInstrumentId(): string {
@@ -81,10 +93,10 @@ export class Note {
         this.playbackInstrumentId = value;
     }
     public calculateNoteLengthWithoutTie(): Fraction {
-        let withoutTieLength: Fraction = new Fraction(this.length);
+        let withoutTieLength: Fraction = Fraction.CreateFractionFromFraction(this.length);
         if (this.tie !== undefined) {
-            let tempLength: Fraction = new Fraction(this.length);
-            for (let idx: number = 0, len: number = this.tie.Fractions.Count; idx < len; ++idx) {
+            let tempLength: Fraction = Fraction.CreateFractionFromFraction(this.length);
+            for (let idx: number = 0, len: number = this.tie.Fractions.length; idx < len; ++idx) {
                 let fraction: Fraction = this.tie.Fractions[idx];
                 tempLength.Sub(fraction);
             }
@@ -93,7 +105,7 @@ export class Note {
         return withoutTieLength;
     }
     public calculateNoteOriginalLength(): Fraction {
-        return this.calculateNoteOriginalLength(new Fraction(this.length));
+        return this.calculateNoteOriginalLength(Fraction.CreateFractionFromFraction(this.length));
     }
     public calculateNoteOriginalLength(originalLength: Fraction): Fraction {
         if (this.tie !== undefined) {
@@ -103,8 +115,8 @@ export class Note {
             return this.length;
         }
         if (originalLength.Numerator > 1) {
-            let exp: number = <number>Math.Log(originalLength.Denominator, 2) - this.calculateNumberOfNeededDots(originalLength);
-            originalLength.Denominator = <number>Math.Pow(2, exp);
+            let exp: number = Math.floor(Math.log(originalLength.Denominator) / Math.LN2) - this.calculateNumberOfNeededDots(originalLength);
+            originalLength.Denominator = 1 << exp;
             originalLength.Numerator = 1;
         }
         return originalLength;
@@ -124,10 +136,10 @@ export class Note {
         if (this.tuplet === undefined) {
             while (product < fraction.Numerator) {
                 num++;
-                product = <number>Math.Pow(2, num); // FIXME
+                product = 1 << num; // FIXME some logarithm
             }
         }
-        return number - 1;
+        return num - 1;
     }
     public ToString(): string {
         if (this.pitch !== undefined) {
@@ -137,7 +149,7 @@ export class Note {
         }
     }
     public getAbsoluteTimestamp(): Fraction {
-        let absolute: Fraction = new Fraction(this.voiceEntry.Timestamp);
+        let absolute: Fraction = Fraction.CreateFractionFromFraction(this.voiceEntry.Timestamp);
         absolute += this.parentStaffEntry.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp;
         return absolute;
     }
@@ -156,10 +168,8 @@ export class Note {
     }
 }
 
-export module Note {
-    export enum Appearance {
-        Normal,
-        Grace,
-        Cue
-    }
+export enum Appearance {
+    Normal,
+    Grace,
+    Cue
 }

+ 37 - 25
src/MusicalScore/VoiceData/SourceStaffEntry.ts

@@ -1,3 +1,15 @@
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {VerticalSourceStaffEntryContainer} from "./VerticalSourceStaffEntryContainer";
+import {Staff} from "./Staff";
+import {AbstractNotationInstruction} from "./Instructions/AbstractNotationInstruction";
+import {VoiceEntry} from "./VoiceEntry";
+import {Note} from "./Note";
+import {StaffEntryLink} from "./StaffEntryLink";
+
+// FIXME
+type ChordSymbolContainer = any;
+
+
 export class SourceStaffEntry {
   constructor(verticalContainerParent: VerticalSourceStaffEntryContainer, parentStaff: Staff) {
     this.verticalContainerParent = verticalContainerParent;
@@ -5,11 +17,11 @@ export class SourceStaffEntry {
   }
   private parentStaff: Staff;
   private verticalContainerParent: VerticalSourceStaffEntryContainer;
-  private voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+  private voiceEntries: VoiceEntry[] = new Array();
   private staffEntryLink: StaffEntryLink;
-  private instructions: List<AbstractNotationInstruction> = new List<AbstractNotationInstruction>();
-  //private graceVoiceEntriesBefore: List<VoiceEntry> = new List<VoiceEntry>();
-  //private graceVoiceEntriesAfter: List<VoiceEntry> = new List<VoiceEntry>();
+  private instructions: AbstractNotationInstruction[] = new Array();
+  //private graceVoiceEntriesBefore: VoiceEntry[] = new Array();
+  //private graceVoiceEntriesAfter: VoiceEntry[] = new Array();
   private chordSymbolContainer: ChordSymbolContainer;
   public get ParentStaff(): Staff {
     return this.parentStaff;
@@ -29,10 +41,10 @@ export class SourceStaffEntry {
     }
     return undefined;
   }
-  public get VoiceEntries(): List<VoiceEntry> {
+  public get VoiceEntries(): VoiceEntry[] {
     return this.voiceEntries;
   }
-  public set VoiceEntries(value: List<VoiceEntry>) {
+  public set VoiceEntries(value: VoiceEntry[]) {
     this.voiceEntries = value;
   }
   public get Link(): StaffEntryLink {
@@ -41,10 +53,10 @@ export class SourceStaffEntry {
   public set Link(value: StaffEntryLink) {
     this.staffEntryLink = value;
   }
-  public get Instructions(): List<AbstractNotationInstruction> {
+  public get Instructions(): AbstractNotationInstruction[] {
     return this.instructions;
   }
-  public set Instructions(value: List<AbstractNotationInstruction>) {
+  public set Instructions(value: AbstractNotationInstruction[]) {
     this.instructions = value;
   }
   public get ChordContainer(): ChordSymbolContainer {
@@ -56,28 +68,28 @@ export class SourceStaffEntry {
   public removeAllInstructionsOfType<T>(): number {
     let i: number = 0;
     let ret: number = 0;
-    while (i < this.instructions.Count) {
+    while (i < this.instructions.length) {
       if (this.instructions[i] instanceof T) {
-        this.instructions.RemoveAt(i);
+        this.instructions.splice(i, 1);
         ret++;
       } else { i++; }
     }
     return ret;
   }
   public removeFirstInstructionOfType<T>(): boolean {
-    for (let i: number = 0; i < this.instructions.Count; i++) {
+    for (let i: number = 0; i < this.instructions.length; i++) {
       if (this.instructions[i] instanceof T) {
-        this.instructions.RemoveAt(i);
+        this.instructions.splice(i, 1);
         return true;
       }
     }
     return false;
   }
   public calculateMinNoteLength(): Fraction {
-    let duration: Fraction = new Fraction(number.MaxValue, 1);
-    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+    let duration: Fraction = new Fraction(Number.MAX_VALUE, 1);
+    for (let idx: number = 0, len: number = this.VoiceEntries.length; idx < len; ++idx) {
       let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
         let note: Note = voiceEntry.Notes[idx2];
         if (note.NoteTie !== undefined) {
           if (duration > note.calculateNoteLengthWithoutTie()) {
@@ -92,14 +104,14 @@ export class SourceStaffEntry {
   }
   public calculateMaxNoteLength(): Fraction {
     let duration: Fraction = new Fraction(0, 1);
-    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.VoiceEntries.length; idx < len; ++idx) {
       let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
         let note: Note = voiceEntry.Notes[idx2];
         if (note.NoteTie !== undefined) {
           if (duration < note.calculateNoteLengthWithoutTie()) {
             duration = note.calculateNoteLengthWithoutTie();
-            for (let idx3: number = 0, len3: number = note.NoteTie.Fractions.Count; idx3 < len3; ++idx3) {
+            for (let idx3: number = 0, len3: number = note.NoteTie.Fractions.length; idx3 < len3; ++idx3) {
               let fraction: Fraction = note.NoteTie.Fractions[idx3];
               duration.Add(fraction);
             }
@@ -110,14 +122,14 @@ export class SourceStaffEntry {
     return duration;
   }
   public hasNotes(): boolean {
-    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.VoiceEntries.length; idx < len; ++idx) {
       let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-      if (voiceEntry.Notes.Count > 0) { return true; }
+      if (voiceEntry.Notes.length > 0) { return true; }
     }
     return false;
   }
   public hasTie(): boolean {
-    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.VoiceEntries.length; idx < len; ++idx) {
       let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
       if (voiceEntry.hasTie()) {
         return true;
@@ -125,13 +137,13 @@ export class SourceStaffEntry {
     }
     return false;
   }
-  public findLinkedNotes(linkedNotes: List<Note>): void {
-    for (let idx: number = 0, len: number = this.voiceEntries.Count; idx < len; ++idx) {
+  public findLinkedNotes(linkedNotes: Note[]): void {
+    for (let idx: number = 0, len: number = this.voiceEntries.length; idx < len; ++idx) {
       let voiceEntry: VoiceEntry = this.voiceEntries[idx];
-      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
         let note: Note = voiceEntry.Notes[idx2];
         if (note.ParentStaffEntry === this) {
-          linkedNotes.Add(note);
+          linkedNotes.push(note);
         }
       }
     }

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

@@ -1,3 +1,7 @@
+import {Voice} from "./Voice";
+import {Instrument} from "../Instrument";
+
+
 export class Staff {
     constructor(parentInstrument: Instrument, instrumentStaffId: number) {
         this.parentInstrument = parentInstrument;
@@ -5,20 +9,23 @@ export class Staff {
         this.Audible = true;
         this.Following = true;
     }
+
     public IdInMusicSheet: number;
     public Audible: boolean;
     public Following: boolean;
+
     private parentInstrument: Instrument;
     private voices: Voice[] = new Array();
     private volume: number = 1;
     private id: number;
+
     public get ParentInstrument(): Instrument {
         return this.parentInstrument;
     }
     public set ParentInstrument(value: Instrument) {
         this.parentInstrument = value;
     }
-    public get Voices(): List<Voice> {
+    public get Voices(): Voice[] {
         return this.voices;
     }
     public get Id(): number {

+ 62 - 51
src/MusicalScore/VoiceData/VoiceEntry.ts

@@ -1,19 +1,32 @@
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {Voice} from "./Voice";
+import {SourceStaffEntry} from "./SourceStaffEntry";
+import {Note} from "./Note";
+import {Pitch} from "../../Common/DataObjects/pitch";
+import {LyricsEntry} from "./Lyrics/LyricsEntry";
+import {TechnicalInstruction} from "./Instructions/TechnicalInstruction";
+import {OrnamentContainer} from "./OrnamentContainer";
+import {KeyInstruction} from "./Instructions/KeyInstruction";
+import {OrnamentEnum} from "./OrnamentContainer";
+import {AccidentalEnum} from "../../Common/DataObjects/pitch";
+
+
 export class VoiceEntry {
   constructor(timestamp: Fraction, parentVoice: Voice, parentSourceStaffEntry: SourceStaffEntry) {
     this.timestamp = timestamp;
     this.parentVoice = parentVoice;
     this.parentSourceStaffEntry = parentSourceStaffEntry;
   }
-  public GraceVoiceEntriesBefore: List<VoiceEntry>;
-  public GraceVoiceEntriesAfter: List<VoiceEntry>;
+  public GraceVoiceEntriesBefore: VoiceEntry[];
+  public GraceVoiceEntriesAfter: VoiceEntry[];
   private parentVoice: Voice;
   private parentSourceStaffEntry: SourceStaffEntry;
   private timestamp: Fraction;
-  private notes: List<Note> = new List<Note>();
-  private articulations: List<ArticulationEnum> = new List<ArticulationEnum>();
-  private technicalInstructions: List<TechnicalInstruction> = new List<TechnicalInstruction>();
-  private lyricsEntries: Dictionary<number, LyricsEntry> = new Dictionary<number, LyricsEntry>();
-  private arpeggiosNotesIndices: List<number> = new List<number>();
+  private notes: Note[] = new Array();
+  private articulations: ArticulationEnum[] = new Array();
+  private technicalInstructions: TechnicalInstruction[] = new Array();
+  private lyricsEntries: { [n: number]: LyricsEntry; } = {};
+  private arpeggiosNotesIndices: number[] = new Array();
   private ornamentContainer: OrnamentContainer;
   public get ParentSourceStaffEntry(): SourceStaffEntry {
     return this.parentSourceStaffEntry;
@@ -27,25 +40,25 @@ export class VoiceEntry {
   public set Timestamp(value: Fraction) {
     this.timestamp = value;
   }
-  public get Notes(): List<Note> {
+  public get Notes(): Note[] {
     return this.notes;
   }
-  public get Articulations(): List<ArticulationEnum> {
+  public get Articulations(): ArticulationEnum[] {
     return this.articulations;
   }
-  public get TechnicalInstructions(): List<TechnicalInstruction> {
+  public get TechnicalInstructions(): TechnicalInstruction[] {
     return this.technicalInstructions;
   }
-  public get LyricsEntries(): Dictionary<number, LyricsEntry> {
+  public get LyricsEntries(): { [n: number]: LyricsEntry; } {
     return this.lyricsEntries;
   }
-  public set LyricsEntries(value: Dictionary<number, LyricsEntry>) {
+  public set LyricsEntries(value: { [n: number]: LyricsEntry; }) {
     this.lyricsEntries = value;
   }
-  public get ArpeggiosNotesIndices(): List<number> {
+  public get ArpeggiosNotesIndices(): number[] {
     return this.arpeggiosNotesIndices;
   }
-  public set ArpeggiosNotesIndices(value: List<number>) {
+  public set ArpeggiosNotesIndices(value: number[]) {
     this.arpeggiosNotesIndices = value;
   }
   public get OrnamentContainer(): OrnamentContainer {
@@ -78,28 +91,28 @@ export class VoiceEntry {
     }
   }
   public hasTie(): boolean {
-    for (let idx: number = 0, len: number = this.Notes.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
       let note: Note = this.Notes[idx];
       if (note.NoteTie !== undefined) { return true; }
     }
     return false;
   }
   public hasSlur(): boolean {
-    for (let idx: number = 0, len: number = this.Notes.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
       let note: Note = this.Notes[idx];
-      if (note.NoteSlurs.Count > 0) { return true; }
+      if (note.NoteSlurs.length > 0) { return true; }
     }
     return false;
   }
   public isStaccato(): boolean {
-    for (let idx: number = 0, len: number = this.Articulations.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.Articulations.length; idx < len; ++idx) {
       let articulation: ArticulationEnum = this.Articulations[idx];
       if (articulation === ArticulationEnum.staccato) { return true; }
     }
     return false;
   }
   public isAccent(): boolean {
-    for (let idx: number = 0, len: number = this.Articulations.Count; idx < len; ++idx) {
+    for (let idx: number = 0, len: number = this.Articulations.length; idx < len; ++idx) {
       let articulation: ArticulationEnum = this.Articulations[idx];
       if (articulation === ArticulationEnum.accent || articulation === ArticulationEnum.strongaccent) {
         return true;
@@ -108,21 +121,18 @@ export class VoiceEntry {
     return false;
   }
   public getVerseNumberForLyricEntry(lyricsEntry: LyricsEntry): number {
-    let key: number = 1;
-    let lyricsEntriesArr: KeyValuePair<number, LyricsEntry>[] = this.lyricsEntries.ToArray();
-    for (let idx: number = 0, len: number = lyricsEntriesArr.length; idx < len; ++idx) {
-      let keyValuePair: KeyValuePair<number, LyricsEntry> = lyricsEntriesArr[idx];
-      if (lyricsEntry === keyValuePair.Value) {
-        key = keyValuePair.Key;
+    for (let key in this.lyricsEntries) {
+      if (lyricsEntry === this.lyricsEntries[key]) {
+        return key;
       } // FIXME
     }
-    return key;
+    return 1;
   }
-  public createVoiceEntriesForOrnament(activeKey: KeyInstruction): List<VoiceEntry> {
+  public createVoiceEntriesForOrnament(activeKey: KeyInstruction): VoiceEntry[] {
     return this.createVoiceEntriesForOrnament(this, activeKey);
   }
-  public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): List<VoiceEntry> {
-    let voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+  public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): VoiceEntry[] {
+    let voiceEntries: VoiceEntry[] = new Array();
     if (voiceEntryWithOrnament.ornamentContainer === undefined) {
       return;
     }
@@ -130,22 +140,22 @@ export class VoiceEntry {
     let baselength: Fraction = baseNote.calculateNoteLengthWithoutTie();
     let baseVoice: Voice = voiceEntryWithOrnament.ParentVoice;
     let baseTimestamp: Fraction = voiceEntryWithOrnament.Timestamp;
-    let currentTimestamp: Fraction = new Fraction(baseTimestamp);
-    let length: Fraction;
+    let currentTimestamp: Fraction = Fraction.CreateFractionFromFraction(baseTimestamp);
+    //let length: Fraction;
     switch (voiceEntryWithOrnament.ornamentContainer.GetOrnament) {
       case OrnamentEnum.Trill: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 8);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 8);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-          if (voiceEntryWithOrnament.OrnamentContainer.AccidentalAbove !== AccEnum.NONE) {
+          if (voiceEntryWithOrnament.OrnamentContainer.AccidentalAbove !== AccidentalEnum.NONE) {
             alteration = <AccidentalEnum><number>voiceEntryWithOrnament.ornamentContainer.AccidentalAbove;
           }
           for (let i: number = 0; i < 8; i++) {
             if ((i % 2) === 0) {
-              currentTimestamp = baseTimestamp + new Fraction(i * length.Numerator, length.Denominator);
+              currentTimestamp = Fraction.plus(baseTimestamp, new Fraction(i * length.Numerator, length.Denominator));
               this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
             } else {
-              currentTimestamp = baseTimestamp + new Fraction(i * length.Numerator, length.Denominator);
+              currentTimestamp = Fraction.plus(baseTimestamp, new Fraction(i * length.Numerator, length.Denominator));
               this.createAlteratedVoiceEntry(
                 currentTimestamp, length, baseVoice, higherPitch, alteration, voiceEntries
               );
@@ -154,10 +164,10 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.Turn: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-          //let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
+          let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           this.createAlteratedVoiceEntry(
             currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries
@@ -173,7 +183,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.InvertedTurn: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
@@ -192,13 +202,13 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.DelayedTurn: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-          currentTimestamp = baseTimestamp + new Fraction(length);
+          currentTimestamp = Fraction.plus(baseTimestamp, length);
           length.Denominator = baselength.Denominator * 8;
           this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries);
           currentTimestamp += length;
@@ -210,13 +220,13 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.DelayedInvertedTurn: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-          currentTimestamp = baseTimestamp + new Fraction(length);
+          currentTimestamp = Fraction.plus(baseTimestamp, length);
           length.Denominator = baselength.Denominator * 8;
           this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration, voiceEntries);
           currentTimestamp += length;
@@ -228,7 +238,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.Mordent: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
@@ -240,7 +250,7 @@ export class VoiceEntry {
         }
         break;
       case OrnamentEnum.InvertedMordent: {
-          length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
+          let length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
           let lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
           let alteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
           this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
@@ -252,29 +262,30 @@ export class VoiceEntry {
         }
         break;
       default:
-        throw new ArgumentOutOfRangeException();
+        throw new RangeError();
     }
     return voiceEntries;
   }
   private createBaseVoiceEntry(
-    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, baseNote: Note, voiceEntries: List<VoiceEntry>
+    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, baseNote: Note, voiceEntries: VoiceEntry[]
   ): void {
     let voiceEntry: VoiceEntry = new VoiceEntry(currentTimestamp, baseVoice, baseNote.ParentStaffEntry);
     let pitch: Pitch = new Pitch(baseNote.Pitch.FundamentalNote, baseNote.Pitch.Octave, baseNote.Pitch.Accidental);
     let note: Note = new Note(voiceEntry, undefined, length, pitch);
-    voiceEntry.Notes.Add(note);
-    voiceEntries.Add(voiceEntry);
+    voiceEntry.Notes.push(note);
+    voiceEntries.push(voiceEntry);
   }
   private createAlteratedVoiceEntry(
-    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, higherPitch: Pitch, alteration: AccidentalEnum, voiceEntries: List<VoiceEntry>
+    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, higherPitch: Pitch, alteration: AccidentalEnum, voiceEntries: VoiceEntry[]
   ): void {
     let voiceEntry: VoiceEntry = new VoiceEntry(currentTimestamp, baseVoice, undefined);
     let pitch: Pitch = new Pitch(higherPitch.FundamentalNote, higherPitch.Octave, alteration);
     let note: Note = new Note(voiceEntry, undefined, length, pitch);
-    voiceEntry.Notes.Add(note);
-    voiceEntries.Add(voiceEntry);
+    voiceEntry.Notes.push(note);
+    voiceEntries.push(voiceEntry);
   }
 }
+
 export enum ArticulationEnum {
   accent,
   strongaccent,

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

@@ -1,4 +1,4 @@
-import { XmlElement } from "../../../src/Common/FileIO/Xml.ts";
+import { IXmlElement } from "../../../src/Common/FileIO/Xml.ts";
 
 let xml_test_data: string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE score-partwise PUBLIC \"-//Recordare//DTD MusicXML 2.0 Partwise//EN\" \"http://www.musicxml.org/dtds/partwise.dtd\"><score-partwise>  <identification>    <encoding>      <software>Example Software Name</software>      <encoding-date>2016-04-04</encoding-date>      </encoding>    </identification>   <credit page=\"1\"> <credit-words justify=\"center\" valign=\"top\">Example Credit Words</credit-words> </credit>  </score-partwise>";
 
@@ -6,9 +6,9 @@ let xml_test_data: string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE
 describe("XML Unit Tests", () => {
   let parser: DOMParser = new DOMParser();
   let doc: Document = parser.parseFromString(xml_test_data, "text/xml");
-  let documentElement: XmlElement = new XmlElement(doc.documentElement);
+  let documentElement: IXmlElement = new IXmlElement(doc.documentElement);
 
-  it("XmlElement Tests", (done: MochaDone) => {
+  it("IXmlElement Tests", (done: MochaDone) => {
     // Test Name attribute
     chai.expect(documentElement.Name).to.equal("score-partwise");
     // Test Element method
@@ -20,13 +20,13 @@ describe("XML Unit Tests", () => {
       .Element("software").Value).to.equal("Example Software Name");
       done();
   });
-  it("XmlAttribute Tests", (done: MochaDone) => {
+  it("IXmlAttribute Tests", (done: MochaDone) => {
     // Test Attributes method
     chai.expect(
       documentElement.Element("credit").Attributes()[0].Name
     ).to.equal("page");
 
-    let creditWords: XmlElement =
+    let creditWords: IXmlElement =
       documentElement.Element("credit").Element("credit-words");
     // Test Attributes method
     chai.expect(creditWords.Attributes().length).to.equal(2);