]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Implement staff changes in piano staves
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 27 Oct 2007 17:36:15 +0000 (19:36 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 27 Oct 2007 17:36:15 +0000 (19:36 +0200)
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...

python/musicexp.py
scripts/musicxml2ly.py

index ef896f9e53752ec80ab325e8966225865dc6ae23..3fdb7955e981ff94742d1949dc26c1585ca94ea0 100644 (file)
@@ -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):
index 192c3f613702b704572db6e1631b62d86275ed04..8bb9b2560a7aaceaa3f8c3b9f5cecb8fbbac4700 100644 (file)
@@ -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: