diff options
author | Robin Gareus <robin@gareus.org> | 2019-12-09 18:23:17 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-12-09 18:54:44 +0100 |
commit | 21f682164e8c4d7d0c1361a62e63c9ab09bc079f (patch) | |
tree | 2b425dad1c5cf32c7abe50a69fa34d9d865afb3e /libs/ardour/route.cc | |
parent | 319b029579aa7a7b72b70bdd663e0025fae4471c (diff) |
Fix automation alignment for latent plugins
This also solves bi-stable automation for plugins where latency
can change due to automation. e.g.
cycle 1: run (t): automation (t) = on: -> increase latency
cycle 2: run (t-latency): automation (t-latency) = off -> decrease latency
repeat.
Diffstat (limited to 'libs/ardour/route.cc')
-rw-r--r-- | libs/ardour/route.cc | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a06d4fd3d6..3bc66f1a30 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -513,24 +513,32 @@ Route::process_output_buffers (BufferSet& bufs, pspeed = 0; } - if (speed < 0) { - (*i)->run (bufs, start_sample + latency, end_sample + latency, pspeed, nframes, *i != _processors.back()); - } else { - (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); - } - - bufs.set_count ((*i)->output_streams()); - - /* Note: plugin latency may change. While the plugin does inform the session via + /* Note: plugin latency may change. The plugin does inform the session via * processor_latency_changed(). But the session may not yet have gotten around to * update the actual worste-case and update this track's _signal_latency. - * * So there can be cases where adding up all latencies may not equal _signal_latency. + * + * Also running a plugin may change the plugin's latency, so we need to + * add the latency first. Otherwise this can lead to bistable case + * in case of automation playback. e.g. + * + * cycle 1: run (t): automation (t) = on: -> increase latency + * cycle 2: run (t-latency): automation (t-latency) = off -> decrease latency + * reapeat. */ + if ((*i)->active ()) { latency += (*i)->effective_latency (); } + if (speed < 0) { + (*i)->run (bufs, start_sample + latency, end_sample + latency, pspeed, nframes, *i != _processors.back()); + } else { + (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); + } + + bufs.set_count ((*i)->output_streams()); + if (re_inject_oob_data) { write_out_of_band_data (bufs, nframes); } |