]> git.donarmstrong.com Git - lilypond.git/commitdiff
Do not output CC#7 events in MIDI on dynamic changes
authorHeikki Tauriainen <g034737@welho.com>
Thu, 7 Jan 2016 08:05:27 +0000 (10:05 +0200)
committerJames Lowe <pkx166h@gmail.com>
Fri, 15 Jan 2016 19:51:33 +0000 (19:51 +0000)
As volume changes for MIDI are encoded as note velocities, it is not
necessary to add "silent" Audio_dynamic elements to Audio_staffs to
be processed by Midi_walker.  (Every "silent" Audio_dynamic event
will only get converted to a Midi_dynamic event outputted as a CC#7
event with fixed volume 100 in MIDI, see Midi_dynamic::to_string.
This behavior is not consistent with the handling of other MIDI
controls on which LilyPond will not enforce any "default" values.)

As Staff_performer::get_audio_staff has the side effect of creating
a new Audio_staff for a voice if it does not yet exist, accessing the
current voice's associated Audio_staff was moved before the handling
of Audio_dynamic elements.

Based on the revision history, not emitting any CC#7 events in MIDI
appears to have been the original intention when encoding dynamic
changes as note velocities (93b7a6ff072d73dcdd41da59cd18da8aa8d8e8cb),
but apparently the initial implementation (of passing "silent"
Audio_dynamic events to Midi_walker, and ignoring them only at the
output stage) caused problems with MIDI timing (#1593), possibly
because skipping these events only just before outputting them might
have interfered with the logic for tracking the delta times between
the MIDI events that would be actually outputted.  To fix #1593,
commit f114e3c33f9c37c39c7a3fedf66ca5a074785118 conservatively
restored the emission of CC#7 events in MIDI.

The current commit tries to avoid the issues with MIDI timing by
pruning all Audio_dynamic events already from the input given to
Midi_walker, so that Midi_walker sees no events, the skipping of
which would confuse the measurement of delta times at the output
stage.

lily/staff-performer.cc

index 0648d0aae8bee5c8a7214c563d54798526344092..26781f0dcd5b53529d6f1ba986b011cdfc73a09a 100644 (file)
@@ -331,6 +331,7 @@ Staff_performer::acknowledge_audio_element (Audio_element_info inf)
           set_instrument_name (voice);
         }
       ai->channel_ = channel_;
+      Audio_staff *audio_staff = get_audio_staff (voice);
       bool encode_dynamics_as_velocity_ = true;
       if (encode_dynamics_as_velocity_)
         {
@@ -344,11 +345,11 @@ Staff_performer::acknowledge_audio_element (Audio_element_info inf)
           else if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (inf.elem_))
             {
               dynamic_map_[voice] = d;
-              // Output volume as velocity: must disable Midi_dynamic output
-              d->silent_ = true;
+              // Output volume as velocity: skip Midi_dynamic output for the
+              // current element.
+              return;
             }
         }
-      Audio_staff *audio_staff = get_audio_staff (voice);
       audio_staff->add_audio_item (ai);
     }
 }