Finish automation polling. Get rid of strip_from_route.

git-svn-id: svn://localhost/ardour2/trunk@1567 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
John Anderson
2007-03-09 12:09:11 +00:00
parent 04a7c950ab
commit 765d0f4785
7 changed files with 67 additions and 84 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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 );
}
}

View File

@@ -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 );

View File

@@ -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

View File

@@ -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<ARDOUR::Track&>( _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 );
}

View File

@@ -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;