From: Reinhold Kainhofer Date: Sat, 27 Oct 2007 17:36:15 +0000 (+0200) Subject: MusicXML: Implement staff changes in piano staves X-Git-Tag: release/2.11.35-1~62 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=afd8d005f0a4a06c1f1036df68885f7b0dc003c4;p=lilypond.git MusicXML: Implement staff changes in piano staves When we encounter a note with a different staff value than the previous note in that voice, simply add the \change Staff=.. event into the notes. However, this does not work inside chords, so we ignore all staff changes inside chords. I'll have to find a different way to print some notes of a chord on one staff and the other notes on the other staff... --- diff --git a/python/musicexp.py b/python/musicexp.py index ef896f9e53..3fdb7955e9 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -997,6 +997,17 @@ class ClefChange (Music): return clefsetting +class StaffChange (Music): + def __init__ (self, staff): + Music.__init__ (self) + self.staff = staff + def ly_expression (self): + if self.staff: + return "\\change Staff=\"%s\"" % self.staff + else: + return '' + + class MultiMeasureRest(Music): def lisp_expression (self): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 192c3f6137..8bb9b2560a 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -948,6 +948,8 @@ def musicxml_voice_to_lily_voice (voice): is_chord = False ignore_lyrics = False + current_staff = None + # TODO: Make sure that the keys in the dict don't get reordered, since # we need the correct ordering of the lyrics stanzas! By default, # a dict will reorder its keys @@ -984,6 +986,12 @@ def musicxml_voice_to_lily_voice (voice): is_chord = n.get_maybe_exist_named_child ('chord') if not is_chord: + s = n.get_maybe_exist_named_child ('staff') + if s: + staff = s.get_text () + if current_staff and staff <> current_staff: + voice_builder.add_command (musicexp.StaffChange (staff)) + current_staff = staff try: voice_builder.jumpto (n._when) except NegativeSkip, neg: