From: Anders Pilegaard Date: Fri, 22 Feb 2013 08:32:18 +0000 (+0100) Subject: Make midiMaximumVolume take effect without initial dynamic X-Git-Tag: release/2.17.15-1~17^2~22 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a970166b725ea78a1b3866e0a0bd208155193222;p=lilypond.git Make midiMaximumVolume take effect without initial dynamic Issue 3234 My idea is to ensure that the volume is *always* initialised in Dynamic_performer::process_music. The code to do that is mostly copied from what happens if there is an actual script event. The constant 0.71 was obtained by calculating backwards from the default velocity value (0x5a) in the Midi_note constructor, midi-item.cc line 179. I found that I had to create and announce an Audio_element_info for the change to take effect. Backward compatibility notes ---------------------------- As far as the music itself goes there are a few cases: - Music that doesn't set midiMaximumVolume or midiMinimumVolume will be unchanged, as the default dynamic setting is chosen so the calculated midi velocity is the same as the current default when no volume is set. - Music that sets midiMaximumVolume or midiMinimumVolume and has initial dynamic expressions will be unchanged - the explicit dynamic takes effect before the first midi note is created. - Music that sets midiMaximumVolume or midiMinimumVolume but doesn't have an initial dynamic expression will change. In the current version such would be an error, so I don't expect many of those. --- diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 86734d7ee6..936060bfc6 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -162,6 +162,18 @@ Dynamic_performer::process_music () announce_element (info); } + if (!last_volume_initialized_) + { + absolute_ = new Audio_dynamic (); + + last_volume_ + = absolute_->volume_ = equalize_volume (0.71); // Backward compatible + last_volume_initialized_ = true; + + Audio_element_info info (absolute_, script_event_); + announce_element (info); + } + if (span_dynamic_) span_dynamic_->add_absolute (absolute_);