2010-12-05 17:35:22 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Paul Davis
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2010-12-05 17:35:22 -05:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "boost/lambda/lambda.hpp"
|
|
|
|
|
|
|
|
#include "ardour/route.h"
|
2011-01-19 17:05:38 -05:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/midi_track.h"
|
2010-12-05 17:35:22 -05:00
|
|
|
|
|
|
|
#include "osc.h"
|
|
|
|
#include "osc_route_observer.h"
|
2011-04-22 23:34:42 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
2010-12-05 17:35:22 -05:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
using namespace std;
|
2010-12-05 17:35:22 -05:00
|
|
|
using namespace PBD;
|
|
|
|
using namespace ARDOUR;
|
2015-04-15 17:21:47 -04:00
|
|
|
using namespace ArdourSurface;
|
2010-12-05 17:35:22 -05:00
|
|
|
|
2011-01-28 17:58:47 -05:00
|
|
|
OSCRouteObserver::OSCRouteObserver (boost::shared_ptr<Route> r, lo_address a)
|
2010-12-05 17:35:22 -05:00
|
|
|
: _route (r)
|
|
|
|
{
|
|
|
|
addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-25 08:58:19 -04:00
|
|
|
_route->PropertyChanged.connect (name_changed_connection, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::name_changed, this, boost::lambda::_1), OSC::instance());
|
2011-01-19 17:05:38 -05:00
|
|
|
|
2014-07-22 17:19:46 -04:00
|
|
|
if (boost::dynamic_pointer_cast<AudioTrack>(_route) || boost::dynamic_pointer_cast<MidiTrack>(_route)) {
|
2011-01-19 17:05:38 -05:00
|
|
|
|
2014-07-22 17:19:46 -04:00
|
|
|
boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(r);
|
|
|
|
boost::shared_ptr<Controllable> rec_controllable = boost::dynamic_pointer_cast<Controllable>(track->rec_enable_control());
|
2011-01-19 17:05:38 -05:00
|
|
|
|
|
|
|
rec_controllable->Changed.connect (rec_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/rec"), track->rec_enable_control()), OSC::instance());
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-07-22 17:19:46 -04:00
|
|
|
boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(_route->mute_control());
|
2011-01-19 17:05:38 -05:00
|
|
|
mute_controllable->Changed.connect (mute_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/mute"), _route->mute_control()), OSC::instance());
|
|
|
|
|
2014-07-22 17:19:46 -04:00
|
|
|
boost::shared_ptr<Controllable> solo_controllable = boost::dynamic_pointer_cast<Controllable>(_route->solo_control());
|
2011-01-19 17:05:38 -05:00
|
|
|
solo_controllable->Changed.connect (solo_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/solo"), _route->solo_control()), OSC::instance());
|
|
|
|
|
2014-07-22 17:19:46 -04:00
|
|
|
boost::shared_ptr<Controllable> gain_controllable = boost::dynamic_pointer_cast<Controllable>(_route->gain_control());
|
2011-01-19 17:05:38 -05:00
|
|
|
gain_controllable->Changed.connect (gain_changed_connection, MISSING_INVALIDATOR, bind (&OSCRouteObserver::send_change_message, this, X_("/route/gain"), _route->gain_control()), OSC::instance());
|
2010-12-05 17:35:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
OSCRouteObserver::~OSCRouteObserver ()
|
|
|
|
{
|
2011-01-19 17:05:38 -05:00
|
|
|
name_changed_connection.disconnect();
|
|
|
|
rec_changed_connection.disconnect();
|
|
|
|
mute_changed_connection.disconnect();
|
|
|
|
solo_changed_connection.disconnect();
|
|
|
|
gain_changed_connection.disconnect();
|
|
|
|
|
2010-12-05 17:35:22 -05:00
|
|
|
lo_address_free (addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCRouteObserver::name_changed (const PBD::PropertyChange& what_changed)
|
|
|
|
{
|
|
|
|
if (!what_changed.contains (ARDOUR::Properties::name)) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2010-12-05 17:35:22 -05:00
|
|
|
if (!_route) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2010-12-05 17:35:22 -05:00
|
|
|
lo_message msg = lo_message_new ();
|
|
|
|
|
2016-05-16 07:30:28 -04:00
|
|
|
/* XXX can only use group part of ID at present */
|
|
|
|
lo_message_add_int32 (msg, _route->presentation_info().group_order());
|
2010-12-05 17:35:22 -05:00
|
|
|
lo_message_add_string (msg, _route->name().c_str());
|
|
|
|
|
|
|
|
lo_send_message (addr, "/route/name", msg);
|
|
|
|
lo_message_free (msg);
|
|
|
|
}
|
2011-01-19 17:05:38 -05:00
|
|
|
|
|
|
|
void
|
2011-01-28 17:58:47 -05:00
|
|
|
OSCRouteObserver::send_change_message (string path, boost::shared_ptr<Controllable> controllable)
|
2011-01-19 17:05:38 -05:00
|
|
|
{
|
|
|
|
lo_message msg = lo_message_new ();
|
|
|
|
|
2016-05-16 07:30:28 -04:00
|
|
|
/* XXX can only use group part of ID at present */
|
|
|
|
lo_message_add_int32 (msg, _route->presentation_info().group_order());
|
2011-01-19 17:05:38 -05:00
|
|
|
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);
|
|
|
|
}
|