OSC: added solo isolate and solo safe/lock.
[ardour.git] / libs / surfaces / osc / osc_select_observer.cc
index 0b57bda728e3f15b53a45ace4c820186bdba6e23..a51f9e702aba38570cc7b307bf613f1021a5927c 100644 (file)
@@ -24,6 +24,9 @@
 #include "ardour/monitor_control.h"
 #include "ardour/dB.h"
 #include "ardour/meter.h"
+#include "ardour/phase_control.h"
+#include "ardour/solo_isolate_control.h"
+#include "ardour/solo_safe_control.h"
 
 #include "osc.h"
 #include "osc_select_observer.h"
@@ -48,55 +51,69 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address
                _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
                name_changed (ARDOUR::Properties::name);
 
-               _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
-               send_change_message ("/select/mute", _strip->mute_control());
+               _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
+               change_message ("/select/mute", _strip->mute_control());
 
-               _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
-               send_change_message ("/select/solo", _strip->solo_control());
+               _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
+               change_message ("/select/solo", _strip->solo_control());
+
+               _strip->solo_isolate_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo_iso"), _strip->solo_isolate_control()), OSC::instance());
+               change_message ("/select/solo_iso", _strip->solo_isolate_control());
+
+               _strip->solo_safe_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo_safe"), _strip->solo_safe_control()), OSC::instance());
+               change_message ("/select/solo_safe", _strip->solo_safe_control());
 
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
                if (track) {
-               track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_monitor_status, this, track->monitoring_control()), OSC::instance());
-               send_monitor_status (track->monitoring_control());
+               track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
+               monitor_status (track->monitoring_control());
                }
 
                boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
                if (rec_controllable) {
-                       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());
+                       rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
+                       change_message ("/select/recenable", _strip->rec_enable_control());
                }
+
                boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
-               if (rec_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());
+               if (recsafe_controllable) {
+                       recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
+                       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::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
+                       change_message ("/select/polarity", _strip->phase_control());
+               }
+
        }
 
        if (feedback[1]) { // level controls
                if (gainmode) {
-                       _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain_message, this, X_("/select/fader"), _strip->gain_control()), OSC::instance());
-                       send_gain_message ("/select/fader", _strip->gain_control());
+                       _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/fader"), _strip->gain_control()), OSC::instance());
+                       gain_message ("/select/fader", _strip->gain_control());
                } else {
-                       _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain_message, this, X_("/select/gain"), _strip->gain_control()), OSC::instance());
-                       send_gain_message ("/select/gain", _strip->gain_control());
+                       _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/gain"), _strip->gain_control()), OSC::instance());
+                       gain_message ("/select/gain", _strip->gain_control());
                }
 
                boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
                if (trim_controllable) {
-                       trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
-                       send_trim_message ("/select/trimdB", _strip->trim_control());
+                       trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
+                       trim_message ("/select/trimdB", _strip->trim_control());
                }
 
                boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
                if (pan_controllable) {
-                       pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/pan_stereo_position"), _strip->pan_azimuth_control()), OSC::instance());
-                       send_change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
+                       pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_stereo_position"), _strip->pan_azimuth_control()), OSC::instance());
+                       change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
                }
 
                boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
                if (width_controllable) {
-                       width_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_change_message, this, X_("/select/pan_stereo_width"), _strip->pan_width_control()), OSC::instance());
-                       send_change_message ("/select/pan_stereo_width", _strip->pan_width_control());
+                       width_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_stereo_width"), _strip->pan_width_control()), OSC::instance());
+                       change_message ("/select/pan_stereo_width", _strip->pan_width_control());
                }
 
                // detecting processor changes requires cast to route
@@ -125,6 +142,7 @@ OSCSelectObserver::~OSCSelectObserver ()
                clear_strip ("/select/record_safe", 0);
                clear_strip ("/select/monitor_input", 0);
                clear_strip ("/select/monitor_disk", 0);
