convert faderport to use Stripable instead of Route
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 17 May 2016 15:42:31 +0000 (11:42 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:43 +0000 (15:30 -0400)
libs/surfaces/faderport/faderport.cc
libs/surfaces/faderport/faderport.h
libs/surfaces/faderport/operations.cc

index 7b76e9950d372f5433bf45ac4c5bcc3f666b0686..bfeb20b76b3ca600e72fbbbeb77675704fb7ec2b 100644 (file)
@@ -47,7 +47,7 @@
 #include "ardour/monitor_processor.h"
 #include "ardour/profile.h"
 #include "ardour/rc_configuration.h"
-#include "ardour/route.h"
+#include "ardour/stripable.h"
 #include "ardour/session.h"
 #include "ardour/session_configuration.h"
 #include "ardour/track.h"
@@ -108,7 +108,7 @@ FaderPort::FaderPort (Session& s)
                );
 
 
-       TrackSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::gui_track_selection_changed, this, _1), this);
+       StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::gui_track_selection_changed, this, _1), this);
 
        /* Catch port connections and disconnections */
        ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::connection_handler, this, _1, _2, _3, _4, _5), this);
@@ -372,8 +372,8 @@ FaderPort::button_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
                break;
        case FaderTouch:
                fader_is_touched = tb->value;
-               if (_current_route) {
-                       boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+               if (_current_stripable) {
+                       boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                        if (gain) {
                                framepos_t now = session->engine().sample_time();
                                if (tb->value) {
@@ -443,7 +443,7 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                last_good_encoder_delta = delta;
        }
 
-       if (_current_route) {
+       if (_current_stripable) {
 
                ButtonState trim_modifier;
                ButtonState width_modifier;
@@ -457,7 +457,7 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                }
 
                if ((button_state & trim_modifier) == trim_modifier ) {    // mod+encoder = input trim
-                       boost::shared_ptr<AutomationControl> trim = _current_route->trim()->gain_control ();
+                       boost::shared_ptr<AutomationControl> trim = _current_stripable->trim_control ();
                        if (trim) {
                                float val = trim->get_user();  //for gain elements, the "user" value is in dB
                                val += delta;
@@ -498,16 +498,16 @@ FaderPort::fader_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
        }
 
        if (was_fader) {
-               if (_current_route) {
-                       boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+               if (_current_stripable) {
+                       boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                        if (gain) {
                                int ival = (fader_msb << 7) | fader_lsb;
                                float val = gain->interface_to_internal (ival/16384.0);
                                /* even though the faderport only controls a
-                                  single route at a time, allow the fader to
+                                  single stripable at a time, allow the fader to
                                   modify the group, if appropriate.
                                */
-                               _current_route->gain_control()->set_value (val, Controllable::UseGroup);
+                               _current_stripable->gain_control()->set_value (val, Controllable::UseGroup);
                        }
                }
        }
@@ -601,11 +601,11 @@ FaderPort::set_active (bool yn)
 bool
 FaderPort::periodic ()
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                return true;
        }
 
-       ARDOUR::AutoState gain_state = _current_route->gain_control()->automation_state();
+       ARDOUR::AutoState gain_state = _current_stripable->gain_control()->automation_state();
 
        if (gain_state == ARDOUR::Touch || gain_state == ARDOUR::Play) {
                map_gain ();
@@ -652,10 +652,10 @@ FaderPort::close ()
        port_connection.disconnect ();
        blink_connection.disconnect ();
        selection_connection.disconnect ();
-       route_connections.drop_connections ();
+       stripable_connections.drop_connections ();
 
 #if 0
-       route_connections.drop_connections ();
+       stripable_connections.drop_connections ();
 #endif
 }
 
@@ -1104,67 +1104,67 @@ FaderPort::Button::get_state () const
 }
 
 void
-FaderPort::gui_track_selection_changed (RouteNotificationListPtr routes)
+FaderPort::gui_track_selection_changed (StripableNotificationListPtr stripables)
 {
-       boost::shared_ptr<Route> r;
+       boost::shared_ptr<Stripable> r;
 
-       if (!routes->empty()) {
-               r = routes->front().lock();
+       if (!stripables->empty()) {
+               r = stripables->front().lock();
        }
 
-       set_current_route (r);
+       set_current_stripable (r);
 }
 
 void
-FaderPort::drop_current_route ()
+FaderPort::drop_current_stripable ()
 {
-       if (_current_route) {
-               if (_current_route == session->monitor_out()) {
-                       set_current_route (session->master_out());
+       if (_current_stripable) {
+               if (_current_stripable == session->monitor_out()) {
+                       set_current_stripable (session->master_out());
                } else {
-                       set_current_route (boost::shared_ptr<Route>());
+                       set_current_stripable (boost::shared_ptr<Stripable>());
                }
        }
 }
 
 void
-FaderPort::set_current_route (boost::shared_ptr<Route> r)
+FaderPort::set_current_stripable (boost::shared_ptr<Stripable> r)
 {
-       route_connections.drop_connections ();
+       stripable_connections.drop_connections ();
 
-       _current_route = r;
+       _current_stripable = r;
 
        /* turn this off. It will be turned on back on in use_master() or
           use_monitor() as appropriate.
        */
        get_button(Output).set_led_state (_output_port, false);
 
-       if (_current_route) {
-               _current_route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::drop_current_route, this), this);
+       if (_current_stripable) {
+               _current_stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::drop_current_stripable, this), this);
 
-               _current_route->mute_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_mute, this), this);
-               _current_route->solo_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_solo, this), this);
+               _current_stripable->mute_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_mute, this), this);
+               _current_stripable->solo_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_solo, this), this);
 
