per-route OSC control of solo/mute/recenable/gain

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4214 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-11-19 07:38:45 +00:00
parent 3e89ba31b5
commit a4b461f207
3 changed files with 103 additions and 5 deletions

View file

@ -120,6 +120,29 @@ class OSC : public BasicUI, public sigc::trackable
PATH_CALLBACK1(set_transport_speed,f,);
PATH_CALLBACK1(access_action,s,&);
#define PATH_CALLBACK2(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) { \
if (argc > 1) { \
name (argv[0]->arg1type, argv[1]->arg2type); \
} \
return 0; \
}
PATH_CALLBACK2(route_mute,i,i);
PATH_CALLBACK2(route_solo,i,i);
PATH_CALLBACK2(route_recenable,i,i);
PATH_CALLBACK2(route_set_gain_abs,i,f);
PATH_CALLBACK2(route_set_gain_dB,i,f);
int route_mute (int rid, int yn);
int route_solo (int rid, int yn);
int route_recenable (int rid, int yn);
int route_set_gain_abs (int rid, float level);
int route_set_gain_dB (int rid, float dB);
};
}

View file

@ -119,6 +119,7 @@ setup_osc ()
return 0;
}
}
#endif
int

View file

@ -36,6 +36,7 @@
#include <ardour/session.h>
#include <ardour/route.h>
#include <ardour/audio_track.h>
#include <ardour/dB.h>
#include "i18n.h"
@ -146,9 +147,9 @@ OSC::stop ()
unlink(_osc_unix_socket_path.c_str());
}
if (! _osc_url_file.empty() ) {
unlink(_osc_url_file.c_str() );
}
if (! _osc_url_file.empty() ) {
unlink(_osc_url_file.c_str() );
}
return 0;
}
@ -196,6 +197,12 @@ OSC::register_callbacks()
REGISTER_CALLBACK (serv, "/ardour/rec_enable_toggle", "", rec_enable_toggle);
REGISTER_CALLBACK (serv, "/ardour/toggle_all_rec_enables", "", toggle_all_rec_enables);
REGISTER_CALLBACK (serv, "/ardour/routes/mute", "ii", route_mute);
REGISTER_CALLBACK (serv, "/ardour/routes/solo", "ii", route_solo);
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);
#if 0
REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value);
REGISTER_CALLBACK (serv, "/ardour/set", "", set);
@ -369,7 +376,7 @@ OSC::osc_receiver()
if (pfd[i].revents & POLLIN)
{
// this invokes callbacks
//cerr << "invoking recv on " << pfd[i].fd << endl;
// cerr << "invoking recv on " << pfd[i].fd << endl;
lo_server_recv(srvs[i]);
}
}
@ -381,7 +388,7 @@ OSC::osc_receiver()
if (_osc_server) {
int fd = lo_server_get_socket_fd(_osc_server);
if (fd >=0) {
// hack around
// hack around
close(fd);
}
lo_server_free (_osc_server);
@ -491,3 +498,70 @@ OSC::current_value (const char *path, const char *types, lo_arg **argv, int argc
#endif
return 0;
}
int
OSC::route_mute (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_mute (yn, this);
}
return 0;
}
int
OSC::route_solo (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_solo (yn, this);
}
return 0;
}
int
OSC::route_recenable (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_record_enable (yn, this);
}
return 0;
}
int
OSC::route_set_gain_abs (int rid, float level)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_gain (level, this);
}
return 0;
}
int
OSC::route_set_gain_dB (int rid, float dB)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_gain (dB_to_coefficient (dB), this);
}
return 0;
}