diff options
author | Robin Gareus <robin@gareus.org> | 2017-09-28 16:06:57 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-09-29 05:03:48 +0200 |
commit | ddd4e3cf1d9e253f638719ca0664a0598383e857 (patch) | |
tree | de52e7ee2208218d610c4cc10167844128adceed | |
parent | f974cd5401f8e042f7c221261c5ce18b9adb8859 (diff) |
Aux-Send Latency compensation, part 1: latent sources
-rw-r--r-- | libs/ardour/ardour/internal_return.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/send.h | 1 | ||||
-rw-r--r-- | libs/ardour/internal_return.cc | 11 | ||||
-rw-r--r-- | libs/ardour/route.cc | 5 | ||||
-rw-r--r-- | libs/ardour/send.cc | 23 |
5 files changed, 29 insertions, 13 deletions
diff --git a/libs/ardour/ardour/internal_return.h b/libs/ardour/ardour/internal_return.h index d2c55b1763..dbc9bab3f2 100644 --- a/libs/ardour/ardour/internal_return.h +++ b/libs/ardour/ardour/internal_return.h @@ -44,6 +44,8 @@ class LIBARDOUR_API InternalReturn : public Return void add_send (InternalSend *); void remove_send (InternalSend *); + void set_playback_offset (samplecnt_t cnt); + private: /** sends that we are receiving data from */ std::list<InternalSend*> _sends; diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h index 6db3e61540..c0111936e5 100644 --- a/libs/ardour/ardour/send.h +++ b/libs/ardour/ardour/send.h @@ -67,6 +67,7 @@ class LIBARDOUR_API Send : public Delivery bool configure_io (ChanCount in, ChanCount out); /* latency compensation */ + void set_output_latency (samplecnt_t cnt); void set_delay_in (samplecnt_t); void set_delay_out (samplecnt_t); samplecnt_t get_delay_in () const { return _delay_in; } diff --git a/libs/ardour/internal_return.cc b/libs/ardour/internal_return.cc index b56e9e6a2f..0f7eb295d6 100644 --- a/libs/ardour/internal_return.cc +++ b/libs/ardour/internal_return.cc @@ -65,6 +65,17 @@ InternalReturn::remove_send (InternalSend* send) _sends.remove (send); } +void +InternalReturn::set_playback_offset (samplecnt_t cnt) +{ + Processor::set_playback_offset (cnt); + + Glib::Threads::Mutex::Lock lm (_sends_mutex); // TODO reader lock + for (list<InternalSend*>::iterator i = _sends.begin(); i != _sends.end(); ++i) { + (*i)->set_delay_out (cnt); + } +} + XMLNode& InternalReturn::state (bool full) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 2d24ac4ac6..6d1544fe41 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -502,11 +502,6 @@ Route::process_output_buffers (BufferSet& bufs, } #endif - if (boost::dynamic_pointer_cast<Send>(*i) != 0) { - // inform the reader that we're sending a late signal, - // relative to original (output aligned) start_sample - boost::dynamic_pointer_cast<Send>(*i)->set_delay_in (latency); - } if (boost::dynamic_pointer_cast<PluginInsert>(*i) != 0) { /* set potential sidechain ports, capture and playback latency. * This effectively sets jack port latency which should include diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 28f4286f70..ae442d5715 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -131,7 +131,14 @@ Send::deactivate () } void -Send::set_delay_in(samplecnt_t delay) +Send::set_output_latency (samplecnt_t cnt) +{ + Processor::set_output_latency (cnt); + set_delay_in (cnt); +} + +void +Send::set_delay_in (samplecnt_t delay) { if (!_delayline) return; if (_delay_in == delay) { @@ -140,13 +147,13 @@ Send::set_delay_in(samplecnt_t delay) _delay_in = delay; DEBUG_TRACE (DEBUG::LatencyCompensation, - string_compose ("Send::set_delay_in(%1) + %2 = %3\n", - delay, _delay_out, _delay_out + _delay_in)); - _delayline.get()->set_delay(_delay_out + _delay_in); + string_compose ("Send::set_delay_in %1: (%2) - %3 = %4\n", + name (), _delay_in, _delay_out, _delay_in - _delay_out)); + _delayline->set_delay(_delay_in - _delay_out); } void -Send::set_delay_out(samplecnt_t delay) +Send::set_delay_out (samplecnt_t delay) { if (!_delayline) return; if (_delay_out == delay) { @@ -154,9 +161,9 @@ Send::set_delay_out(samplecnt_t delay) } _delay_out = delay; DEBUG_TRACE (DEBUG::LatencyCompensation, - string_compose ("Send::set_delay_out(%1) + %2 = %3\n", - delay, _delay_in, _delay_out + _delay_in)); - _delayline.get()->set_delay(_delay_out + _delay_in); + string_compose ("Send::set_delay_out %1: %2 - (%3) = %4\n", + name (), _delay_in, _delay_out, _delay_in - _delay_out)); + _delayline->set_delay(_delay_in - _delay_out); } void |