From 0a52b325f4e1eaf39be65a24f9a594ffe1f66e79 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 10 Jul 2016 02:40:24 +0200 Subject: [PATCH] align stem-export (raw track outputs (with and w/p processing) --- libs/ardour/ardour/capturing_processor.h | 6 +++++- libs/ardour/capturing_processor.cc | 15 ++++++++++++--- libs/ardour/route.cc | 4 +++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/capturing_processor.h b/libs/ardour/ardour/capturing_processor.h index b5cdc8739c..dccb7eb99e 100644 --- a/libs/ardour/ardour/capturing_processor.h +++ b/libs/ardour/ardour/capturing_processor.h @@ -20,14 +20,16 @@ #ifndef __ardour_capturing_processor_h__ #define __ardour_capturing_processor_h__ +#include "ardour/fixed_delay.h" #include "ardour/processor.h" +#include "ardour/types.h" namespace ARDOUR { class LIBARDOUR_API CapturingProcessor : public Processor { public: - CapturingProcessor (Session & session); + CapturingProcessor (Session & session, framecnt_t latency); ~CapturingProcessor(); public: // main interface @@ -47,6 +49,8 @@ class LIBARDOUR_API CapturingProcessor : public Processor framecnt_t block_size; BufferSet capture_buffers; + FixedDelay _delaybuffers; + framecnt_t _latency; }; } // namespace ARDOUR diff --git a/libs/ardour/capturing_processor.cc b/libs/ardour/capturing_processor.cc index 755a00c4c4..8951bee487 100644 --- a/libs/ardour/capturing_processor.cc +++ b/libs/ardour/capturing_processor.cc @@ -26,9 +26,10 @@ namespace ARDOUR { -CapturingProcessor::CapturingProcessor (Session & session) +CapturingProcessor::CapturingProcessor (Session & session, framecnt_t latency) : Processor (session, X_("capture point")) , block_size (AudioEngine::instance()->samples_per_cycle()) + , _latency (latency) { realloc_buffers (); } @@ -48,8 +49,14 @@ CapturingProcessor::set_block_size (pframes_t nframes) void CapturingProcessor::run (BufferSet& bufs, framepos_t, framepos_t, double, pframes_t nframes, bool) { - if (active()) { - capture_buffers.read_from (bufs, nframes); + if (!active()) { + _delaybuffers.flush (); + return; + } + for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { + for (uint32_t b = 0; b < bufs.count().get (*t); ++b) { + _delaybuffers.delay (*t, b, capture_buffers.get (*t, b), bufs.get (*t, b), nframes, 0, 0); + } } } @@ -57,6 +64,7 @@ bool CapturingProcessor::configure_io (ChanCount in, ChanCount out) { Processor::configure_io (in, out); + _delaybuffers.set (out, _latency); realloc_buffers(); return true; } @@ -72,6 +80,7 @@ void CapturingProcessor::realloc_buffers() { capture_buffers.ensure_buffers (_configured_input, block_size); + _delaybuffers.flush (); } XMLNode & diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 56cd04d84a..fa564968ed 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3716,7 +3716,9 @@ Route::add_export_point() Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); Glib::Threads::RWLock::WriterLock lw (_processor_lock); - _capturing_processor.reset (new CapturingProcessor (_session)); + // this aligns all tracks; but not tracks + busses + assert (_session.worst_track_latency () >= _initial_delay); + _capturing_processor.reset (new CapturingProcessor (_session, _session.worst_track_latency () - _initial_delay)); _capturing_processor->activate (); configure_processors_unlocked (0, &lw);