+               clear_strip ("/select/polarity", 0);
        }
        if (feedback[1]) { // level controls
                if (gainmode) {
@@ -161,8 +179,8 @@ OSCSelectObserver::send_init()
        do {
                sends = false;
                if (_strip->send_level_controllable (nsends)) {
-                       _strip->send_level_controllable(nsends)->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain, this, X_("/select/send_gain"), nsends, _strip->send_level_controllable(nsends)), OSC::instance());
-                       send_gain ("/select/send_gain", nsends, _strip->send_level_controllable(nsends));
+                       _strip->send_level_controllable(nsends)->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain, this, nsends, _strip->send_level_controllable(nsends)), OSC::instance());
+                       send_gain (nsends, _strip->send_level_controllable(nsends));
                        sends = true;
                }
 
@@ -182,10 +200,10 @@ OSCSelectObserver::send_init()
                        lo_message_add_int32 (msg, 1);
                        lo_send_message (addr, path.c_str(), msg);
                        lo_message_free (msg);
-                       }
-
+               }
+               // this should get signalled by the route the send goes to, (TODO)
                if (sends) { // if the gain control is there, this is too
-                       send_rename ("/select/send_name", nsends, _strip->send_name(nsends));
+                       send_name ("/select/send_name", nsends, _strip->send_name(nsends));
                }
                // Send numbers are 0 based, OSC is 1 based so this gets incremented at the end
                if (sends) {
@@ -321,7 +339,7 @@ OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
 }
 
 void
-OSCSelectObserver::send_change_message (string path, boost::shared_ptr<Controllable> controllable)
+OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
 {
        lo_message msg = lo_message_new ();
 
@@ -332,7 +350,7 @@ OSCSelectObserver::send_change_message (string path, boost::shared_ptr<Controlla
 }
 
 void
-OSCSelectObserver::send_monitor_status (boost::shared_ptr<Controllable> controllable)
+OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
 {
        int disk, input;
        float val = controllable->get_value();
@@ -365,7 +383,7 @@ OSCSelectObserver::send_monitor_status (boost::shared_ptr<Controllable> controll
 }
 
 void
-OSCSelectObserver::send_trim_message (string path, boost::shared_ptr<Controllable> controllable)
+OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
 {
        lo_message msg = lo_message_new ();
 
@@ -376,7 +394,7 @@ OSCSelectObserver::send_trim_message (string path, boost::shared_ptr<Controllabl
 }
 
 void
-OSCSelectObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
+OSCSelectObserver::gain_message (string path, boost::shared_ptr<Controllable> controllable)
 {
        lo_message msg = lo_message_new ();
 
@@ -399,30 +417,35 @@ OSCSelectObserver::send_gain_message (string path, boost::shared_ptr<Controllabl
 }
 
 void
-OSCSelectObserver::send_gain (std::string path, uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
+OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
 {
        lo_message msg = lo_message_new ();
-
-       if (feedback[2]) {
-               path = set_path (path, id + 1);
-       } else {
-               lo_message_add_int32 (msg, id + 1);
-       }
+       string path;
+       float value;
 
        if (gainmode) {
+               path = "/select/send_fader";
                if (controllable->get_value() == 1) {
-                       lo_message_add_int32 (msg, 800);
+                       value = 800;
                } else {
-                       lo_message_add_int32 (msg, gain_to_slider_position (controllable->get_value()) * 1023);
+                       value = gain_to_slider_position (controllable->get_value());
                }
        } else {
+               path = "/select/send_gain";
                if (controllable->get_value() < 1e-15) {
-                       lo_message_add_float (msg, -200);
+                       value = -193;
                } else {
-                       lo_message_add_float (msg, accurate_coefficient_to_dB (controllable->get_value()));
+                       value = accurate_coefficient_to_dB (controllable->get_value());
                }
        }
 
+       if (feedback[2]) {
+               path = set_path (path, id + 1);
+       } else {
+               lo_message_add_int32 (msg, id + 1);
+       }
+
+       lo_message_add_float (msg, value);
        lo_send_message (addr, path.c_str(), msg);
        lo_message_free (msg);
 }
@@ -444,7 +467,7 @@ OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Cont
 }
 
 void
-OSCSelectObserver::send_rename (string path, uint32_t id, string name)
+OSCSelectObserver::send_name (string path, uint32_t id, string name)
 {
        lo_message msg = lo_message_new ();
        if (feedback[2]) {