X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdynamic-performer.cc;h=2a2a1fbd2a2af41b63aa76b8bb68e5e42a865ab2;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=6acf7d00a19ff0dafc37a7d38abc1c55daf81614;hpb=3f196c939480dbb2b82c4aeb5692c90c0677e67d;p=lilypond.git diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 6acf7d00a1..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) { @@ -256,11 +269,11 @@ Dynamic_performer::compute_departure_volume (Direction depart_dir, const Real vol_range = max_vol - min_vol; - const Real near = minmax (depart_dir, start_vol, end_vol) + const Real near_vol = minmax (depart_dir, start_vol, end_vol) + depart_dir * near_padding * vol_range; - const Real far = minmax (-depart_dir, start_vol, end_vol) + const Real far_vol = minmax (-depart_dir, start_vol, end_vol) + depart_dir * far_padding * vol_range; - const Real depart_vol = minmax (depart_dir, near, far); + const Real depart_vol = minmax (depart_dir, near_vol, far_vol); return max (min (depart_vol, max_vol), min_vol); } @@ -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;