#include "osc_controllable.h"
#include "osc_route_observer.h"
#include "osc_global_observer.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace ARDOUR;
using namespace std;
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
periodic_timeout->attach (main_loop()->get_context());
- // catch GUI select changes for GUI_select mode
- StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this, _1), this);
+ // catch changes to selection for GUI_select mode
+ StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this), this);
// catch track reordering
// receive routes added
// order changed
PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
+ _select = boost::shared_ptr<Stripable>();
return 0;
}
REGISTER_CALLBACK (serv, "/toggle_all_rec_enables", "f", toggle_all_rec_enables);
REGISTER_CALLBACK (serv, "/all_tracks_rec_in", "f", all_tracks_rec_in);
REGISTER_CALLBACK (serv, "/all_tracks_rec_out", "f", all_tracks_rec_out);
+ REGISTER_CALLBACK (serv, "/cancel_all_solos", "f", cancel_all_solos);
REGISTER_CALLBACK (serv, "/remove_marker", "", remove_marker_at_playhead);
REGISTER_CALLBACK (serv, "/remove_marker", "f", remove_marker_at_playhead);
REGISTER_CALLBACK (serv, "/jump_bars", "f", jump_by_bars);
REGISTER_CALLBACK (serv, "/select/send_gain", "if", sel_sendgain);
REGISTER_CALLBACK (serv, "/select/send_fader", "if", sel_sendfader);
REGISTER_CALLBACK (serv, "/select/send_enable", "if", sel_sendenable);
+ REGISTER_CALLBACK (serv, "/select/expand", "i", sel_expand);
+ REGISTER_CALLBACK (serv, "/select/pan_elevation_position", "f", sel_pan_elevation);
+ REGISTER_CALLBACK (serv, "/select/pan_frontback_position", "f", sel_pan_frontback);
+ REGISTER_CALLBACK (serv, "/select/pan_lfe_position", "f", sel_pan_lfe);
+ REGISTER_CALLBACK (serv, "/select/comp_enable", "f", sel_comp_enable);
+ REGISTER_CALLBACK (serv, "/select/comp_threshold", "f", sel_comp_threshold);
+ REGISTER_CALLBACK (serv, "/select/comp_speed", "f", sel_comp_speed);
+ REGISTER_CALLBACK (serv, "/select/comp_mode", "f", sel_comp_mode);
+ REGISTER_CALLBACK (serv, "/select/comp_makeup", "f", sel_comp_makeup);
+ REGISTER_CALLBACK (serv, "/select/eq_enable", "f", sel_eq_enable);
+ REGISTER_CALLBACK (serv, "/select/eq_hpf", "f", sel_eq_hpf);
+ REGISTER_CALLBACK (serv, "/select/eq_gain", "if", sel_eq_gain);
+ REGISTER_CALLBACK (serv, "/select/eq_freq", "if", sel_eq_freq);
+ REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q);
+ REGISTER_CALLBACK (serv, "/select/eq_shape", "if", sel_eq_shape);
/* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */
REGISTER_CALLBACK (serv, "/strip/mute", "ii", route_mute);
REGISTER_CALLBACK (serv, "/strip/record_safe", "ii", route_recsafe);
REGISTER_CALLBACK (serv, "/strip/monitor_input", "ii", route_monitor_input);
REGISTER_CALLBACK (serv, "/strip/monitor_disk", "ii", route_monitor_disk);
- REGISTER_CALLBACK (serv, "/strip/select", "ii", strip_select);
- REGISTER_CALLBACK (serv, "/strip/gui_select", "ii", strip_gui_select);
+ REGISTER_CALLBACK (serv, "/strip/expand", "ii", strip_expand);
+ REGISTER_CALLBACK (serv, "/strip/select", "ii", strip_gui_select);
REGISTER_CALLBACK (serv, "/strip/polarity", "ii", strip_phase);
REGISTER_CALLBACK (serv, "/strip/gain", "if", route_set_gain_dB);
REGISTER_CALLBACK (serv, "/strip/fader", "if", route_set_gain_fader);
route_recsafe (ssid, argv[0]->f == 1.0, msg);
ret = 0;
}
- else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) {
+ else if (!strncmp (path, "/strip/expand/", 14) && strlen (path) > 14) {
int ssid = atoi (&path[14]);
- strip_select (ssid, argv[0]->f == 1.0, msg);
+ strip_expand (ssid, argv[0]->f == 1.0, msg);
ret = 0;
}
- else if (!strncmp (path, "/strip/gui_select/", 18) && strlen (path) > 18) {
- int ssid = atoi (&path[18]);
+ else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) {
+ int ssid = atoi (&path[14]);
strip_gui_select (ssid, argv[0]->f == 1.0, msg);
ret = 0;
}
route_solo (ssid, argv[0]->f == 1.0, msg);
ret = 0;
}
+ else if (!strncmp (path, "/select/eq_gain/", 16) && strlen (path) > 16) {
+ int ssid = atoi (&path[16]);
+ route_solo (ssid, argv[0]->f == 1.0, msg);
+ ret = 0;
+ }
+ else if (!strncmp (path, "/select/eq_freq/", 16) && strlen (path) > 16) {
+ int ssid = atoi (&path[16]);
+ route_solo (ssid, argv[0]->f == 1.0, msg);
+ ret = 0;
+ }
+ else if (!strncmp (path, "/select/eq_q/", 13) && strlen (path) > 13) {
+ int ssid = atoi (&path[13]);
+ route_solo (ssid, argv[0]->f == 1.0, msg);
+ ret = 0;
+ }
+ else if (!strncmp (path, "/select/eq_shape/", 17) && strlen (path) > 17) {
+ int ssid = atoi (&path[17]);
+ route_solo (ssid, argv[0]->f == 1.0, msg);
+ ret = 0;
+ }
}
if ((ret && _debugmode == Unhandled)) {
lo_message_free (reply);
}
+int
+OSC::cancel_all_solos ()
+{
+ session->clear_all_solo_state (session->get_routes());
+ return 0;
+}
+
int
OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, lo_message msg)
{
// set bank and strip feedback
set_bank(s->bank, msg);
- global_feedback (s->feedback, msg, s->gainmode);
+ global_feedback (s->feedback, lo_message_get_source (msg), s->gainmode);
return 0;
}
set_bank(s->bank, msg);
// Set global/master feedback
- global_feedback (s->feedback, msg, s->gainmode);
+ global_feedback (s->feedback, lo_message_get_source (msg), s->gainmode);
return 0;
}
set_bank(s->bank, msg);
// Set global/master feedback
- global_feedback (s->feedback, msg, s->gainmode);
+ global_feedback (s->feedback, lo_message_get_source (msg), s->gainmode);
return 0;
}
return &_surface[it];
}
}
+ // if we do this when OSC is started we get the wrong stripable
+ // we don't need this until we actually have a surface to deal with
+ if (!_select || (_select != ControlProtocol::first_selected_stripable())) {
+ gui_selection_changed();
+ }
+
// No surface create one with default values
OSCSurface s;
s.remote_url = r_url;
s.feedback = 0;
s.gainmode = 0;
s.sel_obs = 0;
- s.surface_sel = 0;
+ s.expand = 0;
+ s.expand_enable = false;
s.strips = get_sorted_stripables(s.strip_types);
- // I think the line below can be removed
s.nstrips = s.strips.size();
_surface.push_back (s);
// setup global feedback for a surface
void
-OSC::global_feedback (bitset<32> feedback, lo_address msg, uint32_t gainmode)
+OSC::global_feedback (bitset<32> feedback, lo_address addr, uint32_t gainmode)
{
// first destroy global observer for this surface
GlobalObservers::iterator x;
-
for (x = global_observers.begin(); x != global_observers.end();) {
OSCGlobalObserver* ro;
if ((ro = dynamic_cast<OSCGlobalObserver*>(*x)) != 0) {
- int res = strcmp(lo_address_get_url(ro->address()), lo_address_get_url(lo_message_get_source (msg)));
+ int res = strcmp(lo_address_get_url(ro->address()), lo_address_get_url(addr));
if (res == 0) {
delete *x;
}
if (feedback[4] || feedback[3] || feedback[5] || feedback[6]) {
// create a new Global Observer for this surface
- //OSCSurface *s = get_surface (lo_message_get_source (msg));
- OSCGlobalObserver* o = new OSCGlobalObserver (*session, lo_message_get_source (msg), gainmode, /*s->*/feedback);
+ OSCGlobalObserver* o = new OSCGlobalObserver (*session, addr, gainmode, /*s->*/feedback);
global_observers.push_back (o);
}
}
void
OSC::notify_routes_added (ARDOUR::RouteList &)
{
+ // not sure if we need this
//recalcbanks();
}
void
OSC::notify_vca_added (ARDOUR::VCAList &)
{
+ // not sure if we need this
//recalcbanks();
}
void
OSC::_recalcbanks ()
{
+ if (!_select || (_select != ControlProtocol::first_selected_stripable())) {
+ _select = ControlProtocol::first_selected_stripable();
+ }
+
// do a set_bank for each surface we know about.
for (uint32_t it = 0; it < _surface.size(); ++it) {
OSCSurface* sur = &_surface[it];
return _set_bank (bank_start, lo_message_get_source (msg));
}
+// set bank is callable with either message or address
int
OSC::_set_bank (uint32_t bank_start, lo_address addr)
{
return -1;
}
- // reset local select
- _strip_select (0, addr);
+ OSCSurface *s = get_surface (addr);
+
+ // revert any expand to select
+ s->expand = 0;
+ s->expand_enable = false;
+ _strip_select (ControlProtocol::first_selected_stripable(), addr);
// undo all listeners for this url
StripableList stripables;
}
}
- OSCSurface *s = get_surface (addr);
s->strips = get_sorted_stripables(s->strip_types);
- // I think the line below can be removed
s->nstrips = s->strips.size();
uint32_t b_size;
b_size = s->bank_size;
}
- // Do limits checking - high end still not quite right
+ // Do limits checking
if (bank_start < 1) bank_start = 1;
if (b_size >= s->nstrips) {
bank_start = 1;
} else if (bank_start > ((s->nstrips - b_size) + 1)) {
+ // top bank is always filled if there are enough strips for at least one bank
bank_start = (uint32_t)((s->nstrips - b_size) + 1);
}
//save bank in case we have had to change it
if (stp) {
listen_to_route(stp, addr);
- if (!s->feedback[10]) {
- if (stp->is_selected()) {
- _strip_select (n + 1 - s->bank , addr);
- }
- }
}
}
}
}
+ // light bankup or bankdown buttons if it is possible to bank in that direction
if (s->feedback[4]) {
+ // these two messages could be bundled
lo_message reply;
reply = lo_message_new ();
if ((s->bank > (s->nstrips - s->bank_size)) || (s->nstrips < s->bank_size)) {
uint32_t
OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
{
+ if (!strip) {
+ return 0;
+ }
+
OSCSurface *s = get_surface(addr);
uint32_t b_size;
return 0;
}
-uint32_t
-OSC::get_rid (uint32_t ssid, lo_address addr)
-{
- OSCSurface *s = get_surface(addr);
- return ssid + s->bank - 1;
-}
-
boost::shared_ptr<ARDOUR::Stripable>
OSC::get_strip (uint32_t ssid, lo_address addr)
{
OSCSurface *s = get_surface(addr);
- if ((ssid + s->bank - 2) < s->nstrips) {
+ if (ssid && ((ssid + s->bank - 2) < s->nstrips)) {
return s->strips[ssid + s->bank - 2];
}
// guess it is out of range
OSC::sel_mute (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_mute(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("mute", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->mute_control()) {
+ s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("mute", 0, lo_message_get_source (msg));
}
int
OSC::sel_solo (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_solo(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("solo", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->solo_control()) {
+ s->solo_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("solo", 0, lo_message_get_source (msg));
}
int
OSC::sel_solo_iso (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_solo_iso(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("solo_iso", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->solo_isolate_control()) {
+ s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
}
+ return sel_fail ("solo_iso", 0, lo_message_get_source (msg));
}
int
OSC::sel_solo_safe (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_solo_safe(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("solo_safe", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->solo_safe_control()) {
+ s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("solo_safe", 0, lo_message_get_source (msg));
}
int
OSC::sel_recenable (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_recenable(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("recenable", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->rec_enable_control()) {
+ s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("recenable", 0, lo_message_get_source (msg));
}
int
OSC::sel_recsafe (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_recsafe(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("record_safe", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->rec_safe_control()) {
+ s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("record_safe", 0, lo_message_get_source (msg));
}
int
OSC::sel_monitor_input (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_monitor_input(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("monitor_input", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
+ if (track) {
+ if (track->monitoring_control()) {
+ track->monitoring_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
}
+ return sel_fail ("monitor_input", 0, lo_message_get_source (msg));
}
int
OSC::sel_monitor_disk (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_monitor_disk(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("monitor_disk", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
+ if (track) {
+ if (track->monitoring_control()) {
+ track->monitoring_control()->set_value (yn ? 2.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
}
+ return sel_fail ("monitor_disk", 0, lo_message_get_source (msg));
}
OSC::sel_phase (uint32_t yn, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return strip_phase(sur->surface_sel, yn, msg);
- } else {
- return route_send_fail ("polarity", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->phase_control()) {
+ s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+ return 0;
+ }
}
+ return sel_fail ("polarity", 0, lo_message_get_source (msg));
}
int
-OSC::strip_select (int ssid, int yn, lo_message msg)
+OSC::strip_expand (int ssid, int yn, lo_message msg)
{
- //ignore button release
- if (!yn) return 0;
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ sur->expand_enable = (bool) yn;
+ sur->expand = ssid;
+ boost::shared_ptr<Stripable> s;
+ if (yn) {
+ s = get_strip (ssid, lo_message_get_source (msg));
+ } else {
+ s = ControlProtocol::first_selected_stripable();
+ }
- return _strip_select ( ssid, lo_message_get_source (msg));
+ return _strip_select (s, lo_message_get_source (msg));
}
int
-OSC::_strip_select (int ssid, lo_address addr)
+OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
{
if (!session) {
- route_send_fail ("select", ssid, 0, addr);
return -1;
}
OSCSurface *sur = get_surface(addr);
delete sur->sel_obs;
sur->sel_obs = 0;
}
- sur->surface_sel = 0;
- boost::shared_ptr<Stripable> s;
- if (ssid){
- s = get_strip (ssid, addr);
- }
if (s) {
- sur->surface_sel = ssid;
- OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, ssid, sur->gainmode, sur->feedback);
+ OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, sur->gainmode, sur->feedback);
s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
sur->sel_obs = sel_fb;
+ } else if (sur->expand_enable) {
+ sur->expand = 0;
+ sur->expand_enable = false;
+ if (_select) {
+ OSCSelectObserver* sel_fb = new OSCSelectObserver (_select, addr, sur->gainmode, sur->feedback);
+ _select->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
+ sur->sel_obs = sel_fb;
+ }
} else {
- route_send_fail ("select", ssid, 0 , addr);
+ route_send_fail ("select", sur->expand, 0 , addr);
}
+ //update buttons on surface
int b_s = sur->bank_size;
if (!b_s) { // bank size 0 means we need to know how many strips there are.
b_s = sur->nstrips;
}
for (int i = 1; i <= b_s; i++) {
- string path = "select";
- if (!sur->feedback[10]) {
- path = "gui_select";
- }
- if (i==(int)sur->surface_sel) {
+ string path = "expand";
+
+ if ((i == (int) sur->expand) && sur->expand_enable) {
lo_message reply = lo_message_new ();
if (sur->feedback[2]) {
ostringstream os;
- os << "/strip/" << path << "/" << ssid;
+ os << "/strip/" << path << "/" << i;
path = os.str();
} else {
ostringstream os;
os << "/strip/" << path;
path = os.str();
- lo_message_add_int32 (reply, ssid);
+ lo_message_add_int32 (reply, i);
}
- lo_message_add_float (reply, (float) 1);
+ lo_message_add_float (reply, (float) 1);
- lo_send_message (addr, path.c_str(), reply);
- lo_message_free (reply);
- } else {
- route_send_fail (path, i, 0, addr);
- }
+ lo_send_message (addr, path.c_str(), reply);
+ lo_message_free (reply);
+ reply = lo_message_new ();
+ lo_message_add_float (reply, 1.0);
+ lo_send_message (addr, "/select/expand", reply);
+ lo_message_free (reply);
+
+ } else {
+ lo_message reply = lo_message_new ();
+ lo_message_add_int32 (reply, i);
+ lo_message_add_float (reply, 0.0);
+ lo_send_message (addr, "/strip/expand", reply);
+ lo_message_free (reply);
+ }
+ }
+ if (!sur->expand_enable) {
+ lo_message reply = lo_message_new ();
+ lo_message_add_float (reply, 0.0);
+ lo_send_message (addr, "/select/expand", reply);
+ lo_message_free (reply);
}
return 0;
if (!yn) return 0;
if (!session) {
- route_send_fail ("gui_select", ssid, 0, lo_message_get_source (msg));
+ route_send_fail ("select", ssid, 0, lo_message_get_source (msg));
return -1;
}
-
- int rid = get_rid (ssid, lo_message_get_source (msg));
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ sur->expand_enable = false;
boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
if (s) {
- SetStripableSelection (rid);
+ SetStripableSelection (s);
} else {
- route_send_fail ("gui_select", ssid, 0, lo_message_get_source (msg));
+ route_send_fail ("select", ssid, 0, lo_message_get_source (msg));
}
return 0;
}
+int
+OSC::sel_expand (uint32_t state, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ sur->expand_enable = (bool) state;
+ if (state && sur->expand) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = ControlProtocol::first_selected_stripable();
+ }
+
+ return _strip_select (s, lo_message_get_source (msg));
+}
+
int
OSC::route_set_gain_abs (int ssid, float level, lo_message msg)
{
OSC::sel_gain (float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_set_gain_dB(sur->surface_sel, val, msg);
- } else {
- return route_send_fail ("gain", 0, -193, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ float abs;
+ if (val < -192) {
+ abs = 0;
+ } else {
+ abs = dB_to_coefficient (val);
+ }
+ if (s->gain_control()) {
+ s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("gain", -193, lo_message_get_source (msg));
}
int
OSC::sel_fader (float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_set_gain_fader(sur->surface_sel, val, msg);
- } else {
- return route_send_fail ("fader", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ float abs;
+ if ((val > 799.5) && (val < 800.5)) {
+ abs = 1.0;
+ } else {
+ abs = slider_position_to_gain_with_max ((val/1023), 2.0);
+ }
+ if (s->gain_control()) {
+ s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
}
+ return sel_fail ("fader", 0, lo_message_get_source (msg));
}
int
OSC::sel_trim (float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_set_trim_dB (sur->surface_sel, val, msg);
- } else {
- return route_send_fail ("trimdB", 0, 0, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->trim_control()) {
+ s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("trimdB", 0, lo_message_get_source (msg));
}
int
OSC::sel_pan_position (float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_set_pan_stereo_position (sur->surface_sel, val, msg);
- } else {
- return route_send_fail ("pan_stereo_position", 0, 0.5, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if(s->pan_azimuth_control()) {
+ s->pan_azimuth_control()->set_value (val, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_stereo_position", 0.5, lo_message_get_source (msg));
}
int
OSC::sel_pan_width (float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- if (sur->surface_sel) {
- return route_set_pan_stereo_width (sur->surface_sel, val, msg);
- } else {
- return route_send_fail ("pan_stereo_width", 0, 1, lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->pan_width_control()) {
+ s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_stereo_width", 1, lo_message_get_source (msg));
}
int
OSC::sel_sendgain (int id, float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- int ret;
- if (sur->surface_sel) {
- ret = route_set_send_gain_dB(sur->surface_sel, id, val, msg);
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
- if (!ret) {
- return ret;
+ float abs;
+ if (s) {
+ if (val < -192) {
+ abs = 0;
+ } else {
+ abs = dB_to_coefficient (val);
+ }
+ if (id > 0) {
+ --id;
+ }
+
+ if (s->send_level_controllable (id)) {
+ s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
}
- return sel_send_fail ("send_gain", id, -193, lo_message_get_source (msg));
+ return sel_send_fail ("send_gain", id + 1, -193, lo_message_get_source (msg));
}
int
OSC::sel_sendfader (int id, float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- int ret;
- if (sur->surface_sel) {
- ret = route_set_send_fader(sur->surface_sel, id, val, msg);
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
- if (!ret) {
- return ret;
+ float abs;
+ if (s) {
+ if ((val > 799.5) && (val < 800.5)) {
+ abs = 1.0;
+ } else {
+ abs = slider_position_to_gain_with_max ((val/1023), 2.0);
+ }
+ if (id > 0) {
+ --id;
+ }
+
+ if (s->send_level_controllable (id)) {
+ s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
}
return sel_send_fail ("send_gain", id, 0, lo_message_get_source (msg));
-
}
int
}
if (s->send_level_controllable (sid)) {
- return 1;
+ return 0;
}
}
OSC::sel_sendenable (int id, float val, lo_message msg)
{
OSCSurface *sur = get_surface(lo_message_get_source (msg));
- int ret;
- if (sur->surface_sel) {
- ret = route_set_send_enable(sur->surface_sel, id, val, msg);
- }
- switch (ret) {
- case 0:
- return ret;
- case 1:
- return sel_send_fail ("send_enable", id, 1, lo_message_get_source (msg));
- default:
- sel_send_fail ("send_enable", id, 0, lo_message_get_source (msg));
- return -1;
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
- return -1;
-
-
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+ if (s->send_enable_controllable (id)) {
+ s->send_enable_controllable (id)->set_value (val, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ if (s->send_level_controllable (id)) {
+ return sel_send_fail ("send_enable", id + 1, 1, lo_message_get_source (msg));
+ }
+ }
+ return sel_send_fail ("send_enable", id + 1, 0, lo_message_get_source (msg));
}
int
return 0;
}
-void
-OSC::gui_selection_changed (StripableNotificationListPtr stripables)
+// select
+
+int
+OSC::sel_pan_elevation (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->pan_elevation_control()) {
+ s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_elevation_position", 0.5, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_pan_frontback (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->pan_frontback_control()) {
+ s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_frontback_position", 0.5, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_pan_lfe (float val, lo_message msg)
{
- boost::shared_ptr<Stripable> strip;
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->pan_lfe_control()) {
+ s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_lfe_position", 0, lo_message_get_source (msg));
+}
- if (!stripables->empty()) {
- strip = stripables->front().lock();
+// compressor control
+int
+OSC::sel_comp_enable (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
}
+ if (s) {
+ if (s->comp_enable_controllable()) {
+ s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("comp_enable", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_comp_threshold (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->comp_threshold_controllable()) {
+ s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("comp_threshold", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_comp_speed (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->comp_speed_controllable()) {
+ s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("comp_speed", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_comp_mode (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->comp_mode_controllable()) {
+ s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("comp_mode", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_comp_makeup (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->comp_makeup_controllable()) {
+ s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("comp_makeup", 0, lo_message_get_source (msg));
+}
+
+// EQ control
+
+int
+OSC::sel_eq_enable (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->eq_enable_controllable()) {
+ s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("eq_enable", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_eq_hpf (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (s->eq_hpf_controllable()) {
+ s->eq_hpf_controllable()->set_value (s->eq_hpf_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("eq_hpf", 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_eq_gain (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+ if (s->eq_gain_controllable (id)) {
+ s->eq_gain_controllable (id)->set_value (s->eq_gain_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_send_fail ("eq_gain", id + 1, 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_eq_freq (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+ if (s->eq_freq_controllable (id)) {
+ s->eq_freq_controllable (id)->set_value (s->eq_freq_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_send_fail ("eq_freq", id + 1, 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_eq_q (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+ if (s->eq_q_controllable (id)) {
+ s->eq_q_controllable (id)->set_value (s->eq_q_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_send_fail ("eq_q", id + 1, 0, lo_message_get_source (msg));
+}
+
+int
+OSC::sel_eq_shape (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(lo_message_get_source (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, lo_message_get_source (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+ if (s->eq_shape_controllable (id)) {
+ s->eq_shape_controllable (id)->set_value (s->eq_shape_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_send_fail ("eq_shape", id + 1, 0, lo_message_get_source (msg));
+}
+
+void
+OSC::gui_selection_changed ()
+{
+ boost::shared_ptr<Stripable> strip = ControlProtocol::first_selected_stripable();
+
if (strip) {
+ _select = strip;
for (uint32_t it = 0; it < _surface.size(); ++it) {
OSCSurface* sur = &_surface[it];
- if(!sur->feedback[10]) {
+ if(!sur->expand_enable) {
lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
- uint32_t sel_strip = get_sid (strip, addr);
- _strip_select (sel_strip, addr);
+ _strip_select (strip, addr);
}
}
}
-
}
// timer callbacks
{
if (!tick) {
Glib::usleep(100); // let flurry of signals subside
+ if (global_init) {
+ for (uint32_t it = 0; it < _surface.size(); it++) {
+ OSCSurface* sur = &_surface[it];
+ lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
+ global_feedback (sur->feedback, addr, sur->gainmode);
+ }
+ global_init = false;
+ tick = true;
+ }
if (bank_dirty) {
_recalcbanks ();
bank_dirty = false;
lo_send_message (addr, str_pth.c_str(), reply);
lo_message_free (reply);
}
- if (sur->surface_sel == ssid) {
+ if ((_select == get_strip (ssid, addr)) || ((sur->expand == ssid) && (sur->expand_enable))) {
os.str("");
os << "/select/" << path;
string sel_pth = os.str();
return 0;
}
+int
+OSC::sel_fail (string path, float val, lo_address addr)
+{
+ ostringstream os;
+ os.str("");
+ os << "/select/" << path;
+ string sel_pth = os.str();
+ lo_message reply = lo_message_new ();
+ lo_message_add_float (reply, (float) val);
+ lo_send_message (addr, sel_pth.c_str(), reply);
+ lo_message_free (reply);
+
+ return 0;
+}
+
int
OSC::sel_send_fail (string path, uint32_t id, float val, lo_address addr)
{
{
XMLNode& node (ControlProtocol::get_state());
node.add_property("debugmode", (int) _debugmode); // TODO: enum2str
+ if (_surface.size()) {
+ XMLNode* config = new XMLNode (X_("Configurations"));
+ for (uint32_t it = 0; it < _surface.size(); ++it) {
+ OSCSurface* sur = &_surface[it];
+ XMLNode* devnode = new XMLNode (X_("Configuration"));
+ devnode->add_property (X_("url"), sur->remote_url);
+ devnode->add_property (X_("bank-size"), sur->bank_size);
+ devnode->add_property (X_("strip-types"), sur->strip_types.to_ulong());
+ devnode->add_property (X_("feedback"), sur->feedback.to_ulong());
+ devnode->add_property (X_("gainmode"), sur->gainmode);
+ config->add_child_nocopy (*devnode);
+ }
+ node.add_child_nocopy (*config);
+ }
return node;
}
if (p) {
_debugmode = OSCDebugMode (PBD::atoi(p->value ()));
}
+ XMLNode* cnode = node.child (X_("Configurations"));
+
+ if (cnode) {
+ XMLNodeList const& devices = cnode->children();
+ for (XMLNodeList::const_iterator d = devices.begin(); d != devices.end(); ++d) {
+ XMLProperty const * prop = (*d)->property (X_("url"));
+ if (prop) {
+ OSCSurface s;
+ bank_dirty = true;
+ s.remote_url = prop->value();
+ prop = (*d)->property (X_("bank-size"));
+ if (prop) {
+ s.bank_size = atoi (prop->value().c_str());
+ }
+ prop = (*d)->property (X_("strip-types"));
+ if (prop) {
+ s.strip_types = atoi (prop->value().c_str());
+ }
+ prop = (*d)->property (X_("feedback"));
+ if (prop) {
+ s.feedback = atoi (prop->value().c_str());
+ }
+ prop = (*d)->property (X_("gainmode"));
+ if (prop) {
+ s.gainmode = atoi (prop->value().c_str());
+ }
+ s.bank = 1;
+ s.sel_obs = 0;
+ s.expand = 0;
+ s.expand_enable = false;
+ s.strips = get_sorted_stripables(s.strip_types);
+ s.nstrips = s.strips.size();
+ _surface.push_back (s);
+ }
+ }
+ }
+ global_init = true;
+ tick = false;
return 0;
}