Lincoln's OSC clean-ups (#3716).
git-svn-id: svn://localhost/ardour2/branches/3.0@8552 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -17,36 +17,57 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdio> /* for sprintf, sigh */
|
||||
#include <climits>
|
||||
|
||||
#include "boost/lambda/lambda.hpp"
|
||||
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/xml++.h"
|
||||
|
||||
#include "ardour/route.h"
|
||||
#include "ardour/audio_track.h"
|
||||
#include "ardour/midi_track.h"
|
||||
|
||||
#include "osc.h"
|
||||
#include "osc_route_observer.h"
|
||||
|
||||
#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
|
||||
|
||||
using namespace std;
|
||||
using namespace sigc;
|
||||
using namespace PBD;
|
||||
using namespace ARDOUR;
|
||||
using namespace boost;
|
||||
|
||||
|
||||
OSCRouteObserver::OSCRouteObserver (lo_address a, const std::string& p, boost::shared_ptr<Route> r)
|
||||
OSCRouteObserver::OSCRouteObserver (shared_ptr<Route> r, lo_address a)
|
||||
: _route (r)
|
||||
{
|
||||
addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
|
||||
_route->PropertyChanged.connect (changed_connection, MISSING_INVALIDATOR, ui_bind (&OSCRouteObserver::name_changed, this, boost::lambda::_1), OSC::instance());
|
||||
|
||||
_route->PropertyChanged.connect (name_changed_connection, MISSING_INVALIDATOR, ui_bind (&OSCRouteObserver::name_changed, this, boost::lambda::_1), OSC::instance());
|
||||
|
||||
if (dynamic_pointer_cast<AudioTrack>(_route) || dynamic_pointer_cast<MidiTrack>(_route)) {
|
||||
|
||||
shared_ptr<Track> track = dynamic_pointer_cast<Track>(r);
|
||||
shared_ptr<Controllable> rec_controllable = dynamic_pointer_cast<Controllable>(track->rec_enable_control());
|
||||
|
||||
rec_controllable->Changed.connect (rec_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/rec"), track->rec_enable_control()), OSC::instance());
|
||||
}
|
||||
|
||||
shared_ptr<Controllable> mute_controllable = dynamic_pointer_cast<Controllable>(_route->mute_control());
|
||||
mute_controllable->Changed.connect (mute_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/mute"), _route->mute_control()), OSC::instance());
|
||||
|
||||
shared_ptr<Controllable> solo_controllable = dynamic_pointer_cast<Controllable>(_route->solo_control());
|
||||
solo_controllable->Changed.connect (solo_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/solo"), _route->solo_control()), OSC::instance());
|
||||
|
||||
shared_ptr<Controllable> gain_controllable = dynamic_pointer_cast<Controllable>(_route->gain_control());
|
||||
gain_controllable->Changed.connect (gain_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/gain"), _route->gain_control()), OSC::instance());
|
||||
}
|
||||
|
||||
OSCRouteObserver::~OSCRouteObserver ()
|
||||
{
|
||||
changed_connection.disconnect();
|
||||
name_changed_connection.disconnect();
|
||||
rec_changed_connection.disconnect();
|
||||
mute_changed_connection.disconnect();
|
||||
solo_changed_connection.disconnect();
|
||||
gain_changed_connection.disconnect();
|
||||
|
||||
lo_address_free (addr);
|
||||
}
|
||||
|
||||
@@ -69,3 +90,19 @@ OSCRouteObserver::name_changed (const PBD::PropertyChange& what_changed)
|
||||
lo_send_message (addr, "/route/name", msg);
|
||||
lo_message_free (msg);
|
||||
}
|
||||
|
||||
void
|
||||
OSCRouteObserver::send_change_message (string path, shared_ptr<Controllable> controllable)
|
||||
{
|
||||
lo_message msg = lo_message_new ();
|
||||
|
||||
lo_message_add_int32 (msg, _route->remote_control_id());
|
||||
lo_message_add_float (msg, (float) controllable->get_value());
|
||||
|
||||
/* XXX thread issues */
|
||||
|
||||
//std::cerr << "ORC: send " << path << " = " << controllable->get_value() << std::endl;
|
||||
|
||||
lo_send_message (addr, path.c_str(), msg);
|
||||
lo_message_free (msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user