summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorLen Ovens <len@ovenwerks.net>2016-11-25 07:26:18 -0800
committerLen Ovens <len@ovenwerks.net>2016-11-25 07:26:18 -0800
commit98f1cb76edc316cc9e69b210b4ca2b22797caa13 (patch)
tree61977bf3f11085762869bece3684c9652b71a64e /libs/surfaces
parent01f8ca831ae2966b4bd54c0a15a341b0b9790593 (diff)
OSC: Patch from 7136 added cleaned and tested.
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/osc/osc.cc128
-rw-r--r--libs/surfaces/osc/osc.h18
2 files changed, 146 insertions, 0 deletions
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<Stripable> strip = get_strip(rid, get_address(msg));
+ if (!strip) {
+ return -1;
+ }
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
+ if (!r) {
+ return -1;
+ }
+
+ lo_message reply = lo_message_new();
+ lo_message_add_int32(reply, rid);
+
+ int i = 0;
+ for (;;) {
+ boost::shared_ptr<Processor> p = r->nth_send(i++);
+
+ if (!p) {
+ break;
+ }
+
+ boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (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<Amp> 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<Stripable> strip = get_strip(rid, get_address(msg));
+ if (!strip) {
+ return -1;
+ }
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
+ if (!r) {
+ return -1;
+ }
+
+ boost::shared_ptr<RouteList> 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<Route> tr = boost::dynamic_pointer_cast<Route> (*i);
+ if (!tr) {
+ continue;
+ }
+ int j = 0;
+
+ for (;;) {
+ boost::shared_ptr<Processor> p = tr->nth_send(j++);
+
+ if (!p) {
+ break;
+ }
+
+ boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (p);
+ if (isend) {
+ if( isend->target_route()->id() == r->id()){
+ boost::shared_ptr<Amp> 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)
@@ -1967,6 +2080,21 @@ OSC::route_recenable (int ssid, int yn, lo_message msg)
}
int
+OSC::route_rename(int ssid, char *newname, lo_message msg) {
+ if (!session) {
+ return -1;
+ }
+
+ boost::shared_ptr<Stripable> 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)
{
OSCSurface *sur = get_surface(get_address (msg));
diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h
index ced0c906a6..d581a43d7e 100644
--- a/libs/surfaces/osc/osc.h
+++ b/libs/surfaces/osc/osc.h
@@ -212,6 +212,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
int catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data);
static int _catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
+ int route_get_sends (lo_message msg);
+ int route_get_receives(lo_message msg);
void routes_list (lo_message msg);
void transport_frame (lo_message msg);
void transport_speed (lo_message msg);
@@ -233,6 +235,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
return 0; \
}
+ PATH_CALLBACK_MSG(route_get_sends);
+ PATH_CALLBACK_MSG(route_get_receives);
PATH_CALLBACK_MSG(routes_list);
PATH_CALLBACK_MSG(transport_frame);
PATH_CALLBACK_MSG(transport_speed);
@@ -401,6 +405,18 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
return 0; \
}
+#define PATH_CALLBACK2_MSG_s(name,arg1type,arg2type) \
+ static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
+ return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
+ } \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
+ OSC_DEBUG; \
+ if (argc > 1) { \
+ name (argv[0]->arg1type, &argv[1]->arg2type, data); \
+ } \
+ return 0; \
+ }
+
#define PATH_CALLBACK3(name,arg1type,arg2type,arg3type) \
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
@@ -436,6 +452,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
PATH_CALLBACK4(set_surface,i,i,i,i);
PATH_CALLBACK2(locate,i,i);
PATH_CALLBACK2(loop_location,i,i);
+ PATH_CALLBACK2_MSG_s(route_rename,i,s);
PATH_CALLBACK2_MSG(route_mute,i,i);
PATH_CALLBACK2_MSG(route_solo,i,i);
PATH_CALLBACK2_MSG(route_solo_iso,i,i);
@@ -460,6 +477,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
PATH_CALLBACK2_MSG(route_plugin_activate,i,i);
PATH_CALLBACK2_MSG(route_plugin_deactivate,i,i);
+ int route_rename (int rid, char *s, lo_message msg);
int route_mute (int rid, int yn, lo_message msg);
int route_solo (int rid, int yn, lo_message msg);
int route_solo_iso (int rid, int yn, lo_message msg);