]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-dynamic-performer.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / span-dynamic-performer.cc
index 557168fee5ba5a1e3096674885a81d13db5c1aff..3d8d053be2a303afa8213e18b00b2680fd9106a5 100644 (file)
@@ -3,11 +3,13 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "performer.hh"
+
 #include "audio-item.hh"
+#include "international.hh"
 #include "music.hh"
 
 /*
@@ -31,16 +33,16 @@ public:
 protected:
   virtual bool try_music (Music *);
   virtual void acknowledge_audio_element (Audio_element_info);
-  PRECOMPUTED_VIRTUAL void process_music ();
-  PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+  void process_music ();
+  void stop_translation_timestep ();
 
 private:
   Audio_dynamic *audio_;
   Real last_volume_;
   Music *span_start_event_;
   Drul_array<Music *> span_events_;
-  Array<Audio_dynamic_tuple> dynamic_tuples_;
-  Array<Audio_dynamic_tuple> finished_dynamic_tuples_;
+  vector<Audio_dynamic_tuple> dynamic_tuples_;
+  vector<Audio_dynamic_tuple> finished_dynamic_tuples_;
   Direction dir_;
   Direction finished_dir_;
 };
@@ -58,9 +60,7 @@ void
 Span_dynamic_performer::acknowledge_audio_element (Audio_element_info i)
 {
   if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (i.elem_))
-    {
-      last_volume_ = d->volume_;
-    }
+    last_volume_ = d->volume_;
 }
 
 void
@@ -74,7 +74,7 @@ Span_dynamic_performer::process_music ()
                               : span_events_[STOP]);
       announce_element (info);
       Audio_dynamic_tuple a = { audio_, now_mom () };
-      dynamic_tuples_.push (a);
+      dynamic_tuples_.push_back (a);
     }
 
   if (span_events_[STOP])
@@ -101,18 +101,14 @@ Span_dynamic_performer::process_music ()
 
       dynamic_tuples_.clear ();
       Audio_dynamic_tuple a = { audio_, now_mom () };
-      dynamic_tuples_.push (a);
+      dynamic_tuples_.push_back (a);
     }
 
   if (span_events_[STOP])
-    {
-      finished_dynamic_tuples_.top ().audio_->volume_ = last_volume_;
-    }
+    finished_dynamic_tuples_.back ().audio_->volume_ = last_volume_;
 
   if (span_events_[START])
-    {
-      dynamic_tuples_[0].audio_->volume_ = last_volume_;
-    }
+    dynamic_tuples_[0].audio_->volume_ = last_volume_;
 
   span_events_[START] = 0;
   span_events_[STOP] = 0;
@@ -124,7 +120,7 @@ Span_dynamic_performer::stop_translation_timestep ()
   if (finished_dynamic_tuples_.size () > 1)
     {
       Real start_volume = finished_dynamic_tuples_[0].audio_->volume_;
-      Real dv = finished_dynamic_tuples_.top ().audio_->volume_
+      Real dv = finished_dynamic_tuples_.back ().audio_->volume_
        - start_volume;
       /*
        urg.
@@ -142,12 +138,12 @@ Span_dynamic_performer::stop_translation_timestep ()
          // urg.  20%: about two volume steps
          dv = (Real)finished_dir_ * 0.2;
          if (!start_volume)
-           start_volume = finished_dynamic_tuples_.top
-             ().audio_->volume_ - dv;
+           start_volume = finished_dynamic_tuples_.back ().audio_->volume_
+             - dv;
        }
       Moment start_mom = finished_dynamic_tuples_[0].mom_;
-      Moment dt = finished_dynamic_tuples_.top ().mom_ - start_mom;
-      for (int i = 0; i < finished_dynamic_tuples_.size (); i++)
+      Moment dt = finished_dynamic_tuples_.back ().mom_ - start_mom;
+      for (vsize i = 0; i < finished_dynamic_tuples_.size (); i++)
        {
          Audio_dynamic_tuple *a = &finished_dynamic_tuples_[i];
          Real volume = start_volume + dv * (Real) (a->mom_ - start_mom).main_part_
@@ -184,4 +180,4 @@ Span_dynamic_performer::try_music (Music *r)
 ADD_TRANSLATOR (Span_dynamic_performer,
                "", "",
                "crescendo-event decrescendo-event",
-                "", "");
+               "", "");