Parcourir la source

Fix: articulations placement for beams.
The call createArticulations(...) was moved at the end after the call to finalizeBeams and finalizeTuplets in staffMeasureCreatedCalculations() in File VexFlowMeasure.ts

Christoph Uiberacker il y a 7 ans
Parent
commit
24fd5539e2

+ 6 - 5
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -147,7 +147,6 @@ export class VexFlowConverter {
         const accidentals: string[] = [];
         const frac: Fraction = notes[0].graphicalNoteLength;
         const isTuplet: boolean = notes[0].sourceNote.NoteTuplet !== undefined;
-        const articulations: ArticulationEnum[] = notes[0].sourceNote.ParentVoiceEntry.Articulations;
         let duration: string = VexFlowConverter.duration(frac, isTuplet);
         let vfClefType: string = undefined;
         let numDots: number = 0;
@@ -190,8 +189,6 @@ export class VexFlowConverter {
                 break;
         }
 
-        const stemDirection: number = vfnote.getStemDirection();
-
         for (let i: number = 0, len: number = notes.length; i < len; i += 1) {
             (notes[i] as VexFlowGraphicalNote).setIndex(vfnote, i);
             if (accidentals[i]) {
@@ -201,12 +198,17 @@ export class VexFlowConverter {
         for (let i: number = 0, len: number = numDots; i < len; ++i) {
             vfnote.addDotToAll();
         }
+        return vfnote;
+    }
 
+    public static generateArticulations(vfnote: Vex.Flow.StaveNote, articulations: ArticulationEnum[]): void {
         // Articulations:
         let vfArtPosition: number = Vex.Flow.Modifier.Position.ABOVE;
-        if (stemDirection === Vex.Flow.Stem.UP) {
+
+        if (vfnote.getStemDirection() === Vex.Flow.Stem.UP) {
             vfArtPosition = Vex.Flow.Modifier.Position.BELOW;
         }
+
         for (const articulation of articulations) {
             // tslint:disable-next-line:switch-default
             let vfArt: Vex.Flow.Articulation = undefined;
@@ -266,7 +268,6 @@ export class VexFlowConverter {
                 vfnote.addModifier(0, vfArt);
             }
         }
-        return vfnote;
     }
 
     /**

+ 16 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -489,6 +489,22 @@ export class VexFlowMeasure extends StaffMeasure {
                 }
             }
         }
+        this.createArticulations();
+    }
+
+    private createArticulations(): void {
+        for (let idx: number = 0, len: number = this.staffEntries.length; idx < len; ++idx) {
+            const graphicalStaffEntry: VexFlowStaffEntry = (this.staffEntries[idx] as VexFlowStaffEntry);
+
+            // create vex flow Notes:
+            const gnotes: { [voiceID: number]: GraphicalNote[]; } = graphicalStaffEntry.graphicalNotes;
+            for (const voiceID in gnotes) {
+                if (gnotes.hasOwnProperty(voiceID)) {
+                    const vfnote: StaveNote = (graphicalStaffEntry as VexFlowStaffEntry).vfNotes[voiceID];
+                    VexFlowConverter.generateArticulations(vfnote, gnotes[voiceID][0].sourceNote.ParentVoiceEntry.Articulations);
+                }
+            }
+        }
     }
 
     /**