From: Reinhold Kainhofer Date: Sat, 15 Nov 2008 19:34:41 +0000 (+0100) Subject: MusicXML: Fix notes that don't have a voice setting (assign it to voice "None") X-Git-Tag: release/2.11.64-1~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f13c054f0795e10f06931a267af51220a6b9fc66;p=lilypond.git MusicXML: Fix notes that don't have a voice setting (assign it to voice "None") --- diff --git a/input/regression/musicxml/00n-NoVoiceElement.xml b/input/regression/musicxml/00n-NoVoiceElement.xml new file mode 100644 index 0000000000..f7dee8ec14 --- /dev/null +++ b/input/regression/musicxml/00n-NoVoiceElement.xml @@ -0,0 +1,44 @@ + + + + + + The <voice> element + of notes is optional in MusicXML (although Dolet always writes it out). + Here, there is one note with lyrics, but without a voice assigned. It + should still be correctly converted. + + + + + MusicXML Part + + + + + + + 4 + + G + 2 + + + + + G + 4 + + 16 + whole + + single + A + + + + light-heavy + + + + diff --git a/python/musicxml.py b/python/musicxml.py index c6de611b9b..3c9d8a0111 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -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