]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix notes that don't have a voice setting (assign it to voice "None")
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 15 Nov 2008 19:34:41 +0000 (20:34 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 15 Nov 2008 22:28:16 +0000 (23:28 +0100)
input/regression/musicxml/00n-NoVoiceElement.xml [new file with mode: 0644]
python/musicxml.py

diff --git a/input/regression/musicxml/00n-NoVoiceElement.xml b/input/regression/musicxml/00n-NoVoiceElement.xml
new file mode 100644 (file)
index 0000000..f7dee8e
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise version="2.0">\r
+  <identification>\r
+    <miscellaneous>\r
+      <miscellaneous-field name="description">The &lt;voice&gt; element \r
+        of notes is optional in MusicXML (although Dolet always writes it out). \r
+        Here, there is one note with lyrics, but without a voice assigned. It \r
+        should still be correctly converted.</miscellaneous-field>\r
+    </miscellaneous>\r
+  </identification>\r
+  <part-list>\r
+    <score-part id="P1">\r
+      <part-name>MusicXML Part</part-name>\r
+    </score-part>\r
+  </part-list>\r
+  <!--=========================================================-->\r
+  <part id="P1">\r
+    <measure number="1">\r
+      <attributes>\r
+        <divisions>4</divisions>\r
+        <clef>\r
+          <sign>G</sign>\r
+          <line>2</line>\r
+        </clef>\r
+      </attributes>\r
+      <note>\r
+        <pitch>\r
+          <step>G</step>\r
+          <octave>4</octave>\r
+        </pitch>\r
+        <duration>16</duration>\r
+        <type>whole</type>\r
+        <lyric number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>A</text>\r
+        </lyric>\r
+      </note>\r
+      <barline location="right">\r
+        <bar-style>light-heavy</bar-style>\r
+      </barline>\r
+    </measure>\r
+  </part>\r
+</score-partwise>\r
index c6de611b9be8d812ba8673667f2ba17e001988a8..3c9d8a0111da3e9f0a2f6d21c0dc9943aa8d0cf3 100644 (file)
@@ -702,7 +702,7 @@ class Part (Music_xml_node):
         voice_to_staff_dict = {}
         for n in elements:
             voice_id = n.get_maybe_exist_named_child (u'voice')
-            vid = None
+            vid = "None"
             if voice_id:
                 vid = voice_id.get_text ()
 
@@ -734,8 +734,15 @@ class Part (Music_xml_node):
         id = None
        for n in elements:
            voice_id = n.get_maybe_exist_typed_child (get_class ('voice'))
+            if voice_id:
+                id = voice_id.get_text ()
+            else:
+                id = "None"
 
-           if not (voice_id or isinstance (n, Attributes) or
+            # We don't need backup/forward any more, since we have already 
+            # assigned the correct onset times. 
+            # TODO: Let Grouping through. Also: link, print, bokmark sound
+           if not (isinstance (n, Note) or isinstance (n, Attributes) or
                     isinstance (n, Direction) or isinstance (n, Partial) or
                     isinstance (n, Barline) or isinstance (n, Harmony) or
                     isinstance (n, FiguredBass) ):
@@ -777,7 +784,6 @@ class Part (Music_xml_node):
                 assign_to_next_note.append (n)
                 continue
 
-           id = voice_id.get_text ()
             if hasattr (n, 'print-object') and getattr (n, 'print-object') == "no":
                 #Skip this note. 
                 pass