]> git.donarmstrong.com Git - lilypond.git/commitdiff
Make midiMaximumVolume take effect without initial dynamic
authorAnders Pilegaard <arrowyard@gmail.com>
Fri, 22 Feb 2013 08:32:18 +0000 (09:32 +0100)
committerJames Lowe <pkx166h@gmail.com>
Sun, 17 Mar 2013 12:48:18 +0000 (12:48 +0000)
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.

lily/dynamic-performer.cc

index 86734d7ee62fb4bce8cd54a54ab6c6832899c3ed..936060bfc60bf7c4e673c9e699fa150abb2ab5c5 100644 (file)
@@ -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_);