Parcourir la source

Merge branch 'feature/OSMD-6_Porting' into feature/VexFlowIntegration

Andrea Condoluci il y a 9 ans
Parent
commit
f8809767bb

+ 47 - 47
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -827,6 +827,53 @@ export abstract class MusicSheetCalculator {
         return posX;
     }
 
+    protected calculatePageLabels(page: GraphicalMusicPage): void {
+        let relative: PointF2D = new PointF2D();
+        let firstSystemAbsoluteTopMargin: number = 10;
+        if (page.MusicSystems.length > 0) {
+            let firstMusicSystem: MusicSystem = page.MusicSystems[0];
+            firstSystemAbsoluteTopMargin = firstMusicSystem.PositionAndShape.RelativePosition.y + firstMusicSystem.PositionAndShape.BorderTop;
+        }
+        if (this.graphicalMusicSheet.Title !== undefined) {
+            let title: GraphicalLabel = this.graphicalMusicSheet.Title;
+            title.PositionAndShape.Parent = page.PositionAndShape;
+            page.PositionAndShape.ChildElements.push(title.PositionAndShape);
+            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth / 2;
+            relative.y = this.rules.TitleTopDistance + this.rules.SheetTitleHeight;
+            title.PositionAndShape.RelativePosition = relative;
+            page.Labels.push(title);
+        }
+        if (this.graphicalMusicSheet.Subtitle !== undefined) {
+            let subtitle: GraphicalLabel = this.graphicalMusicSheet.Subtitle;
+            subtitle.PositionAndShape.Parent = page.PositionAndShape;
+            page.PositionAndShape.ChildElements.push(subtitle.PositionAndShape);
+            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth / 2;
+            relative.y = this.rules.TitleTopDistance + this.rules.SheetTitleHeight + this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;
+            subtitle.PositionAndShape.RelativePosition = relative;
+            page.Labels.push(subtitle);
+        }
+        if (this.graphicalMusicSheet.Composer !== undefined) {
+            let composer: GraphicalLabel = this.graphicalMusicSheet.Composer;
+            composer.PositionAndShape.Parent = page.PositionAndShape;
+            page.PositionAndShape.ChildElements.push(composer.PositionAndShape);
+            composer.setLabelPositionAndShapeBorders();
+            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth - this.rules.PageRightMargin;
+            relative.y = firstSystemAbsoluteTopMargin - this.rules.SystemComposerDistance;
+            composer.PositionAndShape.RelativePosition = relative;
+            page.Labels.push(composer);
+        }
+        if (this.graphicalMusicSheet.Lyricist !== undefined) {
+            let lyricist: GraphicalLabel = this.graphicalMusicSheet.Lyricist;
+            lyricist.PositionAndShape.Parent = page.PositionAndShape;
+            page.PositionAndShape.ChildElements.push(lyricist.PositionAndShape);
+            lyricist.setLabelPositionAndShapeBorders();
+            relative.x = this.rules.PageLeftMargin;
+            relative.y = firstSystemAbsoluteTopMargin - this.rules.SystemComposerDistance;
+            lyricist.PositionAndShape.RelativePosition = relative;
+            page.Labels.push(lyricist);
+        }
+    }
+
     private createAccidentalCalculators(): AccidentalCalculator[] {
         let accidentalCalculators: AccidentalCalculator[] = [];
         let firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
@@ -1029,53 +1076,6 @@ export abstract class MusicSheetCalculator {
         return measure;
     }
 
-    private calculatePageLabels(page: GraphicalMusicPage): void {
-        let relative: PointF2D = new PointF2D();
-        let firstSystemAbsoluteTopMargin: number = 10;
-        if (page.MusicSystems.length > 0) {
-            let firstMusicSystem: MusicSystem = page.MusicSystems[0];
-            firstSystemAbsoluteTopMargin = firstMusicSystem.PositionAndShape.RelativePosition.y + firstMusicSystem.PositionAndShape.BorderTop;
-        }
-        if (this.graphicalMusicSheet.Title !== undefined) {
-            let title: GraphicalLabel = this.graphicalMusicSheet.Title;
-            title.PositionAndShape.Parent = page.PositionAndShape;
-            page.PositionAndShape.ChildElements.push(title.PositionAndShape);
-            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth / 2;
-            relative.y = this.rules.TitleTopDistance + this.rules.SheetTitleHeight;
-            title.PositionAndShape.RelativePosition = relative;
-            page.Labels.push(title);
-        }
-        if (this.graphicalMusicSheet.Subtitle !== undefined) {
-            let subtitle: GraphicalLabel = this.graphicalMusicSheet.Subtitle;
-            subtitle.PositionAndShape.Parent = page.PositionAndShape;
-            page.PositionAndShape.ChildElements.push(subtitle.PositionAndShape);
-            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth / 2;
-            relative.y = this.rules.TitleTopDistance + this.rules.SheetTitleHeight + this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;
-            subtitle.PositionAndShape.RelativePosition = relative;
-            page.Labels.push(subtitle);
-        }
-        if (this.graphicalMusicSheet.Composer !== undefined) {
-            let composer: GraphicalLabel = this.graphicalMusicSheet.Composer;
-            composer.PositionAndShape.Parent = page.PositionAndShape;
-            page.PositionAndShape.ChildElements.push(composer.PositionAndShape);
-            composer.setLabelPositionAndShapeBorders();
-            relative.x = this.graphicalMusicSheet.ParentMusicSheet.pageWidth - this.rules.PageRightMargin;
-            relative.y = firstSystemAbsoluteTopMargin - this.rules.SystemComposerDistance;
-            composer.PositionAndShape.RelativePosition = relative;
-            page.Labels.push(composer);
-        }
-        if (this.graphicalMusicSheet.Lyricist !== undefined) {
-            let lyricist: GraphicalLabel = this.graphicalMusicSheet.Lyricist;
-            lyricist.PositionAndShape.Parent = page.PositionAndShape;
-            page.PositionAndShape.ChildElements.push(lyricist.PositionAndShape);
-            lyricist.setLabelPositionAndShapeBorders();
-            relative.x = this.rules.PageLeftMargin;
-            relative.y = firstSystemAbsoluteTopMargin - this.rules.SystemComposerDistance;
-            lyricist.PositionAndShape.RelativePosition = relative;
-            page.Labels.push(lyricist);
-        }
-    }
-
     private checkVoiceEntriesForTechnicalInstructions(voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void {
         for (let idx: number = 0, len: number = voiceEntry.TechnicalInstructions.length; idx < len; ++idx) {
             let technicalInstruction: TechnicalInstruction = voiceEntry.TechnicalInstructions[idx];

+ 63 - 26
src/MusicalScore/Graphical/MusicSystem.ts

@@ -35,7 +35,7 @@ export abstract class MusicSystem extends GraphicalObject {
     protected groupBrackets: GraphicalObject[] = [];
     protected graphicalMarkedAreas: GraphicalMarkedArea[] = [];
     protected graphicalComments: GraphicalComment[] = [];
-    protected systemLines: SystemLine[]  = [];
+    protected systemLines: SystemLine[] = [];
     protected rules: EngravingRules;
 
     constructor(parent: GraphicalMusicPage, id: number) {
@@ -99,8 +99,31 @@ export abstract class MusicSystem extends GraphicalObject {
         return this.id;
     }
 
+    /**
+     * This method creates the left vertical Line connecting all staves of the MusicSystem.
+     * @param lineWidth
+     * @param systemLabelsRightMargin
+     */
     public createSystemLeftLine(lineWidth: number, systemLabelsRightMargin: number): void {
-        throw new Error("not implemented");
+        let xPosition: number = -lineWidth / 2;
+        if (this === this.parent.MusicSystems[0] && this.parent === this.parent.Parent.MusicPages[0]) {
+            xPosition = this.maxLabelLength + systemLabelsRightMargin - lineWidth / 2;
+        }
+        let top: StaffMeasure = this.staffLines[0].Measures[0];
+        let bottom: StaffMeasure = undefined;
+        if (this.staffLines.length > 1) {
+            bottom = this.staffLines[this.staffLines.length - 1].Measures[0];
+        }
+        let leftSystemLine: SystemLine = this.createSystemLine(xPosition, lineWidth, SystemLinesEnum.SingleThin,
+                                                               SystemLinePosition.MeasureBegin, this, top, bottom);
+        this.SystemLines.push(leftSystemLine);
+        this.boundingBox.ChildElements.push(leftSystemLine.PositionAndShape);
+        leftSystemLine.PositionAndShape.RelativePosition = new PointF2D(xPosition, 0);
+        leftSystemLine.PositionAndShape.BorderLeft = 0;
+        leftSystemLine.PositionAndShape.BorderRight = lineWidth;
+        leftSystemLine.PositionAndShape.BorderTop = 0;
+        leftSystemLine.PositionAndShape.BorderBottom = this.boundingBox.Size.height;
+        this.createLinesForSystemLine(leftSystemLine);
     }
 
     /**
@@ -117,17 +140,11 @@ export abstract class MusicSystem extends GraphicalObject {
         let staffLine: StaffLine = measure.ParentStaffLine;
         let staffLineRelative: PointF2D = new PointF2D(staffLine.PositionAndShape.RelativePosition.x,
                                                        staffLine.PositionAndShape.RelativePosition.y);
-        let staves: Staff[]  = staffLine.ParentStaff.ParentInstrument.Staves;
+        let staves: Staff[] = staffLine.ParentStaff.ParentInstrument.Staves;
         if (staffLine.ParentStaff === staves[0]) {
             let bottomMeasure: StaffMeasure = undefined;
             if (staves.length > 1) {
-                let last: Staff = staves[staves.length - 1];
-                for (let line of staffLine.ParentMusicSystem.staffLines) {
-                    if (line.ParentStaff === last) {
-                        bottomMeasure = line.Measures[measureIndex];
-                        break;
-                    }
-                }
+                bottomMeasure = this.getBottomStaffLine(staffLine).Measures[measureIndex];
             }
             let singleVerticalLineAfterMeasure: SystemLine = this.createSystemLine(xPosition, lineWidth, lineType, linePosition, this, measure, bottomMeasure);
             let systemXPosition: number = staffLineRelative.x + xPosition;
@@ -139,23 +156,8 @@ export abstract class MusicSystem extends GraphicalObject {
         }
     }
 
-    /**
-     * This method creates all the graphical lines and dots needed to render a system line (e.g. bold-thin-dots..).
-     * @param xPosition
-     * @param lineWidth
-     * @param lineType
-     * @param linePosition indicates if the line belongs to start or end of measure
-     * @param musicSystem
-     * @param topMeasure
-     * @param bottomMeasure
-     */
-    public createSystemLine(xPosition: number, lineWidth: number, lineType: SystemLinesEnum, linePosition: SystemLinePosition,
-                            musicSystem: MusicSystem, topMeasure: StaffMeasure, bottomMeasure: StaffMeasure = undefined): SystemLine {
-        throw new Error("not implemented");
-    }
-
     public setYPositionsToVerticalLineObjectsAndCreateLines(rules: EngravingRules): void {
-        throw new Error("not implemented");
+        // empty
     }
 
     public calculateBorders(rules: EngravingRules): void {
@@ -338,6 +340,41 @@ export abstract class MusicSystem extends GraphicalObject {
         return false;
     }
 
+    public getBottomStaffLine(topStaffLine: StaffLine): StaffLine {
+        let staves: Staff[] = topStaffLine.ParentStaff.ParentInstrument.Staves;
+        let last: Staff = staves[staves.length - 1];
+        for (let line of topStaffLine.ParentMusicSystem.staffLines) {
+            if (line.ParentStaff === last) {
+                return line;
+            }
+        }
+        return undefined;
+    }
+
+    /**
+     * Here the system line is generated, which acts as the container of graphical lines and dots that will be finally rendered.
+     * It holds al the logical parameters of the system line.
+     * @param xPosition The x position within the system
+     * @param lineWidth The total x width
+     * @param lineType The line type enum
+     * @param linePosition indicates if the line belongs to start or end of measure
+     * @param musicSystem
+     * @param topMeasure
+     * @param bottomMeasure
+     */
+    protected createSystemLine(xPosition: number, lineWidth: number, lineType: SystemLinesEnum, linePosition: SystemLinePosition,
+                               musicSystem: MusicSystem, topMeasure: StaffMeasure, bottomMeasure: StaffMeasure = undefined): SystemLine {
+        throw new Error("not implemented");
+    }
+
+    /// <summary>
+    /// This method creates all the graphical lines and dots needed to render a system line (e.g. bold-thin-dots..).
+    /// </summary>
+    /// <param name="psSystemLine"></param>
+    protected createLinesForSystemLine(systemLine: SystemLine): void {
+        //Empty
+    }
+
     protected calcInstrumentsBracketsWidth(): number {
         throw new Error("not implemented");
     }

+ 13 - 2
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -52,7 +52,17 @@ export class VexFlowConverter {
         let octave: number = pitch.Octave + clef.OctaveOffset + 3; // FIXME + 3
         let acc: string = "";
 
-        switch (pitch.Accidental) {
+        return [fund + acc + "/" + octave, acc, clef];
+    }
+
+    /**
+     * Converts AccidentalEnum to vexFlow accidental string
+     * @param accidental
+     * @returns {string}
+     */
+    public static accidental(accidental: AccidentalEnum): string {
+        let acc: string = "";
+        switch (accidental) {
             case AccidentalEnum.NONE:
                 break;
             case AccidentalEnum.FLAT:
@@ -69,9 +79,10 @@ export class VexFlowConverter {
                 break;
             default:
         }
-        return [fund + acc + "/" + octave, acc, clef];
+        return acc;
     }
 
+
     public static StaveNote(notes: GraphicalNote[]): Vex.Flow.StaveNote {
         let keys: string[] = [];
         let frac: Fraction = notes[0].sourceNote.Length;

+ 1 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowGraphicalNote.ts

@@ -8,6 +8,7 @@ export class VexFlowGraphicalNote extends GraphicalNote {
     constructor(note: Note, parent: GraphicalStaffEntry, activeClef: ClefInstruction) {
         super(note, parent);
         if (note.Pitch) {
+            // ToDo: don't use accidental info here - set it in factory.
             this.vfpitch = VexFlowConverter.pitch(note.Pitch, activeClef);
         } else {
             this.vfpitch = undefined;

+ 3 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowGraphicalSymbolFactory.ts

@@ -127,7 +127,9 @@ export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory {
      * @param graceScalingFactor
      */
     public addGraphicalAccidental(graphicalNote: GraphicalNote, pitch: Pitch, grace: boolean, graceScalingFactor: number): void {
-        return;
+        // ToDo: set accidental here from pitch.Accidental
+        // let note: VexFlowGraphicalNote = <VexFlowGraphicalNote> graphicalNote;
+        //note.vfpitch = 
     }
 
     /**

+ 33 - 11
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -29,6 +29,7 @@ import {VexFlowTextMeasurer} from "./VexFlowTextMeasurer";
 //import {VexFlowMeasure} from "./VexFlowMeasure";
 
 import Vex = require("vexflow");
+import {PointF2D} from "../../../Common/DataObjects/PointF2D";
 
 export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
     constructor() {
@@ -118,20 +119,41 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         musicSystemBuilder.buildMusicSystems();
         this.checkMeasuresForWholeRestNotes();
         this.calculateSystemYLayout();
-        for (let page of this.graphicalMusicSheet.MusicPages) {
-            for (let system of page.MusicSystems) {
-                //system.setMusicSystemLabelsYPosition();
+        for (let idx: number = 0, len: number = this.graphicalMusicSheet.MusicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.graphicalMusicSheet.MusicPages[idx];
+            for (let idx2: number = 0, len2: number = graphicalMusicPage.MusicSystems.length; idx2 < len2; ++idx2) {
+                let musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
+                musicSystem.setMusicSystemLabelsYPosition();
                 if (!this.leadSheet) {
-                    system.setYPositionsToVerticalLineObjectsAndCreateLines(this.rules);
-                    system.createSystemLeftLine(this.rules.SystemThinLineWidth, this.rules.SystemLabelsRightMargin);
-                    //system.createInstrumentBrackets(this.graphicalMusicSheet.ParentMusicSheet.Instruments, this.rules.StaffHeight);
-                    //system.createGroupBrackets(this.graphicalMusicSheet.ParentMusicSheet.InstrumentalGroups, this.rules.StaffHeight, 0);
-                    //system.alignBeginInstructions();
-                } else if (system === system.Parent.MusicSystems[0]) {
-                    system.createSystemLeftLine(this.rules.SystemThinLineWidth, this.rules.SystemLabelsRightMargin);
+                    musicSystem.setYPositionsToVerticalLineObjectsAndCreateLines(this.rules);
+                    musicSystem.createSystemLeftLine(this.rules.SystemThinLineWidth, this.rules.SystemLabelsRightMargin);
+                    musicSystem.createInstrumentBrackets(this.graphicalMusicSheet.ParentMusicSheet.Instruments, this.rules.StaffHeight);
+                    musicSystem.createGroupBrackets(this.graphicalMusicSheet.ParentMusicSheet.InstrumentalGroups, this.rules.StaffHeight, 0);
+                    musicSystem.alignBeginInstructions();
+                } else if (musicSystem === musicSystem.Parent.MusicSystems[0]) {
+                    musicSystem.createSystemLeftLine(this.rules.SystemThinLineWidth, this.rules.SystemLabelsRightMargin);
+                }
+                musicSystem.calculateBorders(this.rules);
+            }
+            let distance: number = graphicalMusicPage.MusicSystems[0].PositionAndShape.BorderTop;
+            for (let idx2: number = 0, len2: number = graphicalMusicPage.MusicSystems.length; idx2 < len2; ++idx2) {
+                let musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
+                // let newPosition: PointF2D = new PointF2D(musicSystem.PositionAndShape.RelativePosition.x,
+                // musicSystem.PositionAndShape.RelativePosition.y - distance);
+                musicSystem.PositionAndShape.RelativePosition =
+                    new PointF2D(musicSystem.PositionAndShape.RelativePosition.x, musicSystem.PositionAndShape.RelativePosition.y - distance);
+            }
+            for (let idx2: number = 0, len2: number = graphicalMusicPage.MusicSystems.length; idx2 < len2; ++idx2) {
+                let musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
+                for (let idx3: number = 0, len3: number = musicSystem.StaffLines.length; idx3 < len3; ++idx3) {
+                    let staffLine: StaffLine = musicSystem.StaffLines[idx3];
+                    staffLine.addActivitySymbolClickArea();
                 }
-                //system.calculateBorders(this.rules);
             }
+            if (graphicalMusicPage === this.graphicalMusicSheet.MusicPages[0]) {
+                this.calculatePageLabels(graphicalMusicPage);
+            }
+            graphicalMusicPage.PositionAndShape.calculateTopBottomBorders();
         }
     }
 

+ 3 - 42
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSystem.ts

@@ -1,7 +1,6 @@
-import {MusicSystem} from "../MusicSystem";
+import {MusicSystem} from "../MusicSystem";
 import {GraphicalMusicPage} from "../GraphicalMusicPage";
 import {SystemLinesEnum} from "../SystemLinesEnum";
-import {EngravingRules} from "../EngravingRules";
 import {PointF2D} from "../../../Common/DataObjects/PointF2D";
 import {SystemLinePosition} from "../SystemLinePosition";
 import {StaffMeasure} from "../StaffMeasure";
@@ -18,36 +17,6 @@ export class VexFlowMusicSystem extends MusicSystem {
     }
 
     /**
-     * This method creates the left vertical Line of the MusicSystem.
-     * @param lineWidth
-     * @param systemLabelsRightMargin
-     */
-    public createSystemLeftLine(lineWidth: number, systemLabelsRightMargin: number): void {
-        //let len: number = this.graphicalMeasures.length;
-        //if (len > 1) {
-        //    (this.graphicalMeasures[0][0] as VexFlowMeasure).connectTo(
-        //        this.graphicalMeasures[len - 1][0] as VexFlowMeasure,
-        //        Vex.Flow.StaveConnector.type.SINGLE
-        //    );
-        //}
-        //(this.systemLines as VexFlowMeasure).connectTo(
-        //    this.graphicalMeasures[len - 1][0] as VexFlowMeasure,
-        //    Vex.Flow.StaveConnector.type.SINGLE
-        //);
-    }
-
-    /**
-     * This method creates the vertical Line Objects after the End of all StaffLine's Measures
-     * @param position
-     * @param lineType
-     * @param lineWidth
-     * @param index
-     */
-    public createVerticalLineForMeasure(position: number, lineType: SystemLinesEnum, lineWidth: number, index: number): void {
-        return;
-    }
-
-    /**
      * This method creates all the graphical lines and dots needed to render a system line (e.g. bold-thin-dots..).
      * @param xPosition
      * @param lineWidth
@@ -57,22 +26,14 @@ export class VexFlowMusicSystem extends MusicSystem {
      * @param topMeasure
      * @param bottomMeasure
      */
-    public createSystemLine(xPosition: number, lineWidth: number, lineType: SystemLinesEnum, linePosition: SystemLinePosition,
-                            musicSystem: MusicSystem, topMeasure: StaffMeasure, bottomMeasure: StaffMeasure = undefined): SystemLine {
+    protected createSystemLine(xPosition: number, lineWidth: number, lineType: SystemLinesEnum, linePosition: SystemLinePosition,
+                               musicSystem: MusicSystem, topMeasure: StaffMeasure, bottomMeasure: StaffMeasure = undefined): SystemLine {
         // ToDo: create line in Vexflow
         (topMeasure as VexFlowMeasure).connectTo(bottomMeasure as VexFlowMeasure, VexFlowConverter.line(lineType));
         return new SystemLine(lineType, linePosition, this, topMeasure, bottomMeasure);
     }
 
     /**
-     * This method sets the y-Positions of vertical Line Objects and creates the Lines within.
-     * @param rules
-     */
-    public setYPositionsToVerticalLineObjectsAndCreateLines(rules: EngravingRules): void {
-        return;
-    }
-
-    /**
      * Calculates the summed x-width of a possibly given Instrument Brace and/or Group Bracket(s).
      * @returns {number} the x-width
      */

+ 7 - 10
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -735,7 +735,7 @@ export class InstrumentReader {
                         === this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff)) {
                         let newClefInstruction: ClefInstruction = clefInstruction;
                         newClefInstruction.Parent = this.currentStaffEntry;
-                        this.currentStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
+                        this.currentStaffEntry.removeFirstInstructionOfTypeClefInstruction();
                         this.currentStaffEntry.Instructions.push(newClefInstruction);
                         this.activeClefs[key - 1] = clefInstruction;
                         this.abstractInstructions.splice(i, 1);
@@ -757,7 +757,7 @@ export class InstrumentReader {
                                     undefined && !(firstSse.Instructions[0] instanceof ClefInstruction)) {
                                     firstStaffEntry = firstSse;
                                     newClefInstruction.Parent = firstStaffEntry;
-                                    firstStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
+                                    firstStaffEntry.removeFirstInstructionOfTypeClefInstruction();
                                     firstStaffEntry.Instructions.splice(0, 0, newClefInstruction);
                                     this.activeClefsHaveBeenInitialized[key - 1] = true;
                                 } else {
@@ -772,7 +772,7 @@ export class InstrumentReader {
                                     firstStaffEntry = new SourceStaffEntry(undefined, undefined);
                                 } else {
                                     firstStaffEntry = first.FirstInstructionsStaffEntries[sseIndex];
-                                    firstStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
+                                    firstStaffEntry.removeFirstInstructionOfTypeClefInstruction();
                                 }
                                 newClefInstruction.Parent = firstStaffEntry;
                                 firstStaffEntry.Instructions.splice(0, 0, newClefInstruction);
@@ -787,8 +787,7 @@ export class InstrumentReader {
                             this.abstractInstructions.splice(i, 1);
                         }
                     }
-                }
-                if (key <= this.activeClefs.length && clefInstruction === this.activeClefs[key - 1]) {
+                } else if (key <= this.activeClefs.length && clefInstruction === this.activeClefs[key - 1]) {
                     this.abstractInstructions.splice(i, 1);
                 }
             }
@@ -832,8 +831,7 @@ export class InstrumentReader {
                             }
                         }
                     }
-                }
-                if (this.activeKey !== undefined && this.activeKey === keyInstruction) {
+                } else {
                     this.abstractInstructions.splice(i, 1);
                 }
             }
@@ -851,14 +849,13 @@ export class InstrumentReader {
                                 this.currentMeasure.FirstInstructionsStaffEntries[j] = firstStaffEntry;
                             } else {
                                 firstStaffEntry = this.currentMeasure.FirstInstructionsStaffEntries[j];
-                                firstStaffEntry.removeFirstInstructionOfType<RhythmInstruction>();
+                                firstStaffEntry.removeFirstInstructionOfTypeRhythmInstruction();
                             }
                             newRhythmInstruction.Parent = firstStaffEntry;
                             firstStaffEntry.Instructions.push(newRhythmInstruction);
                         }
                     }
-                }
-                if (this.activeRhythm !== undefined && this.activeRhythm === rhythmInstruction) {
+                } else {
                     this.abstractInstructions.splice(i, 1);
                 }
             }

+ 0 - 1
src/MusicalScore/VoiceData/Note.ts

@@ -8,7 +8,6 @@ import {Tie} from "./Tie";
 import {Staff} from "./Staff";
 import {Slur} from "./Expressions/ContinuousExpressions/Slur";
 import {NoteState} from "../Graphical/DrawingEnums";
-import {MusicSymbol} from "../Graphical/MusicSymbol";
 
 export class Note {
 

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

@@ -77,31 +77,30 @@ export class SourceStaffEntry {
         this.chordSymbolContainer = value;
     }
 
-    public removeAllInstructionsOfType<T>(): number {
-        let i: number = 0;
-        let ret: number = 0;
-        while (i < this.instructions.length) {
-            let instruction: Object = this.instructions[i];
-            if (<T>instruction !== undefined) {
-                this.instructions.splice(i, 1);
-                ret++;
-            } else {
-                i++;
-            }
-        }
-        return ret;
-    }
-
-    public removeFirstInstructionOfType<T>(): boolean {
-        for (let i: number = 0; i < this.instructions.length; i++) {
-            let instruction: Object = this.instructions[i];
-            if (<T>instruction !== undefined) {
-                this.instructions.splice(i, 1);
-                return true;
-            }
-        }
-        return false;
-    }
+    // public removeAllInstructionsOfType(type: AbstractNotationInstruction): number {
+    //     let i: number = 0;
+    //     let ret: number = 0;
+    //     while (i < this.instructions.length) {
+    //         let instruction: AbstractNotationInstruction = this.instructions[i];
+    //         if (instruction instanceof type) {
+    //             this.instructions.splice(i, 1);
+    //             ret++;
+    //         } else {
+    //             i++;
+    //         }
+    //     }
+    //     return ret;
+    // }
+    //
+    // public removeFirstInstructionOfType(type: AbstractNotationInstruction): boolean {
+    //     for (let i: number = 0; i < this.instructions.length; i++) {
+    //         if (this.instructions[i] instanceof type) {
+    //             this.instructions.splice(i, 1);
+    //             return true;
+    //         }
+    //     }
+    //     return false;
+    // }
 
     public removeAllInstructionsOfTypeClefInstruction(): number {
         let i: number = 0;
@@ -165,6 +164,16 @@ export class SourceStaffEntry {
         return ret;
     }
 
+    public removeFirstInstructionOfTypeRhythmInstruction(): boolean {
+        for (let i: number = 0; i < this.instructions.length; i++) {
+            if (this.instructions[i] instanceof RhythmInstruction) {
+                this.instructions.splice(i, 1);
+                return true;
+            }
+        }
+        return false;
+    }
+
     public calculateMinNoteLength(): Fraction {
         let duration: Fraction = new Fraction(Number.MAX_VALUE, 1);
         for (let idx: number = 0, len: number = this.VoiceEntries.length; idx < len; ++idx) {

+ 1 - 1
test/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer.ts

@@ -9,7 +9,7 @@ import {IXmlElement} from "../../../../src/Common/FileIO/Xml";
 describe("VexFlow Music Sheet Drawer", () => {
 
     it(".drawSheet (Clementi pt. 1)", (done: MochaDone) => {
-        let path: string = "test/data/MuzioClementi_SonatinaOpus36No1_Part1.xml";
+        let path: string = "test/data/MuzioClementi_SonatinaOpus36No1_Part2.xml";
         // "test/data/MuzioClementi_SonatinaOpus36No1_Part1.xml";
         let score: IXmlElement = TestUtils.getScore(path);
         chai.expect(score).to.not.be.undefined;