allow surface to work with linked panners on stereo input tracks/busses

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2137 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
John Anderson 2007-07-17 10:17:59 +00:00
parent a1a859b1e8
commit f2a9371d28
9 changed files with 63 additions and 64 deletions

View file

@ -7,11 +7,6 @@
#include "controls.h"
#include "mackie_button_handler.h"
#ifdef DEBUG
#include <iostream>
using namespace std;
#endif
using namespace Mackie;
void Mackie::BcfSurface::init_controls()
@ -936,9 +931,6 @@ void Mackie::BcfSurface::handle_button( MackieButtonHandler & mbh, ButtonState b
}
LedState ls;
#ifdef DEBUG
cout << button << " switching on " << hex << button.id() << endl;
#endif
switch ( button.id() )
{

View file

@ -107,3 +107,23 @@ Button & Strip::fader_touch()
throw MackieControlException( "fader_touch is null" );
return *_fader_touch;
}
ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
{
os << typeid( control ).name();
os << " { ";
os << "name: " << control.name();
os << ", ";
os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
os << ", ";
os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
os << ", ";
os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
os << ", ";
os << "ordinal: " << dec << control.ordinal();
os << ", ";
os << "group: " << control.group().name();
os << " }";
return os;
}

View file

@ -876,7 +876,7 @@ void MackieControlProtocol::handle_control_event( SurfacePort & port, Control &
{
if ( route != 0 )
{
if ( route->panner().size() == 1 )
if ( route->panner().size() == 1 || ( route->panner().size() == 2 && route->panner().linked() ) )
{
// assume pan for now
float xpos;
@ -1006,18 +1006,18 @@ void MackieControlProtocol::notify_name_changed( void *, RouteSignal * route_sig
}
}
// TODO deal with > 1 channel being panned
void MackieControlProtocol::notify_panner_changed( RouteSignal * route_signal )
{
try
{
Pot & pot = route_signal->strip().vpot();
if ( route_signal->route().panner().size() == 1 )
const Panner & panner = route_signal->route().panner();
cout << "panner from ardour" << panner.size() << " " << boolalpha << panner.linked() << endl;
if ( panner.size() == 1 || ( panner.size() == 2 && panner.linked() ) )
{
float pos;
route_signal->route().panner()[0]->get_effective_position( pos);
route_signal->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 ), MackieMidiBuilder::midi_pot_mode_dot ) );
}
else
{

View file

@ -88,7 +88,9 @@ void MackieControlProtocol::update_ports()
for( MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it )
{
//cout << "adding port " << (*it)->port().name() << " to pollfd" << endl;
#ifdef DEBUG
cout << "adding port " << (*it)->port().name() << " to pollfd" << endl;
#endif
pfd[nfds].fd = (*it)->port().selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
++nfds;
@ -179,14 +181,18 @@ void MackieControlProtocol::handle_port_active( SurfacePort * port )
// finally update session state to the surface
// TODO but this is also done in set_active, and
// in fact update_surface won't execute unless
#ifdef DEBUG
cout << "update_surface in handle_port_active" << endl;
#endif
// _active == true
//cout << "update_surface in handle_port_active" << endl;
update_surface();
}
void MackieControlProtocol::handle_port_init( Mackie::SurfacePort * sport )
{
//cout << "MackieControlProtocol::handle_port_init" << endl;
#ifdef DEBUG
cout << "MackieControlProtocol::handle_port_init" << endl;
#endif
_ports_changed = true;
update_ports();
}

View file

@ -44,12 +44,12 @@ MIDI::byte MackieMidiBuilder::calculate_pot_value( midi_pot_mode mode, const Con
return retval;
}
MidiByteArray MackieMidiBuilder::build_led_ring( const Pot & pot, const ControlState & state )
MidiByteArray MackieMidiBuilder::build_led_ring( const Pot & pot, const ControlState & state, midi_pot_mode mode )
{
return build_led_ring( pot.led_ring(), state );
return build_led_ring( pot.led_ring(), state, mode );
}
MidiByteArray MackieMidiBuilder::build_led_ring( const LedRing & led_ring, const ControlState & state )
MidiByteArray MackieMidiBuilder::build_led_ring( const LedRing & led_ring, const ControlState & state, midi_pot_mode mode )
{
// The other way of doing this:
// 0x30 + pot/ring number (0-7)
@ -60,7 +60,7 @@ MidiByteArray MackieMidiBuilder::build_led_ring( const LedRing & led_ring, const
// the id
, 0x20 + led_ring.raw_id()
// the value
, calculate_pot_value( midi_pot_mode_dot, state )
, calculate_pot_value( mode, state )
);
}

View file

@ -53,8 +53,8 @@ public:
, midi_pot_mode_spread = 3
};
MidiByteArray build_led_ring( const Pot & pot, const ControlState & );
MidiByteArray build_led_ring( const LedRing & led_ring, const ControlState & );
MidiByteArray build_led_ring( const Pot & pot, const ControlState &, midi_pot_mode mode = midi_pot_mode_dot );
MidiByteArray build_led_ring( const LedRing & led_ring, const ControlState &, midi_pot_mode mode = midi_pot_mode_dot );
MidiByteArray build_led( const Led & led, LedState ls );
MidiByteArray build_led( const Button & button, LedState ls );

View file

@ -26,30 +26,35 @@
#include <stdexcept>
using namespace Mackie;
using namespace std;
void RouteSignal::connect()
{
back_insert_iterator<Connections> cins = back_inserter( _connections );
if ( _strip.has_solo() )
_solo_changed_connection = _route.solo_control().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_solo_changed ), this ) );
cins = _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 ), this ) );
cins = _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 ), this ) );
cins = _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 ), this ) );
cins = _route.name_changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_name_changed ), this ) );
if ( _route.panner().size() == 1 )
cins = _route.panner().Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this ) );
for ( unsigned int i = 0; i < _route.panner().size(); ++i )
{
_panner_changed_connection = _route.panner()[0]->Changed.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_panner_changed ), this ) );
cins = _route.panner()[i]->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 ), this ) )
cins = dynamic_cast<ARDOUR::Track&>( _route )
.rec_enable_control()
.Changed
.connect( sigc::bind ( mem_fun ( _mcp, &MackieControlProtocol::notify_record_enable_changed ), this ) )
;
}
catch ( std::bad_cast & )
@ -66,12 +71,10 @@ void RouteSignal::connect()
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();
for ( Connections::iterator it = _connections.begin(); it != _connections.end(); ++it )
{
it->disconnect();
}
}
void RouteSignal::notify_all()

View file

@ -20,6 +20,8 @@
#include <sigc++/sigc++.h>
#include <vector>
class MackieControlProtocol;
namespace ARDOUR {
@ -68,12 +70,8 @@ private:
Strip & _strip;
MackiePort & _port;
sigc::connection _solo_changed_connection;
sigc::connection _mute_changed_connection;
sigc::connection _record_enable_changed_connection;
sigc::connection _gain_changed_connection;
sigc::connection _name_changed_connection;
sigc::connection _panner_changed_connection;
typedef std::vector<sigc::connection> Connections;
Connections _connections;
};
}

View file

@ -64,26 +64,6 @@ void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips )
}
}
ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
{
os << typeid( control ).name();
os << " { ";
os << "name: " << control.name();
os << ", ";
os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
os << ", ";
os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
os << ", ";
os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
os << ", ";
os << "ordinal: " << dec << control.ordinal();
os << ", ";
os << "group: " << control.group().name();
os << " }";
return os;
}
/**
TODO could optimise this to use enum, but it's only
called during the protocol class instantiation.