]> git.donarmstrong.com Git - lilypond.git/commitdiff
Midi2ly: handle staves with more than four voices. Fixes #1580.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 28 Mar 2011 18:31:26 +0000 (20:31 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 28 Mar 2011 18:31:49 +0000 (20:31 +0200)
The correct \voiceOne, \voiceTwo,.. etc. mapping is probably lost in
such cases.  We need a good test file that shows how the mapping
should be handled.

input/regression/midi/voice-5.ly [new file with mode: 0644]
scripts/midi2ly.py

diff --git a/input/regression/midi/voice-5.ly b/input/regression/midi/voice-5.ly
new file mode 100644 (file)
index 0000000..297e39f
--- /dev/null
@@ -0,0 +1,92 @@
+% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out-www/voice-4.midi
+\version "2.13.53"
+
+\layout {
+  \context {
+    \Voice
+    \remove "Note_heads_engraver"
+    \consists "Completion_heads_engraver"
+    \remove "Rest_engraver"
+    \consists "Completion_rest_engraver"
+  }
+}
+
+% included from ./out-www/voice-5.header
+\header {
+texidoc="midi2ly still produces output for a staff with five voices.  However, in such cases, most probably the the correct \voiceOne, \voiceX... mapping is lost."
+options=""
+}
+% end
+
+trackAchannelA = {
+  
+  % [SEQUENCE_TRACK_NAME] control track
+  
+  % [TEXT_EVENT] creator: 
+  
+  % [TEXT_EVENT] GNU LilyPond 2.13.54          
+  
+  \time 4/4 
+  
+  \tempo 4 = 60 
+  
+}
+
+trackA = <<
+  \context Voice = voiceA \trackAchannelA
+>>
+
+
+trackBchannelA = \relative c {
+  \voiceOne
+  
+  \set Staff.instrumentName = ":1"
+  <c''' a >2 b 
+  | % 2
+  
+}
+
+trackBchannelB = \relative c {
+  \voiceThree
+  c''4. d8 e4 f 
+  | % 2
+  
+}
+
+trackBchannelC = \relative c {
+  \voiceFour
+  d'1 
+  | % 2
+  
+}
+
+trackBchannelD = \relative c {
+  \voiceTwo
+  c'4 c2 c4 
+  | % 2
+  
+}
+
+trackBchannelE = \relative c {
+  s1 d1
+  | % 2
+  
+}
+
+trackB = <<
+  \context Voice = voiceA \trackBchannelA
+  \context Voice = voiceB \trackBchannelB
+  \context Voice = voiceC \trackBchannelC
+  \context Voice = voiceD \trackBchannelD
+  \context Voice = voiceE \trackBchannelE
+>>
+
+
+\score {
+  <<
+    \context Staff=trackB \trackA
+    \context Staff=trackB \trackB
+  >>
+  \layout {}
+  \midi {}
+}
index 60a2febde0b583fb7e3cf0a776594660167f0663..1ab0233b79afe4e6cbd0d2fbd7071e539063a034 100644 (file)
@@ -827,7 +827,11 @@ def dump_track (track, n):
             if not n and not vv and global_options.key:
                 s += global_options.key.dump ()
             if average_pitch[vv+1] and voices > 1:
-                s += '  \\voice' + get_voice_layout (average_pitch[1:])[vv] + '\n'
+                vl = get_voice_layout (average_pitch[1:])[vv]
+                if vl:
+                    s += '  \\voice' + vl + '\n'
+                else:
+                    warning (_ ('found more than 5 voices on a staff, expect bad output'))
             s += '  ' + dump_voice (voice, skip)
             s += '}\n\n'
             v += 1