]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/staff-performer.cc
Midi: always set instrument for new track. Unconfuses some midi players.
[lilypond.git] / lily / staff-performer.cc
index 3fc26fa45632d826e05345ea2f778aaf47fb6e15..1f34290aac4451d185499cb8c01678daff86534f 100644 (file)
@@ -105,12 +105,18 @@ 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 (name_, 0));
+    }
   announce_element (Audio_element_info (audio_staff, 0));
-  announce_element (Audio_element_info (name_, 0));
   staff_map_[voice] = audio_staff;
+  if (!instrument_string_.empty ())
+    set_instrument (channel_, voice);
   return audio_staff;
 }
 
@@ -118,7 +124,7 @@ Audio_staff*
 Staff_performer::get_audio_staff (string voice)
 {
   SCM channel_mapping = get_property ("midiChannelMapping");
-  if (channel_mapping == ly_symbol2scm ("voice")
+  if (channel_mapping != ly_symbol2scm ("instrument")
       && staff_map_.size ())
     return staff_map_.begin ()->second;
 
@@ -184,8 +190,6 @@ Staff_performer::finalize ()
 {
   staff_map_.clear ();
   channel_map_.clear ();
-  channel_count_ = 0;
-  static_channel_map_.clear ();
 }
 
 string
@@ -223,7 +227,10 @@ Staff_performer::get_channel (string instrument)
   /* 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)
     {
@@ -259,8 +266,12 @@ Staff_performer::acknowledge_audio_element (Audio_element_info inf)
        }
       Audio_staff* audio_staff = get_audio_staff (voice);
       ai->channel_ = channel_;
+      // Output volume as velocity and disable Midi_dynamic output
       if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (inf.elem_))
-       dynamic_map_[voice] = d->volume_;
+       {
+         dynamic_map_[voice] = d->volume_;
+         d->volume_ = -1;
+       }
       if (Real d = get_dynamic (voice))
        if (Audio_note *n = dynamic_cast<Audio_note *> (inf.elem_))
          n->volume_ = d;