OSC: Added slaved feedback to select
[ardour.git] / libs / surfaces / osc / osc_select_observer.cc
index e5995edf2fbb745aeeb5278bfde41f77d26d7580..de58cd8916779cb858a49a05ab99ee8687b98a5a 100644 (file)
@@ -38,6 +38,7 @@
 #include "ardour/plugin_insert.h"
 #include "ardour/processor.h"
 #include "ardour/readonly_control.h"
+#include "ardour/vca.h"
 
 #include "osc.h"
 #include "osc_select_observer.h"
@@ -195,6 +196,10 @@ OSCSelectObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip
        _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
        gain_automation ();
 
+       boost::shared_ptr<Slavable> slv = boost::dynamic_pointer_cast<Slavable> (_strip);
+       slv->AssignmentChange.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::slaved_changed, this, _1, _2), OSC::instance());
+       slaved_changed (boost::shared_ptr<VCA>(), false);
+
        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::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
@@ -1021,3 +1026,28 @@ OSCSelectObserver::eq_restart(int x)
        //eq_end();
        eq_init();
 }
+
+void
+OSCSelectObserver::slaved_changed (boost::shared_ptr<VCA> vca, bool state)
+{
+       lo_message reply;
+       reply = lo_message_new ();
+       StripableList stripables;
+       session->get_stripables (stripables);
+       for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
+               boost::shared_ptr<Stripable> s = *it;
+
+               // we only want VCAs
+               boost::shared_ptr<VCA> v = boost::dynamic_pointer_cast<VCA> (s);
+               if (v) {
+                       lo_message_add_string (reply, v->name().c_str());
+                       if (_strip->slaved_to (v)) {
+                               lo_message_add_int32 (reply, 1);
+                       } else {
+                               lo_message_add_int32 (reply, 0);
+                       }
+               }
+       }
+       lo_send_message (addr, X_("/select/vcas"), reply);
+       lo_message_free (reply);
+}