From: Reinhold Kainhofer Date: Fri, 26 Oct 2007 15:00:18 +0000 (+0200) Subject: MusicXMl: Fix fretboard assignment to voices. X-Git-Tag: release/2.11.35-1~73 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c76eb56deebde56cb0add2c4f05e8f1261283d5c;p=lilypond.git MusicXMl: Fix fretboard assignment to voices. Instead of assigning elements to every voice or only the very first voice (in the frist case, we'll have duplicated frets, in the second one the fretboards will often be inserted at the completely wrong position), simply insert the fretboard into the next note that we encounter in the MusicXML file. I suppose we could also do something similar for text markup (i.e. ...), but there we need to distinguish direction elements with words-only subelements and with dynamics subelements. --- diff --git a/python/musicxml.py b/python/musicxml.py index 3c38f30828..84ffb75080 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -613,6 +613,7 @@ class Part (Music_xml_node): start_attr = None + assign_to_next_note = [] for n in elements: voice_id = n.get_maybe_exist_typed_child (get_class ('voice')) @@ -639,18 +640,21 @@ class Part (Music_xml_node): continue if isinstance (n, Direction) or isinstance (n, Harmony): - staff_id = n.get_maybe_exist_named_child (u'staff') - if staff_id: - staff_id = staff_id.get_text () - if staff_id: - 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) + # store the harmony element until we encounter the next note + # and assign it only to that one voice. + assign_to_next_note.append (n) + #staff_id = n.get_maybe_exist_named_child (u'staff') + #if staff_id: + #staff_id = staff_id.get_text () + #if staff_id: + #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) continue id = voice_id.get_text () @@ -658,6 +662,9 @@ 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) if start_attr: