]> git.donarmstrong.com Git - lilypond.git/commitdiff
Midi: initial volume if a Voice begins in (de)cresc
authorHeikki Tauriainen <g034737@welho.com>
Sun, 5 Aug 2012 19:32:12 +0000 (12:32 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Fri, 10 Aug 2012 08:28:00 +0000 (01:28 -0700)
morgenleid.ly: put dynamic in logical Voice; no print changes

input/regression/morgenlied.ly
input/regression/typography-demo.ly
lily/dynamic-performer.cc

index 182cc640864970706951b12db58e3df5069121df..49fd4b1826201f40b382f37f03852f0b9a7f125c 100644 (file)
@@ -112,7 +112,7 @@ pianoRH =  \relative c''' \repeat volta 2 {
     <g e>8( <es fis a> <d f b> <c e c'>) r8 r | 
     r8 c'( e,) f r a |
     \once \override DynamicLineSpanner   #'padding =#3
-    r8 << { s8 s8 }  << { fis(\> g)\!
+    r8 << { s8\> s8\! }  << { fis( g)
                            } \\ { c,4 } >> >> r8 <e c g> <e c g> |
     <d c a>4. r8 \clef bass  <d b f> <d b f> |
     e,16_" "_\markup { \bold\italic cresc. } g c g e g d gis b gis d gis |
index d6d87d15d8f1d10e170d7d7daf9638efa1d85f73..b6d2c74f88812cb2e3933bdb7b8baacb63089cdc 100644 (file)
@@ -9,6 +9,8 @@ heavily mutilated Edition Peters Morgenlied by Schubert"
 }
 
 \version "2.15.32"
+#(ly:expect-warning (_ "(De)crescendo with unspecified starting volume in MIDI."))
+#(ly:expect-warning (_ "(De)crescendo with unspecified starting volume in MIDI."))
 
 ignoreMelisma =        \set ignoreMelismata = ##t
 ignoreMelismaOff = \unset ignoreMelismata 
index 978a8d2a6e1e768bfb3995a273a32647b7c554b3..86734d7ee62fb4bce8cd54a54ab6c6832899c3ed 100644 (file)
@@ -20,6 +20,7 @@
 #include "performer.hh"
 #include "audio-item.hh"
 #include "stream-event.hh"
+#include "international.hh"
 
 #include "translator.icc"
 
@@ -40,6 +41,7 @@ private:
   Drul_array<Stream_event *> span_events_;
   Drul_array<Direction> grow_dir_;
   Real last_volume_;
+  bool last_volume_initialized_;
   Audio_dynamic *absolute_;
   Audio_span_dynamic *span_dynamic_;
   Audio_span_dynamic *finished_span_dynamic_;
@@ -47,7 +49,8 @@ private:
 
 Dynamic_performer::Dynamic_performer ()
 {
-  last_volume_ = 0.5;
+  last_volume_ = 0.0;
+  last_volume_initialized_ = false;
   script_event_ = 0;
   absolute_ = 0;
   span_events_[LEFT]
@@ -104,26 +107,41 @@ Dynamic_performer::process_music ()
 {
   if (span_events_[STOP] || script_event_)
     {
+      // End of a dynamic spanner, or an explicit dynamic script event.
       finished_span_dynamic_ = span_dynamic_;
       span_dynamic_ = 0;
     }
 
   if (span_events_[START])
     {
+      // Start of a dynamic spanner.  Create a new Audio_span_dynamic for
+      // collecting changes in dynamics within this spanner.
       span_dynamic_ = new Audio_span_dynamic (equalize_volume (0.1), equalize_volume (1.0));
       announce_element (Audio_element_info (span_dynamic_, span_events_[START]));
 
       span_dynamic_->grow_dir_ = grow_dir_[START];
+
+      if (!last_volume_initialized_ && !script_event_)
+        {
+          // No explicit dynamic script events have occurred yet, but there is
+          // nevertheless a dynamic spanner.  Initialize last_volume_ to a
+          // value within the available range.
+          span_events_[START]->origin ()->warning (_ ("(De)crescendo with unspecified starting volume in MIDI."));
+          last_volume_ = equalize_volume (0.5);
+          last_volume_initialized_ = true;
+        }
     }
 
   if (script_event_
       || span_dynamic_
       || finished_span_dynamic_)
     {
+      // New change in dynamics.
       absolute_ = new Audio_dynamic ();
 
       if (script_event_)
         {
+          // Explicit dynamic script event: determine the volume.
           SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
 
           SCM svolume = SCM_EOL;
@@ -137,6 +155,7 @@ Dynamic_performer::process_music ()
 
           last_volume_
             = absolute_->volume_ = equalize_volume (volume);
+          last_volume_initialized_ = true;
         }
 
       Audio_element_info info (absolute_, script_event_);
@@ -166,6 +185,7 @@ Dynamic_performer::stop_translation_timestep ()
   else if (absolute_)
     {
       last_volume_ = absolute_->volume_;
+      last_volume_initialized_ = true;
     }
 
   absolute_ = 0;