From d9de72215b85fb480bca948069d2c583aa342544 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 5 Jul 2016 00:38:52 +0200 Subject: [PATCH] fix bypassing plugins with sidechain i/o --- libs/ardour/ardour/plugin_insert.h | 1 + libs/ardour/plugin_insert.cc | 34 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 5ec35d0589..9f1d56b811 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -96,6 +96,7 @@ class LIBARDOUR_API PluginInsert : public Processor bool pre_seed (const ChanCount&, const ChanCount&, const ChanMapping&, const ChanMapping&, const ChanMapping&); ChanMapping input_map () const; ///< combined (all instances) input map + ChanMapping no_sc_input_map () const; ///< combined (all instances) input map w/o sidechain sinks ChanMapping output_map () const; ///< combined (all instances) output map bool has_midi_bypass () const; bool has_midi_thru () const; diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 92d4897c6b..8c1fe8bac6 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -858,8 +858,8 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes) */ // TODO: atomically copy maps & _no_inplace - ChanMapping in_map (input_map ()); - ChanMapping out_map (output_map ()); + const ChanMapping in_map (no_sc_input_map ()); + const ChanMapping out_map (output_map ()); if (_mapping_changed) { _no_inplace = check_inplace (); _mapping_changed = false; @@ -988,15 +988,15 @@ PluginInsert::silence (framecnt_t nframes, framepos_t start_frame) void PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool) { + if (_sidechain) { + // collect sidechain input for complete cycle (!) + // TODO we need delaylines here for latency compensation + _sidechain->run (bufs, start_frame, end_frame, speed, nframes, true); + } + if (_pending_active) { /* run as normal if we are active or moving from inactive to active */ - if (_sidechain) { - // collect sidechain input for complete cycle (!) - // TODO we need delaylines here for latency compensation - _sidechain->run (bufs, start_frame, end_frame, speed, nframes, true); - } - if (_session.transport_rolling() || _session.bounce_processing()) { automation_run (bufs, start_frame, end_frame, speed, nframes); } else { @@ -1254,6 +1254,24 @@ PluginInsert::input_map () const return rv; } + +ChanMapping +PluginInsert::no_sc_input_map () const +{ + ChanMapping rv; + uint32_t pc = 0; + for (PinMappings::const_iterator i = _in_map.begin (); i != _in_map.end (); ++i, ++pc) { + ChanMapping m (i->second); + const ChanMapping::Mappings& mp ((*i).second.mappings()); + for (ChanMapping::Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) { + for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) { + rv.set (tm->first, i->first + pc * (natural_input_streams().get(tm->first) - _cached_sidechain_pins.get(tm->first)), i->second); + } + } + } + return rv; +} + ChanMapping PluginInsert::output_map () const { -- 2.30.2