X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdynamic-performer.cc;h=2a2a1fbd2a2af41b63aa76b8bb68e5e42a865ab2;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=857b3590dc1a143e29ec813c71bb1fa523129c2f;hpb=cb2895f4abe165c0022ae2519111f73a0e775c30;p=lilypond.git diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 857b3590dc..2a2a1fbd2a 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -30,6 +30,7 @@ class Dynamic_performer : public Performer public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: + virtual void acknowledge_audio_element (Audio_element_info info); virtual void finalize (); void stop_translation_timestep (); void process_music (); @@ -111,6 +112,7 @@ private: }; private: + vector notes_; Stream_event *script_event_; Drul_array span_events_; Direction next_grow_dir_; @@ -121,8 +123,9 @@ private: State state_; }; -Dynamic_performer::Dynamic_performer () - : script_event_ (0), +Dynamic_performer::Dynamic_performer (Context *c) + : Performer (c), + script_event_ (0), next_grow_dir_ (CENTER), depart_dir_ (CENTER), state_ (STATE_INITIAL) @@ -131,6 +134,16 @@ Dynamic_performer::Dynamic_performer () = span_events_[RIGHT] = 0; } +void +Dynamic_performer::acknowledge_audio_element (Audio_element_info inf) +{ + // Keep track of the notes played in this translation time step so that they + // can be pointed to the current dynamic in stop_translation_timestep. + if (Audio_note *n = dynamic_cast (inf.elem_)) { + notes_.push_back (n); + } +} + bool Dynamic_performer::drive_state_machine (Direction next_grow_dir) { @@ -429,6 +442,19 @@ Dynamic_performer::process_music () void Dynamic_performer::stop_translation_timestep () { + // link notes to the current dynamic + if (!open_span_.dynamic_) + programming_error("no current dynamic"); + else + { + for (vector::const_iterator ni = notes_.begin (); + ni != notes_.end (); ++ni) + { + (*ni)->dynamic_ = open_span_.dynamic_; + } + } + notes_.clear (); + script_event_ = 0; span_events_[LEFT] = span_events_[RIGHT] = 0;