ソースを参照

Fixing types & imports pt.3

Andrea Condoluci 9 年 前
コミット
e8cdb610ba

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

@@ -55,6 +55,10 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
         return a;
     }
 
+    public clone(): Fraction {
+        return new Fraction(this.numerator, this.denominator, false);
+    }
+
     public get Numerator(): number {
         return this.numerator;
     }

+ 30 - 32
src/MusicalScore/MusicParts/MusicPartManager.ts

@@ -4,8 +4,6 @@ import { Repetition } from "../MusicSource/Repetition"
 import { Fraction } from "../../Common/DataObjects/fraction"
 import { MusicPartManagerIterator } from "./MusicPartManagerIterator"
 
-type TimestampTransform = any;
-
 export class MusicPartManager /*implements ISelectionListener*/ {
     constructor(musicSheet: MusicSheet) {
         this.musicSheet = musicSheet;
@@ -39,7 +37,7 @@ export class MusicPartManager /*implements ISelectionListener*/ {
             return timestamp;
         }
         let transform: TimestampTransform = this.getCurrentRepetitionTimestampTransform(timestamp);
-        return Fraction.plus(timestamp, <any>(transform.to - transform.$from)); // FIXME
+        return Fraction.plus(timestamp, Fraction.minus(transform.to, transform.$from)); // FIXME
     }
     public get Parts(): PartListEntry[] {
         return this.parts;
@@ -62,16 +60,16 @@ export class MusicPartManager /*implements ISelectionListener*/ {
         this.musicSheet.SelectionEnd = end === undefined ? this.sheetEnd : end;
     }
     private calcMapping(): void {
-        this.timestamps = new Array();
+        let timestamps: TimestampTransform[] = new Array();
         let iterator: MusicPartManagerIterator = this.getIterator();
         let currentRepetition: Repetition = iterator.CurrentRepetition;
         let curTimestampTransform: TimestampTransform = new TimestampTransform(
-            new Fraction(iterator.CurrentEnrolledTimestamp),
-            new Fraction(iterator.CurrentSourceTimestamp),
+            iterator.CurrentEnrolledTimestamp.clone(),
+            iterator.CurrentSourceTimestamp.clone(),
             undefined,
-            0,
+            0
         );
-        this.timestamps.push(curTimestampTransform);
+        timestamps.push(curTimestampTransform);
         while (!iterator.EndReached) {
             if (iterator.JumpOccurred || currentRepetition !== iterator.CurrentRepetition) {
                 currentRepetition = iterator.CurrentRepetition;
@@ -81,42 +79,42 @@ export class MusicPartManager /*implements ISelectionListener*/ {
                     curTimestampTransform.curRepetition = jumpRep;
                     curTimestampTransform.curRepetitionIteration = iterator.CurrentJumpResponsibleRepetitionIterationBeforeJump;
                     for (let i: number = this.timestamps.length - 2; i >= 0; i--) {
-                        if (jumpRep.AbsoluteTimestamp > this.timestamps[i].to || this.timestamps[i].curRepetition !== undefined) {
+                        if (jumpRep.AbsoluteTimestamp > timestamps[i].to || timestamps[i].curRepetition !== undefined) {
                             break;
                         }
-                        this.timestamps[i].nextBackJump = curTimestampTransform.nextBackJump;
-                        this.timestamps[i].curRepetition = jumpRep;
-                        this.timestamps[i].curRepetitionIteration = curTimestampTransform.curRepetitionIteration;
+                        timestamps[i].nextBackJump = curTimestampTransform.nextBackJump;
+                        timestamps[i].curRepetition = jumpRep;
+                        timestamps[i].curRepetitionIteration = curTimestampTransform.curRepetitionIteration;
                     }
                 }
                 curTimestampTransform = new TimestampTransform(
-                    new Fraction(iterator.CurrentEnrolledTimestamp),
-                    new Fraction(iterator.CurrentSourceTimestamp),
+                    iterator.CurrentEnrolledTimestamp.clone(),
+                    iterator.CurrentSourceTimestamp.clone(),
                     undefined,
-                    0,
+                    0
                 );
-                this.timestamps.push(curTimestampTransform);
+                timestamps.push(curTimestampTransform);
             }
             iterator.moveToNext();
         }
+        this.timestamps = timestamps;
     }
 }
 
-export module MusicPartManager {
-    class TimestampTransform {
-        constructor(sourceTimestamp: Fraction, enrolledTimestamp: Fraction, repetition: Repetition, curRepetitionIteration: number) {
-            this.$from = sourceTimestamp;
-            this.to = enrolledTimestamp;
-            this.curRepetition = repetition;
-            this.curRepetitionIteration = curRepetitionIteration;
-            this.nextBackJump = undefined;
-            this.nextForwardJump = undefined;
-        }
-        public $from: Fraction;
-        public to: Fraction;
-        public nextBackJump: Fraction;
-        public nextForwardJump: Fraction;
-        public curRepetition: Repetition;
-        public curRepetitionIteration: number;
+
+class TimestampTransform {
+    constructor(sourceTimestamp: Fraction, enrolledTimestamp: Fraction, repetition: Repetition, curRepetitionIteration: number) {
+        this.$from = sourceTimestamp;
+        this.to = enrolledTimestamp;
+        this.curRepetition = repetition;
+        this.curRepetitionIteration = curRepetitionIteration;
+        this.nextBackJump = undefined;
+        this.nextForwardJump = undefined;
     }
+    public $from: Fraction;
+    public to: Fraction;
+    public nextBackJump: Fraction;
+    public nextForwardJump: Fraction;
+    public curRepetition: Repetition;
+    public curRepetitionIteration: number;
 }

+ 112 - 96
src/MusicalScore/MusicParts/MusicPartManagerIterator.ts

@@ -1,3 +1,22 @@
+import {MusicPartManager} from "./MusicPartManager";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {Repetition} from "../MusicSource/Repetition";
+import {DynamicsContainer} from "../VoiceData/HelperObjects/DynamicsContainer";
+import {MappingSourceMusicPart} from "../MusicSource/MappingSourceMusicPart";
+import {SourceMeasure} from "../VoiceData/SourceMeasure";
+import {VoiceEntry} from "../VoiceData/VoiceEntry";
+import {Instrument} from "../Instrument";
+import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
+import {VerticalSourceStaffEntryContainer} from "../VoiceData/VerticalSourceStaffEntryContainer";
+import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
+import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
+
+// FIXME:
+type ContinuousDynamicExpression = AbstractExpression;
+type InstantaniousDynamicExpression = AbstractExpression;
+type MultiTempoExpression = any;
+type AbstractExpression = any;
+
 export class MusicPartManagerIterator {
     constructor(manager: MusicPartManager, startTimestamp?: Fraction, endTimestamp?: Fraction) {
         try {
@@ -5,27 +24,28 @@ export class MusicPartManagerIterator {
             this.manager = manager;
             this.currentVoiceEntries = undefined;
             this.frontReached = false;
-            for (let idx: number = 0, len: number = manager.MusicSheet.Repetitions.Count; idx < len; ++idx) {
-                let rep: Repetition = manager.MusicSheet.Repetitions[idx];
-                this.repetitionIterationCountDict.Add(rep, 1);
-            }
-            for (let i: number = 0; i < manager.MusicSheet.getCompleteNumberOfStaves(); i++) {
-                this.activeDynamicExpressions.Add(undefined);
+            for (let rep of manager.MusicSheet.Repetitions.length) {
+                this.repetitionIterationCountDict[rep] = 1;
             }
+            this.activeDynamicExpressions = new Array(manager.MusicSheet.getCompleteNumberOfStaves());
             this.currentMeasure = this.manager.MusicSheet.SourceMeasures[0];
             if (startTimestamp === undefined) { return; }
             do {
                 this.moveToNext();
             } while ((this.currentVoiceEntries === undefined || this.currentTimeStamp < startTimestamp) && !this.endReached);
-            for (let staffIndex: number = 0; staffIndex < this.activeDynamicExpressions.Count; staffIndex++) {
+            for (let staffIndex: number = 0; staffIndex < this.activeDynamicExpressions.length; staffIndex++) {
                 if (this.activeDynamicExpressions[staffIndex] !== undefined) {
+                    /*
                     if (this.activeDynamicExpressions[staffIndex] instanceof ContinuousDynamicExpression) {
-                        let continuousDynamic: ContinuousDynamicExpression = <ContinuousDynamicExpression>this.activeDynamicExpressions[staffIndex];
-                        this.currentDynamicChangingExpressions.Add(new DynamicsContainer(continuousDynamic, staffIndex));
+                        let continuousDynamic: ContinuousDynamicExpression =
+                            <ContinuousDynamicExpression>this.activeDynamicExpressions[staffIndex];
+                        this.currentDynamicChangingExpressions.push(new DynamicsContainer(continuousDynamic, staffIndex));
                     } else {
-                        let instantaniousDynamic: InstantaniousDynamicExpression = <InstantaniousDynamicExpression>this.activeDynamicExpressions[staffIndex];
-                        this.currentDynamicChangingExpressions.Add(new DynamicsContainer(instantaniousDynamic, staffIndex));
+                        let instantaniousDynamic: InstantaniousDynamicExpression =
+                            <InstantaniousDynamicExpression>this.activeDynamicExpressions[staffIndex];
+                        this.currentDynamicChangingExpressions.push(new DynamicsContainer(instantaniousDynamic, staffIndex));
                     }
+                    */ // FIXME TODO DynamicExpression problems!
                 }
             }
             this.currentTempoChangingExpression = this.activeTempoExpression;
@@ -44,18 +64,18 @@ export class MusicPartManagerIterator {
     private currentVoiceEntryIndex: number = -1;
     private currentDynamicEntryIndex: number = 0;
     private currentTempoEntryIndex: number = 0;
-    private currentVoiceEntries: List<VoiceEntry>;
-    private currentDynamicChangingExpressions: List<DynamicsContainer> = new List<DynamicsContainer>();
+    private currentVoiceEntries: VoiceEntry[];
+    private currentDynamicChangingExpressions: DynamicsContainer[] = new Array();
     private currentTempoChangingExpression: MultiTempoExpression;
-    private repetitionIterationCountDict: Dictionary<Repetition, number> = new Dictionary<Repetition, number>();
+    private repetitionIterationCountDict: { [rep: Repetition] : number; } = {};
     private currentRepetition: Repetition = undefined;
     private endReached: boolean = false;
     private frontReached: boolean = false;
-    private currentTimeStamp: Fraction = new Fraction(new Fraction(0, 1));
-    private currentEnrolledMeasureTimestamp: Fraction = new Fraction(new Fraction(0, 1));
-    private currentVerticalContainerInMeasureTimestamp: Fraction = new Fraction(new Fraction(0, 1));
+    private currentTimeStamp: Fraction = new Fraction(0, 1);
+    private currentEnrolledMeasureTimestamp: Fraction = new Fraction(0, 1);
+    private currentVerticalContainerInMeasureTimestamp: Fraction = new Fraction(0, 1);
     private jumpResponsibleRepetition: Repetition = undefined;
-    private activeDynamicExpressions: List<AbstractExpression> = new List<AbstractExpression>();
+    private activeDynamicExpressions: AbstractExpression[] = new Array();
     private activeTempoExpression: MultiTempoExpression;
     public get EndReached(): boolean {
         return this.endReached;
@@ -81,7 +101,7 @@ export class MusicPartManagerIterator {
         }
         return 0;
     }
-    public get CurrentVoiceEntries(): List<VoiceEntry> {
+    public get CurrentVoiceEntries(): VoiceEntry[] {
         return this.currentVoiceEntries;
     }
     public get CurrentMeasureIndex(): number {
@@ -99,7 +119,7 @@ export class MusicPartManagerIterator {
     public get ActiveTempoExpression(): MultiTempoExpression {
         return this.activeTempoExpression;
     }
-    public get ActiveDynamicExpressions(): List<AbstractExpression> {
+    public get ActiveDynamicExpressions(): AbstractExpression[] {
         return this.activeDynamicExpressions;
     }
     public get CurrentTempoChangingExpression(): MultiTempoExpression {
@@ -118,12 +138,12 @@ export class MusicPartManagerIterator {
         ret.frontReached = this.frontReached;
         return ret;
     }
-    public CurrentVisibleVoiceEntries(instrument: Instrument): List<VoiceEntry> {
-        let ret: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentVisibleVoiceEntries(instrument: Instrument): VoiceEntry[] {
+        let ret: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries === undefined) {
             return ret;
         }
-        for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
             let entry: VoiceEntry = this.currentVoiceEntries[idx];
             if (entry.ParentVoice.Parent.IdString === instrument.IdString) {
                 this.getVisibleEntries(entry, ret);
@@ -132,22 +152,22 @@ export class MusicPartManagerIterator {
         }
         return ret;
     }
-    public CurrentVisibleVoiceEntries(): List<VoiceEntry> {
-        let voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentVisibleVoiceEntries(): VoiceEntry[] {
+        let voiceEntries: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries !== undefined) {
-            for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+            for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
                 let entry: VoiceEntry = this.currentVoiceEntries[idx];
                 this.getVisibleEntries(entry, voiceEntries);
             }
         }
         return voiceEntries;
     }
-    public CurrentAudibleVoiceEntries(instrument: Instrument): List<VoiceEntry> {
-        let ret: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentAudibleVoiceEntries(instrument: Instrument): VoiceEntry[] {
+        let ret: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries === undefined) {
             return ret;
         }
-        for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
             let entry: VoiceEntry = this.currentVoiceEntries[idx];
             if (entry.ParentVoice.Parent.IdString === instrument.IdString) {
                 this.getAudibleEntries(entry, ret);
@@ -156,25 +176,25 @@ export class MusicPartManagerIterator {
         }
         return ret;
     }
-    public CurrentAudibleVoiceEntries(): List<VoiceEntry> {
-        let voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentAudibleVoiceEntries(): VoiceEntry[] {
+        let voiceEntries: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries !== undefined) {
-            for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+            for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
                 let entry: VoiceEntry = this.currentVoiceEntries[idx];
                 this.getAudibleEntries(entry, voiceEntries);
             }
         }
         return voiceEntries;
     }
-    public getCurrentDynamicChangingExpressions(): List<DynamicsContainer> {
+    public getCurrentDynamicChangingExpressions(): DynamicsContainer[] {
         return this.currentDynamicChangingExpressions;
     }
-    public CurrentScoreFollowingVoiceEntries(instrument: Instrument): List<VoiceEntry> {
-        let ret: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentScoreFollowingVoiceEntries(instrument: Instrument): VoiceEntry[] {
+        let ret: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries === undefined) {
             return ret;
         }
-        for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
             let entry: VoiceEntry = this.currentVoiceEntries[idx];
             if (entry.ParentVoice.Parent.IdString === instrument.IdString) {
                 this.getScoreFollowingEntries(entry, ret);
@@ -183,24 +203,24 @@ export class MusicPartManagerIterator {
         }
         return ret;
     }
-    public CurrentScoreFollowingVoiceEntries(): List<VoiceEntry> {
-        let voiceEntries: List<VoiceEntry> = new List<VoiceEntry>();
+    public CurrentScoreFollowingVoiceEntries(): VoiceEntry[] {
+        let voiceEntries: VoiceEntry[] = new Array();
         if (this.currentVoiceEntries !== undefined) {
-            for (let idx: number = 0, len: number = this.currentVoiceEntries.Count; idx < len; ++idx) {
+            for (let idx: number = 0, len: number = this.currentVoiceEntries.length; idx < len; ++idx) {
                 let entry: VoiceEntry = this.currentVoiceEntries[idx];
                 this.getScoreFollowingEntries(entry, voiceEntries);
             }
         }
         return voiceEntries;
     }
-    public currentPlaybackSettings(): PlaybackSettings {
-        return this.manager.MusicSheet.SheetPlaybackSetting;
-    }
+    //public currentPlaybackSettings(): PlaybackSettings {
+    //    return this.manager.MusicSheet.SheetPlaybackSetting;
+    //}
     public moveToNext(): void {
         this.ForwardJumpOccurred = this.BackJumpOccurred = false;
         if (this.endReached) { return; }
         if (this.currentVoiceEntries !== undefined) {
-            this.currentVoiceEntries.Clear();
+            this.currentVoiceEntries = [];
         }
         this.recursiveMove();
         if (this.currentMeasure === undefined) {
@@ -218,24 +238,20 @@ export class MusicPartManagerIterator {
         return 1;
     }
     private incrementRepetitionIterationCount(repetition: Repetition): number {
-        if (this.repetitionIterationCountDict.ContainsKey(repetition)) {
+        if (this.repetitionIterationCountDict[repetition] !== undefined) {
             let newIteration: number = this.repetitionIterationCountDict[repetition] + 1;
             this.repetitionIterationCountDict[repetition] = newIteration;
             return newIteration;
         } else {
-            this.repetitionIterationCountDict.Add(repetition, 1);
+            this.repetitionIterationCountDict[repetition] = 1;
             return 1;
         }
     }
     private setRepetitionIterationCount(repetition: Repetition, iterationCount: number): void {
-        if (this.repetitionIterationCountDict.ContainsKey(repetition)) {
-            this.repetitionIterationCountDict[repetition] = iterationCount;
-        } else {
-            this.repetitionIterationCountDict.Add(repetition, iterationCount);
-        }
+        this.repetitionIterationCountDict[repetition] = iterationCount;
     }
 /*    private moveTempoIndexToTimestamp(measureNumber: number): void {
-        for (let index: number = 0; index < this.manager.MusicSheet.TimestampSortedTempoExpressionsList.Count; index++) {
+        for (let index: number = 0; index < this.manager.MusicSheet.TimestampSortedTempoExpressionsList.length; index++) {
             if (this.manager.MusicSheet.TimestampSortedTempoExpressionsList[index].SourceMeasureParent.MeasureNumber >= measureNumber) {
                 this.currentTempoEntryIndex = Math.Max(-1, index - 1);
                 return
@@ -243,7 +259,7 @@ export class MusicPartManagerIterator {
         }
     }
     private getNextTempoEntryTimestamp(): Fraction {
-        if (this.currentTempoEntryIndex >= this.manager.MusicSheet.TimestampSortedTempoExpressionsList.Count - 1) {
+        if (this.currentTempoEntryIndex >= this.manager.MusicSheet.TimestampSortedTempoExpressionsList.length - 1) {
             return new Fraction(99999, 1);
         }
         return this.manager.MusicSheet.TimestampSortedTempoExpressionsList[this.currentTempoEntryIndex + 1].SourceMeasureParent.AbsoluteTimestamp +
@@ -253,18 +269,18 @@ export class MusicPartManagerIterator {
         this.currentDynamicEntryIndex++;
         this.currentDynamicChangingExpressions.Clear();
         let curDynamicEntry: DynamicsContainer = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList[this.currentDynamicEntryIndex];
-        this.currentDynamicChangingExpressions.Add(curDynamicEntry);
+        this.currentDynamicChangingExpressions.push(curDynamicEntry);
         let tsNow: Fraction = curDynamicEntry.parMultiExpression().AbsoluteTimestamp;
-        for (let i: number = this.currentDynamicEntryIndex + 1; i < this.manager.MusicSheet.TimestampSortedDynamicExpressionsList.Count; i++) {
+        for (let i: number = this.currentDynamicEntryIndex + 1; i < this.manager.MusicSheet.TimestampSortedDynamicExpressionsList.length; i++) {
             curDynamicEntry = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList[i];
             if ((curDynamicEntry.parMultiExpression().AbsoluteTimestamp !== tsNow)) { break; }
             this.currentDynamicEntryIndex = i;
-            this.currentDynamicChangingExpressions.Add(curDynamicEntry);
+            this.currentDynamicChangingExpressions.push(curDynamicEntry);
         }
     }
     private moveDynamicIndexToTimestamp(absoluteTimestamp: Fraction): void {
-        let dynamics: List<DynamicsContainer> = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList;
-        for (let index: number = 0; index < dynamics.Count; index++) {
+        let dynamics: DynamicsContainer[] = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList;
+        for (let index: number = 0; index < dynamics.length; index++) {
             if (dynamics[index].parMultiExpression().AbsoluteTimestamp >= absoluteTimestamp) {
                 this.currentDynamicEntryIndex = Math.Max(0, index - 1);
                 return
@@ -272,13 +288,13 @@ export class MusicPartManagerIterator {
         }
     }
     private getNextDynamicsEntryTimestamp(): Fraction {
-        if (this.currentDynamicEntryIndex >= this.manager.MusicSheet.TimestampSortedDynamicExpressionsList.Count - 1) {
+        if (this.currentDynamicEntryIndex >= this.manager.MusicSheet.TimestampSortedDynamicExpressionsList.length - 1) {
             return new Fraction(99999, 1);
         }
         return this.manager.MusicSheet.TimestampSortedDynamicExpressionsList[this.currentDynamicEntryIndex + 1].parMultiExpression().AbsoluteTimestamp;
     }
     private handleRepetitionsAtMeasureBegin(): void {
-        for (let idx: number = 0, len: number = this.currentMeasure.FirstRepetitionInstructions.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.currentMeasure.FirstRepetitionInstructions.length; idx < len; ++idx) {
             let repetitionInstruction: RepetitionInstruction = this.currentMeasure.FirstRepetitionInstructions[idx];
             if (repetitionInstruction.ParentRepetition === undefined)
                 continue;
@@ -298,11 +314,11 @@ export class MusicPartManagerIterator {
     }
 */
     private handleRepetitionsAtMeasureEnd(): void {
-        for (let idx: number = 0, len: number = this.currentMeasure.LastRepetitionInstructions.Count; idx < len; ++idx) {
+        for (let idx: number = 0, len: number = this.currentMeasure.LastRepetitionInstructions.length; idx < len; ++idx) {
             let repetitionInstruction: RepetitionInstruction = this.currentMeasure.LastRepetitionInstructions[idx];
             let currentRepetition: Repetition = repetitionInstruction.ParentRepetition;
             if (currentRepetition === undefined) { continue; }
-            if (currentRepetition.BackwardJumpInstructions.Contains(repetitionInstruction)) {
+            if (currentRepetition.BackwardJumpInstructions[repetitionInstruction] !== undefined) {
                 if (this.repetitionIterationCountDict[currentRepetition] < currentRepetition.UserNumberOfRepetitions) {
                     this.doBackJump(currentRepetition);
                     this.BackJumpOccurred = true;
@@ -350,11 +366,11 @@ export class MusicPartManagerIterator {
     private activateCurrentRhythmInstructions(): void {
         if (
           this.currentMeasure !== undefined &&
-          this.currentMeasure.FirstInstructionsStaffEntries.Count > 0 &&
+          this.currentMeasure.FirstInstructionsStaffEntries.length > 0 &&
           this.currentMeasure.FirstInstructionsStaffEntries[0] !== undefined
         ) {
-            let instructions: List<AbstractNotationInstruction> = this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;
-            for (let idx: number = 0, len: number = instructions.Count; idx < len; ++idx) {
+            let instructions: AbstractNotationInstruction[] = this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;
+            for (let idx: number = 0, len: number = instructions.length; idx < len; ++idx) {
                 let abstractNotationInstruction: AbstractNotationInstruction = instructions[idx];
                 if (abstractNotationInstruction instanceof RhythmInstruction) {
                     this.manager.MusicSheet.SheetPlaybackSetting.Rhythm = (<RhythmInstruction>abstractNotationInstruction).Rhythm;
@@ -363,23 +379,23 @@ export class MusicPartManagerIterator {
         }
     }
     private activateCurrentDynamicOrTempoInstructions(): void {
-        let timeSortedDynamics: List<DynamicsContainer> = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList;
+        let timeSortedDynamics: DynamicsContainer[] = this.manager.MusicSheet.TimestampSortedDynamicExpressionsList;
         while (
           this.currentDynamicEntryIndex > 0 && (
-            this.currentDynamicEntryIndex >= timeSortedDynamics.Count ||
+            this.currentDynamicEntryIndex >= timeSortedDynamics.length ||
             timeSortedDynamics[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp >= this.CurrentSourceTimestamp
           )
         ) {
             this.currentDynamicEntryIndex--;
         }
         while (
-          this.currentDynamicEntryIndex < timeSortedDynamics.Count &&
+          this.currentDynamicEntryIndex < timeSortedDynamics.length &&
           timeSortedDynamics[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp < this.CurrentSourceTimestamp
         ) {
             this.currentDynamicEntryIndex++;
         }
         while (
-          this.currentDynamicEntryIndex < timeSortedDynamics.Count
+          this.currentDynamicEntryIndex < timeSortedDynamics.length
           && timeSortedDynamics[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp === this.CurrentSourceTimestamp
         ) {
             let dynamicsContainer: DynamicsContainer = timeSortedDynamics[this.currentDynamicEntryIndex];
@@ -394,7 +410,7 @@ export class MusicPartManagerIterator {
             this.currentDynamicEntryIndex++;
         }
         this.currentDynamicChangingExpressions.Clear();
-        for (let staffIndex: number = 0; staffIndex < this.activeDynamicExpressions.Count; staffIndex++) {
+        for (let staffIndex: number = 0; staffIndex < this.activeDynamicExpressions.length; staffIndex++) {
             if (this.activeDynamicExpressions[staffIndex] !== undefined) {
                 let startTime: Fraction;
                 let endTime: Fraction;
@@ -403,36 +419,35 @@ export class MusicPartManagerIterator {
                     startTime = continuousDynamic.StartMultiExpression.AbsoluteTimestamp;
                     endTime = continuousDynamic.EndMultiExpression.AbsoluteTimestamp;
                     if (this.CurrentSourceTimestamp >= startTime && this.CurrentSourceTimestamp <= endTime) {
-                        this.currentDynamicChangingExpressions.Add(new DynamicsContainer(continuousDynamic, staffIndex));
+                        this.currentDynamicChangingExpressions.push(new DynamicsContainer(continuousDynamic, staffIndex));
                     }
                 } else {
                     let instantaniousDynamic: InstantaniousDynamicExpression = <InstantaniousDynamicExpression>this.activeDynamicExpressions[staffIndex];
                     if (this.CurrentSourceTimestamp === instantaniousDynamic.ParentMultiExpression.AbsoluteTimestamp) {
-                        this.currentDynamicChangingExpressions.Add(new DynamicsContainer(instantaniousDynamic, staffIndex));
+                        this.currentDynamicChangingExpressions.push(new DynamicsContainer(instantaniousDynamic, staffIndex));
                     }
                 }
             }
         }
-        let timeSortedTempoExpressions: List<MultiTempoExpression> = this.manager.MusicSheet.TimestampSortedTempoExpressionsList;
+        let timeSortedTempoExpressions: MultiTempoExpression[] = this.manager.MusicSheet.TimestampSortedTempoExpressionsList;
 
         while (this.currentTempoEntryIndex > 0 && (
-          this.currentTempoEntryIndex >= timeSortedTempoExpressions.Count
+          this.currentTempoEntryIndex >= timeSortedTempoExpressions.length
           || timeSortedTempoExpressions[this.currentTempoEntryIndex].AbsoluteTimestamp >= this.CurrentSourceTimestamp
         )) {
             this.currentTempoEntryIndex--;
         }
 
         while (
-          this.currentTempoEntryIndex < timeSortedTempoExpressions.Count &&
+          this.currentTempoEntryIndex < timeSortedTempoExpressions.length &&
           timeSortedTempoExpressions[this.currentTempoEntryIndex].AbsoluteTimestamp < this.CurrentSourceTimestamp
         ) {
             this.currentTempoEntryIndex++;
         }
 
         while (
-          this.currentTempoEntryIndex < timeSortedTempoExpressions.Count
-          && timeSortedTempoExpressions[this.currentTempoEntryIndex]
-              .AbsoluteTimestamp === this.CurrentSourceTimestamp
+          this.currentTempoEntryIndex < timeSortedTempoExpressions.length
+          && timeSortedTempoExpressions[this.currentTempoEntryIndex].AbsoluteTimestamp === this.CurrentSourceTimestamp
         ) {
             this.activeTempoExpression = timeSortedTempoExpressions[this.currentTempoEntryIndex];
             this.currentTempoEntryIndex++;
@@ -443,7 +458,10 @@ export class MusicPartManagerIterator {
             if (this.activeTempoExpression.ContinuousTempo !== undefined) {
                 endTime = this.activeTempoExpression.ContinuousTempo.AbsoluteEndTimestamp;
             }
-            if (this.CurrentSourceTimestamp >= this.activeTempoExpression.AbsoluteTimestamp || this.CurrentSourceTimestamp <= endTime) {
+            if (
+                   this.CurrentSourceTimestamp >= this.activeTempoExpression.AbsoluteTimestamp
+                || this.CurrentSourceTimestamp <= endTime
+            ) {
                 this.currentTempoChangingExpression = this.activeTempoExpression;
             }
         }
@@ -454,7 +472,7 @@ export class MusicPartManagerIterator {
             this.handleRepetitionsAtMeasureBegin();
             this.activateCurrentRhythmInstructions();
         }
-        if (this.currentVoiceEntryIndex >= 0 && this.currentVoiceEntryIndex < this.currentMeasure.VerticalSourceStaffEntryContainers.Count) {
+        if (this.currentVoiceEntryIndex >= 0 && this.currentVoiceEntryIndex < this.currentMeasure.VerticalSourceStaffEntryContainers.length) {
             let currentContainer: VerticalSourceStaffEntryContainer = this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];
             this.currentVoiceEntries = this.getVoiceEntries(currentContainer);
             this.currentVerticalContainerInMeasureTimestamp = currentContainer.Timestamp;
@@ -467,7 +485,7 @@ export class MusicPartManagerIterator {
         }
         this.currentEnrolledMeasureTimestamp.Add(this.currentMeasure.Duration);
         this.handleRepetitionsAtMeasureEnd();
-        if (this.currentMeasureIndex >= 0 && this.currentMeasureIndex < this.manager.MusicSheet.SourceMeasures.Count) {
+        if (this.currentMeasureIndex >= 0 && this.currentMeasureIndex < this.manager.MusicSheet.SourceMeasures.length) {
             this.currentMeasure = this.manager.MusicSheet.SourceMeasures[this.currentMeasureIndex];
             this.currentTimeStamp = new Fraction(this.currentMeasure.AbsoluteTimestamp + this.currentVerticalContainerInMeasureTimestamp);
             this.currentVoiceEntryIndex = -1;
@@ -480,39 +498,37 @@ export class MusicPartManagerIterator {
         this.endReached = true;
     }
     private checkEntries(notesOnly: boolean): boolean {
-        let tlist: List<VoiceEntry> = this.CurrentVisibleVoiceEntries();
-        if (tlist.Count > 0) {
+        let tlist: VoiceEntry[] = this.CurrentVisibleVoiceEntries();
+        if (tlist.length > 0) {
             if (!notesOnly) { return true; }
-            for (let idx: number = 0, len: number = tlist.Count; idx < len; ++idx) {
+            for (let idx: number = 0, len: number = tlist.length; idx < len; ++idx) {
                 let entry: VoiceEntry = tlist[idx];
                 if (entry.Notes[0].Pitch !== undefined) { return true; }
             }
         }
         return false;
     }
-    private getVisibleEntries(entry: VoiceEntry, visibleEntries: List<VoiceEntry>): void {
+    private getVisibleEntries(entry: VoiceEntry, visibleEntries: VoiceEntry[]): void {
         if (entry.ParentVoice.Visible) {
-            visibleEntries.Add(entry);
+            visibleEntries.push(entry);
         }
     }
-    private getAudibleEntries(entry: VoiceEntry, audibleEntries: List<VoiceEntry>): void {
+    private getAudibleEntries(entry: VoiceEntry, audibleEntries: VoiceEntry[]): void {
         if (entry.ParentVoice.Audible) {
-            audibleEntries.Add(entry);
+            audibleEntries.push(entry);
         }
     }
-    private getScoreFollowingEntries(entry: VoiceEntry, followingEntries: List<VoiceEntry>): void {
+    private getScoreFollowingEntries(entry: VoiceEntry, followingEntries: VoiceEntry[]): void {
         if (entry.ParentVoice.Following && entry.ParentVoice.Parent.Following) {
-            followingEntries.Add(entry);
+            followingEntries.push(entry);
         }
     }
-    private getVoiceEntries(container: VerticalSourceStaffEntryContainer): List<VoiceEntry> {
-        let entries: List<VoiceEntry> = new List<VoiceEntry>();
-        for (let idx: number = 0, len: number = container.StaffEntries.Count; idx < len; ++idx) {
-            let sourceStaffEntry: SourceStaffEntry = container.StaffEntries[idx];
+    private getVoiceEntries(container: VerticalSourceStaffEntryContainer): VoiceEntry[] {
+        let entries: VoiceEntry[] = new Array();
+        for (let sourceStaffEntry: SourceStaffEntry of container.StaffEntries) {
             if (sourceStaffEntry === undefined) { continue; }
-            for (let idx2: number = 0, len2: number = sourceStaffEntry.VoiceEntries.Count; idx2 < len2; ++idx2) {
-                let voiceEntry: VoiceEntry = sourceStaffEntry.VoiceEntries[idx2];
-                entries.Add(voiceEntry);
+            for (let voiceEntry: VoiceEntry of sourceStaffEntry.VoiceEntries) {
+                entries.push(voiceEntry);
             }
         }
         return entries;

+ 52 - 45
src/MusicalScore/MusicSource/Repetition.ts

@@ -1,4 +1,13 @@
-export class Repetition extends PartListEntry implements IRepetition {
+import {SourceMusicPart} from "./SourceMusicPart";
+import {VoiceEntry} from "../VoiceData/VoiceEntry";
+import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
+import {SourceMeasure} from "../VoiceData/SourceMeasure";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {MusicSheet} from "../MusicSheet";
+import {RepetitionInstruction} from "../VoiceData/Instructions/RepetitionInstruction";
+import {PartListEntry} from "./PartListEntry";
+
+export class Repetition extends PartListEntry /*implements IRepetition*/ {
     constructor(musicSheet: MusicSheet, virtualOverallRepetition: boolean) {
         super(musicSheet);
         this.musicSheet = musicSheet;
@@ -9,55 +18,55 @@ export class Repetition extends PartListEntry implements IRepetition {
     public EndMarker: RepetitionInstruction;
     public ForwardJumpInstruction: RepetitionInstruction;
 
-    private backwardJumpInstructions: List<RepetitionInstruction> = new List<RepetitionInstruction>();
-    private endingParts: List<RepetitionEndingPart> = new List<RepetitionEndingPart>();
-    private endingIndexDict: Dictionary<number, RepetitionEndingPart> = new Dictionary<number, RepetitionEndingPart>();
+    private backwardJumpInstructions: RepetitionInstruction[] = new Array();
+    private endingParts: RepetitionEndingPart[] = new Array();
+    private endingIndexDict: { [_: number] : RepetitionEndingPart; } = {};
     private userNumberOfRepetitions: number = 0;
-    private visibles: List<boolean> = new List<boolean>();
+    private visibles: boolean[] = new Array();
     private fromWords: boolean = false;
     private musicSheet: MusicSheet;
-    private repetitonIterationOrder: List<number> = new List<number>();
+    private repetitonIterationOrder: number[] = new Array();
     private numberOfEndings: number = 1;
     private virtualOverallRepetition: boolean;
 
-    public get BackwardJumpInstructions(): List<RepetitionInstruction> {
+    public get BackwardJumpInstructions(): RepetitionInstruction[] {
         return this.backwardJumpInstructions;
     }
-    public get EndingIndexDict(): Dictionary<number, RepetitionEndingPart> {
+    public get EndingIndexDict(): { [_: number] : RepetitionEndingPart; } {
         return this.endingIndexDict;
     }
-    public get EndingParts(): List<RepetitionEndingPart> {
+    public get EndingParts(): RepetitionEndingPart[] {
         return this.endingParts;
     }
-    public get Visibles(): List<boolean> {
+    public get Visibles(): boolean[] {
         return this.visibles;
     }
-    public set Visibles(value: List<boolean>) {
+    public set Visibles(value: boolean[]) {
         this.visibles = value;
     }
     public get DefaultNumberOfRepetitions(): number {
         let defaultNumber: number = 2;
         if (this.virtualOverallRepetition) { defaultNumber = 1; }
-        return Math.Max(Math.Max(defaultNumber, this.endingIndexDict.Count), this.checkRepetitionForMultipleLyricVerses());
+        return Math.Max(Math.Max(defaultNumber, this.endingIndexDict.length), this.checkRepetitionForMultipleLyricVerses());
     }
     public get UserNumberOfRepetitions(): number {
         return this.userNumberOfRepetitions;
     }
     public set UserNumberOfRepetitions(value: number) {
         this.userNumberOfRepetitions = value;
-        this.repetitonIterationOrder.Clear();
+        this.repetitonIterationOrder = [];
         let endingsDiff: number = this.userNumberOfRepetitions - this.NumberOfEndings;
         for (let i: number = 1; i <= this.userNumberOfRepetitions; i++) {
             if (i <= endingsDiff) {
-                this.repetitonIterationOrder.Add(1);
+                this.repetitonIterationOrder.push(1);
             } else {
-                this.repetitonIterationOrder.Add(i - endingsDiff);
+                this.repetitonIterationOrder.push(i - endingsDiff);
             }
         }
     }
     public getForwardJumpTargetForIteration(iteration: number): number {
         let endingIndex: number = this.repetitonIterationOrder[iteration - 1];
-        if (this.endingIndexDict.ContainsKey(endingIndex)) {
+        if (this.endingIndexDict[endingIndex] !== undefined) {
             return this.endingIndexDict[endingIndex].part.StartIndex;
         }
         return -1;
@@ -65,14 +74,14 @@ export class Repetition extends PartListEntry implements IRepetition {
     public getBackwardJumpTarget(): number {
         return this.StartMarker.MeasureIndex;
     }
-    public SetEndingStartIndex(endingNumbers: List<number>, startIndex: number): void {
+    public SetEndingStartIndex(endingNumbers: number[], startIndex: number): void {
         let part: RepetitionEndingPart = new RepetitionEndingPart(new SourceMusicPart(this.musicSheet, startIndex, startIndex));
-        this.endingParts.Add(part);
-        for (let idx: number = 0, len: number = endingNumbers.Count; idx < len; ++idx) {
+        this.endingParts.push(part);
+        for (let idx: number = 0, len: number = endingNumbers.length; idx < len; ++idx) {
             let endingNumber: number = endingNumbers[idx];
             try {
-                this.endingIndexDict.Add(endingNumber, part);
-                part.endingIndices.Add(endingNumber);
+                this.endingIndexDict[endingNumber] = part;
+                part.endingIndices.push(endingNumber);
                 if (this.numberOfEndings < endingNumber) {
                     this.numberOfEndings = endingNumber;
                 }
@@ -84,15 +93,15 @@ export class Repetition extends PartListEntry implements IRepetition {
     }
     public SetEndingStartIndex(endingNumber: number, startIndex: number): void {
         let part: RepetitionEndingPart = new RepetitionEndingPart(new SourceMusicPart(this.musicSheet, startIndex, startIndex));
-        this.endingParts.Add(part);
-        this.endingIndexDict.Add(endingNumber, part);
-        part.endingIndices.Add(endingNumber);
+        this.endingParts.push(part);
+        this.endingIndexDict[endingNumber] = part;
+        part.endingIndices.push(endingNumber);
         if (this.numberOfEndings < endingNumber) {
             this.numberOfEndings = endingNumber;
         }
     }
     public setEndingEndIndex(endingNumber: number, endIndex: number): void {
-        if (this.endingIndexDict.ContainsKey(endingNumber)) {
+        if (this.endingIndexDict[endingNumber] !== undefined) {
             this.endingIndexDict[endingNumber].part.setEndIndex(endIndex);
         }
     }
@@ -112,12 +121,12 @@ export class Repetition extends PartListEntry implements IRepetition {
         return this.StartMarker.MeasureIndex;
     }
     public get EndIndex(): number {
-        if (this.BackwardJumpInstructions.Count === 0) {
+        if (this.BackwardJumpInstructions.length === 0) {
             return this.StartIndex;
         }
-        let result: number = this.BackwardJumpInstructions.Last().MeasureIndex;
-        if (this.endingIndexDict.ContainsKey(this.NumberOfEndings)) {
-            result = Math.Max(this.endingIndexDict[this.NumberOfEndings].part.EndIndex, result);
+        let result: number = this.backwardJumpInstructions[this.backwardJumpInstructions.length - 1].MeasureIndex;
+        if (this.endingIndexDict[this.NumberOfEndings] !== undefined) {
+            result = Math.max(this.endingIndexDict[this.NumberOfEndings].part.EndIndex, result);
         }
         return result;
     }
@@ -128,15 +137,15 @@ export class Repetition extends PartListEntry implements IRepetition {
         for (let measureIndex: number = start; measureIndex <= end; measureIndex++) {
             let sourceMeasure: SourceMeasure = this.musicSheet.SourceMeasures[measureIndex];
             for (let i: number = 0; i < sourceMeasure.CompleteNumberOfStaves; i++) {
-                for (let j: number = 0; j < sourceMeasure.VerticalSourceStaffEntryContainers.Count; j++) {
+                for (let j: number = 0; j < sourceMeasure.VerticalSourceStaffEntryContainers.length; j++) {
                     if (sourceMeasure.VerticalSourceStaffEntryContainers[j][i] !== undefined) {
                         let sourceStaffEntry: SourceStaffEntry = sourceMeasure.VerticalSourceStaffEntryContainers[j][i];
                         let verses: number = 0;
-                        for (let idx: number = 0, len: number = sourceStaffEntry.VoiceEntries.Count; idx < len; ++idx) {
+                        for (let idx: number = 0, len: number = sourceStaffEntry.VoiceEntries.length; idx < len; ++idx) {
                             let voiceEntry: VoiceEntry = sourceStaffEntry.VoiceEntries[idx];
-                            verses += voiceEntry.LyricsEntries.Count;
+                            verses += voiceEntry.LyricsEntries.length;
                         }
-                        lyricVerses = Math.Max(lyricVerses, verses);
+                        lyricVerses = Math.max(lyricVerses, verses);
                     }
                 }
             }
@@ -144,23 +153,21 @@ export class Repetition extends PartListEntry implements IRepetition {
         return lyricVerses;
     }
     public get FirstSourceMeasureNumber(): number {
-        return getFirstSourceMeasure().MeasureNumber;
+        return this.getFirstSourceMeasure().MeasureNumber;
     }
     public get LastSourceMeasureNumber(): number {
-        return getLastSourceMeasure().MeasureNumber;
+        return this.getLastSourceMeasure().MeasureNumber;
     }
 
 }
 
-export module Repetition {
-    export class RepetitionEndingPart {
-        constructor(endingPart: SourceMusicPart) {
-            this.part = endingPart;
-        }
-        public part: SourceMusicPart;
-        public endingIndices: number[] = new Array();
-        public ToString(): string {
-          return this.endingIndices.join(", ");
-        }
+export class RepetitionEndingPart {
+    constructor(endingPart: SourceMusicPart) {
+        this.part = endingPart;
+    }
+    public part: SourceMusicPart;
+    public endingIndices: number[] = new Array();
+    public ToString(): string {
+      return this.endingIndices.join(", ");
     }
 }