From 765d0f4785d1bf6a82c7acc19eebdf851fc305a5 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Fri, 9 Mar 2007 12:09:11 +0000 Subject: Finish automation polling. Get rid of strip_from_route. git-svn-id: svn://localhost/ardour2/trunk@1567 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/io.h | 3 +- libs/surfaces/mackie/TODO | 2 - libs/surfaces/mackie/mackie_control_protocol.cc | 95 ++++++++++------------ libs/surfaces/mackie/mackie_control_protocol.h | 21 ++--- .../mackie/mackie_control_protocol_poll.cc | 4 - libs/surfaces/mackie/route_signal.cc | 24 +++--- libs/surfaces/mackie/route_signal.h | 2 +- 7 files changed, 67 insertions(+), 84 deletions(-) diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 46b19d4f39..ab918345b1 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -108,7 +108,8 @@ class IO : public PBD::StatefulDestructible virtual gain_t effective_gain () const; Panner& panner() { return *_panner; } - + const Panner& panner() const { return *_panner; } + int ensure_io (uint32_t, uint32_t, bool clear, void *src); int use_input_connection (Connection&, void *src); diff --git a/libs/surfaces/mackie/TODO b/libs/surfaces/mackie/TODO index 88b1788668..534ee4f64c 100644 --- a/libs/surfaces/mackie/TODO +++ b/libs/surfaces/mackie/TODO @@ -2,8 +2,6 @@ where ENSURE_CORRECT_THREAD is a macro that is modelled on ENSURE_GUI_THREAD if the handler is not called in the "correct thread", it will use a pseudo-RT-safe-enough technique to get the correct thread to recall "handler" later on, and return. -* automation feedback not working. gtk2_ardour seems to poll. -* optimise strip_from_route. Can just pass in strips. * jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work. * finish button mapping. Click on/off. start/end locate. punch in/out * discuss button mapping for Ardour diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 53466004e4..26fd15e777 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -915,45 +915,17 @@ struct RouteSignalByRoute Route & _route; }; -Strip & MackieControlProtocol::strip_from_route( Route * route ) -{ - if ( route == 0 ) - { - throw MackieControlException( "route is null in MackieControlProtocol::strip_from_route" ); - } - - if ( route->master() ) - { - return master_strip(); - } - - RouteSignals::iterator it = find_if( - route_signals.begin() - , route_signals.end() - , RouteSignalByRoute( *route ) - ); - - if ( it == route_signals.end() ) - { - ostringstream os; - os << "No strip for route " << route->name(); - throw MackieControlException( os.str() ); - } - - return (*it)->strip(); -} - ///////////////////////////////////////////////// // handlers for Route signals // TODO should these be part of RouteSignal? ///////////////////////////////////////////////// -void MackieControlProtocol::notify_solo_changed( ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_solo_changed( RouteSignal * route_signal ) { try { - Button & button = strip_from_route( route ).solo(); - port->write( builder.build_led( button, route->soloed() ) ); + Button & button = route_signal->strip().solo(); + route_signal->port().write( builder.build_led( button, route_signal->route().soloed() ) ); } catch( exception & e ) { @@ -961,12 +933,12 @@ void MackieControlProtocol::notify_solo_changed( ARDOUR::Route * route, MackiePo } } -void MackieControlProtocol::notify_mute_changed( ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_mute_changed( RouteSignal * route_signal ) { try { - Button & button = strip_from_route( route ).mute(); - port->write( builder.build_led( button, route->muted() ) ); + Button & button = route_signal->strip().mute(); + route_signal->port().write( builder.build_led( button, route_signal->route().muted() ) ); } catch( exception & e ) { @@ -974,12 +946,12 @@ void MackieControlProtocol::notify_mute_changed( ARDOUR::Route * route, MackiePo } } -void MackieControlProtocol::notify_record_enable_changed( ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_record_enable_changed( RouteSignal * route_signal ) { try { - Button & button = strip_from_route( route ).recenable(); - port->write( builder.build_led( button, route->record_enabled() ) ); + Button & button = route_signal->strip().recenable(); + route_signal->port().write( builder.build_led( button, route_signal->route().record_enabled() ) ); } catch( exception & e ) { @@ -987,14 +959,14 @@ void MackieControlProtocol::notify_record_enable_changed( ARDOUR::Route * route, } } -void MackieControlProtocol::notify_gain_changed( ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_gain_changed( RouteSignal * route_signal ) { try { - Fader & fader = strip_from_route( route ).gain(); + Fader & fader = route_signal->strip().gain(); if ( !fader.touch() ) { - port->write( builder.build_fader( fader, gain_to_slider_position( route->effective_gain() ) ) ); + route_signal->port().write( builder.build_fader( fader, gain_to_slider_position( route_signal->route().effective_gain() ) ) ); } } catch( exception & e ) @@ -1003,7 +975,7 @@ void MackieControlProtocol::notify_gain_changed( ARDOUR::Route * route, MackieP } } -void MackieControlProtocol::notify_name_changed( void *, ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_name_changed( void *, RouteSignal * route_signal ) { try { @@ -1016,20 +988,21 @@ void MackieControlProtocol::notify_name_changed( void *, ARDOUR::Route * route, } // TODO deal with > 1 channel being panned -void MackieControlProtocol::notify_panner_changed( ARDOUR::Route * route, MackiePort * port ) +void MackieControlProtocol::notify_panner_changed( RouteSignal * route_signal ) { try { - Pot & pot = strip_from_route( route ).vpot(); - if ( route->panner().size() == 1 ) + Pot & pot = route_signal->strip().vpot(); + + if ( route_signal->route().panner().size() == 1 ) { float pos; - route->panner()[0]->get_effective_position( pos); - port->write( builder.build_led_ring( pot, ControlState( on, pos ) ) ); + route_signal->route().panner()[0]->get_effective_position( pos); + route_signal->port().write( builder.build_led_ring( pot, ControlState( on, pos ) ) ); } else { - port->write( builder.zero_control( pot ) ); + route_signal->port().write( builder.zero_control( pot ) ); } } catch( exception & e ) @@ -1038,16 +1011,34 @@ void MackieControlProtocol::notify_panner_changed( ARDOUR::Route * route, Mackie } } +// TODO handle plugin automation polling +void MackieControlProtocol::update_automation( RouteSignal & rs ) +{ + ARDOUR::AutoState gain_state = rs.route().gain_automation_state(); + if ( gain_state == Touch || gain_state == Play ) + { + notify_gain_changed( &rs ); + } + + ARDOUR::AutoState panner_state = rs.route().panner().automation_state(); + if ( panner_state == Touch || panner_state == Play ) + { + notify_panner_changed( &rs ); + } +} + void MackieControlProtocol::poll_automation() { - for( RouteSignals::iterator it = route_signals.begin(); it != route_signals.end(); ++it ) + if ( _active ) { - // update strip from route - ARDOUR::AutoState state = (*it)->route().gain_automation_state(); - if ( state == Touch || state == Play ) + // do all currently mapped routes + for( RouteSignals::iterator it = route_signals.begin(); it != route_signals.end(); ++it ) { - (*it)->notify_all(); + update_automation( **it ); } + + // and the master strip + update_automation( *master_route_signal ); } } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 4ba9443b96..64a75f2ee6 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -87,17 +87,17 @@ class MackieControlProtocol // strip/route related stuff public: /// Signal handler for Route::solo - void notify_solo_changed( ARDOUR::Route *, Mackie::MackiePort * ); + void notify_solo_changed( Mackie::RouteSignal * ); /// Signal handler for Route::mute - void notify_mute_changed( ARDOUR::Route *, Mackie::MackiePort * ); + void notify_mute_changed( Mackie::RouteSignal * ); /// Signal handler for Route::record_enable_changed - void notify_record_enable_changed( ARDOUR::Route *, Mackie::MackiePort * ); + void notify_record_enable_changed( Mackie::RouteSignal * ); /// Signal handler for Route::gain_changed ( from IO ) - void notify_gain_changed( ARDOUR::Route *, Mackie::MackiePort * ); + void notify_gain_changed( Mackie::RouteSignal * ); /// Signal handler for Route::name_change - void notify_name_changed( void *, ARDOUR::Route *, Mackie::MackiePort * ); + void notify_name_changed( void *, Mackie::RouteSignal * ); /// Signal handler from Panner::Change - void notify_panner_changed( ARDOUR::Route *, Mackie::MackiePort * ); + void notify_panner_changed( Mackie::RouteSignal * ); /// Signal handler for new routes added void notify_route_added( ARDOUR::Session::RouteList & ); @@ -237,12 +237,9 @@ class MackieControlProtocol /// read automation data from the currently active routes and send to surface void poll_automation(); - /** - used by the notify_XXX methods to find - a strip corresponding to the Route passed in. - */ - Mackie::Strip & strip_from_route( ARDOUR::Route * route ); - + // called from poll_automation to figure out which automations need to be sent + void update_automation( Mackie::RouteSignal & ); + /// notification from the MackiePorts that their status has changed void handle_port_changed( Mackie::SurfacePort *, bool active ); diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index 8ef0431ed8..ebbb292f63 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -182,14 +182,10 @@ void MackieControlProtocol::handle_port_changed( SurfacePort * port, bool active } else { -cout << __FILE__ << ':' << __LINE__ << endl; _ports_changed = true; -cout << __FILE__ << ':' << __LINE__ << endl; // port added update_ports(); -cout << __FILE__ << ':' << __LINE__ << endl; update_surface(); -cout << __FILE__ << ':' << __LINE__ << endl; // TODO update bank size diff --git a/libs/surfaces/mackie/route_signal.cc b/libs/surfaces/mackie/route_signal.cc index 8c62548714..d77d0520a1 100644 --- a/libs/surfaces/mackie/route_signal.cc +++ b/libs/surfaces/mackie/route_signal.cc @@ -30,26 +30,26 @@ using namespace Mackie; 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 ) ); + _solo_changed_connection = _route.solo_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), this ) ); if ( _strip.has_mute() ) - _mute_changed_connection = _route.mute_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), &_route, &_port ) ); + _mute_changed_connection = _route.mute_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_mute_changed ), this ) ); if ( _strip.has_gain() ) - _gain_changed_connection = _route.gain_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), &_route, &_port ) ); + _gain_changed_connection = _route.gain_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_gain_changed ), this ) ); - _name_changed_connection = _route.name_changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), &_route, &_port ) ); + _name_changed_connection = _route.name_changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), this ) ); if ( _route.panner().size() == 1 ) { - _panner_changed_connection = _route.panner()[0]->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), &_route, &_port ) ); + _panner_changed_connection = _route.panner()[0]->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this ) ); } 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 ) ) + .connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), this ) ) ; } catch ( std::bad_cast & ) @@ -77,19 +77,19 @@ void RouteSignal::disconnect() void RouteSignal::notify_all() { 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( &_route, &_route, &_port ); + _mcp.notify_name_changed( &_route, 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 ); } diff --git a/libs/surfaces/mackie/route_signal.h b/libs/surfaces/mackie/route_signal.h index 0cc5d36898..0239980fd4 100644 --- a/libs/surfaces/mackie/route_signal.h +++ b/libs/surfaces/mackie/route_signal.h @@ -60,7 +60,7 @@ public: const ARDOUR::Route & route() const { return _route; } Strip & strip() { return _strip; } - Port & port() { return _port; } + MackiePort & port() { return _port; } private: ARDOUR::Route & _route; -- cgit v1.2.3