diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-11-25 12:37:29 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-11-25 12:38:22 -0500 |
commit | fe06e3b7e81feebb0be5544fdd6bf3a96295a89e (patch) | |
tree | 5f62781464a435a872ebba27799ce16282151daf /libs/surfaces | |
parent | dc78fcfb2fc968f22e69857dae25c6619892d44f (diff) |
faderport: track GUI selection, use first selected route; implement mute, solo, rec
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/faderport/faderport.cc | 86 | ||||
-rw-r--r-- | libs/surfaces/faderport/faderport.h | 14 | ||||
-rw-r--r-- | libs/surfaces/faderport/operations.cc | 52 |
3 files changed, 147 insertions, 5 deletions
diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index cc7c2fa1d4..62b1cc1ae1 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -36,15 +36,16 @@ #include "midi++/port.h" +#include "ardour/async_midi_port.h" #include "ardour/audioengine.h" +#include "ardour/debug.h" #include "ardour/filesystem_paths.h" -#include "ardour/session.h" -#include "ardour/route.h" #include "ardour/midi_port.h" -#include "ardour/rc_configuration.h" #include "ardour/midiport_manager.h" -#include "ardour/debug.h" -#include "ardour/async_midi_port.h" +#include "ardour/rc_configuration.h" +#include "ardour/route.h" +#include "ardour/session.h" +#include "ardour/track.h" #include "faderport.h" @@ -92,6 +93,8 @@ FaderPort::FaderPort (Session& s) _current_bank = 0; _bank_size = 0; + TrackSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::gui_track_selection_changed, this, _1), this); + Session::SendFeedback.connect_same_thread (*this, boost::bind (&FaderPort::send_feedback, this)); //Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&FaderPort::send_feedback, this), this);; @@ -151,6 +154,9 @@ FaderPort::FaderPort (Session& s) button_info (Punch).set_action (boost::bind (&BasicUI::prev_marker, this), true, ShiftDown); button_info (User).set_action (boost::bind (&BasicUI::next_marker, this), true, ShiftDown); + 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); } FaderPort::~FaderPort () @@ -410,6 +416,8 @@ FaderPort::close () session_connections.drop_connections (); port_connection.disconnect (); blink_connection.disconnect (); + selection_connection.disconnect (); + route_connections.drop_connections (); #if 0 route_connections.drop_connections (); @@ -763,3 +771,71 @@ FaderPort::ButtonInfo::set_led_state (boost::shared_ptr<MIDI::Port> port, int on port->write (buf, 3, 0); led_on = (onoff ? true : false); } + +void +FaderPort::gui_track_selection_changed (RouteNotificationListPtr routes) +{ + if (routes->empty()) { + _current_route.reset (); + } else { + _current_route = routes->front().lock(); + } + + route_connections.drop_connections (); + + if (_current_route) { + _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); + boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_route); + if (t) { + t->RecordEnableChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_recenable, this), this); + } + } + + map_route_state (); +} + +void +FaderPort::map_mute (void*) +{ + button_info (Mute).set_led_state (_output_port, _current_route->muted()); +} + +void +FaderPort::map_solo (bool, void*, bool) +{ + button_info (Solo).set_led_state (_output_port, _current_route->soloed() || _current_route->listening_via_monitor()); +} + +void +FaderPort::map_listen (void*, bool) +{ + button_info (Solo).set_led_state (_output_port, _current_route->listening_via_monitor()); +} + +void +FaderPort::map_recenable () +{ + boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_current_route); + if (t) { + button_info (Rec).set_led_state (_output_port, t->record_enabled()); + } else { + button_info (Rec).set_led_state (_output_port, false); + } +} + +void +FaderPort::map_route_state () +{ + if (!_current_route) { + button_info (Mute).set_led_state (_output_port, false); + button_info (Solo).set_led_state (_output_port, false); + button_info (Rec).set_led_state (_output_port, false); + } else { + /* arguments to these map_*() methods are all ignored */ + map_mute (0); + map_solo (false, 0, false); + map_recenable (); + } +} diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 94ac2dcfed..cc2dd1fd3c 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -125,6 +125,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq void thread_init (); private: + boost::shared_ptr<ARDOUR::Route> _current_route; boost::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port; boost::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port; @@ -278,10 +279,23 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq bool blink_state; bool blink (); + void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr); + PBD::ScopedConnection selection_connection; + PBD::ScopedConnectionList route_connections; + + void map_route_state (); + void map_solo (bool,void*,bool); + void map_listen (void*,bool); + void map_mute (void*); + void map_recenable (); + /* operations (defined in operations.cc) */ void undo (); void redo (); + void solo (); + void mute (); + void rec_enable (); }; } diff --git a/libs/surfaces/faderport/operations.cc b/libs/surfaces/faderport/operations.cc index 2f2361beb5..05c9e02beb 100644 --- a/libs/surfaces/faderport/operations.cc +++ b/libs/surfaces/faderport/operations.cc @@ -17,6 +17,10 @@ */ +#include "ardour/rc_configuration.h" +#include "ardour/session.h" +#include "ardour/track.h" + #include "faderport.h" using namespace ARDOUR; @@ -33,3 +37,51 @@ FaderPort::redo () { ControlProtocol::Redo (); /* EMIT SIGNAL */ } + +void +FaderPort::mute () +{ + if (!_current_route) { + return; + } + + boost::shared_ptr<RouteList> rl (new RouteList); + rl->push_back (_current_route); + session->set_mute (rl, !_current_route->muted()); +} + +void +FaderPort::solo () +{ + if (!_current_route) { + return; + } + + boost::shared_ptr<RouteList> rl (new RouteList); + rl->push_back (_current_route); + + if (Config->get_solo_control_is_listen_control()) { + session->set_listen (rl, !_current_route->listening_via_monitor()); + } else { + session->set_solo (rl, !_current_route->soloed()); + } +} + +void +FaderPort::rec_enable () +{ + if (!_current_route) { + return; + } + + boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_route); + + if (!t) { + return; + } + + boost::shared_ptr<RouteList> rl (new RouteList); + rl->push_back (_current_route); + + session->set_record_enabled (rl, !t->record_enabled()); +} |