Browse Source

fix(grace notes): fix stem direction for beamed grace note connected to beamed main note

demo: correct haydn sample beam numbering for bar 57
sschmidTU 6 years ago
parent
commit
28fc01e752

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

@@ -284,6 +284,11 @@ export class VexFlowConverter {
 
         vfnote.x_shift = xShift;
 
+        if (gve.parentVoiceEntry.IsGrace && gve.notes[0].sourceNote.NoteBeam) {
+            // Vexflow seems to have issues with wanted stem direction for beamed grace notes,
+            // when the stem is connected to a beamed main note (e.g. Haydn Concertante bar 57)
+            gve.parentVoiceEntry.WantedStemDirection = gve.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection;
+        }
         if (gve.parentVoiceEntry !== undefined) {
             const wantedStemDirection: StemDirectionType = gve.parentVoiceEntry.WantedStemDirection;
             switch (wantedStemDirection) {

+ 3 - 3
test/data/JosephHaydn_ConcertanteCello.xml

@@ -4788,8 +4788,8 @@
         <voice>1</voice>
         <type>16th</type>
         <stem>up</stem>
-        <beam number="1">begin</beam>
         <beam number="2">begin</beam>
+        <beam number="3">begin</beam>
         <notations>
           <slur number="1" type="start"/>
         </notations>
@@ -4804,8 +4804,8 @@
         <voice>1</voice>
         <type>16th</type>
         <stem>up</stem>
-        <beam number="1">continue</beam>
         <beam number="2">continue</beam>
+        <beam number="3">continue</beam>
       </note>
       <note>
         <grace/>
@@ -4816,8 +4816,8 @@
         <voice>1</voice>
         <type>16th</type>
         <stem>up</stem>
-        <beam number="1">end</beam>
         <beam number="2">end</beam>
+        <beam number="3">end</beam>
       </note>
       <note>
         <pitch>