]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Make tuplet detection work a bit better with nested tuplets
authorReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 18 Nov 2008 21:44:15 +0000 (22:44 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 18 Nov 2008 21:52:17 +0000 (22:52 +0100)
At least the script now detects the correct boundaries for nested
tuplets. It does not, however, correctly group the notes. For this,
the code needs to be substantially changed...

scripts/musicxml2ly.py

index 4a04cb4af857c6c936f325b22700902e58f29cc6..e2a54008e321eef92b447d57d51f77a525eb710b 100644 (file)
@@ -603,6 +603,7 @@ def group_tuplets (music_list, events):
 
     
     indices = []
+    brackets = {}
 
     j = 0
     for (ev_chord, tuplet_elt, fraction) in events:
@@ -610,10 +611,16 @@ def group_tuplets (music_list, events):
             if music_list[j] == ev_chord:
                 break
             j += 1
+        nr = tuplet_elt.number
         if tuplet_elt.type == 'start':
-            indices.append ((j, None, fraction))
+            tuplet_info = [j, None, fraction]
+            indices.append (tuplet_info)
+            brackets[nr] = tuplet_info
         elif tuplet_elt.type == 'stop':
-            indices[-1] = (indices[-1][0], j, indices[-1][2])
+            bracket_info = brackets.get (nr, None)
+            if bracket_info:
+                bracket_info[1] = j
+                del brackets[nr]
 
     new_list = []
     last = 0