]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-dynamic-performer.cc
Fix #122.
[lilypond.git] / lily / span-dynamic-performer.cc
index 3d8d053be2a303afa8213e18b00b2680fd9106a5..e5938f0852e7ae3a48e9d14f4ba6f40b211cdb59 100644 (file)
@@ -10,7 +10,9 @@
 
 #include "audio-item.hh"
 #include "international.hh"
-#include "music.hh"
+#include "stream-event.hh"
+
+#include "translator.icc"
 
 /*
   TODO: fold this into 1 engraver: \< and \> should also stop when
@@ -31,16 +33,17 @@ public:
   TRANSLATOR_DECLARATIONS (Span_dynamic_performer);
 
 protected:
-  virtual bool try_music (Music *);
   virtual void acknowledge_audio_element (Audio_element_info);
   void process_music ();
   void stop_translation_timestep ();
 
+  DECLARE_TRANSLATOR_LISTENER (decrescendo);
+  DECLARE_TRANSLATOR_LISTENER (crescendo);
 private:
   Audio_dynamic *audio_;
   Real last_volume_;
-  Music *span_start_event_;
-  Drul_array<Music *> span_events_;
+  Stream_event *span_start_event_;
+  Drul_array<Stream_event *> span_events_;
   vector<Audio_dynamic_tuple> dynamic_tuples_;
   vector<Audio_dynamic_tuple> finished_dynamic_tuples_;
   Direction dir_;
@@ -81,7 +84,7 @@ Span_dynamic_performer::process_music ()
     {
       if (!span_start_event_)
        {
-         span_events_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo"));
+         span_events_[STOP]->origin ()->warning (_ ("cannot find start of (de)crescendo"));
          span_events_[STOP] = 0;
        }
       else
@@ -95,7 +98,7 @@ Span_dynamic_performer::process_music ()
 
   if (span_events_[START])
     {
-      dir_ = (span_events_[START]->is_mus_type ("crescendo-event"))
+      dir_ = (span_events_[START]->in_event_class ("crescendo-event"))
        ? RIGHT : LEFT;
       span_start_event_ = span_events_[START];
 
@@ -155,7 +158,6 @@ Span_dynamic_performer::stop_translation_timestep ()
 
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 
@@ -163,21 +165,22 @@ Span_dynamic_performer::stop_translation_timestep ()
   span_events_[START] = 0;
 }
 
-bool
-Span_dynamic_performer::try_music (Music *r)
+IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, decrescendo);
+void
+Span_dynamic_performer::listen_decrescendo (Stream_event *r)
 {
-  if (r->is_mus_type ("crescendo-event")
-      || r->is_mus_type ("decrescendo-event"))
-    {
-      Direction d = to_dir (r->get_property ("span-direction"));
-      span_events_[d] = r;
-      return true;
-    }
-  return false;
+  Direction d = to_dir (r->get_property ("span-direction"));
+  span_events_[d] = r;
+}
+
+IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, crescendo);
+void
+Span_dynamic_performer::listen_crescendo (Stream_event *r)
+{
+  Direction d = to_dir (r->get_property ("span-direction"));
+  span_events_[d] = r;
 }
-#include "translator.icc"
 
 ADD_TRANSLATOR (Span_dynamic_performer,
                "", "",
-               "crescendo-event decrescendo-event",
                "", "");