+ return 0;
+}
+
+int
+OSC::sel_gain (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
+{
+ if (!session) {
+ route_send_fail ("fader", ssid, 0, get_address (msg));
+ return -1;
+ }
+ int ret;
+ ret = route_set_gain_abs (ssid, slider_position_to_gain_with_max (pos, 2.0), msg);
+ if (ret != 0) {
+ return route_send_fail ("fader", ssid, 0, get_address (msg));
+ }
+ return 0;
+}
+
+int
+OSC::sel_fader (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ float abs;
+ abs = slider_position_to_gain_with_max (val, 2.0);
+ if (s->gain_control()) {
+ s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("fader", 0, get_address (msg));
+}
+
+int
+OSC::route_set_trim_abs (int ssid, float level, lo_message msg)
+{
+ if (!session) return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ if (s) {
+ if (s->trim_control()) {
+ s->trim_control()->set_value (level, PBD::Controllable::NoGroup);
+ return 0;
+ }
+
+ }
+
+ return -1;
+}
+
+int
+OSC::route_set_trim_dB (int ssid, float dB, lo_message msg)
+{
+ int ret;
+ ret = route_set_trim_abs(ssid, dB_to_coefficient (dB), msg);
+ if (ret != 0) {
+ return route_send_fail ("trimdB", ssid, 0, get_address (msg));
+ }
+
+return 0;
+}
+
+int
+OSC::sel_trim (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_pan_position (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (msg));
+ } else {
+ s = _select;
+ }
+ if (s) {
+ if(s->pan_azimuth_control()) {
+ s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_fail ("pan_stereo_position", 0.5, get_address (msg));
+}
+
+int
+OSC::sel_pan_width (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
+{
+ if (!session) return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ if (s) {
+ if(s->pan_azimuth_control()) {
+ s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+
+ return route_send_fail ("pan_stereo_position", ssid, 0.5, get_address (msg));
+}
+
+int
+OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg)
+{
+ if (!session) return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ if (s) {
+ if (s->pan_width_control()) {
+ s->pan_width_control()->set_value (pos, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+
+ return route_send_fail ("pan_stereo_width", ssid, 1, get_address (msg));
+}
+
+int
+OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg)
+{
+ if (!session) {
+ return -1;
+ }
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+ float abs;
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+#ifdef MIXBUS
+ abs = val;
+#else
+ if (val < -192) {
+ abs = 0;
+ } else {
+ abs = dB_to_coefficient (val);
+ }
+#endif
+ if (s->send_level_controllable (id)) {
+ s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return 0;
+}
+
+int
+OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg)
+{
+ if (!session) {
+ return -1;
+ }
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+ float abs;
+ if (s) {
+
+ if (id > 0) {
+ --id;
+ }
+
+ if (s->send_level_controllable (id)) {
+#ifdef MIXBUS
+ abs = s->send_level_controllable(id)->interface_to_internal (val);
+#else
+ abs = slider_position_to_gain_with_max (val, 2.0);
+#endif
+ s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return 0;
+}
+
+int
+OSC::sel_sendgain (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (msg));
+ } else {
+ s = _select;
+ }
+ float abs;
+ if (s) {
+ if (id > 0) {
+ --id;
+ }
+#ifdef MIXBUS
+ abs = val;
+#else
+ if (val < -192) {
+ abs = 0;
+ } else {
+ abs = dB_to_coefficient (val);
+ }
+#endif
+ 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 + 1, -193, get_address (msg));
+}
+
+int
+OSC::sel_sendfader (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (msg));
+ } else {
+ s = _select;
+ }
+ float abs;
+ if (s) {
+
+ if (id > 0) {
+ --id;
+ }
+
+ if (s->send_level_controllable (id)) {
+#ifdef MIXBUS
+ abs = s->send_level_controllable(id)->interface_to_internal (val);
+#else
+ abs = slider_position_to_gain_with_max (val, 2.0);
+#endif
+ s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+ return 0;
+ }
+ }
+ return sel_send_fail ("send_fader", id, 0, get_address (msg));
+}
+
+int
+OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
+{
+ if (!session) {
+ return -1;
+ }
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ if (s) {
+
+ /* revert to zero-based counting */
+
+ if (sid > 0) {
+ --sid;
+ }
+
+ if (s->send_enable_controllable (sid)) {
+ s->send_enable_controllable (sid)->set_value (val, PBD::Controllable::NoGroup);
+ return 0;
+ }
+
+ if (s->send_level_controllable (sid)) {
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+ if (!r) {
+ return 0;
+ }
+ boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(sid));
+ if (snd) {
+ if (val) {
+ snd->activate();
+ } else {
+ snd->deactivate();
+ }
+ }
+ return 0;
+ }
+
+ }
+
+ return -1;
+}
+
+int
+OSC::sel_sendenable (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (msg));
+ } else {
+ s = _select;
+ }
+ 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)) {
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+ if (!r) {
+ // should never get here
+ return sel_send_fail ("send_enable", id + 1, 0, get_address (msg));
+ }
+ boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(id));
+ if (snd) {
+ if (val) {
+ snd->activate();
+ } else {
+ snd->deactivate();
+ }
+ }
+ return 0;
+ }
+ }
+ return sel_send_fail ("send_enable", id + 1, 0, get_address (msg));
+}
+
+int
+OSC::route_plugin_list (int ssid, lo_message msg) {
+ if (!session) {
+ return -1;
+ }
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+ int piid = 0;
+
+ lo_message reply = lo_message_new ();
+ lo_message_add_int32 (reply, ssid);
+
+
+ for (;;) {
+ boost::shared_ptr<Processor> redi = r->nth_plugin(piid);
+ if ( !redi ) {
+ break;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ continue;
+ }
+ lo_message_add_int32 (reply, piid + 1);
+
+ boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
+ lo_message_add_string (reply, pip->name());
+
+ piid++;
+ }
+
+ lo_send_message (get_address (msg), "/strip/plugin/list", reply);
+ lo_message_free (reply);
+ return 0;
+}
+
+int
+OSC::route_plugin_descriptor (int ssid, int piid, lo_message msg) {
+ if (!session) {
+ return -1;
+ }
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
+
+ if (!redi) {
+ PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
+ bool ok = false;
+
+ lo_message reply = lo_message_new();
+ lo_message_add_int32 (reply, ssid);
+ lo_message_add_int32 (reply, piid);
+ lo_message_add_string (reply, pip->name());
+ for ( uint32_t ppi = 0; ppi < pip->parameter_count(); ppi++) {
+
+ uint32_t controlid = pip->nth_parameter(ppi, ok);
+ if (!ok) {
+ continue;
+ }
+ if ( pip->parameter_is_input(controlid) || pip->parameter_is_control(controlid) ) {
+ boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
+
+ lo_message_add_int32 (reply, ppi + 1);
+ ParameterDescriptor pd;
+ pi->plugin()->get_parameter_descriptor(controlid, pd);
+ lo_message_add_string (reply, pd.label.c_str());
+
+ // I've combined those binary descriptor parts in a bit-field to reduce lilo message elements
+ int flags = 0;
+ flags |= pd.enumeration ? 1 : 0;
+ flags |= pd.integer_step ? 2 : 0;
+ flags |= pd.logarithmic ? 4 : 0;
+ flags |= pd.max_unbound ? 8 : 0;
+ flags |= pd.min_unbound ? 16 : 0;
+ flags |= pd.sr_dependent ? 32 : 0;
+ flags |= pd.toggled ? 64 : 0;
+ flags |= c != NULL ? 128 : 0; // bit 7 indicates in input control
+ lo_message_add_int32 (reply, flags);
+
+ lo_message_add_int32 (reply, pd.datatype);
+ lo_message_add_float (reply, pd.lower);
+ lo_message_add_float (reply, pd.upper);
+ lo_message_add_string (reply, pd.print_fmt.c_str());
+ if ( pd.scale_points ) {
+ lo_message_add_int32 (reply, pd.scale_points->size());
+ for ( ARDOUR::ScalePoints::const_iterator i = pd.scale_points->begin(); i != pd.scale_points->end(); ++i) {
+ lo_message_add_int32 (reply, i->second);
+ lo_message_add_string (reply, ((std::string)i->first).c_str());
+ }
+ }
+ else {
+ lo_message_add_int32 (reply, 0);
+ }
+ if ( c ) {
+ lo_message_add_double (reply, c->get_value());
+ }
+ else {
+ lo_message_add_double (reply, 0);
+ }
+ }
+ }
+
+ lo_send_message (get_address (msg), "/strip/plugin/descriptor", reply);
+ lo_message_free (reply);
+
+ return 0;
+}
+
+int
+OSC::route_plugin_reset (int ssid, int piid, lo_message msg) {
+ if (!session) {
+ return -1;
+ }
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
+
+ if (!redi) {
+ PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ return -1;
+ }
+
+ pi->reset_parameters_to_default ();
+
+ return 0;
+}
+
+int
+OSC::route_plugin_parameter (int ssid, int piid, int par, float val, lo_message msg)
+{
+ if (!session)
+ return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
+
+ if (!redi) {
+ PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
+ bool ok=false;
+
+ uint32_t controlid = pip->nth_parameter (par - 1,ok);
+
+ if (!ok) {
+ PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ if (!pip->parameter_is_input(controlid)) {
+ PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is not a control input" << endmsg;
+ return -1;
+ }
+
+ 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, PBD::Controllable::NoGroup);
+ } else {
+ PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is out of range" << endmsg;
+ PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg;
+ }
+
+ return 0;
+}
+
+//prints to cerr only
+int
+OSC::route_plugin_parameter_print (int ssid, int piid, int par, lo_message msg)
+{
+ if (!session) {
+ return -1;
+ }
+ boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+
+ if (!r) {
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
+
+ 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 - 1,ok);
+
+ if (!ok) {
+ return -1;
+ }
+
+ 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: " << pd.label << "\n";
+ if (c) {
+ cerr << "current value: " << c->get_value () << "\n";
+ } else {
+ cerr << "current value not available, control does not exist\n";
+ }
+ cerr << "lower value: " << pd.lower << "\n";
+ cerr << "upper value: " << pd.upper << "\n";
+ }
+
+ return 0;
+}
+
+int
+OSC::route_plugin_activate (int ssid, int piid, lo_message msg)
+{
+ if (!session)
+ return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
+
+ if (!redi) {
+ PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
+ pi->activate();
+
+ return 0;
+}
+
+int
+OSC::route_plugin_deactivate (int ssid, int piid, lo_message msg)
+{
+ if (!session)
+ return -1;
+ boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
+
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+
+ if (!r) {
+ PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
+
+ if (!redi) {
+ PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<PluginInsert> pi;
+
+ if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
+ PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
+ return -1;
+ }
+
+ boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
+ pi->deactivate();
+
+ return 0;
+}
+
+// select
+
+int
+OSC::sel_pan_elevation (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_pan_frontback (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_pan_lfe (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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_control", 0, get_address (msg));
+}
+
+// compressor control
+int
+OSC::sel_comp_enable (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_comp_threshold (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_comp_speed (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_comp_mode (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_comp_makeup (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+// EQ control
+
+int
+OSC::sel_eq_enable (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_eq_hpf (float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_eq_gain (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_eq_freq (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_eq_q (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (msg));
+}
+
+int
+OSC::sel_eq_shape (int id, float val, lo_message msg)
+{
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> s;
+ if (sur->expand_enable) {
+ s = get_strip (sur->expand, get_address (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, get_address (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->expand_enable) {
+ lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
+ _strip_select (strip, addr);
+ }
+ }
+ }
+}
+
+// timer callbacks
+bool
+OSC::periodic (void)
+{
+ 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;
+ tick = true;
+ }
+ }
+
+ if (scrub_speed != 0) {
+ // for those jog wheels that don't have 0 on release (touch), time out.
+ int64_t now = ARDOUR::get_microseconds ();
+ int64_t diff = now - scrub_time;
+ if (diff > 120000) {
+ scrub_speed = 0;
+ session->request_transport_speed (0);
+ // locate to the place PH was at last tick
+ session->request_locate (scrub_place, false);
+ }
+ }
+
+ for (GlobalObservers::iterator x = global_observers.begin(); x != global_observers.end(); x++) {
+
+ OSCGlobalObserver* go;
+
+ if ((go = dynamic_cast<OSCGlobalObserver*>(*x)) != 0) {
+ go->tick();
+ }
+ }
+ for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end(); x++) {
+
+ OSCRouteObserver* ro;
+
+ if ((ro = dynamic_cast<OSCRouteObserver*>(*x)) != 0) {
+ ro->tick();
+ }
+ }
+ for (uint32_t it = 0; it < _surface.size(); it++) {
+ OSCSurface* sur = &_surface[it];
+ OSCSelectObserver* so;
+ if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
+ so->tick();
+ }
+ }
+ for (CueObservers::iterator x = cue_observers.begin(); x != cue_observers.end(); x++) {
+
+ OSCCueObserver* co;
+
+ if ((co = dynamic_cast<OSCCueObserver*>(*x)) != 0) {
+ co->tick();
+ }
+ }
+ return true;
+}
+
+int
+OSC::route_send_fail (string path, uint32_t ssid, float val, lo_address addr)
+{
+ OSCSurface *sur = get_surface(addr);
+
+ ostringstream os;
+ lo_message reply;
+ if (ssid) {
+ reply = lo_message_new ();
+ if (sur->feedback[2]) {
+ os << "/strip/" << path << "/" << ssid;
+ } else {
+ os << "/strip/" << path;
+ lo_message_add_int32 (reply, ssid);
+ }
+ string str_pth = os.str();
+ lo_message_add_float (reply, (float) val);
+
+ lo_send_message (addr, str_pth.c_str(), reply);
+ lo_message_free (reply);
+ }
+ if ((_select == get_strip (ssid, addr)) || ((sur->expand == ssid) && (sur->expand_enable))) {
+ os.str("");
+ os << "/select/" << path;
+ string sel_pth = os.str();
+ 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_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);