]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix clefs that appear in only one staff (ignore for the other!)
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 7 Nov 2008 11:54:50 +0000 (12:54 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 7 Nov 2008 12:12:48 +0000 (13:12 +0100)
This bug caused a position-off problem, which messed up chord detection
and caused several other problems. If a clef has a number attribute
(indicating its staff number), only copy it to the relevant staff.
For all other staves, if the remaining attributes are empty, simply
ignore them instead of passing an emtpy <attributes> tag, which was
the real cause for the problem.

python/musicxml.py

index 496b82b405c9fcb75cb8924bd8ad1498d47256be..a7cf59730ff1de9c6886816df7b42abdcb5bfb23 100644 (file)
@@ -613,12 +613,17 @@ class Part (Music_xml_node):
     # modify attributes so that only those applying to the given staff remain
     def extract_attributes_for_staff (part, attr, staff):
         attributes = copy.copy (attr)
-        attributes._children = copy.copy (attr._children)
+        attributes._children = [];
         attributes._dict = attr._dict.copy ()
-        for c in attributes._children:
-            if hasattr (c, 'number') and c.number != staff:
-                attributes._children.remove (c)
-        return attributes
+        # copy only the relevant children over for the given staff
+        for c in attr._children:
+            if (not (hasattr (c, 'number') and (c.number != staff)) and
+                not (isinstance (c, Hash_text))):
+                attributes._children.append (c)
+        if not attributes._children:
+            return None
+        else:
+            return attributes
 
     def extract_voices (part):
        voices = {}
@@ -680,8 +685,9 @@ class Part (Music_xml_node):
                 # assign these only to the voices they really belongs to!
                 for (s, vids) in staff_to_voice_dict.items ():
                     staff_attributes = part.extract_attributes_for_staff (n, s)
-                    for v in vids:
-                        voices[v].add_element (staff_attributes)
+                    if staff_attributes:
+                        for v in vids:
+                            voices[v].add_element (staff_attributes)
                 continue
 
             if isinstance (n, Partial) or isinstance (n, Barline):