]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/musicxml2ly.py
MusicXML: Fine-tune chord detection in combination with dynamics
[lilypond.git] / scripts / musicxml2ly.py
index 3f44e71c4fa80c8153b372a34aee5b6f6c7a7e71..d0bd4183991575e40c60c8f7d0110ea811315e95 100644 (file)
@@ -518,10 +518,19 @@ class LilyPondVoiceBuilder:
     def last_event_chord (self, starting_at):
 
         value = None
+
+        # if the position matches, find the last EventChord, do not cross a bar line!
+        at = len( self.elements ) - 1
+        while (at >= 0 and
+               not isinstance (self.elements[at], musicexp.EventChord) and
+               not isinstance (self.elements[at], musicexp.BarCheck)):
+            at -= 1
+
         if (self.elements
-            and isinstance (self.elements[-1], musicexp.EventChord)
+            and at >= 0
+            and isinstance (self.elements[at], musicexp.EventChord)
             and self.begin_moment == starting_at):
-            value = self.elements[-1]
+            value = self.elements[at]
         else:
             self.jumpto (starting_at)
             value = None