2008-06-02 17:41:35 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Paul Davis
|
2015-03-20 16:38:26 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04: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.
|
2015-03-20 16:38:26 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04:00
|
|
|
* 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.
|
2015-03-20 16:38:26 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04:00
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2015-03-20 16:38:26 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2015-10-05 16:10:58 -04:00
|
|
|
#include "pbd/gstdio_compat.h"
|
2008-09-10 11:03:30 -04:00
|
|
|
#include <glibmm/miscutils.h>
|
|
|
|
|
2013-12-21 15:31:08 -05:00
|
|
|
#include <pbd/convert.h>
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <pbd/pthread_utils.h>
|
|
|
|
#include <pbd/file_utils.h>
|
2009-01-15 17:09:23 -05:00
|
|
|
#include <pbd/failed_constructor.h>
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2013-06-06 11:19:23 -04:00
|
|
|
#include "ardour/amp.h"
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/dB.h"
|
|
|
|
#include "ardour/filesystem_paths.h"
|
2010-11-28 16:28:54 -05:00
|
|
|
#include "ardour/panner.h"
|
2010-12-03 17:29:58 -05:00
|
|
|
#include "ardour/plugin.h"
|
2014-11-03 13:40:50 -05:00
|
|
|
#include "ardour/plugin_insert.h"
|
2013-06-06 11:19:23 -04:00
|
|
|
#include "ardour/send.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
#include "osc.h"
|
2009-01-30 02:40:13 -05:00
|
|
|
#include "osc_controllable.h"
|
2010-12-05 17:28:39 -05:00
|
|
|
#include "osc_route_observer.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
2009-12-09 13:37:06 -05:00
|
|
|
using namespace Glib;
|
2015-04-15 17:21:47 -04:00
|
|
|
using namespace ArdourSurface;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
#include "pbd/abstract_ui.cc" // instantiate template
|
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
OSC* OSC::_instance = 0;
|
|
|
|
|
2009-07-21 11:55:17 -04:00
|
|
|
#ifdef DEBUG
|
2008-06-02 17:41:35 -04:00
|
|
|
static void error_callback(int num, const char *m, const char *path)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "liblo server error %d in path %s: %s\n", num, path, m);
|
|
|
|
}
|
2009-07-21 11:55:17 -04:00
|
|
|
#else
|
|
|
|
static void error_callback(int, const char *, const char *)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
OSC::OSC (Session& s, uint32_t port)
|
2013-12-21 15:31:08 -05:00
|
|
|
: ControlProtocol (s, X_("Open Sound Control (OSC)"))
|
2009-12-09 13:37:06 -05:00
|
|
|
, AbstractUI<OSCUIRequest> ("osc")
|
2013-12-21 15:31:08 -05:00
|
|
|
, local_server (0)
|
|
|
|
, remote_server (0)
|
2009-01-15 17:09:23 -05:00
|
|
|
, _port(port)
|
2013-12-21 15:31:08 -05:00
|
|
|
, _ok (true)
|
|
|
|
, _shutdown (false)
|
|
|
|
, _osc_server (0)
|
|
|
|
, _osc_unix_server (0)
|
|
|
|
, _namespace_root ("/ardour")
|
|
|
|
, _send_route_changes (true)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-12-21 13:23:07 -05:00
|
|
|
_instance = this;
|
2009-01-15 17:09:23 -05:00
|
|
|
|
|
|
|
session_loaded (s);
|
2012-04-25 08:58:19 -04:00
|
|
|
session->Exported.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::session_exported, this, _1, _2), this);
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
OSC::~OSC()
|
|
|
|
{
|
|
|
|
stop ();
|
2009-12-21 13:23:07 -05:00
|
|
|
_instance = 0;
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
void
|
|
|
|
OSC::do_request (OSCUIRequest* req)
|
|
|
|
{
|
|
|
|
if (req->type == CallSlot) {
|
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
call_slot (MISSING_INVALIDATOR, req->the_slot);
|
2009-12-09 13:37:06 -05:00
|
|
|
|
|
|
|
} else if (req->type == Quit) {
|
|
|
|
|
|
|
|
stop ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
int
|
|
|
|
OSC::set_active (bool yn)
|
|
|
|
{
|
2013-12-21 15:31:08 -05:00
|
|
|
if (yn != active()) {
|
|
|
|
|
|
|
|
if (yn) {
|
|
|
|
if (start ()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (stop ()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
2013-12-21 15:31:08 -05:00
|
|
|
|
|
|
|
return ControlProtocol::set_active (yn);
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
OSC::get_active () const
|
|
|
|
{
|
|
|
|
return _osc_server != 0;
|
|
|
|
}
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
int
|
2009-01-15 17:09:23 -05:00
|
|
|
OSC::set_feedback (bool yn)
|
|
|
|
{
|
|
|
|
_send_route_changes = yn;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
OSC::get_feedback () const
|
|
|
|
{
|
|
|
|
return _send_route_changes;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::start ()
|
|
|
|
{
|
|
|
|
char tmpstr[255];
|
|
|
|
|
|
|
|
if (_osc_server) {
|
|
|
|
/* already started */
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
for (int j=0; j < 20; ++j) {
|
|
|
|
snprintf(tmpstr, sizeof(tmpstr), "%d", _port);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2010-12-05 17:28:39 -05:00
|
|
|
//if ((_osc_server = lo_server_new_with_proto (tmpstr, LO_TCP, error_callback))) {
|
|
|
|
// break;
|
|
|
|
//}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if ((_osc_server = lo_server_new (tmpstr, error_callback))) {
|
|
|
|
break;
|
|
|
|
}
|
2010-12-05 17:28:39 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
#ifdef DEBUG
|
2008-06-02 17:41:35 -04:00
|
|
|
cerr << "can't get osc at port: " << _port << endl;
|
|
|
|
#endif
|
|
|
|
_port++;
|
|
|
|
continue;
|
|
|
|
}
|
2013-06-07 10:54:47 -04:00
|
|
|
|
2013-06-07 12:02:04 -04:00
|
|
|
if (!_osc_server) {
|
|
|
|
return 1;
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#ifdef ARDOUR_OSC_UNIX_SERVER
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
// APPEARS sluggish for now
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
// attempt to create unix socket server too
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX");
|
2013-06-07 15:07:41 -04:00
|
|
|
int fd = mkstemp(tmpstr);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (fd >= 0 ) {
|
2013-07-15 14:29:00 -04:00
|
|
|
::g_unlink (tmpstr);
|
2008-06-02 17:41:35 -04:00
|
|
|
close (fd);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
_osc_unix_server = lo_server_new (tmpstr, error_callback);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (_osc_unix_server) {
|
|
|
|
_osc_unix_socket_path = tmpstr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2012-06-09 18:37:05 -04:00
|
|
|
PBD::info << "OSC @ " << get_server_url () << endmsg;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-06-23 01:06:54 -04:00
|
|
|
std::string url_file;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2014-06-19 07:23:12 -04:00
|
|
|
if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
|
2012-06-23 01:06:54 -04:00
|
|
|
_osc_url_file = url_file;
|
2015-10-05 15:43:44 -04:00
|
|
|
if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) {
|
2008-06-02 17:41:35 -04:00
|
|
|
cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
|
|
|
|
}
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
register_callbacks();
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
// lo_server_thread_add_method(_sthread, NULL, NULL, OSC::_dummy_handler, this);
|
2009-12-09 13:37:06 -05:00
|
|
|
|
|
|
|
/* startup the event loop thread */
|
|
|
|
|
|
|
|
BaseUI::run ();
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
void
|
|
|
|
OSC::thread_init ()
|
|
|
|
{
|
2010-12-10 21:34:44 -05:00
|
|
|
pthread_set_name (X_("OSC"));
|
2010-01-24 16:04:31 -05:00
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
if (_osc_unix_server) {
|
|
|
|
Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR);
|
2009-12-12 10:02:15 -05:00
|
|
|
src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server));
|
2009-12-09 13:37:06 -05:00
|
|
|
src->attach (_main_loop->get_context());
|
|
|
|
local_server = src->gobj();
|
|
|
|
g_source_ref (local_server);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_osc_server) {
|
2013-06-07 15:07:41 -04:00
|
|
|
Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_server), IO_IN|IO_HUP|IO_ERR);
|
2009-12-12 10:02:15 -05:00
|
|
|
src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_server));
|
2009-12-09 13:37:06 -05:00
|
|
|
src->attach (_main_loop->get_context());
|
|
|
|
remote_server = src->gobj();
|
|
|
|
g_source_ref (remote_server);
|
|
|
|
}
|
2010-01-24 16:02:31 -05:00
|
|
|
|
|
|
|
PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self(), X_("OSC"), 2048);
|
|
|
|
SessionEvent::create_per_thread_pool (X_("OSC"), 128);
|
2009-12-09 13:37:06 -05:00
|
|
|
}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
int
|
|
|
|
OSC::stop ()
|
2011-01-19 17:05:38 -05:00
|
|
|
{
|
2009-12-09 13:37:06 -05:00
|
|
|
/* stop main loop */
|
|
|
|
|
|
|
|
if (local_server) {
|
|
|
|
g_source_destroy (local_server);
|
|
|
|
g_source_unref (local_server);
|
|
|
|
local_server = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remote_server) {
|
|
|
|
g_source_destroy (remote_server);
|
|
|
|
g_source_unref (remote_server);
|
|
|
|
remote_server = 0;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
BaseUI::quit ();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
if (_osc_server) {
|
|
|
|
lo_server_free (_osc_server);
|
|
|
|
_osc_server = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_osc_unix_server) {
|
|
|
|
lo_server_free (_osc_unix_server);
|
|
|
|
_osc_unix_server = 0;
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (!_osc_unix_socket_path.empty()) {
|
2013-07-15 14:29:00 -04:00
|
|
|
::g_unlink (_osc_unix_socket_path.c_str());
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
if (!_osc_url_file.empty() ) {
|
2013-07-15 14:29:00 -04:00
|
|
|
::g_unlink (_osc_url_file.c_str() );
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2009-12-09 13:37:06 -05:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
// Delete any active route observers
|
|
|
|
for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
|
|
|
|
|
|
|
|
OSCRouteObserver* rc;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if ((rc = dynamic_cast<OSCRouteObserver*>(*x)) != 0) {
|
|
|
|
delete *x;
|
|
|
|
x = route_observers.erase (x);
|
|
|
|
} else {
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSC::register_callbacks()
|
|
|
|
{
|
|
|
|
lo_server srvs[2];
|
|
|
|
lo_server serv;
|
|
|
|
|
|
|
|
srvs[0] = _osc_server;
|
|
|
|
srvs[1] = _osc_unix_server;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
for (size_t i = 0; i < 2; ++i) {
|
|
|
|
|
|
|
|
if (!srvs[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
serv = srvs[i];
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
/* this is a special catchall handler */
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
lo_server_add_method (serv, 0, 0, _catchall, this);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#define REGISTER_CALLBACK(serv,path,types, function) lo_server_add_method (serv, path, types, OSC::_ ## function, this)
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
REGISTER_CALLBACK (serv, "/routes/list", "", routes_list);
|
2008-06-02 17:41:35 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/add_marker", "", add_marker);
|
2008-09-10 11:03:30 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/access_action", "s", access_action);
|
2008-06-02 17:41:35 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/loop_toggle", "", loop_toggle);
|
2015-04-13 10:20:40 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/loop_location", "ii", loop_location);
|
2008-06-02 17:41:35 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/goto_start", "", goto_start);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/goto_end", "", goto_end);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/rewind", "", rewind);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/ffwd", "", ffwd);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/transport_stop", "", transport_stop);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/transport_play", "", transport_play);
|
2011-01-19 17:05:38 -05:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/transport_frame", "", transport_frame);
|
2015-11-13 01:49:13 -05:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/transport_speed", "", transport_speed);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/record_enabled", "", record_enabled);
|
2008-06-02 17:41:35 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/set_transport_speed", "f", set_transport_speed);
|
2015-03-20 16:38:26 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/locate", "ii", locate);
|
2008-06-02 17:41:35 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/save_state", "", save_state);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/prev_marker", "", prev_marker);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/next_marker", "", next_marker);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/undo", "", undo);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/redo", "", redo);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/toggle_punch_in", "", toggle_punch_in);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/toggle_punch_out", "", toggle_punch_out);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/rec_enable_toggle", "", rec_enable_toggle);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/toggle_all_rec_enables", "", toggle_all_rec_enables);
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/mute", "ii", route_mute);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/solo", "ii", route_solo);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/recenable", "ii", route_recenable);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/gainabs", "if", route_set_gain_abs);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/gaindB", "if", route_set_gain_dB);
|
2015-04-25 12:25:46 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/trimabs", "if", route_set_trim_abs);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/trimdB", "if", route_set_trim_dB);
|
2010-12-03 17:29:58 -05:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/pan_stereo_position", "if", route_set_pan_stereo_position);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/pan_stereo_width", "if", route_set_pan_stereo_width);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/plugin/parameter", "iiif", route_plugin_parameter);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/plugin/parameter/print", "iii", route_plugin_parameter_print);
|
2013-06-06 11:14:31 -04:00
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/send/gainabs", "iif", route_set_send_gain_abs);
|
|
|
|
REGISTER_CALLBACK (serv, "/ardour/routes/send/gaindB", "iif", route_set_send_gain_dB);
|
2010-12-05 17:28:39 -05:00
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
/* still not-really-standardized query interface */
|
2010-12-05 17:28:39 -05:00
|
|
|
//REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value);
|
|
|
|
//REGISTER_CALLBACK (serv, "/ardour/set", "", set);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
// un/register_update args= s:ctrl s:returl s:retpath
|
2010-12-05 17:28:39 -05:00
|
|
|
//lo_server_add_method(serv, "/register_update", "sss", OSC::global_register_update_handler, this);
|
|
|
|
//lo_server_add_method(serv, "/unregister_update", "sss", OSC::global_unregister_update_handler, this);
|
|
|
|
//lo_server_add_method(serv, "/register_auto_update", "siss", OSC::global_register_auto_update_handler, this);
|
|
|
|
//lo_server_add_method(serv, "/unregister_auto_update", "sss", OSC::_global_unregister_auto_update_handler, this);
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-12-09 13:37:06 -05:00
|
|
|
OSC::osc_input_handler (IOCondition ioc, lo_server srv)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-12-09 13:37:06 -05:00
|
|
|
if (ioc & ~IO_IN) {
|
2008-06-02 17:41:35 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-09 13:37:06 -05:00
|
|
|
if (ioc & IO_IN) {
|
|
|
|
lo_server_recv (srv);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
OSC::get_server_url()
|
|
|
|
{
|
|
|
|
string url;
|
|
|
|
char * urlstr;
|
|
|
|
|
|
|
|
if (_osc_server) {
|
|
|
|
urlstr = lo_server_get_url (_osc_server);
|
|
|
|
url = urlstr;
|
|
|
|
free (urlstr);
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
OSC::get_unix_server_url()
|
|
|
|
{
|
|
|
|
string url;
|
|
|
|
char * urlstr;
|
|
|
|
|
|
|
|
if (_osc_unix_server) {
|
|
|
|
urlstr = lo_server_get_url (_osc_unix_server);
|
|
|
|
url = urlstr;
|
|
|
|
free (urlstr);
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
void
|
|
|
|
OSC::listen_to_route (boost::shared_ptr<Route> route, lo_address addr)
|
|
|
|
{
|
|
|
|
/* avoid duplicate listens */
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end(); ++x) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
OSCRouteObserver* ro;
|
|
|
|
|
|
|
|
if ((ro = dynamic_cast<OSCRouteObserver*>(*x)) != 0) {
|
|
|
|
|
|
|
|
int res = strcmp(lo_address_get_hostname(ro->address()), lo_address_get_hostname(addr));
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if (ro->route() == route && res == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OSCRouteObserver* o = new OSCRouteObserver (route, addr);
|
|
|
|
route_observers.push_back (o);
|
|
|
|
|
|
|
|
route->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Route> (route)), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSC::drop_route (boost::weak_ptr<Route> wr)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Route> r = wr.lock ();
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
|
|
|
|
|
|
|
|
OSCRouteObserver* rc;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if ((rc = dynamic_cast<OSCRouteObserver*>(*x)) != 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if (rc->route() == r) {
|
|
|
|
delete *x;
|
|
|
|
x = route_observers.erase (x);
|
|
|
|
} else {
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSC::end_listen (boost::shared_ptr<Route> r, lo_address addr)
|
|
|
|
{
|
|
|
|
RouteObservers::iterator x;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
// Remove the route observers
|
|
|
|
for (x = route_observers.begin(); x != route_observers.end();) {
|
|
|
|
|
|
|
|
OSCRouteObserver* ro;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if ((ro = dynamic_cast<OSCRouteObserver*>(*x)) != 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
int res = strcmp(lo_address_get_hostname(ro->address()), lo_address_get_hostname(addr));
|
|
|
|
|
|
|
|
if (ro->route() == r && res == 0) {
|
|
|
|
delete *x;
|
|
|
|
x = route_observers.erase (x);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
void
|
2009-01-15 17:09:23 -05:00
|
|
|
OSC::current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-01-15 17:09:23 -05:00
|
|
|
char* subpath;
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
subpath = (char*) malloc (len-15+1);
|
|
|
|
memcpy (subpath, path, len-15);
|
|
|
|
subpath[len-15] = '\0';
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
send_current_value (subpath, argv, argc, msg);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
free (subpath);
|
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
void
|
|
|
|
OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg)
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
boost::shared_ptr<Route> r;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
lo_message_add_string (reply, path);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
if (argc == 0) {
|
|
|
|
lo_message_add_string (reply, "bad syntax");
|
|
|
|
} else {
|
|
|
|
id = argv[0]->i;
|
|
|
|
r = session->route_by_remote_id (id);
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
lo_message_add_string (reply, "not found");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (strcmp (path, "/routes/state") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
if (boost::dynamic_pointer_cast<AudioTrack>(r)) {
|
|
|
|
lo_message_add_string (reply, "AT");
|
|
|
|
} else if (boost::dynamic_pointer_cast<MidiTrack>(r)) {
|
|
|
|
lo_message_add_string (reply, "MT");
|
|
|
|
} else {
|
|
|
|
lo_message_add_string (reply, "B");
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
lo_message_add_string (reply, r->name().c_str());
|
|
|
|
lo_message_add_int32 (reply, r->n_inputs().n_audio());
|
|
|
|
lo_message_add_int32 (reply, r->n_outputs().n_audio());
|
|
|
|
lo_message_add_int32 (reply, r->muted());
|
|
|
|
lo_message_add_int32 (reply, r->soloed());
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (path, "/routes/mute") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
lo_message_add_int32 (reply, (float) r->muted());
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (path, "/routes/solo") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
lo_message_add_int32 (reply, r->soloed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "#reply", reply);
|
|
|
|
lo_message_free (reply);
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
int
|
2015-03-20 16:38:26 -04:00
|
|
|
OSC::_catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data)
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
|
|
|
return ((OSC*)user_data)->catchall (path, types, argv, argc, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2015-03-20 16:38:26 -04:00
|
|
|
OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, lo_message msg)
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
int ret = 1; /* unhandled */
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
//cerr << "Received a message, path = " << path << " types = \""
|
2010-12-05 17:28:39 -05:00
|
|
|
// << (types ? types : "NULL") << '"' << endl;
|
2009-01-15 17:09:23 -05:00
|
|
|
|
|
|
|
/* 15 for /#current_value plus 2 for /<path> */
|
|
|
|
|
|
|
|
len = strlen (path);
|
|
|
|
|
|
|
|
if (len >= 17 && !strcmp (&path[len-15], "/#current_value")) {
|
|
|
|
current_value_query (path, len, argv, argc, msg);
|
|
|
|
ret = 0;
|
2011-01-19 17:05:38 -05:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (path, "/routes/listen") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
cerr << "set up listener\n";
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
|
2009-01-30 02:40:13 -05:00
|
|
|
if (argc <= 0) {
|
|
|
|
lo_message_add_string (reply, "syntax error");
|
|
|
|
} else {
|
|
|
|
for (int n = 0; n < argc; ++n) {
|
2009-01-15 17:09:23 -05:00
|
|
|
|
2009-01-30 02:40:13 -05:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (argv[n]->i);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-30 02:40:13 -05:00
|
|
|
if (!r) {
|
|
|
|
lo_message_add_string (reply, "not found");
|
|
|
|
cerr << "no such route\n";
|
|
|
|
break;
|
2015-03-20 16:38:26 -04:00
|
|
|
} else {
|
2009-01-30 02:40:13 -05:00
|
|
|
cerr << "add listener\n";
|
|
|
|
listen_to_route (r, lo_message_get_source (msg));
|
|
|
|
lo_message_add_int32 (reply, argv[n]->i);
|
|
|
|
}
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "#reply", reply);
|
|
|
|
lo_message_free (reply);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2010-12-05 17:28:39 -05:00
|
|
|
ret = 0;
|
2009-01-15 17:09:23 -05:00
|
|
|
|
|
|
|
} else if (strcmp (path, "/routes/ignore") == 0) {
|
|
|
|
|
2009-01-30 02:40:13 -05:00
|
|
|
for (int n = 0; n < argc; ++n) {
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (argv[n]->i);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
if (r) {
|
2009-01-30 02:40:13 -05:00
|
|
|
end_listen (r, lo_message_get_source (msg));
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
}
|
2009-01-15 17:09:23 -05:00
|
|
|
|
|
|
|
return ret;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2010-12-05 17:28:39 -05:00
|
|
|
void
|
2011-01-19 17:05:38 -05:00
|
|
|
OSC::update_clock ()
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
// "Application Hook" Handlers //
|
2009-01-15 17:09:23 -05:00
|
|
|
void
|
2011-01-19 17:05:38 -05:00
|
|
|
OSC::session_loaded (Session& s)
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
2011-01-19 17:05:38 -05:00
|
|
|
lo_address listener = lo_address_new (NULL, "7770");
|
|
|
|
lo_send (listener, "/session/loaded", "ss", s.path().c_str(), s.name().c_str());
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-19 17:05:38 -05:00
|
|
|
OSC::session_exported (std::string path, std::string name)
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
2011-01-19 17:05:38 -05:00
|
|
|
lo_address listener = lo_address_new (NULL, "7770");
|
|
|
|
lo_send (listener, "/session/exported", "ss", path.c_str(), name.c_str());
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// end "Application Hook" Handlers //
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
/* path callbacks */
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
int
|
|
|
|
OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv*/, int /*argc*/, void */*data*/, void* /*user_data*/)
|
|
|
|
{
|
2008-06-02 17:41:35 -04:00
|
|
|
#if 0
|
|
|
|
const char* returl;
|
|
|
|
|
|
|
|
if (argc < 3 || types == 0 || strlen (types) < 3 || types[0] != 's' || types[1] != 's' || types[2] != s) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *returl = argv[1]->s;
|
|
|
|
lo_address addr = find_or_cache_addr (returl);
|
|
|
|
|
|
|
|
const char *retpath = argv[2]->s;
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
if (strcmp (argv[0]->s, "transport_frame") == 0) {
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (argv[0]->s, "transport_speed") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (argv[0]->s, "transport_locked") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (argv[0]->s, "punch_in") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (argv[0]->s, "punch_out") == 0) {
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
} else if (strcmp (argv[0]->s, "rec_enable") == 0) {
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (session) {
|
|
|
|
lo_send (addr, retpath, "i", session->transport_frame());
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* error */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
void
|
|
|
|
OSC::routes_list (lo_message msg)
|
|
|
|
{
|
2015-12-02 16:40:36 -05:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-19 17:05:38 -05:00
|
|
|
for (int n = 0; n < (int) session->nroutes(); ++n) {
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (n);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if (r) {
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
if (boost::dynamic_pointer_cast<AudioTrack>(r)) {
|
|
|
|
lo_message_add_string (reply, "AT");
|
|
|
|
} else if (boost::dynamic_pointer_cast<MidiTrack>(r)) {
|
|
|
|
lo_message_add_string (reply, "MT");
|
|
|
|
} else {
|
|
|
|
lo_message_add_string (reply, "B");
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
lo_message_add_string (reply, r->name().c_str());
|
|
|
|
lo_message_add_int32 (reply, r->n_inputs().n_audio());
|
|
|
|
lo_message_add_int32 (reply, r->n_outputs().n_audio());
|
|
|
|
lo_message_add_int32 (reply, r->muted());
|
|
|
|
lo_message_add_int32 (reply, r->soloed());
|
|
|
|
lo_message_add_int32 (reply, r->remote_control_id());
|
2015-03-20 16:38:26 -04:00
|
|
|
|
|
|
|
if (boost::dynamic_pointer_cast<AudioTrack>(r)
|
|
|
|
|| boost::dynamic_pointer_cast<MidiTrack>(r)) {
|
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(r);
|
|
|
|
lo_message_add_int32 (reply, t->record_enabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
//Automatically listen to routes listed
|
|
|
|
listen_to_route(r, lo_message_get_source (msg));
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "#reply", reply);
|
|
|
|
lo_message_free (reply);
|
|
|
|
}
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
// Send end of listing message
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
|
|
|
|
lo_message_add_string (reply, "end_route_list");
|
|
|
|
lo_message_add_int64 (reply, session->frame_rate());
|
|
|
|
lo_message_add_int64 (reply, session->current_end_frame());
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
lo_send_message (lo_message_get_source (msg), "#reply", reply);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2011-01-19 17:05:38 -05:00
|
|
|
lo_message_free (reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSC::transport_frame (lo_message msg)
|
|
|
|
{
|
2015-12-02 16:40:36 -05:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
framepos_t pos = session->transport_frame ();
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
lo_message_add_int64 (reply, pos);
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "/ardour/transport_frame", reply);
|
|
|
|
|
|
|
|
lo_message_free (reply);
|
2011-01-19 17:05:38 -05:00
|
|
|
}
|
|
|
|
|
2015-11-13 01:49:13 -05:00
|
|
|
void
|
2015-11-17 12:05:39 -05:00
|
|
|
OSC::transport_speed (lo_message msg)
|
2015-11-13 01:49:13 -05:00
|
|
|
{
|
2015-12-02 16:40:36 -05:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 01:49:13 -05:00
|
|
|
double ts = session->transport_speed ();
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
lo_message_add_double (reply, ts);
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "/ardour/transport_speed", reply);
|
|
|
|
|
|
|
|
lo_message_free (reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-11-17 12:05:39 -05:00
|
|
|
OSC::record_enabled (lo_message msg)
|
2015-11-13 01:49:13 -05:00
|
|
|
{
|
2015-12-02 16:40:36 -05:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 01:49:13 -05:00
|
|
|
int re = (int)session->get_record_enabled ();
|
|
|
|
|
|
|
|
lo_message reply = lo_message_new ();
|
|
|
|
lo_message_add_int32 (reply, re);
|
|
|
|
|
|
|
|
lo_send_message (lo_message_get_source (msg), "/ardour/record_enabled", reply);
|
|
|
|
|
|
|
|
lo_message_free (reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
int
|
|
|
|
OSC::route_mute (int rid, int yn)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
|
|
|
r->set_mute (yn, this);
|
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_solo (int rid, int yn)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
2015-10-03 20:03:49 -04:00
|
|
|
boost::shared_ptr<RouteList> rl (new RouteList);
|
|
|
|
rl->push_back (r);
|
|
|
|
session->set_solo (rl, yn);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_recenable (int rid, int yn)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
2010-07-24 12:40:56 -04:00
|
|
|
r->set_record_enabled (yn, this);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_set_gain_abs (int rid, float level)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
|
|
|
r->set_gain (level, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_set_gain_dB (int rid, float dB)
|
2015-04-25 12:25:46 -04:00
|
|
|
{
|
|
|
|
return route_set_gain_abs (rid, dB_to_coefficient (dB));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_set_trim_abs (int rid, float level)
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
2015-04-25 12:25:46 -04:00
|
|
|
r->set_trim (level, this);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2009-01-15 17:09:23 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2015-04-25 12:25:46 -04:00
|
|
|
int
|
|
|
|
OSC::route_set_trim_dB (int rid, float dB)
|
|
|
|
{
|
|
|
|
return route_set_trim_abs(rid, dB_to_coefficient (dB));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-28 16:28:54 -05:00
|
|
|
int
|
|
|
|
OSC::route_set_pan_stereo_position (int rid, float pos)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<Panner> panner = r->panner();
|
|
|
|
if (panner) {
|
|
|
|
panner->set_position (pos);
|
|
|
|
}
|
2010-11-28 16:28:54 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2010-11-28 16:28:54 -05:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_set_pan_stereo_width (int rid, float pos)
|
|
|
|
{
|
|
|
|
if (!session) return -1;
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (r) {
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<Panner> panner = r->panner();
|
|
|
|
if (panner) {
|
|
|
|
panner->set_width (pos);
|
|
|
|
}
|
2010-11-28 16:28:54 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2010-11-28 16:28:54 -05:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-06 11:14:31 -04:00
|
|
|
int
|
|
|
|
OSC::route_set_send_gain_abs (int rid, int sid, float val)
|
|
|
|
{
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!session) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-06-06 11:14:31 -04:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
2013-06-06 11:14:31 -04:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!r) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-06-06 11:14:31 -04:00
|
|
|
|
|
|
|
/* revert to zero-based counting */
|
|
|
|
|
|
|
|
if (sid > 0) {
|
|
|
|
--sid;
|
|
|
|
}
|
|
|
|
|
2013-06-06 11:19:23 -04:00
|
|
|
boost::shared_ptr<Processor> p = r->nth_send (sid);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2013-06-06 11:14:31 -04:00
|
|
|
if (p) {
|
|
|
|
boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
|
|
|
|
boost::shared_ptr<Amp> a = s->amp();
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2013-06-06 11:14:31 -04:00
|
|
|
if (a) {
|
|
|
|
a->set_gain (val, this);
|
|
|
|
}
|
|
|
|
}
|
2013-06-06 15:00:34 -04:00
|
|
|
return 0;
|
2013-06-06 11:14:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
OSC::route_set_send_gain_dB (int rid, int sid, float val)
|
|
|
|
{
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!session) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-06-06 11:14:31 -04:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
2013-06-06 11:14:31 -04:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!r) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-06-06 11:14:31 -04:00
|
|
|
|
|
|
|
/* revert to zero-based counting */
|
|
|
|
|
|
|
|
if (sid > 0) {
|
|
|
|
--sid;
|
|
|
|
}
|
|
|
|
|
2013-06-06 11:19:23 -04:00
|
|
|
boost::shared_ptr<Processor> p = r->nth_send (sid);
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2013-06-06 11:14:31 -04:00
|
|
|
if (p) {
|
|
|
|
boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
|
|
|
|
boost::shared_ptr<Amp> a = s->amp();
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2013-06-06 11:14:31 -04:00
|
|
|
if (a) {
|
|
|
|
a->set_gain (dB_to_coefficient (val), this);
|
|
|
|
}
|
|
|
|
}
|
2013-06-06 15:00:34 -04:00
|
|
|
return 0;
|
2013-06-06 11:14:31 -04:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:29:58 -05:00
|
|
|
int
|
2011-01-19 17:05:38 -05:00
|
|
|
OSC::route_plugin_parameter (int rid, int piid, int par, float val)
|
2010-12-03 17:29:58 -05:00
|
|
|
{
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!session)
|
|
|
|
return -1;
|
|
|
|
|
2015-03-20 17:08:17 -04:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 17:08:17 -04:00
|
|
|
if (!r) {
|
|
|
|
PBD::error << "OSC: Invalid Remote Control ID '" << rid << "'" << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<Processor> redi=r->nth_plugin (piid);
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!redi) {
|
2015-03-20 16:32:56 -04:00
|
|
|
PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << rid << "'" << endmsg;
|
2015-03-20 16:38:26 -04:00
|
|
|
return -1;
|
|
|
|
}
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<PluginInsert> pi;
|
|
|
|
|
|
|
|
if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
|
2015-03-20 16:32:56 -04:00
|
|
|
PBD::error << "OSC: given processor # " << piid << " on RID '" << rid << "' is not a Plugin." << endmsg;
|
2015-03-20 16:38:26 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
|
|
|
|
bool ok=false;
|
|
|
|
|
|
|
|
uint32_t controlid = pip->nth_parameter (par,ok);
|
|
|
|
|
|
|
|
if (!ok) {
|
2015-03-20 16:32:56 -04:00
|
|
|
PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "'" << endmsg;
|
2015-03-20 16:38:26 -04:00
|
|
|
return -1;
|
|
|
|
}
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-04-03 21:16:53 -04:00
|
|
|
if (!pip->parameter_is_input(controlid)) {
|
2015-03-20 16:32:56 -04:00
|
|
|
PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "' is not a control input" << endmsg;
|
2015-03-20 16:19:25 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
ParameterDescriptor pd;
|
|
|
|
pi->plugin()->get_parameter_descriptor (controlid,pd);
|
|
|
|
|
|
|
|
if (val >= pd.lower && val < pd.upper) {
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
|
|
|
|
// cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n";
|
|
|
|
c->set_value (val);
|
|
|
|
} else {
|
2015-03-20 16:32:56 -04:00
|
|
|
PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "' is out of range" << endmsg;
|
|
|
|
PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg;
|
|
|
|
}
|
2010-12-03 17:29:58 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
return 0;
|
2010-12-03 17:29:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2011-01-19 17:05:38 -05:00
|
|
|
OSC::route_plugin_parameter_print (int rid, int piid, int par)
|
2010-12-03 17:29:58 -05:00
|
|
|
{
|
2015-03-20 16:38:26 -04:00
|
|
|
if (!session) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Processor> redi=r->nth_processor (piid);
|
|
|
|
|
|
|
|
if (!redi) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<PluginInsert> pi;
|
|
|
|
|
|
|
|
if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
|
|
|
|
bool ok=false;
|
|
|
|
|
|
|
|
uint32_t controlid = pip->nth_parameter (par,ok);
|
|
|
|
|
|
|
|
if (!ok) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParameterDescriptor pd;
|
|
|
|
|
|
|
|
if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) {
|
|
|
|
boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
|
|
|
|
|
|
|
|
cerr << "parameter: " << redi->describe_parameter(controlid) << "\n";
|
|
|
|
cerr << "current value: " << c->get_value ();
|
|
|
|
cerr << "lower value: " << pd.lower << "\n";
|
|
|
|
cerr << "upper value: " << pd.upper << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-12-03 17:29:58 -05:00
|
|
|
}
|
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
XMLNode&
|
|
|
|
OSC::get_state ()
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
2015-06-24 13:46:07 -04:00
|
|
|
return ControlProtocol::get_state();
|
2009-01-15 17:09:23 -05:00
|
|
|
}
|
2011-01-19 17:05:38 -05:00
|
|
|
|
2015-03-20 16:38:26 -04:00
|
|
|
int
|
2015-06-24 13:46:07 -04:00
|
|
|
OSC::set_state (const XMLNode& node, int version)
|
2009-01-15 17:09:23 -05:00
|
|
|
{
|
2015-06-24 13:46:07 -04:00
|
|
|
if (ControlProtocol::set_state (node, version)) {
|
|
|
|
return -1;
|
2013-12-21 15:31:08 -05:00
|
|
|
}
|
2015-03-20 16:38:26 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
return 0;
|
|
|
|
}
|