From e76c6cb9fae87c362133987bcf5129eef0cb1123 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 28 Mar 2011 20:31:26 +0200 Subject: [PATCH] Midi2ly: handle staves with more than four voices. Fixes #1580. 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 | 92 ++++++++++++++++++++++++++++++++ scripts/midi2ly.py | 6 ++- 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 input/regression/midi/voice-5.ly diff --git a/input/regression/midi/voice-5.ly b/input/regression/midi/voice-5.ly new file mode 100644 index 0000000000..297e39f9fa --- /dev/null +++ b/input/regression/midi/voice-5.ly @@ -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" + 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 {} +} diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 60a2febde0..1ab0233b79 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -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 -- 2.39.2