OSC: add phase control
authorLen Ovens <len@ovenwerks.net>
Thu, 9 Jun 2016 19:07:57 +0000 (12:07 -0700)
committerLen Ovens <len@ovenwerks.net>
Thu, 9 Jun 2016 19:07:57 +0000 (12:07 -0700)
libs/surfaces/osc/osc.cc
libs/surfaces/osc/osc.h
libs/surfaces/osc/osc_select_observer.cc

index 12ba1f552a88b7c193708636fbd2f14b70160894..68bea263f2d75fcb99b5dbdc7402af9d6b8be6df 100644 (file)
@@ -46,6 +46,7 @@
 #include "ardour/plugin_insert.h"
 #include "ardour/presentation_info.h"
 #include "ardour/send.h"
+#include "ardour/phase_control.h"
 
 #include "osc_select_observer.h"
 #include "osc.h"
@@ -526,6 +527,8 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, "/select/pan_stereo_position", "f", sel_pan_position);
                REGISTER_CALLBACK (serv, "/select/pan_stereo_width", "f", sel_pan_width);
 
+               REGISTER_CALLBACK (serv, "/select/phase", "i", sel_phase);
+
                /* 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/solo", "ii", route_solo);
@@ -535,6 +538,7 @@ OSC::register_callbacks()
                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/phase", "ii", strip_phase);
                REGISTER_CALLBACK (serv, "/strip/gain", "if", route_set_gain_dB);
                REGISTER_CALLBACK (serv, "/strip/fader", "if", route_set_gain_fader);
                REGISTER_CALLBACK (serv, "/strip/trimabs", "if", route_set_trim_abs);
@@ -1677,6 +1681,33 @@ OSC::sel_monitor_disk (uint32_t yn, lo_message msg)
        }
 }
 
+
+int
+OSC::strip_phase (int ssid, int yn, lo_message msg)
+{
+       if (!session) return -1;
+       int rid = get_rid (ssid, lo_message_get_source (msg));
+
+       boost::shared_ptr<Stripable> s = session->get_remote_nth_stripable (rid, PresentationInfo::Route);
+
+       if (s) {
+               s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+       }
+
+       return 0;
+}
+
+int
+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 ("phase", 0, 0, lo_message_get_source (msg));
+       }
+}
+
 int
 OSC::strip_select (int ssid, int yn, lo_message msg)
 {
index 2818226143e84d290afebd4116dc062165cb92de..5b021bcda7da9a88f8e257184431061b848a5dd8 100644 (file)
@@ -333,6 +333,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        PATH_CALLBACK1_MSG(sel_solo,i);
        PATH_CALLBACK1_MSG(sel_monitor_input,i);
        PATH_CALLBACK1_MSG(sel_monitor_disk,i);
+       PATH_CALLBACK1_MSG(sel_phase,i);
        PATH_CALLBACK1_MSG(sel_gain,f);
        PATH_CALLBACK1_MSG(sel_fader,f);
        PATH_CALLBACK1_MSG(sel_trim,f);
@@ -396,6 +397,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        PATH_CALLBACK2_MSG(route_recsafe,i,i);
        PATH_CALLBACK2_MSG(route_monitor_input,i,i);
        PATH_CALLBACK2_MSG(route_monitor_disk,i,i);
+       PATH_CALLBACK2_MSG(strip_phase,i,i);
        PATH_CALLBACK2_MSG(strip_select,i,i);
        PATH_CALLBACK2_MSG(strip_gui_select,i,i);
        PATH_CALLBACK2_MSG(route_set_gain_abs,i,f);
@@ -417,6 +419,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        int route_recsafe (int ssid, int yn, lo_message msg);
        int route_monitor_input (int rid, int yn, lo_message msg);
        int route_monitor_disk (int rid, int yn, lo_message msg);
+       int strip_phase (int rid, int yn, lo_message msg);
        int strip_select (int rid, int yn, lo_message msg);
        int _strip_select (int rid, lo_address addr);
        int strip_gui_select (int rid, int yn, lo_message msg);
@@ -456,6 +459,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        int sel_solo (uint32_t state, lo_message msg);
        int sel_monitor_input (uint32_t state, lo_message msg);
        int sel_monitor_disk (uint32_t state, lo_message msg);
+       int sel_phase (uint32_t state, lo_message msg);
        int sel_gain (float state, lo_message msg);
        int sel_fader (float state, lo_message msg);
        int sel_trim (float val, lo_message msg);
index 0b57bda728e3f15b53a45ace4c820186bdba6e23..9ba55e48346984d49f5315a2222ed98972265bd9 100644 (file)
@@ -24,6 +24,7 @@
 #include "ardour/monitor_control.h"
 #include "ardour/dB.h"
 #include "ardour/meter.h"
+#include "ardour/phase_control.h"
 
 #include "osc.h"
 #include "osc_select_observer.h"
@@ -65,11 +66,19 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address
                        rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
                        send_change_message ("/select/recenable", _strip->rec_enable_control());
                }
+
                boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
-               if (rec_controllable) {
+               if (recsafe_controllable) {
                        recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
                        send_change_message ("/select/record_safe", _strip->rec_safe_control());
                }
+
+               boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
+               if (phase_controllable) {
+                       phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/phase"), _strip->phase_control()), OSC::instance());
+                       send_change_message ("/select/phase", _strip->phase_control());
+               }
+
        }
 
        if (feedback[1]) { // level controls
@@ -125,6 +134,7 @@ OSCSelectObserver::~OSCSelectObserver ()
                clear_strip ("/select/record_safe", 0);
                clear_strip ("/select/monitor_input", 0);
                clear_strip ("/select/monitor_disk", 0);
+               clear_strip ("/select/phase", 0);
        }
        if (feedback[1]) { // level controls
                if (gainmode) {