From addb33bc630721e623f90b6f3e920eedcdc40742 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 6 Jun 2013 11:14:31 -0400 Subject: [PATCH] implement OSC /ardour/route/send/gainabs and /ardour/route/send/gainDB --- libs/pbd/controllable_descriptor.cc | 3 +- libs/surfaces/osc/osc.cc | 66 ++++++++++++++++++++++++++++- libs/surfaces/osc/osc.h | 4 ++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/libs/pbd/controllable_descriptor.cc b/libs/pbd/controllable_descriptor.cc index 392b917ec8..9c930e4dbd 100644 --- a/libs/pbd/controllable_descriptor.cc +++ b/libs/pbd/controllable_descriptor.cc @@ -104,10 +104,11 @@ ControllableDescriptor::set (const std::string& str) } } else if (path[1] == "send") { - if (path.size() == 3 && rest.size() == 2) { + if (path.size() == 3 && rest.size() == 3) { if (path[2] == "gain") { _subtype = SendGain; _target.push_back (atoi (rest[1])); + _target.push_back (atoi (rest[2])); } else { return -1; } diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 357b82d4d2..ef07ca17fb 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -356,8 +356,8 @@ OSC::register_callbacks() 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); - - + 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); /* still not-really-standardized query interface */ //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value); @@ -891,6 +891,68 @@ 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; + } + + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr p = r->nth_send (send); + + if (p) { + boost::shared_ptr s = boost::dynamic_pointer_cast(p); + boost::shared_ptr a = s->amp(); + + if (a) { + a->set_gain (val, this); + } + } +} + +int +OSC::route_set_send_gain_dB (int rid, int sid, float val) +{ + if (!session) { + return -1; + } + + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr p = r->nth_send (send); + + 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); + } + } +} + int OSC::route_plugin_parameter (int rid, int piid, int par, float val) { diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index c09792ec64..5c3422799b 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -214,6 +214,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI PATH_CALLBACK2(route_set_gain_dB,i,f); PATH_CALLBACK2(route_set_pan_stereo_position,i,f); PATH_CALLBACK2(route_set_pan_stereo_width,i,f); + PATH_CALLBACK3(route_set_send_gain_abs,i,i,f); + PATH_CALLBACK3(route_set_send_gain_dB,i,i,f); PATH_CALLBACK4(route_plugin_parameter,i,i,i,f); PATH_CALLBACK3(route_plugin_parameter_print,i,i,i); @@ -224,6 +226,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI int route_set_gain_dB (int rid, float dB); int route_set_pan_stereo_position (int rid, float left_right_fraction); int route_set_pan_stereo_width (int rid, float percent); + int route_set_send_gain_abs (int rid, int sid, float val); + int route_set_send_gain_dB (int rid, int sid, float val); int route_plugin_parameter (int rid, int piid,int par, float val); int route_plugin_parameter_print (int rid, int piid,int par);