Instrument insert options:
authorRobin Gareus <robin@gareus.org>
Fri, 20 Jan 2017 23:32:15 +0000 (00:32 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 20 Jan 2017 23:38:43 +0000 (00:38 +0100)
 * allow to directly fan-out when adding a multi-channel instrument
 * Mixbus: move multi-channel instruments after Comp & EQ.

libs/ardour/ardour/plugin_insert.h
libs/ardour/ardour/route.h
libs/ardour/route.cc
libs/ardour/session.cc

index 474df73e41d6550bf253f85c51b22e136ed5b07b..0f533d92005743f894297761df408cc3a18b27bb 100644 (file)
@@ -117,6 +117,7 @@ class LIBARDOUR_API PluginInsert : public Processor
        bool reset_map (bool emit = true);
        bool sanitize_maps ();
        bool check_inplace ();
+       bool configured () const { return _configured; }
 
        // these are ports visible on the outside
        ChanCount output_streams() const;
index ea783cadca88a5fb16a95cf159d2fede8efc3fd9..3ac2d6dda6e8cc92cdf0a2d706eb45559a7e10f1 100644 (file)
@@ -279,6 +279,7 @@ public:
        void ab_plugins (bool forward);
        void clear_processors (Placement);
        void all_visible_processors_active (bool);
+       void move_instrument_down (bool postfader = false);
 
        bool strict_io () const { return _strict_io; }
        bool set_strict_io (bool);
@@ -359,6 +360,7 @@ public:
 
        /** the processors have changed; the parameter indicates what changed */
        PBD::Signal1<void,RouteProcessorChange> processors_changed;
+       PBD::Signal0<void> fan_out; // used to signal the GUI to fan-out (track-creation)
        PBD::Signal1<void,void*> record_enable_changed;
        PBD::Signal0<void> processor_latency_changed;
        /** the metering point has changed */
index 4fa9eadff7331cb50f0f7b0ea70068967f783fa5..411f3dc80178753001bb9dd7d894b800a117bf1c 100644 (file)
@@ -905,6 +905,7 @@ int
 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
 {
        ProcessorList::iterator loc;
+       boost::shared_ptr <PluginInsert> fanout;
 
        if (before) {
                loc = find(_processors.begin(), _processors.end(), before);
@@ -963,7 +964,8 @@ Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor>
 
                if (flags != None) {
                        boost::optional<int> rv = PluginSetup (shared_from_this (), pi, flags);  /* EMIT SIGNAL */
-                       switch (rv.get_value_or (0)) {
+                       int mode = rv.get_value_or (0);
+                       switch (mode & 3) {
                                case 1:
                                        to_skip.push_back (*i); // don't add this one;
                                        break;
@@ -974,6 +976,9 @@ Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor>
                                default:
                                        break;
                        }
+                       if ((mode & 5) == 4) {
+                               fanout = pi;
+                       }
                }
        }
 
@@ -1060,6 +1065,11 @@ Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor>
        processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
        set_processor_positions ();
 
+       if (fanout && fanout->configured ()
+                       && fanout->output_streams().n_audio() > 2
+                       && boost::dynamic_pointer_cast<PluginInsert> (the_instrument ()) == fanout) {
+               fan_out (); /* EMIT SIGNAL */
+       }
        return 0;
 }
 
@@ -1970,6 +1980,35 @@ Route::apply_processor_order (const ProcessorList& new_order)
        maybe_note_meter_position ();
 }
 
+void
+Route::move_instrument_down (bool postfader)
+{
+       Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
+       ProcessorList new_order;
+       boost::shared_ptr<Processor> instrument;
+       for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
+               if (pi && pi->plugin ()->get_info ()->is_instrument ()) {
+                       instrument = *i;
+               } else if (instrument && *i == _amp) {
+                       if (postfader) {
+                               new_order.push_back (*i);
+                               new_order.push_back (instrument);
+                       } else {
+                               new_order.push_back (instrument);
+                               new_order.push_back (*i);
+                       }
+               } else {
+                       new_order.push_back (*i);
+               }
+       }
+       if (!instrument) {
+               return;
+       }
+       lm.release ();
+       reorder_processors (new_order, 0);
+}
+
 int
 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
 {
index 256100aab4a3c96c3ffaa84192f1a178d8513114..24a531b4245a9bf1fea6c68f848ce5200462e1a3 100644 (file)
@@ -2574,7 +2574,12 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, bool s
                                if (strict_io) {
                                        pi->set_strict_io (true);
                                }
+
                                (*r)->add_processor (pi, PreFader);
+
+                               if (Profile->get_mixbus () && pi->configured () && pi->output_streams().n_audio() > 2) {
+                                       (*r)->move_instrument_down (false);
+                               }
                        }
                }
        }
@@ -2669,7 +2674,12 @@ Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name
                                if (strict_io) {
                                        pi->set_strict_io (true);
                                }
+
                                (*r)->add_processor (pi, PreFader);
+
+                               if (Profile->get_mixbus () && pi->configured () && pi->output_streams().n_audio() > 2) {
+                                       (*r)->move_instrument_down (false);
+                               }
                        }
                }
        }