From 98f1cb76edc316cc9e69b210b4ca2b22797caa13 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Fri, 25 Nov 2016 07:26:18 -0800 Subject: OSC: Patch from 7136 added cleaned and tested. --- libs/surfaces/osc/osc.cc | 128 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index d0399d212e..3d098da3c4 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -46,6 +46,7 @@ #include "ardour/plugin_insert.h" #include "ardour/presentation_info.h" #include "ardour/send.h" +#include "ardour/internal_send.h" #include "ardour/phase_control.h" #include "ardour/solo_isolate_control.h" #include "ardour/solo_safe_control.h" @@ -598,6 +599,9 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/strip/send/gain", "iif", route_set_send_gain_dB); REGISTER_CALLBACK (serv, "/strip/send/fader", "iif", route_set_send_fader); REGISTER_CALLBACK (serv, "/strip/send/enable", "iif", route_set_send_enable); + REGISTER_CALLBACK(serv, "/strip/name", "is", route_rename); + REGISTER_CALLBACK(serv, "/strip/sends", "i", route_get_sends); + REGISTER_CALLBACK(serv, "/strip/receives", "i", route_get_receives); /* still not-really-standardized query interface */ //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value); @@ -1789,6 +1793,115 @@ OSC::monitor_set_fader (float position) return 0; } +int +OSC::route_get_sends(lo_message msg) { + if (!session) { + return -1; + } + + lo_arg **argv = lo_message_get_argv(msg); + + int rid = argv[0]->i; + + boost::shared_ptr strip = get_strip(rid, get_address(msg)); + if (!strip) { + return -1; + } + + boost::shared_ptr r = boost::dynamic_pointer_cast (strip); + if (!r) { + return -1; + } + + lo_message reply = lo_message_new(); + lo_message_add_int32(reply, rid); + + int i = 0; + for (;;) { + boost::shared_ptr p = r->nth_send(i++); + + if (!p) { + break; + } + + boost::shared_ptr isend = boost::dynamic_pointer_cast (p); + if (isend) { + lo_message_add_int32(reply, get_sid(isend->target_route(), get_address(msg))); + lo_message_add_string(reply, isend->name().c_str()); + lo_message_add_int32(reply, i); + boost::shared_ptr a = isend->amp(); + lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value())); + lo_message_add_int32(reply, p->active() ? 1 : 0); + } + } + // if used dedicated message path to identify this reply in async operation. Naming it #reply wont help the client to identify the content. + lo_send_message(get_address (msg), "/strip/sends", reply); + + lo_message_free(reply); + + return 0; +} + +int +OSC::route_get_receives(lo_message msg) { + if (!session) { + return -1; + } + + lo_arg **argv = lo_message_get_argv(msg); + + uint32_t rid = argv[0]->i; + + + boost::shared_ptr strip = get_strip(rid, get_address(msg)); + if (!strip) { + return -1; + } + + boost::shared_ptr r = boost::dynamic_pointer_cast (strip); + if (!r) { + return -1; + } + + boost::shared_ptr route_list = session->get_routes(); + + lo_message reply = lo_message_new(); + + for (RouteList::iterator i = route_list->begin(); i != route_list->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr) { + continue; + } + int j = 0; + + for (;;) { + boost::shared_ptr p = tr->nth_send(j++); + + if (!p) { + break; + } + + boost::shared_ptr isend = boost::dynamic_pointer_cast (p); + if (isend) { + if( isend->target_route()->id() == r->id()){ + boost::shared_ptr a = isend->amp(); + + lo_message_add_int32(reply, get_sid(tr, get_address(msg))); + lo_message_add_string(reply, tr->name().c_str()); + lo_message_add_int32(reply, j); + lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value())); + lo_message_add_int32(reply, p->active() ? 1 : 0); + } + } + } + } + + // I have used a dedicated message path to identify this reply in async operation. Naming it #reply wont help the client to identify the content. + lo_send_message(get_address (msg), "/strip/receives", reply); + lo_message_free(reply); + return 0; +} + // strip calls int OSC::route_mute (int ssid, int yn, lo_message msg) @@ -1966,6 +2079,21 @@ OSC::route_recenable (int ssid, int yn, lo_message msg) return route_send_fail ("recenable", ssid, 0, get_address (msg)); } +int +OSC::route_rename(int ssid, char *newname, lo_message msg) { + if (!session) { + return -1; + } + + boost::shared_ptr s = get_strip(ssid, get_address(msg)); + + if (s) { + s->set_name(std::string(newname)); + } + + return 0; +} + int OSC::sel_recsafe (uint32_t yn, lo_message msg) { -- cgit v1.2.3