]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix MIDI drums: only override channel if channel was not preassigned.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 3 Dec 2006 16:30:14 +0000 (17:30 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 3 Dec 2006 16:30:14 +0000 (17:30 +0100)
input/no-notation/midi-drums.ly [new file with mode: 0644]
lily/audio-staff.cc
lily/include/audio-staff.hh
lily/performance.cc

diff --git a/input/no-notation/midi-drums.ly b/input/no-notation/midi-drums.ly
new file mode 100644 (file)
index 0000000..acf96b9
--- /dev/null
@@ -0,0 +1,14 @@
+
+\score {
+  \new DrumStaff <<
+    \drummode {
+      bd4 sn4 bd4 sn4
+      <<
+       {\voiceOne \repeat unfold 16 hh16 }
+       \new DrumVoice { \voiceTwo bd4 sn4 bd4 sn4 }
+      >> \oneVoice
+    }
+  >>
+  \layout {}
+  \midi {}
+}
index 5d402febf585c279248d46676b2232b7ab95a17f..1616ceb3c83cb9354f6c3226b194948f792f43d5 100644 (file)
@@ -18,6 +18,11 @@ Audio_staff::add_audio_item (Audio_item *l)
   audio_items_.push_back (l);
 }
 
+Audio_staff::Audio_staff ()
+{
+  channel_ = -1; 
+}
+
 void
 Audio_staff::output (Midi_stream &midi_stream, int channel)
 {
index e20fc1c4d77c2d7ce959d869a392dd39e934f793..fa6e1b942942a5958d057a0c1456a11cec65e223 100644 (file)
@@ -16,6 +16,8 @@ struct Audio_staff : public Audio_element
   void add_audio_item (Audio_item *l);
   void output (Midi_stream &midi_stream_r, int track_i);
 
+  Audio_staff ();
+  
   vector<Audio_item*> audio_items_;
   int channel_;
 };
index 0bfe37ee826581ccab7815b50afd71930725740f..59cc64a2e25c31de2d6036670de92b1c0cce71ba 100644 (file)
@@ -43,6 +43,7 @@ Performance::output (Midi_stream &midi_stream)
 
   midi_stream << Midi_header (1, tracks_, clocks_per_4);
   message (_ ("Track...") + " ");
+  
   int channel = 0;
   for (vsize i = 0; i < audio_staffs_.size (); i++)
     {
@@ -50,30 +51,37 @@ Performance::output (Midi_stream &midi_stream)
       if (be_verbose_global)
        progress_indication ("[" + to_string (i));
 
-      /*
-       MIDI players tend to ignore instrument settings on
-       channel 10, the percussion channel by default.
-      */
-      if (channel % 16 == 9)
-       channel++;
+      int midi_channel =  s->channel_;
+
+      if (midi_channel < 0)
+       {
+         midi_channel = channel;
+         channel ++;
+         /*
+           MIDI players tend to ignore instrument settings on
+           channel 10, the percussion channel.
+         */
+         if (channel % 16 == 9)
+           channel ++;
+       }
 
       /*
        Huh? Why does each staff also have a separate channel? We
        should map channels to voices, not staves. --hwn.
       */
-      if (channel > 15)
+      if (midi_channel > 15)
        {
          warning (_ ("MIDI channel wrapped around"));
          warning (_ ("remapping modulo 16"));
+
+         midi_channel = midi_channel % 16; 
        }
 
-      s->output (midi_stream, channel);
-      channel ++;
+      s->output (midi_stream, midi_channel);
       if (be_verbose_global)
        progress_indication ("]");
     }
 }
-
 void
 Performance::add_element (Audio_element *p)
 {