diff options
author | Robin Gareus <robin@gareus.org> | 2014-06-15 16:21:09 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-06-15 16:21:09 +0200 |
commit | b0bab058d0a89faacf98bb7b6142f7f69c7c9bcb (patch) | |
tree | cf8074e142a25d3d89a1658b14c4170254ccbd6e | |
parent | b6e81dcdae320f69a00ece27434e762d3f18aaae (diff) |
offset automation by latency
-rw-r--r-- | libs/ardour/ardour/route.h | 1 | ||||
-rw-r--r-- | libs/ardour/route.cc | 18 |
2 files changed, 16 insertions, 3 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index ff06724731..9d785e7341 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -485,6 +485,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou bool _active; framecnt_t _signal_latency; + framecnt_t _signal_latency_at_amp_position; framecnt_t _initial_delay; framecnt_t _roll_delay; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index bca3ea9c54..6930b9e71b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -80,6 +80,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type) , GraphNode (sess._process_graph) , _active (true) , _signal_latency (0) + , _signal_latency_at_amp_position (0) , _initial_delay (0) , _roll_delay (0) , _flags (flg) @@ -434,7 +435,10 @@ Route::process_output_buffers (BufferSet& bufs, /* figure out if we're going to use gain automation */ if (gain_automation_ok) { _amp->set_gain_automation_buffer (_session.gain_automation_buffer ()); - _amp->setup_gain_automation (start_frame, end_frame, nframes); + _amp->setup_gain_automation ( + start_frame + _signal_latency_at_amp_position, + end_frame + _signal_latency_at_amp_position, + nframes); } else { _amp->apply_gain_automation (false); } @@ -543,7 +547,7 @@ Route::process_output_buffers (BufferSet& bufs, boost::dynamic_pointer_cast<Send>(*i)->set_delay_in(_signal_latency - latency); } - (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back()); + (*i)->run (bufs, start_frame - latency, end_frame - latency, nframes, *i != _processors.back()); bufs.set_count ((*i)->output_streams()); if ((*i)->active ()) { @@ -562,7 +566,6 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes, return; } - // TODO cache this value. framecnt_t latency = bounce_get_latency(_amp, false, for_export, for_freeze); _amp->set_gain_automation_buffer (_session.gain_automation_buffer ()); _amp->setup_gain_automation (start - latency, start - latency + nframes, nframes); @@ -3313,15 +3316,24 @@ framecnt_t Route::update_signal_latency () { framecnt_t l = _output->user_latency(); + framecnt_t lamp = 0; + bool before_amp = true; for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { if ((*i)->active ()) { l += (*i)->signal_latency (); } + if ((*i) == _amp) { + before_amp = false; + } + if (before_amp) { + lamp = l; + } } DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l)); + _signal_latency_at_amp_position = lamp; if (_signal_latency != l) { _signal_latency = l; signal_latency_changed (); /* EMIT SIGNAL */ |