OSC: Fix select fader automation play feedback as well fixes issue #7160
authorLen Ovens <len@ovenwerks.net>
Tue, 9 May 2017 21:10:49 +0000 (14:10 -0700)
committerLen Ovens <len@ovenwerks.net>
Tue, 9 May 2017 21:10:49 +0000 (14:10 -0700)
libs/surfaces/osc/osc_select_observer.cc
libs/surfaces/osc/osc_select_observer.h

index b11d277947b6fed5e29b9e3a3361c60c1e0854e0..2cc42569cc86c57ca0fc64bd4848d4e77ee486ea 100644 (file)
@@ -49,8 +49,10 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address
        ,gainmode (gm)
        ,feedback (fb)
        ,nsends (0)
+       ,_last_gain (0.0)
 {
        addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
+       as = ARDOUR::AutoState::Off;
 
        if (feedback[0]) { // buttons are separate feedback
                _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
@@ -99,12 +101,15 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address
        }
 
        if (feedback[1]) { // level controls
+               boost::shared_ptr<GainControl> gain_cont = _strip->gain_control();
                if (gainmode) {
-                       _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());
+                       gain_cont->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, bind (&OSCSelectObserver::gain_automation, this, X_("/select/fader")), OSC::instance());
+                       gain_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/fader"), gain_cont), OSC::instance());
+                       gain_automation ("/select/fader");
                } else {
-                       _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());
+                       gain_cont->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, bind (&OSCSelectObserver::gain_automation, this, X_("/select/gain")), OSC::instance());
+                       gain_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/gain"), _strip->gain_control()), OSC::instance());
+                       gain_automation ("/strip/gain");
                }
 
                boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
@@ -366,6 +371,18 @@ OSCSelectObserver::tick ()
                        }
                }
        }
+       if (feedback[1]) {
+               if (as != ARDOUR::AutoState::Off) {
+                       if(_last_gain != _strip->gain_control()->get_value()) {
+                               _last_gain = _strip->gain_control()->get_value();
+                               if (gainmode) {
+                                       gain_message ("/select/fader", _strip->gain_control());
+                               } else {
+                                       gain_message ("/select/fader", _strip->gain_control());
+                               }
+                       }
+               }
+       }
 
 }
 
@@ -510,6 +527,20 @@ OSCSelectObserver::gain_message (string path, boost::shared_ptr<Controllable> co
        lo_message_free (msg);
 }
 
+void
+OSCSelectObserver::gain_automation (string path)
+{
+       lo_message msg = lo_message_new ();
+       string apath = string_compose ("%1/automation", path);
+
+       boost::shared_ptr<GainControl> control = _strip->gain_control();
+       as = control->alist()->automation_state();
+       lo_message_add_float (msg, as);
+       gain_message (path, control);
+       lo_send_message (addr, apath.c_str(), msg);
+       lo_message_free (msg);
+}
+
 void
 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
 {
index b004f938d9cad7826932303d32b76049b07ba627..a603d12fd46c3f72814b6f918b4c0ec59ec139df 100644 (file)
@@ -58,7 +58,8 @@ class OSCSelectObserver
        uint32_t gain_timeout;
        float _last_meter;
        uint32_t nsends;
-
+       float _last_gain;
+       ARDOUR::AutoState as;
 
        void name_changed (const PBD::PropertyChange& what_changed);
        void change_message (std::string path, boost::shared_ptr<PBD::Controllable> controllable);
@@ -70,6 +71,7 @@ class OSCSelectObserver
        void text_with_id (std::string path, uint32_t id, std::string name);
        void monitor_status (boost::shared_ptr<PBD::Controllable> controllable);
        void gain_message (std::string path, boost::shared_ptr<PBD::Controllable> controllable);
+       void gain_automation (std::string path);
        void trim_message (std::string path, boost::shared_ptr<PBD::Controllable> controllable);
        // sends stuff
        void send_init (void);