fix bypassing plugins with sidechain i/o
authorRobin Gareus <robin@gareus.org>
Mon, 4 Jul 2016 22:38:52 +0000 (00:38 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 4 Jul 2016 22:39:46 +0000 (00:39 +0200)
libs/ardour/ardour/plugin_insert.h
libs/ardour/plugin_insert.cc

index 5ec35d0589a961c96b2d7439715d868bbf943099..9f1d56b81103922977b0f16c77dc9e9ba6cee49a 100644 (file)
@@ -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
        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;
        ChanMapping output_map () const; ///< combined (all instances) output map
        bool has_midi_bypass () const;
        bool has_midi_thru () const;
index 92d4897c6b966d7b6f7e6cdb49de1e7aad4594d7..8c1fe8bac630101107c229a9049f4acb6cf06ee5 100644 (file)
@@ -858,8 +858,8 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
         */
 
        // TODO: atomically copy maps & _no_inplace
         */
 
        // 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;
        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)
 {
 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 (_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 {
                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;
 }
 
        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
 {
 ChanMapping
 PluginInsert::output_map () const
 {