X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Froute_signal.cc;h=984a6ccd9f4f6497ef14e4aa6a56dbf3fe193ea2;hb=db8b575c30845bafc34b87bacd52129c95d1c478;hp=824251fe7317effc0a45e6c91e2d2d6afb243dd8;hpb=e878b365193ad9315e557a8245b767d8a0fe568d;p=ardour.git diff --git a/libs/surfaces/mackie/route_signal.cc b/libs/surfaces/mackie/route_signal.cc index 824251fe73..984a6ccd9f 100644 --- a/libs/surfaces/mackie/route_signal.cc +++ b/libs/surfaces/mackie/route_signal.cc @@ -17,81 +17,88 @@ */ #include "route_signal.h" -#include -#include -#include +#include "ardour/route.h" +#include "ardour/track.h" +#include "ardour/midi_ui.h" +#include "ardour/panner.h" +#include "ardour/session_object.h" // for Properties::name #include "mackie_control_protocol.h" #include +using namespace ARDOUR; using namespace Mackie; +using namespace std; + +#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ +#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) void RouteSignal::connect() { - if ( _strip.has_solo() ) - _solo_changed_connection = _route.solo_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), &_route, &_port ) ); - - if ( _strip.has_mute() ) - _mute_changed_connection = _route.mute_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), &_route, &_port ) ); + if (_strip.has_solo()) { + _route->solo_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this), midi_ui_context()); + } + + if (_strip.has_mute()) { + _route->mute_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this), midi_ui_context()); + } + + if (_strip.has_gain()) { + _route->gain_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false), midi_ui_context()); + } + + _route->PropertyChanged.connect (connections, ui_bind (&MackieControlProtocol::notify_property_changed, &_mcp, _1, this), midi_ui_context()); - if ( _strip.has_gain() ) - _gain_changed_connection = _route.gain_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), &_route, &_port ) ); + if (_route->panner()) { + _route->panner()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context()); - _name_changed_connection = _route.name_changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), &_route, &_port ) ); - - if ( _route.panner().size() == 1 ) - { - _panner_changed_connection = _route.panner()[0]->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), &_route, &_port ) ); + for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) { + _route->panner()->streampanner(i).Changed.connect (connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context()); + } } - try - { - _record_enable_changed_connection = - dynamic_cast( _route ).rec_enable_control().Changed - .connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), &_route, &_port ) ) - ; - } - catch ( std::bad_cast & ) - { - // this should catch the dynamic_cast to Track, if what we're working - // with can't be record-enabled + boost::shared_ptr trk = boost::dynamic_pointer_cast(_route); + if (trk) { + trk->rec_enable_control()->Changed .connect(connections, ui_bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this), midi_ui_context()); } - + + // TODO this works when a currently-banked route is made inactive, but not + // when a route is activated which should be currently banked. + _route->active_changed.connect (connections, ui_bind (&MackieControlProtocol::notify_active_changed, &_mcp, this), midi_ui_context()); + // TODO - // active_changed // SelectedChanged - // RemoteControlIDChanged + // RemoteControlIDChanged. Better handled at Session level. } void RouteSignal::disconnect() { - _solo_changed_connection.disconnect(); - _mute_changed_connection.disconnect(); - _gain_changed_connection.disconnect(); - _name_changed_connection.disconnect(); - _panner_changed_connection.disconnect(); - _record_enable_changed_connection.disconnect(); + connections.drop_connections (); } void RouteSignal::notify_all() { - void * src = &_route; - +#ifdef DEBUG + cout << "RouteSignal::notify_all for " << _strip << endl; +#endif if ( _strip.has_solo() ) - _mcp.notify_solo_changed( &_route, &_port ); + _mcp.notify_solo_changed( this ); if ( _strip.has_mute() ) - _mcp.notify_mute_changed( &_route, &_port ); + _mcp.notify_mute_changed( this ); if ( _strip.has_gain() ) - _mcp.notify_gain_changed( &_route, &_port ); + _mcp.notify_gain_changed( this ); - _mcp.notify_name_changed( src, &_route, &_port ); + _mcp.notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name), this ); if ( _strip.has_vpot() ) - _mcp.notify_panner_changed( &_route, &_port ); + _mcp.notify_panner_changed( this ); if ( _strip.has_recenable() ) - _mcp.notify_record_enable_changed( &_route, &_port ); + _mcp.notify_record_enable_changed( this ); +#ifdef DEBUG + cout << "RouteSignal::notify_all finish" << endl; +#endif }