prepare Plugin Pin Management
authorRobin Gareus <robin@gareus.org>
Fri, 25 Mar 2016 18:08:21 +0000 (19:08 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 25 Mar 2016 18:08:21 +0000 (19:08 +0100)
libs/ardour/ardour/chan_mapping.h
libs/ardour/ardour/plugin_insert.h
libs/ardour/chan_mapping.cc
libs/ardour/plugin_insert.cc

index 7b9f81976d52338a3a711847255dab63cfd5e5da..baa3e9f6a9bfc63847e2485cc086a802ecd49b9c 100644 (file)
@@ -38,6 +38,7 @@ class LIBARDOUR_API ChanMapping {
 public:
        ChanMapping() {}
        ChanMapping(ARDOUR::ChanCount identity);
+       ChanMapping(const ChanMapping&);
 
        uint32_t get(DataType t, uint32_t from, bool* valid);
        uint32_t get(DataType t, uint32_t from) { return get (t, from, NULL); }
index ffa55b9eaa4bafc4184a930b00bf4613a3e2c5f1..ed97126e348cd703140e79843f657954354dc731 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "ardour/ardour.h"
 #include "ardour/libardour_visibility.h"
+#include "ardour/chan_mapping.h"
 #include "ardour/types.h"
 #include "ardour/parameter_descriptor.h"
 #include "ardour/processor.h"
@@ -204,6 +205,8 @@ class LIBARDOUR_API PluginInsert : public Processor
 
        /** details of the match currently being used */
        Match _match;
+       ARDOUR::ChanMapping _in_map;
+       ARDOUR::ChanMapping _out_map;
 
        void automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes);
        void connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t offset, bool with_auto, framepos_t now = 0);
index 57734803d2cd5b8751265872f99563b341676800..83ded4141cb5d3475fcb612af6bc0ac684192581 100644 (file)
@@ -40,6 +40,11 @@ ChanMapping::ChanMapping(ChanCount identity)
        }
 }
 
+ChanMapping::ChanMapping (const ChanMapping& other )
+       : _mappings (other._mappings)
+{
+}
+
 uint32_t
 ChanMapping::get(DataType t, uint32_t from, bool* valid)
 {
index c085f1f9cbb5255e0f00845cf98c65ac5db5ab4c..19571c6b5faff5d53b8352547def2b52dd013491 100644 (file)
@@ -369,19 +369,16 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
        ChanCount const in_streams = input_streams ();
        ChanCount const out_streams = output_streams ();
 
-       ChanMapping in_map (in_streams);
-       ChanMapping out_map (out_streams);
        bool valid;
        if (_match.method == Split) {
                /* fix the input mapping so that we have maps for each of the plugin's inputs */
-               in_map = ChanMapping (natural_input_streams ());
 
                /* copy the first stream's buffer contents to the others */
                /* XXX: audio only */
-               uint32_t first_idx = in_map.get (DataType::AUDIO, 0, &valid);
+               uint32_t first_idx = _in_map.get (DataType::AUDIO, 0, &valid);
                if (valid) {
                        for (uint32_t i = in_streams.n_audio(); i < natural_input_streams().n_audio(); ++i) {
-                               bufs.get_audio(in_map.get (DataType::AUDIO, i, &valid)).read_from(bufs.get_audio(first_idx), nframes, offset, offset);
+                               bufs.get_audio(_in_map.get (DataType::AUDIO, i, &valid)).read_from(bufs.get_audio(first_idx), nframes, offset, offset);
                        }
                }
        }
@@ -441,6 +438,12 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
 
        }
 
+
+       // copy - for now - since the map is offset below
+       // TODO: use dedicated maps per plugin
+       ChanMapping in_map (_in_map);
+       ChanMapping out_map (_out_map);
+
        for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
                if ((*i)->connect_and_run(bufs, in_map, out_map, nframes, offset)) {
                        deactivate ();
@@ -486,16 +489,8 @@ PluginInsert::silence (framecnt_t nframes)
                return;
        }
 
-       ChanMapping in_map(input_streams());
-       ChanMapping out_map(output_streams());
-
-       if (_match.method == Split) {
-               /* fix the input mapping so that we have maps for each of the plugin's inputs */
-               in_map = ChanMapping (natural_input_streams ());
-       }
-
        for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
-               (*i)->connect_and_run (_session.get_scratch_buffers ((*i)->get_info()->n_inputs, true), in_map, out_map, nframes, 0);
+               (*i)->connect_and_run (_session.get_scratch_buffers ((*i)->get_info()->n_inputs, true), _in_map, _out_map, nframes, 0);
        }
 }
 
@@ -752,6 +747,22 @@ PluginInsert::configure_io (ChanCount in, ChanCount out)
                break;
        }
 
+       if (_match.method == Split) {
+               /* fix the input mapping so that we have maps for each of the plugin's inputs */
+               _in_map = ChanMapping (natural_input_streams ());
+       } else {
+               _in_map = ChanMapping (input_streams ());
+       }
+       _out_map = ChanMapping (output_streams());
+
+#if 0
+       cout << "Set Channel Maps:" << name () << " " << this
+               << "\nin:\n" << _in_map
+               << "\nout:\n" << _out_map
+               << "\n";
+#endif
+
+
        if (  (old_match.method != _match.method && (old_match.method == Split || _match.method == Split))
                        || old_in != in
                        || old_out != out