faderport: enable "Output" button to select master out (or, with Shift, monitor out...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Nov 2015 21:34:11 +0000 (16:34 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Nov 2015 21:34:11 +0000 (16:34 -0500)
libs/surfaces/faderport/faderport.cc
libs/surfaces/faderport/faderport.h
libs/surfaces/faderport/operations.cc

index 859b69abe403f20042dcae0be65ae7fac102c49e..e8e68475ff0e11024894f5c56dccd728e15a86d7 100644 (file)
@@ -73,7 +73,7 @@ FaderPort::FaderPort (Session& s)
        , blink_state (false)
 {
        last_encoder_time = 0;
-       
+
        boost::shared_ptr<ARDOUR::Port> inp;
        boost::shared_ptr<ARDOUR::Port> outp;
 
@@ -148,6 +148,9 @@ FaderPort::FaderPort (Session& s)
        button_info (Mute).set_action (boost::bind (&FaderPort::mute, this), true);
        button_info (Solo).set_action (boost::bind (&FaderPort::solo, this), true);
        button_info (Rec).set_action (boost::bind (&FaderPort::rec_enable, this), true);
+
+       button_info (Output).set_action (boost::bind (&FaderPort::use_master, this), true);
+       button_info (Output).set_action (boost::bind (&FaderPort::use_monitor, this), true, ShiftDown);
 }
 
 FaderPort::~FaderPort ()
@@ -319,7 +322,7 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                last_encoder_time = now;
                last_good_encoder_delta = delta;
        }
-       
+
        if (_current_route) {
 
                if ( (button_state & ShiftDown) == ShiftDown ) {    //shift+encoder = input trim
@@ -332,9 +335,9 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                } else {  //pan / balance
                        //ToDo
                }
-               
+
        }
-       
+
 }
 
 void
@@ -737,15 +740,37 @@ FaderPort::ButtonInfo::set_led_state (boost::shared_ptr<MIDI::Port> port, int on
 void
 FaderPort::gui_track_selection_changed (RouteNotificationListPtr routes)
 {
-       if (routes->empty()) {
-               _current_route.reset ();
-       } else {
-               _current_route = routes->front().lock();
+       boost::shared_ptr<Route> r;
+
+       if (!routes->empty()) {
+               r = routes->front().lock();
        }
 
+       set_current_route (r);
+}
+
+void
+FaderPort::drop_current_route ()
+{
+       if (_current_route) {
+               if (_current_route == session->monitor_out()) {
+                       set_current_route (session->master_out());
+               } else {
+                       set_current_route (boost::shared_ptr<Route>());
+               }
+       }
+}
+
+void
+FaderPort::set_current_route (boost::shared_ptr<Route> r)
+{
        route_connections.drop_connections ();
 
+       _current_route = r;
+
        if (_current_route) {
+               _current_route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::drop_current_route, this), this);
+
                _current_route->mute_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_mute, this, _1), this);
                _current_route->solo_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_solo, this, _1, _2, _3), this);
                _current_route->listen_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_listen, this, _1, _2), this);
index 3635070d9bec266e96509163257fd1c0b2630039..5fe657c7040d92aacb077dd8a32c2ee21594de72 100644 (file)
@@ -243,6 +243,10 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
        bool blink_state;
        bool blink ();
 
+       void set_current_route (boost::shared_ptr<ARDOUR::Route>);
+       void drop_current_route ();
+       void use_master ();
+       void use_monitor ();
        void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr);
        PBD::ScopedConnection selection_connection;
        PBD::ScopedConnectionList route_connections;
index 05c9e02beb074a28f04fe65731213c48d3326848..01b555f5750077e652357411d255c475c188e2a2 100644 (file)
@@ -85,3 +85,21 @@ FaderPort::rec_enable ()
 
        session->set_record_enabled (rl, !t->record_enabled());
 }
+
+void
+FaderPort::use_master ()
+{
+       boost::shared_ptr<Route> r = session->master_out();
+       if (r) {
+               set_current_route (r);
+       }
+}
+
+void
+FaderPort::use_monitor ()
+{
+       boost::shared_ptr<Route> r = session->monitor_out();
+       if (r) {
+               set_current_route (r);
+       }
+}