-               boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_route);
+               boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_stripable);
                if (t) {
-                       t->rec_enable_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_recenable, this), this);
+                       t->rec_enable_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_recenable, this), this);
                }
 
-               boost::shared_ptr<AutomationControl> control = _current_route->gain_control ();
+               boost::shared_ptr<AutomationControl> control = _current_stripable->gain_control ();
                if (control) {
-                       control->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_gain, this), this);
-                       control->alist()->automation_state_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_auto, this), this);
+                       control->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_gain, this), this);
+                       control->alist()->automation_state_changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_auto, this), this);
                }
 
-               boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
+               boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
                if (mp) {
-                       mp->cut_control()->Changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_cut, this), this);
+                       mp->cut_control()->Changed.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_cut, this), this);
                }
        }
 
        //ToDo: subscribe to the fader automation modes so we can light the LEDs
 
-       map_route_state ();
+       map_stripable_state ();
 }
 
 void
@@ -1174,7 +1174,7 @@ FaderPort::map_auto ()
         * the Off button, because this will disable the fader.
         */
 
-       boost::shared_ptr<AutomationControl> control = _current_route->gain_control ();
+       boost::shared_ptr<AutomationControl> control = _current_stripable->gain_control ();
        const AutoState as = control->automation_state ();
 
        switch (as) {
@@ -1206,7 +1206,7 @@ FaderPort::map_auto ()
 void
 FaderPort::map_cut ()
 {
-       boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
+       boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
 
        if (mp) {
                bool yn = mp->cut_all ();
@@ -1223,11 +1223,11 @@ FaderPort::map_cut ()
 void
 FaderPort::map_mute ()
 {
-       if (_current_route) {
-               if (_current_route->muted()) {
+       if (_current_stripable) {
+               if (_current_stripable->mute_control()->muted()) {
                        stop_blinking (Mute);
                        get_button (Mute).set_led_state (_output_port, true);
-               } else if (_current_route->muted_by_others_soloing () || _current_route->muted_by_masters()) {
+               } else if (_current_stripable->mute_control()->muted_by_others_soloing () || _current_stripable->mute_control()->muted_by_masters()) {
                        start_blinking (Mute);
                } else {
                        stop_blinking (Mute);
@@ -1240,8 +1240,8 @@ FaderPort::map_mute ()
 void
 FaderPort::map_solo ()
 {
-       if (_current_route) {
-               get_button (Solo).set_led_state (_output_port, _current_route->soloed());
+       if (_current_stripable) {
+               get_button (Solo).set_led_state (_output_port, _current_stripable->solo_control()->soloed());
        } else {
                get_button (Solo).set_led_state (_output_port, false);
        }
@@ -1250,7 +1250,7 @@ FaderPort::map_solo ()
 void
 FaderPort::map_recenable ()
 {
-       boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_route);
+       boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_stripable);
        if (t) {
                get_button (Rec).set_led_state (_output_port, t->rec_enable_control()->get_value());
        } else {
@@ -1266,11 +1266,11 @@ FaderPort::map_gain ()
                return;
        }
 
-       if (!_current_route) {
+       if (!_current_stripable) {
                return;
        }
 
-       boost::shared_ptr<AutomationControl> control = _current_route->gain_control ();
+       boost::shared_ptr<AutomationControl> control = _current_stripable->gain_control ();
        double val;
 
        if (!control) {
@@ -1309,9 +1309,9 @@ FaderPort::map_gain ()
 }
 
 void
-FaderPort::map_route_state ()
+FaderPort::map_stripable_state ()
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                stop_blinking (Mute);
                stop_blinking (Solo);
                get_button (Rec).set_led_state (_output_port, false);
@@ -1321,7 +1321,7 @@ FaderPort::map_route_state ()
                map_gain ();
                map_auto ();
 
-               if (_current_route == session->monitor_out()) {
+               if (_current_stripable == session->monitor_out()) {
                        map_cut ();
                } else {
                        map_mute ();
index 10bd23e618ce697f860ae5e40b4882342795be7d..4d5c9702d93e83330c056014200c3976dee1ad32 100644 (file)
@@ -164,9 +164,9 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
        std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
 
   private:
-       boost::shared_ptr<ARDOUR::Route> _current_route;
-       boost::weak_ptr<ARDOUR::Route> pre_master_route;
-       boost::weak_ptr<ARDOUR::Route> pre_monitor_route;
+       boost::shared_ptr<ARDOUR::Stripable> _current_stripable;
+       boost::weak_ptr<ARDOUR::Stripable> pre_master_stripable;
+       boost::weak_ptr<ARDOUR::Stripable> pre_monitor_stripable;
 
        boost::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port;
        boost::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port;
@@ -294,15 +294,15 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
        void start_blinking (ButtonID);
        void stop_blinking (ButtonID);
 
-       void set_current_route (boost::shared_ptr<ARDOUR::Route>);
-       void drop_current_route ();
+       void set_current_stripable (boost::shared_ptr<ARDOUR::Stripable>);
+       void drop_current_stripable ();
        void use_master ();
        void use_monitor ();
-       void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr);
+       void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr);
        PBD::ScopedConnection selection_connection;
-       PBD::ScopedConnectionList route_connections;
+       PBD::ScopedConnectionList stripable_connections;
 
-       void map_route_state ();
+       void map_stripable_state ();
        void map_solo ();
        void map_mute ();
        bool rec_enable_state;
index ec607273929f9422c36d1ca92ead8d9953926f45..cb0351e615298026381600a05271c45c7532bc47 100644 (file)
@@ -60,8 +60,8 @@ FaderPort::right ()
 void
 FaderPort::read ()
 {
-       if (_current_route) {
-               boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+       if (_current_stripable) {
+               boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                if (gain) {
                        gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Play );
                }
@@ -71,8 +71,8 @@ FaderPort::read ()
 void
 FaderPort::write ()
 {
-       if (_current_route) {
-               boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+       if (_current_stripable) {
+               boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                if (gain) {
                        gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Write );
                }
@@ -82,8 +82,8 @@ FaderPort::write ()
 void
 FaderPort::touch ()
 {
-       if (_current_route) {
-               boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+       if (_current_stripable) {
+               boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                if (gain) {
                        gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Touch );
                }
@@ -93,8 +93,8 @@ FaderPort::touch ()
 void
 FaderPort::off ()
 {
-       if (_current_route) {
-               boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
+       if (_current_stripable) {
+               boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
                if (gain) {
                        gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Off );
                }
@@ -119,39 +119,39 @@ FaderPort::redo ()
 void
 FaderPort::mute ()
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                return;
        }
 
-       if (_current_route == session->monitor_out()) {
-               boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
+       if (_current_stripable == session->monitor_out()) {
+               boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
                mp->set_cut_all (!mp->cut_all());
                return;
        }
 
        boost::shared_ptr<ControlList> cl (new ControlList);
-       cl->push_back (_current_route->mute_control());
-       session->set_controls (cl, !_current_route->muted(), PBD::Controllable::UseGroup);
+       cl->push_back (_current_stripable->mute_control());
+       session->set_controls (cl, !_current_stripable->mute_control()->muted(), PBD::Controllable::UseGroup);
 }
 
 void
 FaderPort::solo ()
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                return;
        }
 
-       _current_route->solo_control()->set_value (_current_route->soloed() ? 0.0 : 1.0, PBD::Controllable::UseGroup);
+       _current_stripable->solo_control()->set_value (_current_stripable->solo_control()->soloed() ? 0.0 : 1.0, PBD::Controllable::UseGroup);
 }
 
 void
 FaderPort::rec_enable ()
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                return;
        }
 
-       boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_route);
+       boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_stripable);
 
        if (!t) {
                return;
@@ -163,18 +163,18 @@ FaderPort::rec_enable ()
 void
 FaderPort::use_master ()
 {
-       boost::shared_ptr<Route> r = session->master_out();
+       boost::shared_ptr<Stripable> r = session->master_out();
        if (r) {
-               if (_current_route == r) {
-                       r = pre_master_route.lock();
-                       set_current_route (r);
+               if (_current_stripable == r) {
+                       r = pre_master_stripable.lock();
+                       set_current_stripable (r);
                        get_button(Output).set_led_state (_output_port, false);
                        blinkers.remove (Output);
                } else {
-                       if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
-                               pre_master_route = boost::weak_ptr<Route> (_current_route);
+                       if (_current_stripable != session->master_out() && _current_stripable != session->monitor_out()) {
+                               pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable);
                        }
-                       set_current_route (r);
+                       set_current_stripable (r);
                        get_button(Output).set_led_state (_output_port, true);
                        blinkers.remove (Output);
                }
@@ -184,19 +184,19 @@ FaderPort::use_master ()
 void
 FaderPort::use_monitor ()
 {
-       boost::shared_ptr<Route> r = session->monitor_out();
+       boost::shared_ptr<Stripable> r = session->monitor_out();
 
        if (r) {
-               if (_current_route == r) {
-                       r = pre_monitor_route.lock();
-                       set_current_route (r);
+               if (_current_stripable == r) {
+                       r = pre_monitor_stripable.lock();
+                       set_current_stripable (r);
                        get_button(Output).set_led_state (_output_port, false);
                        blinkers.remove (Output);
                } else {
-                       if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
-                               pre_monitor_route = boost::weak_ptr<Route> (_current_route);
+                       if (_current_stripable != session->master_out() && _current_stripable != session->monitor_out()) {
+                               pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable);
                        }
-                       set_current_route (r);
+                       set_current_stripable (r);
                        get_button(Output).set_led_state (_output_port, true);
                        blinkers.push_back (Output);
                }
@@ -207,11 +207,17 @@ FaderPort::use_monitor ()
 void
 FaderPort::ardour_pan_azimuth (int delta)
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
                return;
        }
 
-       boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
+       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
+
+       if (!r) {
+               return;
+       }
+
+       boost::shared_ptr<Pannable> pannable = r->pannable ();
 
        if (!pannable) {
                return;
@@ -230,11 +236,17 @@ FaderPort::ardour_pan_azimuth (int delta)
 void
 FaderPort::ardour_pan_width(int delta)
 {
-       if (!_current_route) {
+       if (!_current_stripable) {
+               return;
+       }
+
+       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
+
+       if (!r) {
                return;
        }
 
-       boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
+       boost::shared_ptr<Pannable> pannable = r->pannable ();
 
        if (!pannable) {
                return;
@@ -253,12 +265,18 @@ void
 FaderPort::mixbus_pan (int delta)
 {
 #ifdef MIXBUS
-       if (!_current_route) {
+       if (!_current_stripable) {
+               return;
+       }
+       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
+
+       if (!r) {
                return;
        }
 
+
        const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
-       boost::shared_ptr<ARDOUR::PluginInsert> plug = _current_route->ch_post();
+       boost::shared_ptr<ARDOUR::PluginInsert> plug = r->ch_post();
 
        if (!plug) {
                return;