]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/musicxml.py
Document info out=www target in make help.
[lilypond.git] / python / musicxml.py
index 3c38f30828ea09d669a9241deb81e2971c300782..63296f193e0bfc484f118017713e8a2c369295ea 100644 (file)
@@ -439,11 +439,11 @@ class Musicxml_voice:
             return self._lyrics
 
 
-
 class Part (Music_xml_node):
     def __init__ (self):
         Music_xml_node.__init__ (self)
-       self._voices = []
+       self._voices = {}
+        self._staff_attributes_dict = {}
 
     def get_part_list (self):
         n = self
@@ -454,6 +454,7 @@ class Part (Music_xml_node):
         
     def interpret (self):
        """Set durations and starting points."""
+        """The starting point of the very first note is 0!"""
         
         part_list = self.get_part_list ()
         
@@ -467,7 +468,7 @@ class Part (Music_xml_node):
         measure_position = Rational (0)
         measure_start_moment = now
         is_first_measure = True
-        prvious_measure = None
+        previous_measure = None
        for m in measures:
             # implicit measures are used for artificial measures, e.g. when
             # a repeat bar line splits a bar into two halves. In this case,
@@ -478,7 +479,7 @@ class Part (Music_xml_node):
             # know if the next measure is implicit and continues that measure)
             if not m.is_implicit ():
                 # Warn about possibly overfull measures and reset the position
-                if attributes_object:
+                if attributes_object and previous_measure and previous_measure.partial == 0:
                     length = attributes_object.get_measure_length ()
                     new_now = measure_start_moment + length
                     if now <> new_now:
@@ -613,6 +614,8 @@ class Part (Music_xml_node):
 
 
        start_attr = None
+        assign_to_next_note = []
+        id = None
        for n in elements:
            voice_id = n.get_maybe_exist_typed_child (get_class ('voice'))
 
@@ -638,7 +641,7 @@ class Part (Music_xml_node):
                     voices[v].add_element (n)
                 continue
 
-            if isinstance (n, Direction) or isinstance (n, Harmony):
+            if isinstance (n, Direction):
                 staff_id = n.get_maybe_exist_named_child (u'staff')
                 if staff_id:
                     staff_id = staff_id.get_text ()
@@ -646,11 +649,14 @@ class Part (Music_xml_node):
                     dir_voices = staff_to_voice_dict.get (staff_id, voices.keys ())
                 else:
                     dir_voices = voices.keys ()
-                # assign only to first voice, otherwise we'll have duplicates!
-                if dir_voices:
-                    voices[dir_voices[0]].add_element (n)
-                #for v in dir_voices:
-                    #voices[v].add_element (n)
+                for v in dir_voices:
+                    voices[v].add_element (n)
+                continue
+
+            if isinstance (n, Harmony):
+                # store the harmony element until we encounter the next note
+                # and assign it only to that one voice.
+                assign_to_next_note.append (n)
                 continue
 
            id = voice_id.get_text ()
@@ -658,12 +664,22 @@ class Part (Music_xml_node):
                 #Skip this note. 
                 pass
             else:
+                for i in assign_to_next_note:
+                    voices[id].add_element (i)
+                assign_to_next_note = []
                 voices[id].add_element (n)
 
+        # Assign all remaining elements from assign_to_next_note to the voice
+        # of the previous note:
+        for i in assign_to_next_note:
+            voices[id].add_element (i)
+        assign_to_next_note = []
+
        if start_attr:
             for (s, vids) in staff_to_voice_dict.items ():
                 staff_attributes = part.extract_attributes_for_staff (start_attr, s)
                 staff_attributes.read_self ()
+                part._staff_attributes_dict[s] = staff_attributes
                 for v in vids:
                     voices[v].insert (0, staff_attributes)
                     voices[v]._elements[0].read_self()
@@ -672,6 +688,8 @@ class Part (Music_xml_node):
 
     def get_voices (self):
        return self._voices
+    def get_staff_attributes (self):
+        return self._staff_attributes_dict
 
 class Notations (Music_xml_node):
     def get_tie (self):
@@ -682,8 +700,8 @@ class Notations (Music_xml_node):
        else:
            return None
 
-    def get_tuplet (self):
-       return self.get_maybe_exist_typed_child (Tuplet)
+    def get_tuplets (self):
+       return self.get_typed_children (Tuplet)
 
 class Time_modification(Music_xml_node):
     def get_fraction (self):