From 82fed14f41f1d480fef400384d81838d1edf3d32 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Tue, 9 May 2017 14:10:49 -0700 Subject: [PATCH] OSC: Fix select fader automation play feedback as well fixes issue #7160 --- libs/surfaces/osc/osc_select_observer.cc | 39 +++++++++++++++++++++--- libs/surfaces/osc/osc_select_observer.h | 4 ++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/osc/osc_select_observer.cc b/libs/surfaces/osc/osc_select_observer.cc index b11d277947..2cc42569cc 100644 --- a/libs/surfaces/osc/osc_select_observer.cc +++ b/libs/surfaces/osc/osc_select_observer.cc @@ -49,8 +49,10 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr 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 s, lo_address } if (feedback[1]) { // level controls + boost::shared_ptr 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 trim_controllable = boost::dynamic_pointer_cast(_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 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 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 controllable) { diff --git a/libs/surfaces/osc/osc_select_observer.h b/libs/surfaces/osc/osc_select_observer.h index b004f938d9..a603d12fd4 100644 --- a/libs/surfaces/osc/osc_select_observer.h +++ b/libs/surfaces/osc/osc_select_observer.h @@ -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 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 controllable); void gain_message (std::string path, boost::shared_ptr controllable); + void gain_automation (std::string path); void trim_message (std::string path, boost::shared_ptr controllable); // sends stuff void send_init (void);