Ver código fonte

Linting pt. 3

Andrea Condoluci 9 anos atrás
pai
commit
f6f2b6f355

+ 19 - 13
src/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -349,8 +349,9 @@ export class MusicSheetReader implements IMusicSheetReader {
   }
   private staffMeasureIsEmpty(index: number): boolean {
     let counter: number = 0;
-    for (let i: number = 0; i < this.currentMeasure.VerticalSourceStaffEntryContainers.Count; i++)
+    for (let i: number = 0; i < this.currentMeasure.VerticalSourceStaffEntryContainers.Count; i++) {
       if (this.currentMeasure.VerticalSourceStaffEntryContainers[i][index] === undefined) { counter++; }
+    }
     return (counter === this.currentMeasure.VerticalSourceStaffEntryContainers.Count);
   }
   private checkSourceMeasureForundefinedEntries(): void {
@@ -385,8 +386,9 @@ export class MusicSheetReader implements IMusicSheetReader {
   private addSheetLabels(root: IXmlElement, filePath: string): void {
     this.readComposer(root);
     this.readTitle(root);
-    if (this.musicSheet.Title === undefined || this.musicSheet.Composer === undefined)
+    if (this.musicSheet.Title === undefined || this.musicSheet.Composer === undefined) {
       this.readTitleAndComposerFromCredits(root);
+    }
     if (this.musicSheet.Title === undefined) {
       try {
         let bar_i: number = Math.max(
@@ -404,7 +406,7 @@ export class MusicSheetReader implements IMusicSheetReader {
     }
   }
   // Checks whether _elem_ has an attribute with value _val_.
-  private presentAttrWithValue(elem: IXmlElement, val: string): boolean {
+  private presentAttrsWithValue(elem: IXmlElement, val: string): boolean {
     for (let attr of elem.Attributes()) {
       if (attr.Value === val) { return true; }
     }
@@ -496,8 +498,9 @@ export class MusicSheetReader implements IMusicSheetReader {
     }
   }
   private computeSystemYCoordinates(root: IXmlElement): number {
-    if (root.Element("defaults") === undefined)
+    if (root.Element("defaults") === undefined) {
       return 0;
+    }
     let paperHeight: number = 0;
     let topSystemDistance: number = 0;
     let defi: string = root.Element("defaults").Element("page-layout").Element("page-height").Value;
@@ -522,8 +525,7 @@ export class MusicSheetReader implements IMusicSheetReader {
           break;
         }
       }
-      if (found === true)
-        break;
+      if (found) { break; }
     }
     if (root.Element("defaults").Element("system-layout") !== undefined) {
       let syslay: IXmlElement = root.Element("defaults").Element("system-layout");
@@ -532,8 +534,7 @@ export class MusicSheetReader implements IMusicSheetReader {
         topSystemDistance = StringToNumberConverter.ToNumber(topSystemDistanceString);
       }
     }
-    if (topSystemDistance === 0)
-      return 0;
+    if (topSystemDistance === 0) { return 0; }
     return paperHeight - topSystemDistance;
   }
   private readTitle(root: IXmlElement): void {
@@ -567,8 +568,9 @@ export class MusicSheetReader implements IMusicSheetReader {
         }
       }
     }
-    if (!String.IsundefinedOrEmpty(finalSubTitle))
+    if (!String.IsundefinedOrEmpty(finalSubTitle)) {
       this.musicSheet.Subtitle = new Label(finalSubTitle);
+    }
   }
   private createInstrumentGroups(entryList: IEnumerable<IXmlElement>): Dictionary<string, Instrument> {
     let instrumentId: number = 0;
@@ -611,11 +613,13 @@ export class MusicSheetReader implements IMusicSheetReader {
                   let instrumentElement: IXmlElement = instrumentElements[idx3];
                   try {
                     if (instrumentElement.Name === "midi-channel") {
-                      if (StringToNumberConverter.ToInteger(instrumentElement.Value) === 10)
+                      if (StringToNumberConverter.ToInteger(instrumentElement.Value) === 10) {
                         instrument.MidiInstrumentId = MidiInstrument.Percussion;
+                      }
                     } else if (instrumentElement.Name === "midi-program") {
-                      if (instrument.SubInstruments.Count > 0 && instrument.MidiInstrumentId !== MidiInstrument.Percussion)
+                      if (instrument.SubInstruments.Count > 0 && instrument.MidiInstrumentId !== MidiInstrument.Percussion) {
                         subInstrument.MidiInstrumentId = <MidiInstrument>Math.Max(0, StringToNumberConverter.ToInteger(instrumentElement.Value) - 1);
+                      }
                     } else if (instrumentElement.Name === "midi-unpitched") {
                       subInstrument.FixedKey = Math.Max(0, StringToNumberConverter.ToInteger(instrumentElement.Value));
                     } else if (instrumentElement.Name === "volume") {
@@ -711,8 +715,9 @@ export class MusicSheetReader implements IMusicSheetReader {
         let xmlMeasure: IXmlElement = xmlMeasureList.First();
         if (xmlMeasure !== undefined) {
           let stavesNode: IXmlElement = xmlMeasure.Element("attributes");
-          if (stavesNode !== undefined)
+          if (stavesNode !== undefined) {
             stavesNode = stavesNode.Element("staves");
+          }
           if (stavesNode === undefined) {
             number++;
           } else {
@@ -735,8 +740,9 @@ export class MusicSheetReader implements IMusicSheetReader {
     if (xmlMeasure !== undefined) {
       let attributes: IXmlElement = xmlMeasure.Element("attributes");
       let staves: IXmlElement = undefined;
-      if (attributes !== undefined)
+      if (attributes !== undefined) {
         staves = attributes.Element("staves");
+      }
       if (attributes === undefined || staves === undefined) {
         number = 1;
       } else {

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

@@ -1,7 +1,4 @@
 export class Beam {
-    constructor() {
-
-    }
     private notes: List<Note> = new List<Note>();
     private extendedNoteList: List<Note> = new List<Note>();
     public get Notes(): List<Note> {
@@ -17,7 +14,7 @@ export class Beam {
         this.extendedNoteList = value;
     }
     public addNoteToBeam(note: Note): void {
-        if (note != null) {
+        if (note !== undefined) {
             note.NoteBeam = this;
             this.notes.Add(note);
             this.extendedNoteList.Add(note);
@@ -26,14 +23,9 @@ export class Beam {
 }
 export enum BeamEnum {
     BeamNone = -1,
-
     BeamBegin = 0,
-
     BeamContinue = 1,
-
     BeamEnd = 2,
-
     BeamForward = 3,
-
-    BeamBackward = 4
-}
+    BeamBackward = 4,
+}

+ 11 - 12
src/MusicalScore/VoiceData/HelperObjects/DynamicsContainer.ts

@@ -1,5 +1,4 @@
-export class DynamicsContainer implements IComparable<DynamicsContainer>
-{
+export class DynamicsContainer implements IComparable<DynamicsContainer> {
     constructor(continuousDynamicExpression: ContinuousDynamicExpression, staffNumber: number) {
         this.ContinuousDynamicExpression = continuousDynamicExpression;
         this.StaffNumber = staffNumber;
@@ -12,19 +11,19 @@ export class DynamicsContainer implements IComparable<DynamicsContainer>
     public InstantaniousDynamicExpression: InstantaniousDynamicExpression;
     public StaffNumber: number;
     public parMultiExpression(): MultiExpression {
-        if (this.ContinuousDynamicExpression != null)
+        if (this.ContinuousDynamicExpression !== undefined) {
             return this.ContinuousDynamicExpression.StartMultiExpression;
-        if (this.InstantaniousDynamicExpression != null)
+        }
+        if (this.InstantaniousDynamicExpression !== undefined) {
             return this.InstantaniousDynamicExpression.ParentMultiExpression;
-        return null;
+        }
+        return undefined;
     }
     public CompareTo(other: DynamicsContainer): number {
-        var thisTimestamp: number = this.parMultiExpression().AbsoluteTimestamp.RealValue;
-        var otherTimestamp: number = other.parMultiExpression().AbsoluteTimestamp.RealValue;
-        if (thisTimestamp > otherTimestamp)
-            return 1;
-        if (thisTimestamp < otherTimestamp)
-            return -1;
+        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;
     }
-}
+}

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

@@ -1,6 +1,4 @@
 export class AbstractNotationInstruction {
-    constructor() {
-    }
     constructor(parent: SourceStaffEntry) {
         this.parent = parent;
     }

+ 134 - 133
src/MusicalScore/VoiceData/Instructions/ClefInstruction.ts

@@ -1,144 +1,145 @@
 import {Pitch} from "../../../Common/DataObjects/pitch";
 
 export class ClefInstruction extends AbstractNotationInstruction {
-    constructor(clefType: ClefEnum, octaveOffset: number, line: number) {
-        this.line = line;
-        this.clefType = clefType;
-        this.octaveOffset = octaveOffset;
-        this.calcParameters();
-    }
-    private clefType: ClefEnum = ClefEnum.G;
-    private line: number = 2;
-    private octaveOffset: number = 0;
-    private clefPitch: Pitch;
-    private referenceCyPosition: number;
-    public get ClefType(): ClefEnum {
-        return this.clefType;
-    }
-    public set ClefType(value: ClefEnum) {
-        this.clefType = value;
-    }
-    public get Line(): number {
-        return this.line;
-    }
-    public set Line(value: number) {
-        this.line = value;
-    }
-    public get OctaveOffset(): number {
-        return this.octaveOffset;
-    }
-    public set OctaveOffset(value: number) {
-        this.octaveOffset = value;
-    }
-    public get ClefPitch(): Pitch {
-        return this.clefPitch;
-    }
-    public set ClefPitch(value: Pitch) {
-        this.clefPitch = value;
-    }
-    public get ReferenceCyPosition(): number {
-        return this.referenceCyPosition;
-    }
-    public set ReferenceCyPosition(value: number) {
-        this.referenceCyPosition = value;
-    }
-    public OperatorEquals(clef2: ClefInstruction): boolean {
-        var clef1 = this;
-        if (ReferenceEquals(clef1, clef2)) {
-            return true;
-        }
-        if ((<Object>clef1 == null) || (<Object>clef2 == null)) {
-            return false;
-        }
-        return (clef1.ClefPitch == clef2.ClefPitch && clef1.Line == clef2.Line);
-    }
+  constructor(clefType: ClefEnum, octaveOffset: number, line: number) {
+    this.line = line;
+    this.clefType = clefType;
+    this.octaveOffset = octaveOffset;
+    this.calcParameters();
+  }
+  private clefType: ClefEnum = ClefEnum.G;
+  private line: number = 2;
+  private octaveOffset: number = 0;
+  private clefPitch: Pitch;
+  private referenceCyPosition: number;
 
-    public OperatorNotEqual(clef2: ClefInstruction): boolean {
-        var clef1 = this;
-        return !(clef1 == clef2);
-    }
+  public static getDefaultClefFromMidiInstrument(instrument: MidiInstrument): ClefInstruction {
+    switch (instrument) {
+      case MidiInstrument.Acoustic_Grand_Piano:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Electric_Bass_finger:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Electric_Bass_pick:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Fretless_Bass:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Slap_Bass_1:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Slap_Bass_2:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Synth_Bass_1:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Synth_Bass_2:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      case MidiInstrument.Contrabass:
+        return new ClefInstruction(ClefEnum.F, 0, 4);
+      default:
+        return new ClefInstruction(ClefEnum.G, 0, 2);
+    }
+  }
+  public static getAllPossibleClefs(): List<ClefInstruction> {
+    let clefList: List<ClefInstruction> = new List<ClefInstruction>();
+    for (let i: number = 0; i <= 2; i++) {
+      let clefInstructionG: ClefInstruction = new ClefInstruction(ClefEnum.G, i, 2);
+      clefList.Add(clefInstructionG);
+    }
+    for (let j: number = -2; j <= 0; j++) {
+      let clefInstructionF: ClefInstruction = new ClefInstruction(ClefEnum.F, j, 4);
+      clefList.Add(clefInstructionF);
+    }
+    return clefList;
+  }
+  public static isSupportedClef(clef: ClefEnum): boolean {
+    switch (clef) {
+      case ClefEnum.G:
+      case ClefEnum.F:
+      case ClefEnum.C:
+      case ClefEnum.percussion:
+        return true;
+      default:
+        return false;
+    }
+  }
 
-    public static getDefaultClefFromMidiInstrument(instrument: MidiInstrument): ClefInstruction {
-        switch (instrument) {
-            case MidiInstrument.Acoustic_Grand_Piano:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Electric_Bass_finger:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Electric_Bass_pick:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Fretless_Bass:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Slap_Bass_1:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Slap_Bass_2:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Synth_Bass_1:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Synth_Bass_2:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            case MidiInstrument.Contrabass:
-                return new ClefInstruction(ClefEnum.F, 0, 4);
-            default:
-                return new ClefInstruction(ClefEnum.G, 0, 2);
-        }
-    }
-    public static getAllPossibleClefs(): List<ClefInstruction> {
-        var clefList: List<ClefInstruction> = new List<ClefInstruction>();
-        for (var i: number = 0; i <= 2; i++) {
-            var clefInstructionG: ClefInstruction = new ClefInstruction(ClefEnum.G, i, 2);
-            clefList.Add(clefInstructionG);
-        }
-        for (var i: number = -2; i <= 0; i++) {
-            var clefInstructionF: ClefInstruction = new ClefInstruction(ClefEnum.F, i, 4);
-            clefList.Add(clefInstructionF);
-        }
-        return clefList;
-    }
-    public static isSupportedClef(clef: ClefEnum): boolean {
-        switch (clef) {
-            case ClefEnum.G:
-            case ClefEnum.F:
-            case ClefEnum.C:
-            case ClefEnum.percussion:
-                return true;
-            default:
-                return false;
-        }
-    }
-    public ToString(): string {
-        return "ClefType: " + this.clefType.ToString();
-    }
-    private calcParameters(): void {
-        switch (this.clefType) {
-            case ClefEnum.G:
-                this.clefPitch = new Pitch(NoteEnum.G, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
-                this.referenceCyPosition = (5 - this.line) + 2;
-                break;
-            case ClefEnum.F:
-                this.clefPitch = new Pitch(NoteEnum.F, <number>(0 + this.octaveOffset), AccidentalEnum.NONE);
-                this.referenceCyPosition = (5 - this.line) + 1.5f;
-                break;
-            case ClefEnum.C:
-                this.clefPitch = new Pitch(NoteEnum.C, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
-                this.referenceCyPosition = (5 - this.line);
-                break;
-            case ClefEnum.percussion:
-                this.clefPitch = new Pitch(NoteEnum.C, 2, AccidentalEnum.NONE);
-                this.referenceCyPosition = 2;
-                break;
-            default:
-                throw new ArgumentOutOfRangeException("clefType");
-        }
-    }
+  public get ClefType(): ClefEnum {
+    return this.clefType;
+  }
+  public set ClefType(value: ClefEnum) {
+    this.clefType = value;
+  }
+  public get Line(): number {
+    return this.line;
+  }
+  public set Line(value: number) {
+    this.line = value;
+  }
+  public get OctaveOffset(): number {
+    return this.octaveOffset;
+  }
+  public set OctaveOffset(value: number) {
+    this.octaveOffset = value;
+  }
+  public get ClefPitch(): Pitch {
+    return this.clefPitch;
+  }
+  public set ClefPitch(value: Pitch) {
+    this.clefPitch = value;
+  }
+  public get ReferenceCyPosition(): number {
+    return this.referenceCyPosition;
+  }
+  public set ReferenceCyPosition(value: number) {
+    this.referenceCyPosition = value;
+  }
+  public OperatorEquals(clef2: ClefInstruction): boolean {
+    let clef1: ClefInstruction = this;
+    if (ReferenceEquals(clef1, clef2)) {
+      return true;
+    }
+    if (clef1 === undefined || clef2 === undefined) {
+      return false;
+    }
+    return (clef1.ClefPitch === clef2.ClefPitch && clef1.Line === clef2.Line);
+  }
+
+  public OperatorNotEqual(clef2: ClefInstruction): boolean {
+    return this !== clef2;
+  }
+
+  public ToString(): string {
+    return "ClefType: " + this.clefType.ToString();
+  }
+  private calcParameters(): void {
+    switch (this.clefType) {
+      case ClefEnum.G:
+        this.clefPitch = new Pitch(NoteEnum.G, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
+        this.referenceCyPosition = (5 - this.line) + 2;
+        break;
+      case ClefEnum.F:
+        this.clefPitch = new Pitch(NoteEnum.F, <number>(0 + this.octaveOffset), AccidentalEnum.NONE);
+        this.referenceCyPosition = (5 - this.line) + 1.5;
+        break;
+      case ClefEnum.C:
+        this.clefPitch = new Pitch(NoteEnum.C, <number>(1 + this.octaveOffset), AccidentalEnum.NONE);
+        this.referenceCyPosition = (5 - this.line);
+        break;
+      case ClefEnum.percussion:
+        this.clefPitch = new Pitch(NoteEnum.C, 2, AccidentalEnum.NONE);
+        this.referenceCyPosition = 2;
+        break;
+      default:
+        throw new ArgumentOutOfRangeException("clefType");
+    }
+  }
 }
 export enum ClefEnum {
-    G = 0,
+  G = 0,
 
-    F = 1,
+  F = 1,
 
-    C = 2,
+  C = 2,
 
-    percussion = 3,
+  percussion = 3,
 
-    TAB = 4
-}
+  TAB = 4
+}

+ 99 - 94
src/MusicalScore/VoiceData/Instructions/KeyInstruction.ts

@@ -1,108 +1,113 @@
 export class KeyInstruction extends AbstractNotationInstruction {
-    constructor(key: number, mode: KeyEnum) {
-        super();
-        this.Key = key;
-        this.mode = mode;
-    }
-    constructor(parent: SourceStaffEntry, key: number, mode: KeyEnum) {
-        super(parent);
-        this.Key = key;
-        this.mode = mode;
-    }
-    constructor(keyInstruction: KeyInstruction) {
-        this(keyInstruction.parent, keyInstruction.keyType, keyInstruction.mode);
-        this.keyType = keyInstruction.keyType;
-        this.mode = keyInstruction.mode;
-    }
-    private keyType: number;
-    private mode: KeyEnum;
-    private static sharpPositionList: NoteEnum[] = [NoteEnum.F, NoteEnum.C, NoteEnum.G, NoteEnum.D, NoteEnum.A, NoteEnum.E, NoteEnum.B];
-    private static flatPositionList: NoteEnum[] = [NoteEnum.B, NoteEnum.E, NoteEnum.A, NoteEnum.D, NoteEnum.G, NoteEnum.C, NoteEnum.F];
-    public static getAllPossibleMajorKeyInstructions(): List<KeyInstruction> {
-        var keyInstructionList: List<KeyInstruction> = new List<KeyInstruction>();
-        for (var keyType: number = -7; keyType < 7; keyType++) {
-            var currentKeyInstruction: KeyInstruction = new KeyInstruction(keyType, KeyEnum.major);
-            keyInstructionList.Add(currentKeyInstruction);
-        }
-        return keyInstructionList;
-    }
-    public get Key(): number {
-        return this.keyType;
-    }
-    public set Key(value: number) {
-        this.keyType = value;
+  constructor(key: number, mode: KeyEnum) {
+    super();
+    this.Key = key;
+    this.mode = mode;
+  }
+  constructor(parent: SourceStaffEntry, key: number, mode: KeyEnum) {
+    super(parent);
+    this.Key = key;
+    this.mode = mode;
+  }
+  constructor(keyInstruction: KeyInstruction) {
+    this(keyInstruction.parent, keyInstruction.keyType, keyInstruction.mode);
+    this.keyType = keyInstruction.keyType;
+    this.mode = keyInstruction.mode;
+  }
+
+  private static sharpPositionList: NoteEnum[] = [NoteEnum.F, NoteEnum.C, NoteEnum.G, NoteEnum.D, NoteEnum.A, NoteEnum.E, NoteEnum.B];
+  private static flatPositionList: NoteEnum[] = [NoteEnum.B, NoteEnum.E, NoteEnum.A, NoteEnum.D, NoteEnum.G, NoteEnum.C, NoteEnum.F];
+
+  private keyType: number;
+  private mode: KeyEnum;
+
+  public static getNoteEnumList(instruction: KeyInstruction): List<NoteEnum> {
+    let enums: List<NoteEnum> = new List<NoteEnum>();
+    if (instruction.keyType > 0) {
+      for (let i: number = 0; i < instruction.keyType; i++) {
+        enums.Add(KeyInstruction.sharpPositionList[i]);
+      }
     }
-    public get Mode(): KeyEnum {
-        return this.mode;
+    if (instruction.keyType < 0) {
+      for (let i: number = 0; i < Math.Abs(instruction.keyType); i++) {
+        enums.Add(KeyInstruction.flatPositionList[i]);
+      }
     }
-    public set Mode(value: KeyEnum) {
-        this.mode = value;
+    return enums;
+  }
+
+  public static getAllPossibleMajorKeyInstructions(): KeyInstruction[] {
+    let keyInstructionList: KeyInstruction[] = new Array();
+    for (let keyType: number = -7; keyType < 7; keyType++) {
+      let currentKeyInstruction: KeyInstruction = new KeyInstruction(keyType, KeyEnum.major);
+      keyInstructionList.Add(currentKeyInstruction);
     }
-    public getFundamentalNotesOfAccidentals(): List<NoteEnum> {
-        var noteList: List<NoteEnum> = new List<NoteEnum>();
-        if (this.keyType > 0) {
-            for (var i: number = 0; i < this.keyType; i++) {
-                noteList.Add(KeyInstruction.sharpPositionList[i]);
-            }
-        }
-        else if (this.keyType < 0) {
-            for (var i: number = 0; i < -this.keyType; i++) {
-                noteList.Add(KeyInstruction.flatPositionList[i]);
-            }
-        }
-        return noteList;
+    return keyInstructionList;
+  }
+  public get Key(): number {
+    return this.keyType;
+  }
+  public set Key(value: number) {
+    this.keyType = value;
+  }
+  public get Mode(): KeyEnum {
+    return this.mode;
+  }
+  public set Mode(value: KeyEnum) {
+    this.mode = value;
+  }
+  public getFundamentalNotesOfAccidentals(): List<NoteEnum> {
+    let noteList: List<NoteEnum> = new List<NoteEnum>();
+    if (this.keyType > 0) {
+      for (let i: number = 0; i < this.keyType; i++) {
+        noteList.Add(KeyInstruction.sharpPositionList[i]);
+      }
+    } else if (this.keyType < 0) {
+      for (let i: number = 0; i < -this.keyType; i++) {
+        noteList.Add(KeyInstruction.flatPositionList[i]);
+      }
     }
-    public getAlterationForPitch(pitch: Pitch): AccidentalEnum {
-        if (this.keyType > 0 && Array.IndexOf(KeyInstruction.sharpPositionList, pitch.FundamentalNote) <= this.keyType)
-            return AccidentalEnum.SHARP;
-        else if (this.keyType < 0 && Array.IndexOf(KeyInstruction.flatPositionList, pitch.FundamentalNote) <= Math.Abs(this.keyType))
-            return AccidentalEnum.FLAT;
-        return AccidentalEnum.NONE;
+    return noteList;
+  }
+  public getAlterationForPitch(pitch: Pitch): AccidentalEnum {
+    if (this.keyType > 0 && Array.IndexOf(KeyInstruction.sharpPositionList, pitch.FundamentalNote) <= this.keyType) {
+      return AccidentalEnum.SHARP;
+    } else if (this.keyType < 0 && Array.IndexOf(KeyInstruction.flatPositionList, pitch.FundamentalNote) <= Math.Abs(this.keyType)) {
+      return AccidentalEnum.FLAT;
     }
-    public ToString(): string {
-        return "Key: " + this.keyType.ToString() + this.mode.ToString();
+    return AccidentalEnum.NONE;
+  }
+  public ToString(): string {
+    return "Key: " + this.keyType.ToString() + this.mode.ToString();
+  }
+  public OperatorEquals(key2: KeyInstruction): boolean {
+    let key1: KeyInstruction = this;
+    if (ReferenceEquals(key1, key2)) {
+      return true;
     }
-    public OperatorEquals(key2: KeyInstruction): boolean {
-        var key1 = this;
-        if (ReferenceEquals(key1, key2)) {
-            return true;
-        }
-        if ((<Object>key1 == null) || (<Object>key2 == null)) {
-            return false;
-        }
-        return (key1.Key == key2.Key && key1.Mode == key2.Mode);
+    if ((<Object>key1 === undefined) || (<Object>key2 === undefined)) {
+      return false;
     }
+    return (key1.Key === key2.Key && key1.Mode === key2.Mode);
+  }
 
-    public OperatorNotEqual(key2: KeyInstruction): boolean {
-        var key1 = this;
-        return !(key1 == key2);
-    }
+  public OperatorNotEqual(key2: KeyInstruction): boolean {
+    let key1: KeyInstruction = this;
+    return !(key1 === key2);
+  }
 
-    public static getNoteEnumList(instruction: KeyInstruction): List<NoteEnum> {
-        var enums: List<NoteEnum> = new List<NoteEnum>();
-        if (instruction.keyType > 0)
-            for (var i: number = 0; i < instruction.keyType; i++)
-                enums.Add(KeyInstruction.sharpPositionList[i]);
-        if (instruction.keyType < 0)
-            for (var i: number = 0; i < Math.Abs(instruction.keyType); i++)
-                enums.Add(KeyInstruction.flatPositionList[i]);
-        return enums;
+  export class NoteEnumToHalfToneLink {
+    constructor(note: NoteEnum, halftone: number) {
+      this.note = note;
+      this.halfTone = halftone;
     }
+    public note: NoteEnum;
+    public halfTone: number;
+  }
+
 }
 export enum KeyEnum {
-    major = 0,
-
-    minor = 1,
-
-    none = 2
+  major = 0,
+  minor = 1,
+  none = 2,
 }
-export module KeyInstruction {
-    export class NoteEnumToHalfToneLink {
-        constructor(note: NoteEnum, halftone: number) {
-            this.note = note;
-            this.halfTone = halftone;
-        }
-        public note: NoteEnum;
-        public halfTone: number;
-    }
-}

+ 124 - 137
src/MusicalScore/VoiceData/Instructions/RepetitionInstruction.ts

@@ -1,150 +1,137 @@
 export enum RepetitionInstructionEnum {
-    StartLine,
-
-    ForwardJump,
-
-    BackJumpLine,
-
-    Ending,
-
-    DaCapo,
-
-    DalSegno,
-
-    Fine,
-
-    ToCoda,
-
-    DalSegnoAlFine,
-
-    DaCapoAlFine,
-
-    DalSegnoAlCoda,
-
-    DaCapoAlCoda,
-
-    Coda,
-
-    Segno,
-
-    None
+  StartLine,
+  ForwardJump,
+  BackJumpLine,
+  Ending,
+  DaCapo,
+  DalSegno,
+  Fine,
+  ToCoda,
+  DalSegnoAlFine,
+  DaCapoAlFine,
+  DalSegnoAlCoda,
+  DaCapoAlCoda,
+  Coda,
+  Segno,
+  None,
 }
 export enum AlignmentType {
-    Begin,
-
-    End
+  Begin,
+  End,
 }
-export class RepetitionInstructionComparer implements IComparer<RepetitionInstruction>
-{
-    public Compare(x: RepetitionInstruction, y: RepetitionInstruction): number {
-        if (x.ParentRepetition != null && y.ParentRepetition != null) {
-            if (x.Alignment == AlignmentType.End && y.Alignment == AlignmentType.End) {
-                if (x.ParentRepetition.StartIndex < y.ParentRepetition.StartIndex)
-                    return 1;
-                if (x.ParentRepetition.StartIndex > y.ParentRepetition.StartIndex)
-                    return -1;
-            }
-            if (x.Alignment == AlignmentType.Begin && y.Alignment == AlignmentType.Begin) {
-                if (x.ParentRepetition.EndIndex < y.ParentRepetition.EndIndex)
-                    return 1;
-                if (x.ParentRepetition.EndIndex > y.ParentRepetition.EndIndex)
-                    return -1;
-            }
-        }
-        return 0;
+
+export class RepetitionInstructionComparer implements IComparer<RepetitionInstruction> {
+  public Compare(x: RepetitionInstruction, y: RepetitionInstruction): number {
+    if (x.ParentRepetition !== undefined && y.ParentRepetition !== undefined) {
+      if (x.Alignment === AlignmentType.End && y.Alignment === AlignmentType.End) {
+        if (x.ParentRepetition.StartIndex < y.ParentRepetition.StartIndex) { return 1; }
+        if (x.ParentRepetition.StartIndex > y.ParentRepetition.StartIndex) { return -1; }
+      }
+      if (x.Alignment === AlignmentType.Begin && y.Alignment === AlignmentType.Begin) {
+        if (x.ParentRepetition.EndIndex < y.ParentRepetition.EndIndex) { return 1; }
+        if (x.ParentRepetition.EndIndex > y.ParentRepetition.EndIndex) { return -1; }
+      }
     }
+    return 0;
+  }
 }
 export class RepetitionInstruction implements IComparable {
-    constructor(measureIndex: number, type: RepetitionInstructionEnum) {
-        this(measureIndex, new List<number>(), type, AlignmentType.End, null);
-        if (type == RepetitionInstructionEnum.StartLine || type == RepetitionInstructionEnum.Segno || type == RepetitionInstructionEnum.Coda)
-            this.Alignment = AlignmentType.Begin;
+  constructor(measureIndex: number, type: RepetitionInstructionEnum) {
+    this(measureIndex, new List<number>(), type, AlignmentType.End, undefined);
+    if (type === RepetitionInstructionEnum.StartLine || type === RepetitionInstructionEnum.Segno || type === RepetitionInstructionEnum.Coda) {
+      this.Alignment = AlignmentType.Begin;
     }
-    constructor(measureIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
-        this(measureIndex, new List<number>(), type, alignment, parentRepetition);
-
+  }
+  constructor(measureIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
+    this(measureIndex, new List<number>(), type, alignment, parentRepetition);
+
+  }
+  constructor(measureIndex: number, endingIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
+    this(measureIndex, __init(new List<number>(), { endingIndex }), type, alignment, parentRepetition);
+
+  }
+  constructor(measureIndex: number, endingIndices: List<number>, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
+    this.MeasureIndex = measureIndex;
+    this.EndingIndices = new List<number>();
+    for (let idx: number = 0, len: number = endingIndices.Count; idx < len; ++idx) {
+      let endingIndex: number = endingIndices[idx];
+      this.EndingIndices.Add(endingIndex);
     }
-    constructor(measureIndex: number, endingIndex: number, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
-        this(measureIndex, __init(new List<number>(), { endingIndex }), type, alignment, parentRepetition);
-
-    }
-    constructor(measureIndex: number, endingIndices: List<number>, type: RepetitionInstructionEnum, alignment: AlignmentType, parentRepetition: Repetition) {
-        this.MeasureIndex = measureIndex;
-        this.EndingIndices = new List<number>();
-        for (var idx: number = 0, len = endingIndices.Count; idx < len; ++idx) {
-            var endingIndex: number = endingIndices[idx];
-            this.EndingIndices.Add(endingIndex);
-        }
-        this.Type = type;
-        this.Alignment = alignment;
-        this.ParentRepetition = parentRepetition;
+    this.Type = type;
+    this.Alignment = alignment;
+    this.ParentRepetition = parentRepetition;
+  }
+  public MeasureIndex: number;
+  public EndingIndices: List<number>;
+  public Type: RepetitionInstructionEnum;
+  public Alignment: AlignmentType;
+  public ParentRepetition: Repetition;
+  public CompareTo(obj: Object): number {
+    let other: RepetitionInstruction = <RepetitionInstruction>obj;
+    if (this.MeasureIndex > other.MeasureIndex) {
+      return 1;
+    } else if (this.MeasureIndex < other.MeasureIndex) {
+      return -1;
     }
-    public MeasureIndex: number;
-    public EndingIndices: List<number>;
-    public Type: RepetitionInstructionEnum;
-    public Alignment: AlignmentType;
-    public ParentRepetition: Repetition;
-    public CompareTo(obj: Object): number {
-        var other: RepetitionInstruction = <RepetitionInstruction>obj;
-        if (this.MeasureIndex > other.MeasureIndex)
-            return 1;
-        else if (this.MeasureIndex < other.MeasureIndex)
+    if (this.Alignment === AlignmentType.Begin) {
+      if (other.Alignment === AlignmentType.End) { return -1; }
+      switch (this.Type) {
+        case RepetitionInstructionEnum.Ending:
+          return 1;
+        case RepetitionInstructionEnum.StartLine:
+          if (other.Type === RepetitionInstructionEnum.Ending) {
             return -1;
-        if (this.Alignment == AlignmentType.Begin) {
-            if (other.Alignment == AlignmentType.End)
-                return -1;
-            switch (this.Type) {
-                case RepetitionInstructionEnum.Ending:
-                    return 1;
-                case RepetitionInstructionEnum.StartLine:
-                    if (other.Type == RepetitionInstructionEnum.Ending)
-                        return -1;
-                    return 1;
-                case RepetitionInstructionEnum.Coda:
-                case RepetitionInstructionEnum.Segno:
-                    if (other.Type == RepetitionInstructionEnum.Coda)
-                        return 1;
-                    return -1;
-            }
-        }
-        else {
-            if (other.Alignment == AlignmentType.Begin)
-                return 1;
-            switch (this.Type) {
-                case RepetitionInstructionEnum.Ending:
-                    return -1;
-                case RepetitionInstructionEnum.Fine:
-                case RepetitionInstructionEnum.ToCoda:
-                    if (other.Type == RepetitionInstructionEnum.Ending)
-                        return 1;
-                    return -1;
-                case RepetitionInstructionEnum.ForwardJump:
-                    switch (other.Type) {
-                        case RepetitionInstructionEnum.Ending:
-                        case RepetitionInstructionEnum.Fine:
-                        case RepetitionInstructionEnum.ToCoda:
-                            return 1;
-                    }
-                    return -1;
-                case RepetitionInstructionEnum.DalSegnoAlFine:
-                case RepetitionInstructionEnum.DaCapoAlFine:
-                case RepetitionInstructionEnum.DalSegnoAlCoda:
-                case RepetitionInstructionEnum.DaCapoAlCoda:
-                case RepetitionInstructionEnum.DaCapo:
-                case RepetitionInstructionEnum.DalSegno:
-                case RepetitionInstructionEnum.BackJumpLine:
-                    return 1;
-            }
-        }
-        return 0;
+          }
+          return 1;
+        case RepetitionInstructionEnum.Coda:
+        case RepetitionInstructionEnum.Segno:
+          if (other.Type === RepetitionInstructionEnum.Coda) {
+            return 1;
+          }
+          return -1;
+        default:
+      }
+    } else {
+      if (other.Alignment === AlignmentType.Begin) { return 1; }
+      switch (this.Type) {
+        case RepetitionInstructionEnum.Ending:
+          return -1;
+        case RepetitionInstructionEnum.Fine:
+        case RepetitionInstructionEnum.ToCoda:
+          if (other.Type === RepetitionInstructionEnum.Ending) { return 1; }
+          return -1;
+        case RepetitionInstructionEnum.ForwardJump:
+          switch (other.Type) {
+            case RepetitionInstructionEnum.Ending:
+            case RepetitionInstructionEnum.Fine:
+            case RepetitionInstructionEnum.ToCoda:
+              return 1;
+            default:
+          }
+          return -1;
+        case RepetitionInstructionEnum.DalSegnoAlFine:
+        case RepetitionInstructionEnum.DaCapoAlFine:
+        case RepetitionInstructionEnum.DalSegnoAlCoda:
+        case RepetitionInstructionEnum.DaCapoAlCoda:
+        case RepetitionInstructionEnum.DaCapo:
+        case RepetitionInstructionEnum.DalSegno:
+        case RepetitionInstructionEnum.BackJumpLine:
+          return 1;
+        default:
+      }
     }
-    public isIdenticalTo(other: RepetitionInstruction): boolean {
-        if (this.MeasureIndex != other.MeasureIndex || this.Type != other.Type || this.Alignment != other.Alignment || this.EndingIndices.Count != other.EndingIndices.Count)
-            return false;
-        for (var i: number = 0; i < this.EndingIndices.Count; i++) {
-            if (this.EndingIndices[i] != other.EndingIndices[i])
-                return false;
-        }
-        return true;
+    return 0;
+  }
+  public isIdenticalTo(other: RepetitionInstruction): boolean {
+    if (
+      this.MeasureIndex !== other.MeasureIndex
+      || this.Type !== other.Type
+      || this.Alignment !== other.Alignment
+      || this.EndingIndices.Count !== other.EndingIndices.Count
+    ) { return false; }
+    for (let i: number = 0; i < this.EndingIndices.Count; i++) {
+      if (this.EndingIndices[i] !== other.EndingIndices[i]) { return false; }
     }
-}
+    return true;
+  }
+}

+ 8 - 9
src/MusicalScore/VoiceData/Instructions/RhythmInstruction.ts

@@ -30,29 +30,28 @@ export class RhythmInstruction extends AbstractNotationInstruction {
         this.symbolEnum = value;
     }
     public OperatorEquals(rhythm2: RhythmInstruction): boolean {
-        var rhythm1 = this;
+        let rhythm1: RhythmInstruction = this;
         if (ReferenceEquals(rhythm1, rhythm2)) {
             return true;
         }
-        if ((<Object>rhythm1 == null) || (<Object>rhythm2 == null)) {
+        if ((<Object>rhythm1 === undefined) || (<Object>rhythm2 === undefined)) {
             return false;
         }
-        return (rhythm1.numerator == rhythm2.numerator && rhythm1.denominator == rhythm2.denominator);
+        return (rhythm1.numerator === rhythm2.numerator && rhythm1.denominator === rhythm2.denominator);
     }
 
     public OperatorNotEqual(rhythm2: RhythmInstruction): boolean {
-        var rhythm1 = this;
-        return !(rhythm1 == rhythm2);
+        let rhythm1: RhythmInstruction = this;
+        return !(rhythm1 === rhythm2);
     }
 
     public ToString(): string {
         return "Rhythm: " + this.rhythm.ToString();
     }
 }
+
 export enum RhythmSymbolEnum {
     NONE = 0,
-
     COMMON = 1,
-
-    CUT = 2
-}
+    CUT = 2,
+}

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

@@ -4,4 +4,4 @@ export enum TechnicalInstructionType {
 export class TechnicalInstruction {
     public type: TechnicalInstructionType;
     public value: string;
-}
+}

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

@@ -7,4 +7,4 @@ export class LinkedVoice extends Voice {
     public get Master(): Voice {
         return this.master;
     }
-}
+}

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

@@ -1,8 +1,8 @@
 import {LyricsEntry} from "./LyricsEntry";
 
 export class LyricWord {
-    private _syllabels: Array<LyricsEntry> = new Array<LyricsEntry>();
-    public get Syllabels(): Array<LyricsEntry> {
+    private _syllabels: LyricsEntry[] = new Array();
+    public get Syllabels(): LyricsEntry[] {
         return this._syllabels;
     }
     public containsVoiceEntry(voiceEntry: VoiceEntry): boolean {

+ 41 - 31
src/MusicalScore/VoiceData/Note.ts

@@ -4,10 +4,15 @@ export class Note {
         this.parentStaffEntry = parentStaffEntry;
         this.length = length;
         this.pitch = pitch;
-        if (pitch != null)
+        if (pitch !== undefined) {
             this.HalfTone = pitch.getHalfTone();
-        else this.HalfTone = 0;
+        } else {
+          this.HalfTone = 0;
+        }
     }
+    public HalfTone: number;
+    public State: NoteState;
+
     private voiceEntry: VoiceEntry;
     private parentStaffEntry: SourceStaffEntry;
     private length: Fraction;
@@ -17,7 +22,7 @@ export class Note {
     private tie: Tie;
     private slurs: List<Slur> = new List<Slur>();
     private graceNoteSlash: boolean = false;
-    private playbackInstrumentId: string = null;
+    private playbackInstrumentId: string = undefined;
     public get GraceNoteSlash(): boolean {
         return this.graceNoteSlash;
     }
@@ -45,7 +50,6 @@ export class Note {
     public get Pitch(): Pitch {
         return this.pitch;
     }
-    public HalfTone: number;
     public get NoteBeam(): Beam {
         return this.beam;
     }
@@ -70,7 +74,6 @@ export class Note {
     public set NoteSlurs(value: List<Slur>) {
         this.slurs = value;
     }
-    public State: NoteState;
     public get PlaybackInstrumentId(): string {
         return this.playbackInstrumentId;
     }
@@ -78,11 +81,11 @@ export class Note {
         this.playbackInstrumentId = value;
     }
     public calculateNoteLengthWithoutTie(): Fraction {
-        var withoutTieLength: Fraction = new Fraction(this.length);
-        if (this.tie != null) {
-            var tempLength: Fraction = new Fraction(this.length);
-            for (var idx: number = 0, len = this.tie.Fractions.Count; idx < len; ++idx) {
-                var fraction: Fraction = this.tie.Fractions[idx];
+        let withoutTieLength: Fraction = new Fraction(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 fraction: Fraction = this.tie.Fractions[idx];
                 tempLength.Sub(fraction);
             }
             withoutTieLength = tempLength;
@@ -93,61 +96,68 @@ export class Note {
         return this.calculateNoteOriginalLength(new Fraction(this.length));
     }
     public calculateNoteOriginalLength(originalLength: Fraction): Fraction {
-        if (this.tie != null)
+        if (this.tie !== undefined) {
             originalLength = this.calculateNoteLengthWithoutTie();
-        if (this.tuplet != null)
+        }
+        if (this.tuplet !== undefined) {
             return this.length;
+        }
         if (originalLength.Numerator > 1) {
-            var exp: number = <number>Math.Log(originalLength.Denominator, 2) - this.calculateNumberOfNeededDots(originalLength);
+            let exp: number = <number>Math.Log(originalLength.Denominator, 2) - this.calculateNumberOfNeededDots(originalLength);
             originalLength.Denominator = <number>Math.Pow(2, exp);
             originalLength.Numerator = 1;
         }
         return originalLength;
     }
     public calculateNoteLengthWithDots(): Fraction {
-        if (this.tie != null)
+        if (this.tie !== undefined) {
             return this.calculateNoteLengthWithoutTie();
+        }
         return this.length;
     }
     public calculateNumberOfNeededDots(): number {
         return this.calculateNumberOfNeededDots(this.length);
     }
     public calculateNumberOfNeededDots(fraction: Fraction): number {
-        var number: number = 1;
-        var product: number = 2;
-        if (this.tuplet == null) {
+        let num: number = 1;
+        let product: number = 2;
+        if (this.tuplet === undefined) {
             while (product < fraction.Numerator) {
-                number++;
-                product = <number>Math.Pow(2, number);
+                num++;
+                product = <number>Math.Pow(2, num); // FIXME
             }
         }
         return number - 1;
     }
     public ToString(): string {
-        if (this.pitch != null)
+        if (this.pitch !== undefined) {
             return this.Pitch.ToString() + ", length: " + this.Length.ToString();
-        else return "rest note, length: " + this.Length.ToString();
+        } else {
+          return "rest note, length: " + this.Length.ToString();
+        }
     }
     public getAbsoluteTimestamp(): Fraction {
-        var absolute: Fraction = new Fraction(this.voiceEntry.Timestamp);
+        let absolute: Fraction = new Fraction(this.voiceEntry.Timestamp);
         absolute += this.parentStaffEntry.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp;
         return absolute;
     }
     public checkForDoubleSlur(slur: Slur): boolean {
-        for (var idx: number = 0, len = this.slurs.Count; idx < len; ++idx) {
-            var noteSlur: Slur = this.slurs[idx];
-            if (noteSlur.StartNote != null && noteSlur.EndNote != null && slur.StartNote != null && slur.StartNote == noteSlur.StartNote && noteSlur.EndNote == this)
-                return true;
+        for (let idx: number = 0, len: number = this.slurs.Count; idx < len; ++idx) {
+            let noteSlur: Slur = this.slurs[idx];
+            if (
+              noteSlur.StartNote !== undefined &&
+              noteSlur.EndNote !== undefined &&
+              slur.StartNote !== undefined &&
+              slur.StartNote === noteSlur.StartNote &&
+              noteSlur.EndNote === this
+            ) { return true; }
         }
         return false;
     }
-}
-export module Note {
+
     export enum Appearance {
         Normal,
-
         Grace,
-
         Cue
     }
-}
+}

+ 1 - 7
src/MusicalScore/VoiceData/OrnamentContainer.ts

@@ -23,16 +23,10 @@ export class OrnamentContainer {
 }
 export enum OrnamentEnum {
     Trill,
-
     Turn,
-
     InvertedTurn,
-
     DelayedTurn,
-
     DelayedInvertedTurn,
-
     Mordent,
-
     InvertedMordent
-}
+}

+ 276 - 253
src/MusicalScore/VoiceData/SourceMeasure.ts

@@ -1,260 +1,283 @@
 export class SourceMeasure {
-    constructor(completeNumberOfStaves: number) {
-        this.completeNumberOfStaves = completeNumberOfStaves;
-        this.initialize();
-    }
-    public MeasureListIndex: number;
-    public EndsPiece: boolean;
-    private measureNumber: number;
-    private parentMusicPart: SourceMusicPart;
-    private absoluteTimestamp: Fraction;
-    private completeNumberOfStaves: number;
-    private duration: Fraction;
-    private staffLinkedExpressions: List<List<MultiExpression>> = new List<List<MultiExpression>>();
-    private tempoExpressions: List<MultiTempoExpression> = new List<MultiTempoExpression>();
-    private verticalSourceStaffEntryContainers: List<VerticalSourceStaffEntryContainer> = new List<VerticalSourceStaffEntryContainer>();
-    private implicitMeasure: boolean;
-    private breakSystemAfter: boolean;
-    private staffMeasureErrors: List<boolean> = new List<boolean>();
-    private firstInstructionsStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
-    private lastInstructionsStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
-    private firstRepetitionInstructions: List<RepetitionInstruction> = new List<RepetitionInstruction>();
-    private lastRepetitionInstructions: List<RepetitionInstruction> = new List<RepetitionInstruction>();
-    public get MeasureNumber(): number {
-        return this.measureNumber;
-    }
-    public set MeasureNumber(value: number) {
-        this.measureNumber = value;
-    }
-    public get AbsoluteTimestamp(): Fraction {
-        return this.absoluteTimestamp;
-    }
-    public set AbsoluteTimestamp(value: Fraction) {
-        this.absoluteTimestamp = value;
-    }
-    public get CompleteNumberOfStaves(): number {
-        return this.completeNumberOfStaves;
-    }
-    public get Duration(): Fraction {
-        return this.duration;
-    }
-    public set Duration(value: Fraction) {
-        this.duration = value;
-    }
-    public get ImplicitMeasure(): boolean {
-        return this.implicitMeasure;
-    }
-    public set ImplicitMeasure(value: boolean) {
-        this.implicitMeasure = value;
-    }
-    public get BreakSystemAfter(): boolean {
-        return this.breakSystemAfter;
-    }
-    public set BreakSystemAfter(value: boolean) {
-        this.breakSystemAfter = value;
-    }
-    public get StaffLinkedExpressions(): List<List<MultiExpression>> {
-        return this.staffLinkedExpressions;
-    }
-    public get TempoExpressions(): List<MultiTempoExpression> {
-        return this.tempoExpressions;
-    }
-    public get VerticalSourceStaffEntryContainers(): List<VerticalSourceStaffEntryContainer> {
-        return this.verticalSourceStaffEntryContainers;
-    }
-    public get FirstInstructionsStaffEntries(): List<SourceStaffEntry> {
-        return this.firstInstructionsStaffEntries;
-    }
-    public get LastInstructionsStaffEntries(): List<SourceStaffEntry> {
-        return this.lastInstructionsStaffEntries;
-    }
-    public get FirstRepetitionInstructions(): List<RepetitionInstruction> {
-        return this.firstRepetitionInstructions;
-    }
-    public get LastRepetitionInstructions(): List<RepetitionInstruction> {
-        return this.lastRepetitionInstructions;
-    }
-    public getErrorInMeasure(staffIndex: number): boolean {
-        return this.staffMeasureErrors[staffIndex];
-    }
-    public setErrorInStaffMeasure(staffIndex: number, hasError: boolean): void {
-        this.staffMeasureErrors[staffIndex] = hasError;
-    }
-    public getNextMeasure(measures: List<SourceMeasure>): SourceMeasure {
-        if (this.MeasureListIndex + 1 < measures.Count)
-            return measures[this.MeasureListIndex + 1];
-        return null;
-    }
-    public getPreviousMeasure(measures: List<SourceMeasure>): SourceMeasure {
-        if (this.MeasureListIndex - 1 > 0)
-            return measures[this.MeasureListIndex - 1];
-        return null;
-    }
-    public findOrCreateStaffEntry(inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff, createdNewContainer: boolean): SourceStaffEntry {
-        var staffEntry: SourceStaffEntry = null;
-        createdNewContainer = false;
-        var existingVerticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers.Find(o => o.Timestamp == inMeasureTimestamp);
-        if (existingVerticalSourceStaffEntryContainer != null) {
-            if (existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] != null)
-                return existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex];
-            else {
-                staffEntry = new SourceStaffEntry(existingVerticalSourceStaffEntryContainer, staff);
-                existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] = staffEntry;
-                return staffEntry;
-            }
-        }
-        createdNewContainer = true;
-        if (this.verticalSourceStaffEntryContainers.Count == 0 || this.verticalSourceStaffEntryContainers.Last().Timestamp < inMeasureTimestamp) {
-            var container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves);
-            this.verticalSourceStaffEntryContainers.Add(container);
-            staffEntry = new SourceStaffEntry(container, staff);
-            container[inSourceMeasureStaffIndex] = staffEntry;
-        }
-        else {
-            for (var i: number = this.verticalSourceStaffEntryContainers.Count - 1; i >= 0; i--) {
-                if (this.verticalSourceStaffEntryContainers[i].Timestamp < inMeasureTimestamp) {
-                    var container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves);
-                    this.verticalSourceStaffEntryContainers.Insert(i + 1, container);
-                    staffEntry = new SourceStaffEntry(container, staff);
-                    container[inSourceMeasureStaffIndex] = staffEntry;
-                    return staffEntry;
-                }
-                if (i == 0) {
-                    var container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves);
-                    this.verticalSourceStaffEntryContainers.Insert(i, container);
-                    staffEntry = new SourceStaffEntry(container, staff);
-                    container[inSourceMeasureStaffIndex] = staffEntry;
-                    return staffEntry;
-                }
-            }
-        }
+  constructor(completeNumberOfStaves: number) {
+    this.completeNumberOfStaves = completeNumberOfStaves;
+    this.initialize();
+  }
+  public MeasureListIndex: number;
+  public EndsPiece: boolean;
+
+  private measureNumber: number;
+  //private parentMusicPart: SourceMusicPart;
+  private absoluteTimestamp: Fraction;
+  private completeNumberOfStaves: number;
+  private duration: Fraction;
+  private staffLinkedExpressions: List<List<MultiExpression>> = new List<List<MultiExpression>>();
+  private tempoExpressions: List<MultiTempoExpression> = new List<MultiTempoExpression>();
+  private verticalSourceStaffEntryContainers: List<VerticalSourceStaffEntryContainer> = new List<VerticalSourceStaffEntryContainer>();
+  private implicitMeasure: boolean;
+  private breakSystemAfter: boolean;
+  private staffMeasureErrors: List<boolean> = new List<boolean>();
+  private firstInstructionsStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
+  private lastInstructionsStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
+  private firstRepetitionInstructions: List<RepetitionInstruction> = new List<RepetitionInstruction>();
+  private lastRepetitionInstructions: List<RepetitionInstruction> = new List<RepetitionInstruction>();
+  public get MeasureNumber(): number {
+    return this.measureNumber;
+  }
+  public set MeasureNumber(value: number) {
+    this.measureNumber = value;
+  }
+  public get AbsoluteTimestamp(): Fraction {
+    return this.absoluteTimestamp;
+  }
+  public set AbsoluteTimestamp(value: Fraction) {
+    this.absoluteTimestamp = value;
+  }
+  public get CompleteNumberOfStaves(): number {
+    return this.completeNumberOfStaves;
+  }
+  public get Duration(): Fraction {
+    return this.duration;
+  }
+  public set Duration(value: Fraction) {
+    this.duration = value;
+  }
+  public get ImplicitMeasure(): boolean {
+    return this.implicitMeasure;
+  }
+  public set ImplicitMeasure(value: boolean) {
+    this.implicitMeasure = value;
+  }
+  public get BreakSystemAfter(): boolean {
+    return this.breakSystemAfter;
+  }
+  public set BreakSystemAfter(value: boolean) {
+    this.breakSystemAfter = value;
+  }
+  public get StaffLinkedExpressions(): List<List<MultiExpression>> {
+    return this.staffLinkedExpressions;
+  }
+  public get TempoExpressions(): List<MultiTempoExpression> {
+    return this.tempoExpressions;
+  }
+  public get VerticalSourceStaffEntryContainers(): List<VerticalSourceStaffEntryContainer> {
+    return this.verticalSourceStaffEntryContainers;
+  }
+  public get FirstInstructionsStaffEntries(): List<SourceStaffEntry> {
+    return this.firstInstructionsStaffEntries;
+  }
+  public get LastInstructionsStaffEntries(): List<SourceStaffEntry> {
+    return this.lastInstructionsStaffEntries;
+  }
+  public get FirstRepetitionInstructions(): List<RepetitionInstruction> {
+    return this.firstRepetitionInstructions;
+  }
+  public get LastRepetitionInstructions(): List<RepetitionInstruction> {
+    return this.lastRepetitionInstructions;
+  }
+  public getErrorInMeasure(staffIndex: number): boolean {
+    return this.staffMeasureErrors[staffIndex];
+  }
+  public setErrorInStaffMeasure(staffIndex: number, hasError: boolean): void {
+    this.staffMeasureErrors[staffIndex] = hasError;
+  }
+  public getNextMeasure(measures: List<SourceMeasure>): SourceMeasure {
+    if (this.MeasureListIndex + 1 < measures.Count) {
+      return measures[this.MeasureListIndex + 1];
+    }
+    return undefined;
+  }
+  public getPreviousMeasure(measures: List<SourceMeasure>): SourceMeasure {
+    if (this.MeasureListIndex > 1) {
+      return measures[this.MeasureListIndex - 1];
+    }
+    return undefined;
+  }
+  public findOrCreateStaffEntry(inMeasureTimestamp: Fraction, inSourceMeasureStaffIndex: number, staff: Staff, createdNewContainer: boolean): SourceStaffEntry {
+    let staffEntry: SourceStaffEntry = undefined;
+    createdNewContainer = false;
+    let existingVerticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.verticalSourceStaffEntryContainers.Find(
+      o => o.Timestamp === inMeasureTimestamp
+    );
+    if (existingVerticalSourceStaffEntryContainer !== undefined) {
+      if (existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] !== undefined) {
+        return existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex];
+      } else {
+        staffEntry = new SourceStaffEntry(existingVerticalSourceStaffEntryContainer, staff);
+        existingVerticalSourceStaffEntryContainer[inSourceMeasureStaffIndex] = staffEntry;
         return staffEntry;
-    }
-    public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice, createdNewVoiceEntry: boolean): VoiceEntry {
-        var ve: VoiceEntry = null;
-        for (var idx: number = 0, len = sse.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = sse.VoiceEntries[idx];
-            if (voiceEntry.ParentVoice == voice) {
-                ve = voiceEntry;
-                break;
-            }
-        }
-        if (ve == null) {
-            ve = new VoiceEntry(sse.Timestamp, voice, sse);
-            sse.VoiceEntries.Add(ve);
-            createdNewVoiceEntry = true;
-        }
-        else {
-            createdNewVoiceEntry = false;
-        }
-        return ve;
-    }
-    public getPreviousSourceStaffEntryFromIndex(verticalIndex: number, horizontalIndex: number): SourceStaffEntry {
-        for (var i: number = horizontalIndex - 1; i >= 0; i--)
-            if (this.verticalSourceStaffEntryContainers[i][verticalIndex] != null)
-                return this.verticalSourceStaffEntryContainers[i][verticalIndex];
-        return null;
-    }
-    public getVerticalContainerIndexByTimestamp(musicTimestamp: Fraction): number {
-        var index: number = -1;
-        for (var idx: number = 0, len = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
-            var verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
-            if (verticalSourceStaffEntryContainer.Timestamp == musicTimestamp)
-                return this.verticalSourceStaffEntryContainers.IndexOf(verticalSourceStaffEntryContainer);
-        }
-        return index;
-    }
-    public getVerticalContainerByTimestamp(musicTimestamp: Fraction): VerticalSourceStaffEntryContainer {
-        for (var idx: number = 0, len = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
-            var verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
-            if (verticalSourceStaffEntryContainer.Timestamp == musicTimestamp)
-                return verticalSourceStaffEntryContainer;
-        }
-        return null;
-    }
-    public checkForEmptyVerticalContainer(index: number): void {
-        var nullCounter: number = 0;
-        for (var i: number = 0; i < this.completeNumberOfStaves; i++)
-            if (this.verticalSourceStaffEntryContainers[index][i] == null)
-                nullCounter++;
-        if (nullCounter == this.completeNumberOfStaves)
-            this.verticalSourceStaffEntryContainers.Remove(this.verticalSourceStaffEntryContainers[index]);
-    }
-    public reverseCheck(musicSheet: MusicSheet, maxInstDuration: Fraction): Fraction {
-        var maxDuration: Fraction = new Fraction(0, 1);
-        var instrumentsDurations: List<Fraction> = new List<Fraction>();
-        for (var i: number = 0; i < musicSheet.Instruments.Count; i++) {
-            var instrumentDuration: Fraction = new Fraction(0, 1);
-            var inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
-            for (var j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
-                var lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
-                if (lastStaffEntry != null && !lastStaffEntry.hasTie()) {
-                    var verticalContainerIndex: number = this.verticalSourceStaffEntryContainers.IndexOf(lastStaffEntry.VerticalContainerParent);
-                    for (var m: number = verticalContainerIndex - 1; m >= 0; m--) {
-                        var previousStaffEntry: SourceStaffEntry = this.verticalSourceStaffEntryContainers[m][inSourceMeasureInstrumentIndex + j];
-                        if (previousStaffEntry != null && previousStaffEntry.hasTie()) {
-                            if (instrumentDuration < previousStaffEntry.Timestamp + previousStaffEntry.calculateMaxNoteLength()) {
-                                instrumentDuration = previousStaffEntry.Timestamp + previousStaffEntry.calculateMaxNoteLength();
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-            instrumentsDurations.Add(instrumentDuration);
+      }
+    }
+    createdNewContainer = true;
+    if (this.verticalSourceStaffEntryContainers.Count === 0 || this.verticalSourceStaffEntryContainers.Last().Timestamp < inMeasureTimestamp) {
+      let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
+        this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+      );
+      this.verticalSourceStaffEntryContainers.Add(container);
+      staffEntry = new SourceStaffEntry(container, staff);
+      container[inSourceMeasureStaffIndex] = staffEntry;
+    } else {
+      for (
+        let i: number = this.verticalSourceStaffEntryContainers.Count - 1;
+        i >= 0; i--
+      ) {
+        if (this.verticalSourceStaffEntryContainers[i].Timestamp < inMeasureTimestamp) {
+          let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
+            this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+          );
+          this.verticalSourceStaffEntryContainers.Insert(i + 1, container);
+          staffEntry = new SourceStaffEntry(container, staff);
+          container[inSourceMeasureStaffIndex] = staffEntry;
+          return staffEntry;
         }
-        for (var idx: number = 0, len = instrumentsDurations.Count; idx < len; ++idx) {
-            var instrumentsDuration: Fraction = instrumentsDurations[idx];
-            if (maxDuration < instrumentsDuration)
-                maxDuration = instrumentsDuration;
+        if (i === 0) {
+          let container: VerticalSourceStaffEntryContainer = new VerticalSourceStaffEntryContainer(
+            this, new Fraction(inMeasureTimestamp), this.completeNumberOfStaves
+          );
+          this.verticalSourceStaffEntryContainers.Insert(i, container);
+          staffEntry = new SourceStaffEntry(container, staff);
+          container[inSourceMeasureStaffIndex] = staffEntry;
+          return staffEntry;
         }
-        if (maxDuration > maxInstDuration)
-            return maxDuration;
-        return maxInstDuration;
-    }
-    public calculateInstrumentsDuration(musicSheet: MusicSheet, instrumentMaxTieNoteFractions: List<Fraction>): List<Fraction> {
-        var instrumentsDurations: List<Fraction> = new List<Fraction>();
-        for (var i: number = 0; i < musicSheet.Instruments.Count; i++) {
-            var instrumentDuration: Fraction = new Fraction(0, 1);
-            var inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
-            for (var j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
-                var lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
-                if (lastStaffEntry != null && lastStaffEntry.Timestamp != null) {
-                    if (instrumentDuration < lastStaffEntry.Timestamp + lastStaffEntry.calculateMaxNoteLength())
-                        instrumentDuration = new Fraction(lastStaffEntry.Timestamp + lastStaffEntry.calculateMaxNoteLength());
-                }
+      }
+    }
+    return staffEntry;
+  }
+  public findOrCreateVoiceEntry(sse: SourceStaffEntry, voice: Voice, createdNewVoiceEntry: boolean): VoiceEntry {
+    let ve: VoiceEntry = undefined;
+    for (let idx: number = 0, len: number = sse.VoiceEntries.Count; idx < len; ++idx) {
+      let voiceEntry: VoiceEntry = sse.VoiceEntries[idx];
+      if (voiceEntry.ParentVoice === voice) {
+        ve = voiceEntry;
+        break;
+      }
+    }
+    if (ve === undefined) {
+      ve = new VoiceEntry(sse.Timestamp, voice, sse);
+      sse.VoiceEntries.Add(ve);
+      createdNewVoiceEntry = true;
+    } else {
+      createdNewVoiceEntry = false;
+    }
+    return ve;
+  }
+  public getPreviousSourceStaffEntryFromIndex(
+    verticalIndex: number, horizontalIndex: number
+  ): SourceStaffEntry {
+    for (let i: number = horizontalIndex - 1; i >= 0; i--) {
+      if (this.verticalSourceStaffEntryContainers[i][verticalIndex] !== undefined) {
+        return this.verticalSourceStaffEntryContainers[i][verticalIndex];
+      }
+    }
+    return undefined;
+  }
+  public getVerticalContainerIndexByTimestamp(musicTimestamp: Fraction): number {
+    let index: number = -1;
+    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
+      let verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
+      if (verticalSourceStaffEntryContainer.Timestamp === musicTimestamp) {
+        return this.verticalSourceStaffEntryContainers.IndexOf(verticalSourceStaffEntryContainer);
+      }
+    }
+    return index;
+  }
+  public getVerticalContainerByTimestamp(musicTimestamp: Fraction): VerticalSourceStaffEntryContainer {
+    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
+      let verticalSourceStaffEntryContainer: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
+      if (verticalSourceStaffEntryContainer.Timestamp === musicTimestamp) {
+        return verticalSourceStaffEntryContainer;
+      }
+    }
+    return undefined;
+  }
+  public checkForEmptyVerticalContainer(index: number): void {
+    let undefinedCounter: number = 0;
+    for (let i: number = 0; i < this.completeNumberOfStaves; i++) {
+      if (this.verticalSourceStaffEntryContainers[index][i] === undefined) {
+        undefinedCounter++;
+      }
+    }
+    if (undefinedCounter === this.completeNumberOfStaves) {
+      this.verticalSourceStaffEntryContainers.Remove(this.verticalSourceStaffEntryContainers[index]);
+    }
+  }
+  public reverseCheck(musicSheet: MusicSheet, maxInstDuration: Fraction): Fraction {
+    let maxDuration: Fraction = new Fraction(0, 1);
+    let instrumentsDurations: List<Fraction> = new List<Fraction>();
+    for (let i: number = 0; i < musicSheet.Instruments.Count; i++) {
+      let instrumentDuration: Fraction = new Fraction(0, 1);
+      let inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
+      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
+        let lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
+        if (lastStaffEntry !== undefined && !lastStaffEntry.hasTie()) {
+          let verticalContainerIndex: number = this.verticalSourceStaffEntryContainers.IndexOf(lastStaffEntry.VerticalContainerParent);
+          for (let m: number = verticalContainerIndex - 1; m >= 0; m--) {
+            let previousStaffEntry: SourceStaffEntry = this.verticalSourceStaffEntryContainers[m][inSourceMeasureInstrumentIndex + j];
+            if (previousStaffEntry !== undefined && previousStaffEntry.hasTie()) {
+              if (instrumentDuration < previousStaffEntry.Timestamp + previousStaffEntry.calculateMaxNoteLength()) {
+                instrumentDuration = previousStaffEntry.Timestamp + previousStaffEntry.calculateMaxNoteLength();
+                break;
+              }
             }
-            if (instrumentDuration < instrumentMaxTieNoteFractions[i])
-                instrumentDuration = instrumentMaxTieNoteFractions[i];
-            instrumentsDurations.Add(instrumentDuration);
-        }
-        return instrumentsDurations;
-    }
-    public getEntriesPerStaff(staffIndex: number): List<SourceStaffEntry> {
-        var sourceStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
-        for (var idx: number = 0, len = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
-            var container: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
-            var sse: SourceStaffEntry = container[staffIndex];
-            if (sse != null)
-                sourceStaffEntries.Add(sse);
+          }
         }
-        return sourceStaffEntries;
-    }
-    private initialize(): void {
-        for (var i: number = 0; i < this.completeNumberOfStaves; i++) {
-            this.firstInstructionsStaffEntries.Add(null);
-            this.lastInstructionsStaffEntries.Add(null);
-            this.staffMeasureErrors.Add(false);
-            this.staffLinkedExpressions.Add(new List<MultiExpression>());
+      }
+      instrumentsDurations.Add(instrumentDuration);
+    }
+    for (let idx: number = 0, len: number = instrumentsDurations.Count; idx < len; ++idx) {
+      let instrumentsDuration: Fraction = instrumentsDurations[idx];
+      if (maxDuration < instrumentsDuration) {
+        maxDuration = instrumentsDuration;
+      }
+    }
+    return Math.max(maxDuration, maxInstDuration);
+  }
+  public calculateInstrumentsDuration(musicSheet: MusicSheet, instrumentMaxTieNoteFractions: List<Fraction>): List<Fraction> {
+    let instrumentsDurations: List<Fraction> = new List<Fraction>();
+    for (let i: number = 0; i < musicSheet.Instruments.Count; i++) {
+      let instrumentDuration: Fraction = new Fraction(0, 1);
+      let inSourceMeasureInstrumentIndex: number = musicSheet.getGlobalStaffIndexOfFirstStaff(musicSheet.Instruments[i]);
+      for (let j: number = 0; j < musicSheet.Instruments[i].Staves.Count; j++) {
+        let lastStaffEntry: SourceStaffEntry = this.getLastSourceStaffEntryForInstrument(inSourceMeasureInstrumentIndex + j);
+        if (lastStaffEntry !== undefined && lastStaffEntry.Timestamp !== undefined) {
+          if (instrumentDuration < lastStaffEntry.Timestamp + lastStaffEntry.calculateMaxNoteLength()) {
+            instrumentDuration = new Fraction(lastStaffEntry.Timestamp + lastStaffEntry.calculateMaxNoteLength());
+          }
         }
-        this.implicitMeasure = false;
-        this.breakSystemAfter = false;
-        this.EndsPiece = false;
-    }
-    private getLastSourceStaffEntryForInstrument(instrumentIndex: number): SourceStaffEntry {
-        for (var i: number = this.verticalSourceStaffEntryContainers.Count - 1; i >= 0; i--)
-            if (this.verticalSourceStaffEntryContainers[i][instrumentIndex] != null)
-                return this.verticalSourceStaffEntryContainers[i][instrumentIndex];
-        return null;
-    }
-}
+      }
+      if (instrumentDuration < instrumentMaxTieNoteFractions[i]) {
+        instrumentDuration = instrumentMaxTieNoteFractions[i];
+      }
+      instrumentsDurations.Add(instrumentDuration);
+    }
+    return instrumentsDurations;
+  }
+  public getEntriesPerStaff(staffIndex: number): List<SourceStaffEntry> {
+    let sourceStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
+    for (let idx: number = 0, len: number = this.VerticalSourceStaffEntryContainers.Count; idx < len; ++idx) {
+      let container: VerticalSourceStaffEntryContainer = this.VerticalSourceStaffEntryContainers[idx];
+      let sse: SourceStaffEntry = container[staffIndex];
+      if (sse !== undefined) { sourceStaffEntries.Add(sse); }
+    }
+    return sourceStaffEntries;
+  }
+  private initialize(): void {
+    for (let i: number = 0; i < this.completeNumberOfStaves; i++) {
+      this.firstInstructionsStaffEntries.Add(undefined);
+      this.lastInstructionsStaffEntries.Add(undefined);
+      this.staffMeasureErrors.Add(false);
+      this.staffLinkedExpressions.Add(new List<MultiExpression>());
+    }
+    this.implicitMeasure = false;
+    this.breakSystemAfter = false;
+    this.EndsPiece = false;
+  }
+  private getLastSourceStaffEntryForInstrument(instrumentIndex: number): SourceStaffEntry {
+    for (let i: number = this.verticalSourceStaffEntryContainers.Count - 1; i >= 0; i--) {
+      if (this.verticalSourceStaffEntryContainers[i][instrumentIndex] !== undefined) {
+        return this.verticalSourceStaffEntryContainers[i][instrumentIndex];
+      }
+    }
+    //return undefined;
+  }
+}

+ 134 - 137
src/MusicalScore/VoiceData/SourceStaffEntry.ts

@@ -1,142 +1,139 @@
 export class SourceStaffEntry {
-    constructor(verticalContainerParent: VerticalSourceStaffEntryContainer, parentStaff: Staff) {
-        this.verticalContainerParent = verticalContainerParent;
-        this.parentStaff = parentStaff;
-    }
-    private parentStaff: Staff;
-    private verticalContainerParent: VerticalSourceStaffEntryContainer;
-    private voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
-    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 chordSymbolContainer: ChordSymbolContainer;
-    public get ParentStaff(): Staff {
-        return this.parentStaff;
-    }
-    public get VerticalContainerParent(): VerticalSourceStaffEntryContainer {
-        return this.verticalContainerParent;
-    }
-    public get Timestamp(): Fraction {
-        if (this.VerticalContainerParent != null)
-            return this.VerticalContainerParent.Timestamp;
-        return null;
-    }
-    public get AbsoluteTimestamp(): Fraction {
-        if (this.VerticalContainerParent != null)
-            return this.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp + this.VerticalContainerParent.Timestamp;
-        return null;
-    }
-    public get VoiceEntries(): List<VoiceEntry> {
-        return this.voiceEntries;
-    }
-    public set VoiceEntries(value: List<VoiceEntry>) {
-        this.voiceEntries = value;
-    }
-    public get Link(): StaffEntryLink {
-        return this.staffEntryLink;
-    }
-    public set Link(value: StaffEntryLink) {
-        this.staffEntryLink = value;
-    }
-    public get Instructions(): List<AbstractNotationInstruction> {
-        return this.instructions;
-    }
-    public set Instructions(value: List<AbstractNotationInstruction>) {
-        this.instructions = value;
-    }
-    public get ChordContainer(): ChordSymbolContainer {
-        return this.chordSymbolContainer;
-    }
-    public set ChordContainer(value: ChordSymbolContainer) {
-        this.chordSymbolContainer = value;
-    }
-    public removeAllInstructionsOfType<T>(): number {
-        var i: number = 0;
-        var ret: number = 0;
-        while (i < this.instructions.Count) {
-            if (this.instructions[i] instanceof T) {
-                this.instructions.RemoveAt(i);
-                ret++;
-            }
-            else i++;
+  constructor(verticalContainerParent: VerticalSourceStaffEntryContainer, parentStaff: Staff) {
+    this.verticalContainerParent = verticalContainerParent;
+    this.parentStaff = parentStaff;
+  }
+  private parentStaff: Staff;
+  private verticalContainerParent: VerticalSourceStaffEntryContainer;
+  private voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+  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 chordSymbolContainer: ChordSymbolContainer;
+  public get ParentStaff(): Staff {
+    return this.parentStaff;
+  }
+  public get VerticalContainerParent(): VerticalSourceStaffEntryContainer {
+    return this.verticalContainerParent;
+  }
+  public get Timestamp(): Fraction {
+    if (this.VerticalContainerParent !== undefined) {
+      return this.VerticalContainerParent.Timestamp;
+    }
+    return undefined;
+  }
+  public get AbsoluteTimestamp(): Fraction {
+    if (this.VerticalContainerParent !== undefined) {
+      return this.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp + this.VerticalContainerParent.Timestamp;
+    }
+    return undefined;
+  }
+  public get VoiceEntries(): List<VoiceEntry> {
+    return this.voiceEntries;
+  }
+  public set VoiceEntries(value: List<VoiceEntry>) {
+    this.voiceEntries = value;
+  }
+  public get Link(): StaffEntryLink {
+    return this.staffEntryLink;
+  }
+  public set Link(value: StaffEntryLink) {
+    this.staffEntryLink = value;
+  }
+  public get Instructions(): List<AbstractNotationInstruction> {
+    return this.instructions;
+  }
+  public set Instructions(value: List<AbstractNotationInstruction>) {
+    this.instructions = value;
+  }
+  public get ChordContainer(): ChordSymbolContainer {
+    return this.chordSymbolContainer;
+  }
+  public set ChordContainer(value: ChordSymbolContainer) {
+    this.chordSymbolContainer = value;
+  }
+  public removeAllInstructionsOfType<T>(): number {
+    let i: number = 0;
+    let ret: number = 0;
+    while (i < this.instructions.Count) {
+      if (this.instructions[i] instanceof T) {
+        this.instructions.RemoveAt(i);
+        ret++;
+      } else { i++; }
+    }
+    return ret;
+  }
+  public removeFirstInstructionOfType<T>(): boolean {
+    for (let i: number = 0; i < this.instructions.Count; i++) {
+      if (this.instructions[i] instanceof T) {
+        this.instructions.RemoveAt(i);
+        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 voiceEntry: VoiceEntry = this.VoiceEntries[idx];
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
+        let note: Note = voiceEntry.Notes[idx2];
+        if (note.NoteTie !== undefined) {
+          if (duration > note.calculateNoteLengthWithoutTie()) {
+            duration = note.calculateNoteLengthWithoutTie();
+          }
+        } else if (duration > note.Length) {
+            duration = note.Length;
         }
-        return ret;
-    }
-    public removeFirstInstructionOfType<T>(): boolean {
-        for (var i: number = 0; i < this.instructions.Count; i++) {
-            if (this.instructions[i] instanceof T) {
-                this.instructions.RemoveAt(i);
-                return true;
-            }
-        }
-        return false;
-    }
-    public calculateMinNoteLength(): Fraction {
-        var duration: Fraction = new Fraction(number.MaxValue, 1);
-        for (var idx: number = 0, len = this.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-            for (var idx2: number = 0, len2 = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
-                var note: Note = voiceEntry.Notes[idx2];
-                if (note.NoteTie != null) {
-                    if (duration > note.calculateNoteLengthWithoutTie())
-                        duration = note.calculateNoteLengthWithoutTie();
-                }
-                else {
-                    if (duration > note.Length)
-                        duration = note.Length;
-                }
-            }
-        }
-        return duration;
-    }
-    public calculateMaxNoteLength(): Fraction {
-        var duration: Fraction = new Fraction(0, 1);
-        for (var idx: number = 0, len = this.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-            for (var idx2: number = 0, len2 = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
-                var note: Note = voiceEntry.Notes[idx2];
-                if (note.NoteTie != null) {
-                    if (duration < note.calculateNoteLengthWithoutTie()) {
-                        duration = note.calculateNoteLengthWithoutTie();
-                        for (var idx3: number = 0, len3 = note.NoteTie.Fractions.Count; idx3 < len3; ++idx3) {
-                            var fraction: Fraction = note.NoteTie.Fractions[idx3];
-                            duration.Add(fraction);
-                        }
-                    }
-                }
-                else {
-                    if (duration < note.Length)
-                        duration = note.Length;
-                }
-            }
-        }
-        return duration;
-    }
-    public hasNotes(): boolean {
-        for (var idx: number = 0, len = this.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-            if (voiceEntry.Notes.Count > 0)
-                return true;
-        }
-        return false;
-    }
-    public hasTie(): boolean {
-        for (var idx: number = 0, len = this.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.VoiceEntries[idx];
-            if (voiceEntry.hasTie())
-                return true;
-        }
-        return false;
-    }
-    public findLinkedNotes(linkedNotes: List<Note>): void {
-        for (var idx: number = 0, len = this.voiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.voiceEntries[idx];
-            for (var idx2: number = 0, len2 = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
-                var note: Note = voiceEntry.Notes[idx2];
-                if (note.ParentStaffEntry == this)
-                    linkedNotes.Add(note);
+      }
+    }
+    return duration;
+  }
+  public calculateMaxNoteLength(): Fraction {
+    let duration: Fraction = new Fraction(0, 1);
+    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+      let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; 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) {
+              let fraction: Fraction = note.NoteTie.Fractions[idx3];
+              duration.Add(fraction);
             }
+          }
+        } else if (duration < note.Length) { duration = note.Length; }
+      }
+    }
+    return duration;
+  }
+  public hasNotes(): boolean {
+    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+      let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
+      if (voiceEntry.Notes.Count > 0) { return true; }
+    }
+    return false;
+  }
+  public hasTie(): boolean {
+    for (let idx: number = 0, len: number = this.VoiceEntries.Count; idx < len; ++idx) {
+      let voiceEntry: VoiceEntry = this.VoiceEntries[idx];
+      if (voiceEntry.hasTie()) {
+        return true;
+      }
+    }
+    return false;
+  }
+  public findLinkedNotes(linkedNotes: List<Note>): void {
+    for (let idx: number = 0, len: number = this.voiceEntries.Count; idx < len; ++idx) {
+      let voiceEntry: VoiceEntry = this.voiceEntries[idx];
+      for (let idx2: number = 0, len2: number = voiceEntry.Notes.Count; idx2 < len2; ++idx2) {
+        let note: Note = voiceEntry.Notes[idx2];
+        if (note.ParentStaffEntry === this) {
+          linkedNotes.Add(note);
         }
+      }
     }
-}
+  }
+}

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

@@ -9,7 +9,7 @@ export class Staff {
     public Audible: boolean;
     public Following: boolean;
     private parentInstrument: Instrument;
-    private voices: List<Voice> = new List<Voice>();
+    private voices: Voice[] = new Array();
     private volume: number = 1;
     private id: number;
     public get ParentInstrument(): Instrument {
@@ -30,4 +30,4 @@ export class Staff {
     public set Volume(value: number) {
         this.volume = value;
     }
-}
+}

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

@@ -3,14 +3,14 @@ export class StaffEntryLink {
         this.voiceEntry = voiceEntry;
     }
     private voiceEntry: VoiceEntry;
-    private linkStaffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
+    private linkStaffEntries: SourceStaffEntry[] = new Array();
     public get GetVoiceEntry(): VoiceEntry {
         return this.voiceEntry;
     }
-    public get LinkStaffEntries(): List<SourceStaffEntry> {
+    public get LinkStaffEntries(): SourceStaffEntry[] {
         return this.linkStaffEntries;
     }
-    public set LinkStaffEntries(value: List<SourceStaffEntry>) {
+    public set LinkStaffEntries(value: SourceStaffEntry[]) {
         this.linkStaffEntries = value;
     }
-}
+}

+ 6 - 7
src/MusicalScore/VoiceData/Tie.ts

@@ -67,17 +67,16 @@ export class Tie {
     }
     public initializeBoolList(): void {
         this.noteHasBeenCreated.Clear();
-        for (var idx: number = 0, len = this.fractions.Count; idx < len; ++idx) {
-            var fraction: Fraction = this.fractions[idx];
+        for (let idx: number = 0, len: number = this.fractions.Count; idx < len; ++idx) {
+            // let fraction: Fraction = this.fractions[idx];
             this.noteHasBeenCreated.Add(false);
         }
     }
     public allGraphicalNotesHaveBeenCreated(): boolean {
-        for (var idx: number = 0, len = this.noteHasBeenCreated.Count; idx < len; ++idx) {
-            var b: boolean = this.noteHasBeenCreated[idx];
-            if (!b)
-                return false;
+        for (let idx: number = 0, len: number = this.noteHasBeenCreated.Count; idx < len; ++idx) {
+            let b: boolean = this.noteHasBeenCreated[idx];
+            if (!b) { return false; }
         }
         return true;
     }
-}
+}

+ 35 - 33
src/MusicalScore/VoiceData/Tuplet.ts

@@ -1,34 +1,36 @@
 export class Tuplet {
-    constructor(tupletLabelNumber: number) {
-        this.tupletLabelNumber = tupletLabelNumber;
-    }
-    private tupletLabelNumber: number;
-    private notes: List<List<Note>> = new List<List<Note>>();
-    private fractions: List<Fraction> = new List<Fraction>();
-    public get TupletLabelNumber(): number {
-        return this.tupletLabelNumber;
-    }
-    public set TupletLabelNumber(value: number) {
-        this.tupletLabelNumber = value;
-    }
-    public get Notes(): List<List<Note>> {
-        return this.notes;
-    }
-    public set Notes(value: List<List<Note>>) {
-        this.notes = value;
-    }
-    public get Fractions(): List<Fraction> {
-        return this.fractions;
-    }
-    public set Fractions(value: List<Fraction>) {
-        this.fractions = value;
-    }
-    public getNoteIndex(note: Note): number {
-        var index: number = 0;
-        for (var i: number = 0; i < this.notes.Count; i++)
-            for (var j: number = 0; j < this.notes[i].Count; j++)
-                if (note == this.notes[i][j])
-                    index = i;
-        return index;
-    }
-}
+  constructor(tupletLabelNumber: number) {
+    this.tupletLabelNumber = tupletLabelNumber;
+  }
+  private tupletLabelNumber: number;
+  private notes: Note[][] = new Array();
+  private fractions: Fraction[] = new Array();
+  public get TupletLabelNumber(): number {
+    return this.tupletLabelNumber;
+  }
+  public set TupletLabelNumber(value: number) {
+    this.tupletLabelNumber = value;
+  }
+  public get Notes(): Note[][] {
+    return this.notes;
+  }
+  public set Notes(value: Note[][]) {
+    this.notes = value;
+  }
+  public get Fractions(): Fraction[] {
+    return this.fractions;
+  }
+  public set Fractions(value: Fraction[]) {
+    this.fractions = value;
+  }
+  public getNoteIndex(note: Note): number {
+    for (let i: number = this.notes.length - 1; i >= 0; i--) {
+      for (let j: number = 0; j < this.notes[i].length; j++) {
+        if (note === this.notes[i][j]) {
+          return i;
+        }
+      }
+    }
+    return 0;
+  }
+}

+ 17 - 15
src/MusicalScore/VoiceData/VerticalSourceStaffEntryContainer.ts

@@ -7,25 +7,32 @@ export class VerticalSourceStaffEntryContainer {
     }
     private timestamp: Fraction;
     private size: number;
-    private staffEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
-    private comments: List<Comment> = new List<Comment>();
+    private staffEntries: SourceStaffEntry[] = new Array();
+    private comments: Comment[] = new Array();
     private parentMeasure: SourceMeasure;
+
+    public $get$(index: number): SourceStaffEntry {
+        return this.staffEntries[index];
+    }
+    public $set$(index: number, value: SourceStaffEntry): void {
+        this.staffEntries[index] = value;
+    }
     public get Timestamp(): Fraction {
         return this.timestamp;
     }
     public set Timestamp(value: Fraction) {
         this.timestamp = value;
     }
-    public get StaffEntries(): List<SourceStaffEntry> {
+    public get StaffEntries(): SourceStaffEntry[] {
         return this.staffEntries;
     }
-    public set StaffEntries(value: List<SourceStaffEntry>) {
+    public set StaffEntries(value: SourceStaffEntry[]) {
         this.staffEntries = value;
     }
-    public get Comments(): List<Comment> {
+    public get Comments(): Comment[] {
         return this.comments;
     }
-    public set Comments(value: List<Comment>) {
+    public set Comments(value: Comment[]) {
         this.comments = value;
     }
     public get ParentMeasure(): SourceMeasure {
@@ -38,13 +45,8 @@ export class VerticalSourceStaffEntryContainer {
         return new Fraction(this.timestamp + this.parentMeasure.AbsoluteTimestamp);
     }
     private initialize(): void {
-        for (var i: number = 0; i < this.size; i++)
-            this.staffEntries.Add(null);
-    }
-    public $get$(index: number): SourceStaffEntry {
-        return this.staffEntries[index];
-    }
-    public $set$(index: number, value: SourceStaffEntry): void {
-        this.staffEntries[index] = value;
+        for (let i: number = 0; i < this.size; i++) {
+            this.staffEntries.Add();
+        }
     }
-}
+}

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

@@ -6,14 +6,14 @@ export class Voice {
         this.following = true;
         this.voiceId = voiceId;
     }
-    private voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+    private voiceEntries: VoiceEntry[] = new Array();
     private parent: Instrument;
     private visible: boolean;
     private audible: boolean;
     private following: boolean;
     private voiceId: number;
     private volume: number = 1;
-    public get VoiceEntries(): List<VoiceEntry> {
+    public get VoiceEntries(): VoiceEntry[] {
         return this.voiceEntries;
     }
     public get Parent(): Instrument {
@@ -46,4 +46,4 @@ export class Voice {
     public set Volume(value: number) {
         this.volume = value;
     }
-}
+}

+ 285 - 314
src/MusicalScore/VoiceData/VoiceEntry.ts

@@ -1,332 +1,303 @@
 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>;
-    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 ornamentContainer: OrnamentContainer;
-    public get ParentSourceStaffEntry(): SourceStaffEntry {
-        return this.parentSourceStaffEntry;
-    }
-    public get ParentVoice(): Voice {
-        return this.parentVoice;
-    }
-    public get Timestamp(): Fraction {
-        return this.timestamp;
-    }
-    public set Timestamp(value: Fraction) {
-        this.timestamp = value;
-    }
-    public get Notes(): List<Note> {
-        return this.notes;
-    }
-    public get Articulations(): List<ArticulationEnum> {
-        return this.articulations;
-    }
-    public get TechnicalInstructions(): List<TechnicalInstruction> {
-        return this.technicalInstructions;
+  constructor(timestamp: Fraction, parentVoice: Voice, parentSourceStaffEntry: SourceStaffEntry) {
+    this.timestamp = timestamp;
+    this.parentVoice = parentVoice;
+    this.parentSourceStaffEntry = parentSourceStaffEntry;
+  }
+  public GraceVoiceEntriesBefore: List<VoiceEntry>;
+  public GraceVoiceEntriesAfter: List<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 ornamentContainer: OrnamentContainer;
+  public get ParentSourceStaffEntry(): SourceStaffEntry {
+    return this.parentSourceStaffEntry;
+  }
+  public get ParentVoice(): Voice {
+    return this.parentVoice;
+  }
+  public get Timestamp(): Fraction {
+    return this.timestamp;
+  }
+  public set Timestamp(value: Fraction) {
+    this.timestamp = value;
+  }
+  public get Notes(): List<Note> {
+    return this.notes;
+  }
+  public get Articulations(): List<ArticulationEnum> {
+    return this.articulations;
+  }
+  public get TechnicalInstructions(): List<TechnicalInstruction> {
+    return this.technicalInstructions;
+  }
+  public get LyricsEntries(): Dictionary<number, LyricsEntry> {
+    return this.lyricsEntries;
+  }
+  public set LyricsEntries(value: Dictionary<number, LyricsEntry>) {
+    this.lyricsEntries = value;
+  }
+  public get ArpeggiosNotesIndices(): List<number> {
+    return this.arpeggiosNotesIndices;
+  }
+  public set ArpeggiosNotesIndices(value: List<number>) {
+    this.arpeggiosNotesIndices = value;
+  }
+  public get OrnamentContainer(): OrnamentContainer {
+    return this.ornamentContainer;
+  }
+  public set OrnamentContainer(value: OrnamentContainer) {
+    this.ornamentContainer = value;
+  }
+  public static isSupportedArticulation(articulation: ArticulationEnum): boolean {
+    switch (articulation) {
+      case ArticulationEnum.accent:
+      case ArticulationEnum.strongaccent:
+      case ArticulationEnum.invertedstrongaccent:
+      case ArticulationEnum.staccato:
+      case ArticulationEnum.staccatissimo:
+      case ArticulationEnum.spiccato:
+      case ArticulationEnum.tenuto:
+      case ArticulationEnum.fermata:
+      case ArticulationEnum.invertedfermata:
+      case ArticulationEnum.breathmark:
+      case ArticulationEnum.caesura:
+      case ArticulationEnum.lefthandpizzicato:
+      case ArticulationEnum.naturalharmonic:
+      case ArticulationEnum.snappizzicato:
+      case ArticulationEnum.upbow:
+      case ArticulationEnum.downbow:
+        return true;
+      default:
+        return false;
     }
-    public get LyricsEntries(): Dictionary<number, LyricsEntry> {
-        return this.lyricsEntries;
+  }
+  public hasTie(): boolean {
+    for (let idx: number = 0, len: number = this.Notes.Count; idx < len; ++idx) {
+      let note: Note = this.Notes[idx];
+      if (note.NoteTie !== undefined) { return true; }
     }
-    public set LyricsEntries(value: Dictionary<number, LyricsEntry>) {
-        this.lyricsEntries = value;
+    return false;
+  }
+  public hasSlur(): boolean {
+    for (let idx: number = 0, len: number = this.Notes.Count; idx < len; ++idx) {
+      let note: Note = this.Notes[idx];
+      if (note.NoteSlurs.Count > 0) { return true; }
     }
-    public get ArpeggiosNotesIndices(): List<number> {
-        return this.arpeggiosNotesIndices;
+    return false;
+  }
+  public isStaccato(): boolean {
+    for (let idx: number = 0, len: number = this.Articulations.Count; idx < len; ++idx) {
+      let articulation: ArticulationEnum = this.Articulations[idx];
+      if (articulation === ArticulationEnum.staccato) { return true; }
     }
-    public set ArpeggiosNotesIndices(value: List<number>) {
-        this.arpeggiosNotesIndices = value;
+    return false;
+  }
+  public isAccent(): boolean {
+    for (let idx: number = 0, len: number = this.Articulations.Count; idx < len; ++idx) {
+      let articulation: ArticulationEnum = this.Articulations[idx];
+      if (articulation === ArticulationEnum.accent || articulation === ArticulationEnum.strongaccent) {
+        return true;
+      }
     }
-    public get OrnamentContainer(): OrnamentContainer {
-        return this.ornamentContainer;
+    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;
+      } // FIXME
     }
-    public set OrnamentContainer(value: OrnamentContainer) {
-        this.ornamentContainer = value;
+    return key;
+  }
+  public createVoiceEntriesForOrnament(activeKey: KeyInstruction): List<VoiceEntry> {
+    return this.createVoiceEntriesForOrnament(this, activeKey);
+  }
+  public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): List<VoiceEntry> {
+    let voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+    if (voiceEntryWithOrnament.ornamentContainer === undefined) {
+      return;
     }
-    public static isSupportedArticulation(articulation: ArticulationEnum): boolean {
-        switch (articulation) {
-            case ArticulationEnum.accent:
-            case ArticulationEnum.strongaccent:
-            case ArticulationEnum.invertedstrongaccent:
-            case ArticulationEnum.staccato:
-            case ArticulationEnum.staccatissimo:
-            case ArticulationEnum.spiccato:
-            case ArticulationEnum.tenuto:
-            case ArticulationEnum.fermata:
-            case ArticulationEnum.invertedfermata:
-            case ArticulationEnum.breathmark:
-            case ArticulationEnum.caesura:
-            case ArticulationEnum.lefthandpizzicato:
-            case ArticulationEnum.naturalharmonic:
-            case ArticulationEnum.snappizzicato:
-            case ArticulationEnum.upbow:
-            case ArticulationEnum.downbow:
-                return true;
-            default:
-                return false;
+    let baseNote: Note = this.notes[0];
+    let baselength: Fraction = baseNote.calculateNoteLengthWithoutTie();
+    let baseVoice: Voice = voiceEntryWithOrnament.ParentVoice;
+    let baseTimestamp: Fraction = voiceEntryWithOrnament.Timestamp;
+    let currentTimestamp: Fraction = new Fraction(baseTimestamp);
+    let length: Fraction;
+    switch (voiceEntryWithOrnament.ornamentContainer.GetOrnament) {
+      case OrnamentEnum.Trill: {
+          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) {
+            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);
+              this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
+            } else {
+              currentTimestamp = baseTimestamp + new Fraction(i * length.Numerator, length.Denominator);
+              this.createAlteratedVoiceEntry(
+                currentTimestamp, length, baseVoice, higherPitch, alteration, voiceEntries
+              );
+            }
+          }
         }
-    }
-    public hasTie(): boolean {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var note: Note = this.Notes[idx];
-            if (note.NoteTie != null)
-                return true;
+        break;
+      case OrnamentEnum.Turn: {
+          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 higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
+          this.createAlteratedVoiceEntry(
+            currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries
+          );
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(
+            currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration, voiceEntries
+          );
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return false;
-    }
-    public hasSlur(): boolean {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var note: Note = this.Notes[idx];
-            if (note.NoteSlurs.Count > 0)
-                return true;
+        break;
+      case OrnamentEnum.InvertedTurn: {
+          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 higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
+          this.createAlteratedVoiceEntry(
+            currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration, voiceEntries
+          );
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(
+            currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries
+          );
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return false;
-    }
-    public isStaccato(): boolean {
-        for (var idx: number = 0, len = this.Articulations.Count; idx < len; ++idx) {
-            var articulation: ArticulationEnum = this.Articulations[idx];
-            if (articulation == ArticulationEnum.staccato)
-                return true;
+        break;
+      case OrnamentEnum.DelayedTurn: {
+          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);
+          length.Denominator = baselength.Denominator * 8;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries);
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration, voiceEntries);
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return false;
-    }
-    public isAccent(): boolean {
-        for (var idx: number = 0, len = this.Articulations.Count; idx < len; ++idx) {
-            var articulation: ArticulationEnum = this.Articulations[idx];
-            if (articulation == ArticulationEnum.accent || articulation == ArticulationEnum.strongaccent)
-                return true;
+        break;
+      case OrnamentEnum.DelayedInvertedTurn: {
+          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);
+          length.Denominator = baselength.Denominator * 8;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration, voiceEntries);
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration, voiceEntries);
+          currentTimestamp += length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return false;
-    }
-    public getVerseNumberForLyricEntry(lyricsEntry: LyricsEntry): number {
-        var key: number = 1;
-        var lyricsEntriesArr: KeyValuePair<number, LyricsEntry>[] = this.lyricsEntries.ToArray();
-        for (var idx: number = 0, len = lyricsEntriesArr.length; idx < len; ++idx) {
-            var keyValuePair: KeyValuePair<number, LyricsEntry> = lyricsEntriesArr[idx];
-            if (lyricsEntry == keyValuePair.Value)
-                key = keyValuePair.Key;
+        break;
+      case OrnamentEnum.Mordent: {
+          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);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, alteration, voiceEntries);
+          length.Denominator = baselength.Denominator * 2;
+          currentTimestamp = baseTimestamp + length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return key;
-    }
-    public createVoiceEntriesForOrnament(activeKey: KeyInstruction): List<VoiceEntry> {
-        return this.createVoiceEntriesForOrnament(this, activeKey);
-    }
-    public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry,
-        activeKey: KeyInstruction): List<VoiceEntry> {
-        var voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
-        if (voiceEntryWithOrnament.ornamentContainer == null)
-            return null;
-        var baseNote: Note = this.notes[0];
-        var baselength: Fraction = baseNote.calculateNoteLengthWithoutTie();
-        var baseVoice: Voice = voiceEntryWithOrnament.ParentVoice;
-        var baseTimestamp: Fraction = voiceEntryWithOrnament.Timestamp;
-        var currentTimestamp: Fraction = new Fraction(baseTimestamp);
-        var length: Fraction;
-        switch (voiceEntryWithOrnament.ornamentContainer.GetOrnament) {
-            case OrnamentEnum.Trill:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 8);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    if (voiceEntryWithOrnament.OrnamentContainer.AccidentalAbove != AccEnum.NONE)
-                        alteration = <AccidentalEnum><number>voiceEntryWithOrnament.ornamentContainer.AccidentalAbove;
-                    for (var i: number = 0; i < 8; i++) {
-                        if ((i % 2) == 0) {
-                            currentTimestamp = 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);
-                            this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, alteration,
-                                voiceEntries);
-                        }
-                    }
-                    break;
-                }
-            case OrnamentEnum.Turn:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
-                    var lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
-                    var lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            case OrnamentEnum.InvertedTurn:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
-                    var lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
-                    var lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            case OrnamentEnum.DelayedTurn:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
-                    var lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
-                    var lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp = baseTimestamp + new Fraction(length);
-                    length.Denominator = baselength.Denominator * 8;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            case OrnamentEnum.DelayedInvertedTurn:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 2);
-                    var lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
-                    var lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var higherAlteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp = baseTimestamp + new Fraction(length);
-                    length.Denominator = baselength.Denominator * 8;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, lowerAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, higherAlteration,
-                        voiceEntries);
-                    currentTimestamp += length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            case OrnamentEnum.Mordent:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
-                    var higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
-                    var alteration: AccidentalEnum = activeKey.getAlterationForPitch(higherPitch);
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, higherPitch, alteration,
-                        voiceEntries);
-                    length.Denominator = baselength.Denominator * 2;
-                    currentTimestamp = baseTimestamp + length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            case OrnamentEnum.InvertedMordent:
-                {
-                    length = new Fraction(baselength.Numerator, baselength.Denominator * 4);
-                    var lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
-                    var alteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    currentTimestamp += length;
-                    this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, alteration, voiceEntries);
-                    length.Denominator = baselength.Denominator * 2;
-                    currentTimestamp = baseTimestamp + length;
-                    this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
-                    break;
-                }
-            default:
-                throw new ArgumentOutOfRangeException();
+        break;
+      case OrnamentEnum.InvertedMordent: {
+          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);
+          currentTimestamp += length;
+          this.createAlteratedVoiceEntry(currentTimestamp, length, baseVoice, lowerPitch, alteration, voiceEntries);
+          length.Denominator = baselength.Denominator * 2;
+          currentTimestamp = baseTimestamp + length;
+          this.createBaseVoiceEntry(currentTimestamp, length, baseVoice, baseNote, voiceEntries);
         }
-        return voiceEntries;
-    }
-    private createBaseVoiceEntry(currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, baseNote: Note,
-        voiceEntries: List<VoiceEntry>): void {
-        var voiceEntry: VoiceEntry = new VoiceEntry(currentTimestamp, baseVoice, baseNote.ParentStaffEntry);
-        var pitch: Pitch = new Pitch(baseNote.Pitch.FundamentalNote, baseNote.Pitch.Octave, baseNote.Pitch.Accidental);
-        var note: Note = new Note(voiceEntry, null, length, pitch);
-        voiceEntry.Notes.Add(note);
-        voiceEntries.Add(voiceEntry);
-    }
-    private createAlteratedVoiceEntry(currentTimestamp: Fraction, length: Fraction, baseVoice: Voice,
-        higherPitch: Pitch, alteration: AccidentalEnum, voiceEntries: List<VoiceEntry>): void {
-        var voiceEntry: VoiceEntry = new VoiceEntry(currentTimestamp, baseVoice, null);
-        var pitch: Pitch = new Pitch(higherPitch.FundamentalNote, higherPitch.Octave, alteration);
-        var note: Note = new Note(voiceEntry, null, length, pitch);
-        voiceEntry.Notes.Add(note);
-        voiceEntries.Add(voiceEntry);
+        break;
+      default:
+        throw new ArgumentOutOfRangeException();
     }
+    return voiceEntries;
+  }
+  private createBaseVoiceEntry(
+    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, baseNote: Note, voiceEntries: List<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);
+  }
+  private createAlteratedVoiceEntry(
+    currentTimestamp: Fraction, length: Fraction, baseVoice: Voice, higherPitch: Pitch, alteration: AccidentalEnum, voiceEntries: List<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);
+  }
 }
 export enum ArticulationEnum {
-    accent,
-
-    strongaccent,
-
-    invertedstrongaccent,
-
-    staccato,
-
-    staccatissimo,
-
-    spiccato,
-
-    tenuto,
-
-    fermata,
-
-    invertedfermata,
-
-    breathmark,
-
-    caesura,
-
-    lefthandpizzicato,
-
-    naturalharmonic,
-
-    snappizzicato,
-
-    upbow,
-
-    downbow,
-
-    scoop,
-
-    plop,
-
-    doit,
-
-    falloff,
-
-    stress,
-
-    unstress,
-
-    detachedlegato,
-
-    otherarticulation
-}
+  accent,
+  strongaccent,
+  invertedstrongaccent,
+  staccato,
+  staccatissimo,
+  spiccato,
+  tenuto,
+  fermata,
+  invertedfermata,
+  breathmark,
+  caesura,
+  lefthandpizzicato,
+  naturalharmonic,
+  snappizzicato,
+  upbow,
+  downbow,
+  scoop,
+  plop,
+  doit,
+  falloff,
+  stress,
+  unstress,
+  detachedlegato,
+  otherarticulation
+}

+ 1 - 1
tslint.json

@@ -64,7 +64,7 @@
     "no-trailing-whitespace": true,
     "no-unreachable": true,
     "no-unused-expression": true,
-    "no-unused-variable": false,
+    "no-unused-variable": true,
     "no-use-before-declare": true,
     "no-var-keyword": true,
     "no-var-requires": true,