]> git.donarmstrong.com Git - lilypond.git/commitdiff
Midi: only output PORT if midiChannelMapping == #'voice.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 14 Mar 2011 09:08:06 +0000 (10:08 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 14 Mar 2011 09:08:21 +0000 (10:08 +0100)
This reduces the risk of creating trouble for the default
#'instrument-mode output and the old #'staff-mode output,
while leaving the option open for MIDI-players to do the
right thing with ports in the #'voice-mode: in each track,
each channel 0 should be able to play another instrument.

lily/audio-column.cc
lily/audio-staff.cc
lily/include/audio-staff.hh
lily/include/midi-chunk.hh
lily/include/performance.hh
lily/midi-chunk.cc
lily/performance.cc
lily/score-performer.cc

index 3b4fa4819038efef401ea2ef835c28d468caf357..105eb1dda858035047d4f09960295dd997aa73b0 100644 (file)
@@ -20,7 +20,6 @@
 #include "audio-column.hh"
 
 #include "audio-item.hh"
-#include "performance.hh"
 
 Audio_column::Audio_column (Moment when)
 {
index 8de47bf9dea59b051ea6bb4f6b0256aecc3b0422..d40220ca1c13a2e5237e7d65195295a0362dce63 100644 (file)
@@ -35,9 +35,9 @@ Audio_staff::Audio_staff ()
 }
 
 void
-Audio_staff::output (Midi_stream &midi_stream, int track)
+Audio_staff::output (Midi_stream &midi_stream, int track, bool port)
 {
-  Midi_track midi_track (track);
+  Midi_track midi_track (track, port);
 
   Midi_walker i (this, &midi_track);
   for (; i.ok (); i++)
index a76854ddb1c28e3822a4bc51db89090974ad6379..acf31b17a4808d0dbfa5ae921e12508ea0353ddb 100644 (file)
@@ -27,7 +27,7 @@
 struct Audio_staff : public Audio_element
 {
   void add_audio_item (Audio_item *ai);
-  void output (Midi_stream &midi_stream_r, int track);
+  void output (Midi_stream &midi_stream_r, int track, bool port);
 
   Audio_staff ();
   
index 5af4487828676e4689e25a9abfaa684a6ec3f6fe..c567e904f1797a814b4699b8f7a06d5247070c75 100644 (file)
@@ -70,11 +70,12 @@ class Midi_track : public Midi_chunk
 {
 public:
   int number_;
+  int port_;
   DECLARE_CLASSNAME (Midi_track);
 
   vector<Midi_event*> events_;
 
-  Midi_track (int number);
+  Midi_track (int number, bool port);
   ~Midi_track ();
 
   void add (int, Midi_item *midi);
index e69aa8712a04b5c0e63b97aee5ae43fec38633ed..9612fb8aedd6c301639b6e12c21a15533352790d 100644 (file)
@@ -27,7 +27,7 @@
 class Performance : public Music_output
 {
 public:
-  Performance ();
+  Performance (bool ports=false);
   ~Performance ();
   DECLARE_CLASSNAME(Performance);
 
@@ -43,6 +43,7 @@ public:
   vector<Audio_staff*> audio_staffs_;
   vector<Audio_element*> audio_elements_;
   Output_def *midi_;
+  bool ports_;
 };
 
 #endif /* PERFORMANCE_HH */
index aaed0a27feae45056a4d956880018029947cdcd4..9c2a4bdf100caa46ed90e19b5a4f8dc8b007131a 100644 (file)
@@ -24,7 +24,7 @@
 #include "std-string.hh"
 #include "string-convert.hh"
 
-Midi_track::Midi_track (int number)
+Midi_track::Midi_track (int number, bool port)
  : number_ (number)
 {
   //                4D 54 72 6B     MTrk
@@ -55,8 +55,12 @@ Midi_track::Midi_track (int number)
   // only for format 0 (currently using format 1)?
   data_string += String_convert::hex2bin (data_str0);
 
-  string port = "00" "ff" "21" "01" + String_convert::int2hex (number_, 2, '0');
-  data_string += String_convert::hex2bin (port);
+  if (port)
+    {
+      string port = "00" "ff" "21" "01"
+       + String_convert::int2hex (number_, 2, '0');
+      data_string += String_convert::hex2bin (port);
+    }
 
   char const *footer_str0 = "00" "ff2f" "00";
   string footer_string = String_convert::hex2bin (footer_str0);
index b07c8604cfde4c445f1fc1259d64e3c181cab29f..bcd8b42c50f12eb54574fa5443829f9a33b98e6f 100644 (file)
@@ -34,9 +34,10 @@ using namespace std;
 #include "string-convert.hh"
 #include "warn.hh"
 
-Performance::Performance ()
+Performance::Performance (bool ports)
+  : midi_ (0)
+  , ports_ (ports)
 {
-  midi_ = 0;
 }
 
 Performance::~Performance ()
@@ -58,7 +59,7 @@ Performance::output (Midi_stream &midi_stream) const
       Audio_staff *s = audio_staffs_[i];
       if (be_verbose_global)
        progress_indication ("[" + to_string (i));
-      s->output (midi_stream, i);
+      s->output (midi_stream, i, ports_);
       if (be_verbose_global)
        progress_indication ("]");
     }
index 99e41290c324dcf1d446d50d0f30de379533861c..5257788df6b7969ad07ec12925bf5ea0beab0695 100644 (file)
@@ -119,6 +119,9 @@ IMPLEMENT_LISTENER (Score_performer, finish);
 void
 Score_performer::finish (SCM)
 {
+  SCM channel_mapping = context ()->get_property ("midiChannelMapping");
+  bool use_ports = channel_mapping == ly_symbol2scm ("voice");
+  performance_->ports_ = use_ports;
   recurse_over_translators (context (),
                            &Translator::finalize,
                            &Translator_group::finalize,