Aux-Send Latency compensation, part 1: latent sources

This commit is contained in:
Robin Gareus 2017-09-28 16:06:57 +02:00
parent f974cd5401
commit ddd4e3cf1d
5 changed files with 29 additions and 13 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -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)
{

View File

@ -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

View File

@ -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