X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fosc%2Fosc.cc;h=6a771d9b48a7e14af86225409edea9b984917043;hb=cb965cba1648f92654a991a91e211821335b37bb;hp=e252d22e3d7c38fe92d7a8e29b828718e0bb0efb;hpb=59076a7e4c66db12bbbfbf01f012ca2f6ba4bf56;p=ardour.git diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index e252d22e3d..6a771d9b48 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1,34 +1,31 @@ /* * Copyright (C) 2006 Paul Davis - * + * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * */ -#include -#include #include #include #include #include -#include #include #include -#include +#include "pbd/gstdio_compat.h" #include #include @@ -45,6 +42,7 @@ #include "ardour/filesystem_paths.h" #include "ardour/panner.h" #include "ardour/plugin.h" +#include "ardour/plugin_insert.h" #include "ardour/send.h" #include "osc.h" @@ -55,6 +53,7 @@ using namespace ARDOUR; using namespace std; using namespace Glib; +using namespace ArdourSurface; #include "pbd/abstract_ui.cc" // instantiate template @@ -124,7 +123,7 @@ OSC::set_active (bool yn) return -1; } } - + } return ControlProtocol::set_active (yn); @@ -136,7 +135,7 @@ OSC::get_active () const return _osc_server != 0; } -int +int OSC::set_feedback (bool yn) { _send_route_changes = yn; @@ -158,19 +157,19 @@ OSC::start () /* already started */ return 0; } - + for (int j=0; j < 20; ++j) { snprintf(tmpstr, sizeof(tmpstr), "%d", _port); - + //if ((_osc_server = lo_server_new_with_proto (tmpstr, LO_TCP, error_callback))) { // break; //} - + if ((_osc_server = lo_server_new (tmpstr, error_callback))) { break; } -#ifdef DEBUG +#ifdef DEBUG cerr << "can't get osc at port: " << _port << endl; #endif _port++; @@ -180,48 +179,41 @@ OSC::start () if (!_osc_server) { return 1; } - + #ifdef ARDOUR_OSC_UNIX_SERVER - + // APPEARS sluggish for now - + // attempt to create unix socket server too - + snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX"); int fd = mkstemp(tmpstr); - + if (fd >= 0 ) { ::g_unlink (tmpstr); close (fd); - + _osc_unix_server = lo_server_new (tmpstr, error_callback); - + if (_osc_unix_server) { _osc_unix_socket_path = tmpstr; } } #endif - + PBD::info << "OSC @ " << get_server_url () << endmsg; std::string url_file; - if (find_file_in_search_path (ardour_config_search_path(), "osc_url", url_file)) { - + if (find_file (ardour_config_search_path(), "osc_url", url_file)) { _osc_url_file = url_file; - ofstream urlfile; - urlfile.open(_osc_url_file.c_str(), ios::trunc); - - if (urlfile) { - urlfile << get_server_url () << endl; - urlfile.close(); - } else { + if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) { cerr << "Couldn't write '" << _osc_url_file << "'" <=0) { - close(fd); - } lo_server_free (_osc_server); _osc_server = 0; } if (_osc_unix_server) { - int fd = lo_server_get_socket_fd(_osc_unix_server); - if (fd >=0) { - close(fd); - } lo_server_free (_osc_unix_server); _osc_unix_server = 0; } - + if (!_osc_unix_socket_path.empty()) { ::g_unlink (_osc_unix_socket_path.c_str()); } - + if (!_osc_url_file.empty() ) { ::g_unlink (_osc_url_file.c_str() ); } @@ -305,7 +289,7 @@ OSC::stop () for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { OSCRouteObserver* rc; - + if ((rc = dynamic_cast(*x)) != 0) { delete *x; x = route_observers.erase (x); @@ -313,7 +297,7 @@ OSC::stop () ++x; } } - + return 0; } @@ -325,7 +309,7 @@ OSC::register_callbacks() srvs[0] = _osc_server; srvs[1] = _osc_unix_server; - + for (size_t i = 0; i < 2; ++i) { if (!srvs[i]) { @@ -333,17 +317,18 @@ OSC::register_callbacks() } serv = srvs[i]; - + /* this is a special catchall handler */ - + lo_server_add_method (serv, 0, 0, _catchall, this); - + #define REGISTER_CALLBACK(serv,path,types, function) lo_server_add_method (serv, path, types, OSC::_ ## function, this) - + REGISTER_CALLBACK (serv, "/routes/list", "", routes_list); REGISTER_CALLBACK (serv, "/ardour/add_marker", "", add_marker); REGISTER_CALLBACK (serv, "/ardour/access_action", "s", access_action); REGISTER_CALLBACK (serv, "/ardour/loop_toggle", "", loop_toggle); + REGISTER_CALLBACK (serv, "/ardour/loop_location", "ii", loop_location); REGISTER_CALLBACK (serv, "/ardour/goto_start", "", goto_start); REGISTER_CALLBACK (serv, "/ardour/goto_end", "", goto_end); REGISTER_CALLBACK (serv, "/ardour/rewind", "", rewind); @@ -352,7 +337,7 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/ardour/transport_play", "", transport_play); REGISTER_CALLBACK (serv, "/ardour/transport_frame", "", transport_frame); REGISTER_CALLBACK (serv, "/ardour/set_transport_speed", "f", set_transport_speed); - REGISTER_CALLBACK (serv, "/ardour/locate", "ii", locate); + REGISTER_CALLBACK (serv, "/ardour/locate", "ii", locate); REGISTER_CALLBACK (serv, "/ardour/save_state", "", save_state); REGISTER_CALLBACK (serv, "/ardour/prev_marker", "", prev_marker); REGISTER_CALLBACK (serv, "/ardour/next_marker", "", next_marker); @@ -368,6 +353,8 @@ OSC::register_callbacks() 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); + REGISTER_CALLBACK (serv, "/ardour/routes/trimabs", "if", route_set_trim_abs); + REGISTER_CALLBACK (serv, "/ardour/routes/trimdB", "if", route_set_trim_dB); 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); @@ -413,7 +400,7 @@ OSC::get_server_url() url = urlstr; free (urlstr); } - + return url; } @@ -428,7 +415,7 @@ OSC::get_unix_server_url() url = urlstr; free (urlstr); } - + return url; } @@ -436,15 +423,15 @@ void OSC::listen_to_route (boost::shared_ptr route, lo_address addr) { /* avoid duplicate listens */ - + for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end(); ++x) { - + OSCRouteObserver* ro; if ((ro = dynamic_cast(*x)) != 0) { int res = strcmp(lo_address_get_hostname(ro->address()), lo_address_get_hostname(addr)); - + if (ro->route() == route && res == 0) { return; } @@ -469,9 +456,9 @@ OSC::drop_route (boost::weak_ptr wr) for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { OSCRouteObserver* rc; - + if ((rc = dynamic_cast(*x)) != 0) { - + if (rc->route() == r) { delete *x; x = route_observers.erase (x); @@ -488,14 +475,14 @@ void OSC::end_listen (boost::shared_ptr r, lo_address addr) { RouteObservers::iterator x; - + // Remove the route observers for (x = route_observers.begin(); x != route_observers.end();) { OSCRouteObserver* ro; - + if ((ro = dynamic_cast(*x)) != 0) { - + int res = strcmp(lo_address_get_hostname(ro->address()), lo_address_get_hostname(addr)); if (ro->route() == r && res == 0) { @@ -516,13 +503,13 @@ void OSC::current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg) { char* subpath; - + subpath = (char*) malloc (len-15+1); memcpy (subpath, path, len-15); subpath[len-15] = '\0'; - + send_current_value (subpath, argv, argc, msg); - + free (subpath); } @@ -538,7 +525,7 @@ OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message m int id; lo_message_add_string (reply, path); - + if (argc == 0) { lo_message_add_string (reply, "bad syntax"); } else { @@ -550,7 +537,7 @@ OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message m } else { if (strcmp (path, "/routes/state") == 0) { - + if (boost::dynamic_pointer_cast(r)) { lo_message_add_string (reply, "AT"); } else if (boost::dynamic_pointer_cast(r)) { @@ -558,19 +545,19 @@ OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message m } else { lo_message_add_string (reply, "B"); } - + 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()); - + } else if (strcmp (path, "/routes/mute") == 0) { - + lo_message_add_int32 (reply, (float) r->muted()); - + } else if (strcmp (path, "/routes/solo") == 0) { - + lo_message_add_int32 (reply, r->soloed()); } } @@ -579,20 +566,20 @@ OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message m lo_send_message (lo_message_get_source (msg), "#reply", reply); lo_message_free (reply); } - + int -OSC::_catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) +OSC::_catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { return ((OSC*)user_data)->catchall (path, types, argv, argc, data); } int -OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, lo_message msg) +OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, lo_message msg) { size_t len; int ret = 1; /* unhandled */ - //cerr << "Received a message, path = " << path << " types = \"" + //cerr << "Received a message, path = " << path << " types = \"" // << (types ? types : "NULL") << '"' << endl; /* 15 for /#current_value plus 2 for / */ @@ -604,7 +591,7 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, ret = 0; } else if (strcmp (path, "/routes/listen") == 0) { - + cerr << "set up listener\n"; lo_message reply = lo_message_new (); @@ -615,12 +602,12 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, for (int n = 0; n < argc; ++n) { boost::shared_ptr r = session->route_by_remote_id (argv[n]->i); - + if (!r) { lo_message_add_string (reply, "not found"); cerr << "no such route\n"; break; - } else { + } else { cerr << "add listener\n"; listen_to_route (r, lo_message_get_source (msg)); lo_message_add_int32 (reply, argv[n]->i); @@ -630,7 +617,7 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, lo_send_message (lo_message_get_source (msg), "#reply", reply); lo_message_free (reply); - + ret = 0; } else if (strcmp (path, "/routes/ignore") == 0) { @@ -638,14 +625,14 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, for (int n = 0; n < argc; ++n) { boost::shared_ptr r = session->route_by_remote_id (argv[n]->i); - + if (r) { end_listen (r, lo_message_get_source (msg)); } } - - ret = 0; - } + + ret = 0; + } return ret; } @@ -653,7 +640,7 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc, void OSC::update_clock () { - + } // "Application Hook" Handlers // @@ -675,9 +662,9 @@ OSC::session_exported (std::string path, std::string name) /* path callbacks */ -int -OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv*/, int /*argc*/, void */*data*/, void* /*user_data*/) -{ +int +OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv*/, int /*argc*/, void */*data*/, void* /*user_data*/) +{ #if 0 const char* returl; @@ -690,7 +677,7 @@ OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv const char *retpath = argv[2]->s; - + if (strcmp (argv[0]->s, "transport_frame") == 0) { if (session) { @@ -698,31 +685,31 @@ OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv } } else if (strcmp (argv[0]->s, "transport_speed") == 0) { - + if (session) { lo_send (addr, retpath, "i", session->transport_frame()); } - + } else if (strcmp (argv[0]->s, "transport_locked") == 0) { - + if (session) { lo_send (addr, retpath, "i", session->transport_frame()); } - + } else if (strcmp (argv[0]->s, "punch_in") == 0) { - + if (session) { lo_send (addr, retpath, "i", session->transport_frame()); } - + } else if (strcmp (argv[0]->s, "punch_out") == 0) { if (session) { lo_send (addr, retpath, "i", session->transport_frame()); } - + } else if (strcmp (argv[0]->s, "rec_enable") == 0) { - + if (session) { lo_send (addr, retpath, "i", session->transport_frame()); } @@ -741,11 +728,11 @@ OSC::routes_list (lo_message msg) for (int n = 0; n < (int) session->nroutes(); ++n) { boost::shared_ptr r = session->route_by_remote_id (n); - + if (r) { lo_message reply = lo_message_new (); - + if (boost::dynamic_pointer_cast(r)) { lo_message_add_string (reply, "AT"); } else if (boost::dynamic_pointer_cast(r)) { @@ -753,17 +740,17 @@ OSC::routes_list (lo_message msg) } else { lo_message_add_string (reply, "B"); } - + 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()); - - if (boost::dynamic_pointer_cast(r) - || boost::dynamic_pointer_cast(r)) { - + + if (boost::dynamic_pointer_cast(r) + || boost::dynamic_pointer_cast(r)) { + boost::shared_ptr t = boost::dynamic_pointer_cast(r); lo_message_add_int32 (reply, t->record_enabled()); } @@ -775,30 +762,30 @@ OSC::routes_list (lo_message msg) lo_message_free (reply); } } - + // 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()); - + lo_send_message (lo_message_get_source (msg), "#reply", reply); - + lo_message_free (reply); } void OSC::transport_frame (lo_message msg) { - 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); + 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); } int @@ -811,7 +798,7 @@ OSC::route_mute (int rid, int yn) if (r) { r->set_mute (yn, this); } - + return 0; } @@ -823,9 +810,11 @@ OSC::route_solo (int rid, int yn) boost::shared_ptr r = session->route_by_remote_id (rid); if (r) { - r->set_solo (yn, this); + boost::shared_ptr rl (new RouteList); + rl->push_back (r); + session->set_solo (rl, yn); } - + return 0; } @@ -839,7 +828,7 @@ OSC::route_recenable (int rid, int yn) if (r) { r->set_record_enabled (yn, this); } - + return 0; } @@ -859,18 +848,32 @@ OSC::route_set_gain_abs (int rid, float level) int OSC::route_set_gain_dB (int rid, float dB) +{ + return route_set_gain_abs (rid, dB_to_coefficient (dB)); +} + + +int +OSC::route_set_trim_abs (int rid, float level) { if (!session) return -1; boost::shared_ptr r = session->route_by_remote_id (rid); if (r) { - r->set_gain (dB_to_coefficient (dB), this); + r->set_trim (level, this); } - + return 0; } +int +OSC::route_set_trim_dB (int rid, float dB) +{ + return route_set_trim_abs(rid, dB_to_coefficient (dB)); +} + + int OSC::route_set_pan_stereo_position (int rid, float pos) { @@ -879,12 +882,12 @@ OSC::route_set_pan_stereo_position (int rid, float pos) boost::shared_ptr r = session->route_by_remote_id (rid); if (r) { - boost::shared_ptr panner = r->panner(); - if (panner) { - panner->set_position (pos); - } + boost::shared_ptr panner = r->panner(); + if (panner) { + panner->set_position (pos); + } } - + return 0; } @@ -897,12 +900,12 @@ OSC::route_set_pan_stereo_width (int rid, float pos) boost::shared_ptr r = session->route_by_remote_id (rid); if (r) { - boost::shared_ptr panner = r->panner(); - if (panner) { - panner->set_width (pos); - } + boost::shared_ptr panner = r->panner(); + if (panner) { + panner->set_width (pos); + } } - + return 0; } @@ -910,15 +913,15 @@ OSC::route_set_pan_stereo_width (int rid, float pos) int OSC::route_set_send_gain_abs (int rid, int sid, float val) { - if (!session) { - return -1; - } + if (!session) { + return -1; + } - boost::shared_ptr r = session->route_by_remote_id (rid); + boost::shared_ptr r = session->route_by_remote_id (rid); - if (!r) { - return -1; - } + if (!r) { + return -1; + } /* revert to zero-based counting */ @@ -927,11 +930,11 @@ OSC::route_set_send_gain_abs (int rid, int sid, float val) } boost::shared_ptr p = r->nth_send (sid); - + if (p) { boost::shared_ptr s = boost::dynamic_pointer_cast(p); boost::shared_ptr a = s->amp(); - + if (a) { a->set_gain (val, this); } @@ -942,15 +945,15 @@ OSC::route_set_send_gain_abs (int rid, int sid, float val) int OSC::route_set_send_gain_dB (int rid, int sid, float val) { - if (!session) { - return -1; - } + if (!session) { + return -1; + } - boost::shared_ptr r = session->route_by_remote_id (rid); + boost::shared_ptr r = session->route_by_remote_id (rid); - if (!r) { - return -1; - } + if (!r) { + return -1; + } /* revert to zero-based counting */ @@ -959,11 +962,11 @@ OSC::route_set_send_gain_dB (int rid, int sid, float val) } boost::shared_ptr p = r->nth_send (sid); - + if (p) { boost::shared_ptr s = boost::dynamic_pointer_cast(p); boost::shared_ptr a = s->amp(); - + if (a) { a->set_gain (dB_to_coefficient (val), this); } @@ -974,121 +977,121 @@ OSC::route_set_send_gain_dB (int rid, int sid, float val) int OSC::route_plugin_parameter (int rid, int piid, int par, float val) { - if (!session) { - return -1; - } - - boost::shared_ptr r = session->route_by_remote_id (rid); - - if (!r) { - return -1; - } - - boost::shared_ptr redi=r->nth_processor (piid); - - if (!redi) { - return -1; - } - - boost::shared_ptr pi; - - if (!(pi = boost::dynamic_pointer_cast(redi))) { - return -1; - } - - boost::shared_ptr pip = pi->plugin(); - bool ok=false; - - uint32_t controlid = pip->nth_parameter (par,ok); - - if (!ok) { - return -1; - } - - Plugin::ParameterDescriptor pd; - pi->plugin()->get_parameter_descriptor (controlid,pd); - - if (val >= pd.lower && val < pd.upper) { - - boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));; - cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n"; - c->set_value (val); - } - - return 0; + if (!session) + return -1; + + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << rid << "'" << endmsg; + return -1; + } + + boost::shared_ptr redi=r->nth_plugin (piid); + + if (!redi) { + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << rid << "'" << endmsg; + return -1; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << rid << "' is not a Plugin." << endmsg; + return -1; + } + + boost::shared_ptr pip = pi->plugin(); + bool ok=false; + + uint32_t controlid = pip->nth_parameter (par,ok); + + if (!ok) { + PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "'" << endmsg; + return -1; + } + + if (!pip->parameter_is_input(controlid)) { + PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "' is not a control input" << endmsg; + return -1; + } + + ParameterDescriptor pd; + pi->plugin()->get_parameter_descriptor (controlid,pd); + + if (val >= pd.lower && val < pd.upper) { + + boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); + // cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n"; + c->set_value (val); + } else { + 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; + } + + return 0; } int OSC::route_plugin_parameter_print (int rid, int piid, int par) { - if (!session) { - return -1; - } - - boost::shared_ptr r = session->route_by_remote_id (rid); - - if (!r) { - return -1; - } - - boost::shared_ptr redi=r->nth_processor (piid); - - if (!redi) { - return -1; - } - - boost::shared_ptr pi; - - if (!(pi = boost::dynamic_pointer_cast(redi))) { - return -1; - } - - boost::shared_ptr pip = pi->plugin(); - bool ok=false; - - uint32_t controlid = pip->nth_parameter (par,ok); - - if (!ok) { - return -1; - } - - Plugin::ParameterDescriptor pd; - - if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) { - boost::shared_ptr 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; -} + if (!session) { + return -1; + } -XMLNode& -OSC::get_state () -{ - XMLNode& node (ControlProtocol::get_state()); + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + boost::shared_ptr redi=r->nth_processor (piid); - node.add_property (X_("feedback"), _send_route_changes ? "1" : "0"); - return node; + if (!redi) { + return -1; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + return -1; + } + + boost::shared_ptr 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 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; } -int -OSC::set_state (const XMLNode& node, int /*version*/) +XMLNode& +OSC::get_state () { - const XMLProperty* prop = node.property (X_("feedback")); + return ControlProtocol::get_state(); +} - if (prop) { - if (PBD::string_is_affirmative (prop->value())) { - _send_route_changes = true; - } else { - _send_route_changes = false; - } - } else { - /* leave it alone */ +int +OSC::set_state (const XMLNode& node, int version) +{ + if (ControlProtocol::set_state (node, version)) { + return -1; } - + return 0; }