]> git.donarmstrong.com Git - lilypond.git/commitdiff
Midi2ly: have --key option reach all staves. Fixes #1587.
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 31 Mar 2011 20:20:49 +0000 (22:20 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 31 Mar 2011 20:21:05 +0000 (22:21 +0200)
input/regression/midi/key-option-all-staves.ly [new file with mode: 0644]
scripts/midi2ly.py

diff --git a/input/regression/midi/key-option-all-staves.ly b/input/regression/midi/key-option-all-staves.ly
new file mode 100644 (file)
index 0000000..e669b32
--- /dev/null
@@ -0,0 +1,24 @@
+\version "2.13.53"
+
+\header {
+texidoc="Midi2ly --key works on all staves, this is G major (--key=1)"
+options="--key=1"
+}
+
+\score {
+  <<
+    \context Staff = "treble" <<
+      \context Voice="one" \relative c'' {
+       fis
+      }
+    >>
+    \context Staff = "bass" <<
+      \context Voice="two" \relative c {
+       \clef bass
+       fis
+      }
+    >>
+  >>
+  \layout {}
+  \midi {}
+}
index 1ab0233b79afe4e6cbd0d2fbd7071e539063a034..1923d3b8803961cb31523ead1fd6c7567ad0b569 100644 (file)
@@ -1002,6 +1002,7 @@ def convert_midi (in_file, out_file):
 
     s += '\n\\score {\n  <<\n'
 
+    control_track = False
     i = 0
     for i, staff in enumerate (staves):
         track_name = get_track_name (i)
@@ -1009,11 +1010,12 @@ def convert_midi (in_file, out_file):
         staff_name = track_name
         context = None
         if not i and not item and len (staves) > 1:
-            # control track
-            staff_name = get_track_name (1)
-            context = 'Staff'
+            control_track = track_name
+            continue
         elif (item and item.__class__ == Note):
             context = 'Staff'
+            if control_track:
+                s += '    \\context %(context)s=%(staff_name)s \\%(control_track)s\n' % locals ()
         elif item and item.__class__ == Text:
             context = 'Lyrics'
         if context: