lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue 4936: look up "mf" for default initial volume (issue 308890043 by


From: nine . fierce . ballads
Subject: Issue 4936: look up "mf" for default initial volume (issue 308890043 by address@hidden)
Date: Sun, 31 Jul 2016 11:32:11 -0700

Reviewers: ht,

Description:
Issue 4936: look up "mf" for default initial volume

When the Dynamic_performer begins processing, if no dynamic is
specified, act as if "mf" were specified.

Changes in note velocity from 90 to 86 in many MIDI regression tests
are expected.

Please review this at https://codereview.appspot.com/308890043/

Affected files (+24, -12 lines):
  M input/regression/midi/dynamic-initial.ly
  M lily/audio-item.cc
  M lily/dynamic-performer.cc


Index: input/regression/midi/dynamic-initial.ly
diff --git a/input/regression/midi/dynamic-initial.ly b/input/regression/midi/dynamic-initial.ly index fca7c8ab8117f792faca183aaa5410faa1830064..f19f14adadfbfe5fe3cee55f4297c61428550bb4 100644
--- a/input/regression/midi/dynamic-initial.ly
+++ b/input/regression/midi/dynamic-initial.ly
@@ -1,7 +1,19 @@
 \version "2.19.44"

 \header {
-  texidoc="The MIDI performer uses a default initial dynamic"
+  texidoc="The MIDI performer uses mf as the default initial dynamic"
+}
+
+% To demonstrate that the performer is indeed looking up the initial
+% volume, use a value for "mf" that is different than the default.
+\midi {
+  \context {
+    \Voice
+    dynamicAbsoluteVolumeFunction = #(lambda (dynamic)
+        (if (equal? dynamic "mf")
+         (/ 30 127)
+         (default-dynamic-absolute-volume dynamic)))
+  }
 }

 \score {
Index: lily/audio-item.cc
diff --git a/lily/audio-item.cc b/lily/audio-item.cc
index a8a78199c73096c15375110f5c50020b28912d13..ea5e3e0d20225b8d838b075e2b1b11a1584f6786 100644
--- a/lily/audio-item.cc
+++ b/lily/audio-item.cc
@@ -104,7 +104,11 @@ Audio_key::Audio_key (int acc, bool major)

 const Real Audio_span_dynamic::MINIMUM_VOLUME = 0.0;
 const Real Audio_span_dynamic::MAXIMUM_VOLUME = 1.0;
-const Real Audio_span_dynamic::DEFAULT_VOLUME = 90.0 / 127.0;
+// It is preferable to get the value for "mf" from context properties when
+// possible, but we still need a default for robustness.  This value is
+// slightly higher than "mf" in absolute-volume-alist, so it should be obvious +// to a person inspecting MIDI code while not being very noticeable to the ear.
+const Real Audio_span_dynamic::DEFAULT_VOLUME = 88.0 / 127.0;

 Audio_span_dynamic::Audio_span_dynamic (Moment mom, Real volume)
   : start_moment_ (mom),
Index: lily/dynamic-performer.cc
diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc
index 857b3590dc1a143e29ec813c71bb1fa523129c2f..c30676b6f086c110c1cddd8c93fcb11d7d2e5673 100644
--- a/lily/dynamic-performer.cc
+++ b/lily/dynamic-performer.cc
@@ -50,8 +50,7 @@ private:
   // next_vol < 0 means select a target dynamic based on growth direction.
   // return actual next volume (computed if not provided)
   Real finish_queued_spans (Real next_vol = -1.0);
-  Real look_up_absolute_volume (SCM dynamicString,
-                                Real defaultValue);
+  Real look_up_absolute_volume (SCM dynamicString);

 private:
// This performer queues a number of dynamic spans waiting for the following
@@ -363,8 +362,7 @@ Dynamic_performer::finalize ()
 }

 Real
-Dynamic_performer::look_up_absolute_volume (SCM dynamicString,
-                                            Real defaultValue)
+Dynamic_performer::look_up_absolute_volume (SCM dynamicString)
 {
   SCM proc = get_property ("dynamicAbsoluteVolumeFunction");

@@ -372,7 +370,7 @@ Dynamic_performer::look_up_absolute_volume (SCM dynamicString,
   if (ly_is_procedure (proc))
     svolume = scm_call_1 (proc, dynamicString);

-  return robust_scm2double (svolume, defaultValue);
+  return robust_scm2double (svolume, Audio_span_dynamic::DEFAULT_VOLUME);
 }

 void
@@ -382,15 +380,13 @@ Dynamic_performer::process_music ()

   if (script_event_) // explicit dynamic
     {
- volume = look_up_absolute_volume (script_event_->get_property ("text"), - Audio_span_dynamic::DEFAULT_VOLUME); + volume = look_up_absolute_volume (script_event_->get_property ("text"));
       volume = equalize_volume (volume);
     }
   else if (!open_span_.dynamic_) // first time only
     {
-      // Idea: look_up_absolute_volume (ly_symbol2scm ("mf")).
-      // It is likely to change regtests.
-      volume = equalize_volume (Audio_span_dynamic::DEFAULT_VOLUME);
+      volume = look_up_absolute_volume (scm_from_ascii_string ("mf"));
+      volume = equalize_volume (volume);
     }

   // end the current span at relevant points





reply via email to

[Prev in Thread] Current Thread [Next in Thread]