]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Also finish repeats that do not have an explicit ending bar
authorReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 23 Oct 2007 21:32:23 +0000 (23:32 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 23 Oct 2007 21:32:23 +0000 (23:32 +0200)
Some musicXML examples just display the first page of a multi-page score.
Sometimes a repeat occurs on these pages with no ending bar (which would
follow on a subsequent page). Simply finish the \repeat sequence at the
very end of the page.

scripts/musicxml2ly.py

index b81c9e8344976325d307f526f65fbff66ed71a96..d8b184ef433e71c164df40d5ce7946a79867794e 100644 (file)
@@ -193,6 +193,7 @@ def group_repeats (music_list):
         ending_start = -1 # position of current ending start
         endings = [] # list of already finished endings
         pos = 0
+        last = len (music_list) - 1
         repeat_replaced = False
         final_marker = 0
         while pos < len (music_list) and not repeat_replaced:
@@ -234,6 +235,17 @@ def group_repeats (music_list):
                 if repeat_start >= 0 and repeat_end > 0 and ending_start < 0:
                     repeat_finished = True
 
+            # Finish off all repeats without explicit ending bar (e.g. when
+            # we convert only one page of a multi-page score with repeats)
+            if pos == last and repeat_start >= 0:
+                repeat_finished = True
+                final_marker = pos
+                if repeat_end < 0:
+                    repeat_end = pos
+                if ending_start >= 0:
+                    endings.append ([ending_start, pos])
+                    ending_start = -1
+
             if repeat_finished:
                 # We found the whole structure replace it!
                 r = musicexp.RepeatedMusic ()