summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-03 22:29:58 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-03 22:29:58 +0000
commit18b8ec69966f1d54ec41e833221fefb3c6c2c49d (patch)
tree4b87b198f15b9728175711b8f1da07d411570538 /libs/surfaces
parentac84ea82186c723e4cb4f74b15a070d5fd42b5dc (diff)
provide access to plugin parameters from OSC. not tested. from olaf
git-svn-id: svn://localhost/ardour2/branches/3.0@8170 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/osc/osc.cc99
-rw-r--r--libs/surfaces/osc/osc.h26
2 files changed, 125 insertions, 0 deletions
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc
index 264d4eee13..6fcfc308c9 100644
--- a/libs/surfaces/osc/osc.cc
+++ b/libs/surfaces/osc/osc.cc
@@ -43,6 +43,7 @@
#include "ardour/dB.h"
#include "ardour/filesystem_paths.h"
#include "ardour/panner.h"
+#include "ardour/plugin.h"
#include "osc.h"
#include "osc_controllable.h"
@@ -338,6 +339,10 @@ 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/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);
#if 0
@@ -818,6 +823,100 @@ OSC::route_set_pan_stereo_width (int rid, float pos)
}
+int
+OSC::route_plugin_parameter (int rid,int piid,int par, float val)
+{
+ 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;
+ }
+
+ Plugin::ParameterDescriptor pd;
+ pi->plugin()->get_parameter_descriptor (controlid,pd);
+
+ if (val >= pd.lower && val < pd.upper) {
+
+ 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);
+ }
+
+ return 0;
+}
+
+int
+OSC::route_plugin_parameter_print (int rid,int piid,int par)
+{
+ 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;
+ }
+
+ Plugin::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;
+}
+
XMLNode&
OSC::get_state ()
{
diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h
index de73bdb913..804c8a5fbd 100644
--- a/libs/surfaces/osc/osc.h
+++ b/libs/surfaces/osc/osc.h
@@ -167,6 +167,28 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
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); \
+ } \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
+ if (argc > 1) { \
+ name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type); \
+ } \
+ return 0; \
+ }
+
+#define PATH_CALLBACK4(name,arg1type,arg2type,arg3type,arg4type) \
+ 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) { \
+ if (argc > 1) { \
+ name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type,argv[3]->arg4type); \
+ } \
+ return 0; \
+ }
+
PATH_CALLBACK2(locate,i,i);
PATH_CALLBACK2(route_mute,i,i);
PATH_CALLBACK2(route_solo,i,i);
@@ -175,6 +197,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
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_CALLBACK4(route_plugin_parameter,i,i,i,f);
+ PATH_CALLBACK3(route_plugin_parameter_print,i,i,i);
int route_mute (int rid, int yn);
int route_solo (int rid, int yn);
@@ -183,6 +207,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
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_plugin_parameter (int rid, int piid,int par, float val);
+ int route_plugin_parameter_print (int rid, int piid,int par);
void listen_to_route (boost::shared_ptr<ARDOUR::Route>, lo_address);
void end_listen (boost::shared_ptr<ARDOUR::Route>, lo_address);