]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/staff-performer.cc
MIDI: midiChannelMapping = #'staff mode creates only one Track per staff.
[lilypond.git] / lily / staff-performer.cc
index 5e124c8bafb0451680254acc43b745b6c72b0c68..35b1746b8a36800a2db601a2c2d5cc6b16fd723a 100644 (file)
@@ -105,9 +105,13 @@ Audio_staff*
 Staff_performer::new_audio_staff (string voice)
 {
   Audio_staff* audio_staff = new Audio_staff;
-  name_ = new Audio_text (Audio_text::TRACK_NAME, context ()->id_string ()
-                         + ":" + voice);
-  audio_staff->add_audio_item (name_);
+  string track_name = context ()->id_string () + ":" + voice;
+  if (track_name != ":")
+    {
+      name_ = new Audio_text (Audio_text::TRACK_NAME, context ()->id_string ()
+                             + ":" + voice);
+      audio_staff->add_audio_item (name_);
+    }
   announce_element (Audio_element_info (audio_staff, 0));
   announce_element (Audio_element_info (name_, 0));
   staff_map_[voice] = audio_staff;
@@ -117,6 +121,11 @@ Staff_performer::new_audio_staff (string voice)
 Audio_staff*
 Staff_performer::get_audio_staff (string voice)
 {
+  SCM channel_mapping = get_property ("midiChannelMapping");
+  if (channel_mapping != ly_symbol2scm ("instrument")
+      && staff_map_.size ())
+    return staff_map_.begin ()->second;
+
   map<string, Audio_staff*>::const_iterator i = staff_map_.find (voice);
   if (i != staff_map_.end ())
     return i->second;
@@ -179,8 +188,6 @@ Staff_performer::finalize ()
 {
   staff_map_.clear ();
   channel_map_.clear ();
-  channel_count_ = 0;
-  static_channel_map_.clear ();
 }
 
 string
@@ -201,8 +208,9 @@ Staff_performer::new_instrument_string ()
 int
 Staff_performer::get_channel (string instrument)
 {
-  SCM channel_per_staff = get_property ("midiChannelPerStaff");
-  map<string, int>& channel_map = (channel_per_staff == SCM_BOOL_T)
+  SCM channel_mapping = get_property ("midiChannelMapping");
+  map<string, int>& channel_map
+    = (channel_mapping != ly_symbol2scm ("instrument"))
     ? channel_map_
     : static_channel_map_;
 
@@ -210,14 +218,17 @@ Staff_performer::get_channel (string instrument)
   if (i != channel_map.end ())
     return i->second;
  
-  int channel = (channel_per_staff == SCM_BOOL_T)
+  int channel = (channel_mapping == ly_symbol2scm ("staff"))
     ? channel_count_++
-    :channel_map.size ();
+    : channel_map.size ();
 
   /* MIDI players tend to ignore instrument settings on channel
      10, the percussion channel.  */
   if (channel % 16 == 9)
-    channel_map["percussion"] = channel++;
+    {
+      channel_map["percussion"] = channel++;
+      channel_count_++;
+    }
 
   if (channel > 15)
     {
@@ -240,10 +251,14 @@ Staff_performer::acknowledge_audio_element (Audio_element_info inf)
       string voice;
       if (c->is_alias (ly_symbol2scm ("Voice")))
        voice = c->id_string ();
+      SCM channel_mapping = get_property ("midiChannelMapping");
+      if (channel_mapping == ly_symbol2scm ("voice"))
+       channel_ = get_channel (voice);
       string str = new_instrument_string ();
       if (str.length ())
        {
-         channel_ = get_channel (str);
+         if (channel_mapping != ly_symbol2scm ("voice"))
+           channel_ = get_channel (str);
          set_instrument (channel_, voice);
          set_instrument_name (voice);
        }