From bfbab2d0b57777659c1969530110c112613bb18c Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Sat, 17 Mar 2018 23:10:16 -0700 Subject: [PATCH] OSC: Add feedback for bus_only mode and automation and pan --- libs/surfaces/osc/osc.cc | 45 +++++++-- libs/surfaces/osc/osc_route_observer.cc | 120 +++++++++++++++++++----- libs/surfaces/osc/osc_route_observer.h | 4 + 3 files changed, 141 insertions(+), 28 deletions(-) diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index e17b208254..56d8ced698 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -29,6 +29,7 @@ #include #include "pbd/control_math.h" +#include "pbd/controllable.h" #include #include #include @@ -45,6 +46,8 @@ #include "ardour/dB.h" #include "ardour/filesystem_paths.h" #include "ardour/panner.h" +#include "ardour/panner_shell.h" +#include "ardour/pannable.h" #include "ardour/plugin.h" #include "ardour/plugin_insert.h" #include "ardour/presentation_info.h" @@ -2248,6 +2251,14 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) for (uint32_t i = 0; i < bank_size; i++) { OSCRouteObserver* o = new OSCRouteObserver (*this, i + 1, sur); sur->observers.push_back (o); + if (sur->custom_mode == 9) { + boost::shared_ptr str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str())); + boost::shared_ptr send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str())); + if (send) { + o->refresh_send (send, true); + } + } + } } } else { @@ -2255,6 +2266,12 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) for (uint32_t i = 0; i < sur->observers.size(); i++) { boost::shared_ptr str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str())); sur->observers[i]->refresh_strip(str, true); + if (sur->custom_mode == 9) { + boost::shared_ptr send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str())); + if (send) { + sur->observers[i]->refresh_send (send, true); + } + } } } } @@ -3692,6 +3709,7 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg uint32_t ctr = 0; uint32_t aut = 0; uint32_t ssid; + boost::shared_ptr send = boost::shared_ptr (); if (argc) { if (types[argc - 1] == 'f') { @@ -3715,13 +3733,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg ssid = atoi (&(strrchr (path, '/' ))[1]); strp = get_strip (ssid, get_address (msg)); } + send = get_send (strp, get_address (msg)); ctr = 7; } else if (!strncmp (path, X_("/select/"), 8)) { - if (sur->expand_enable && sur->expand) { - strp = get_strip (sur->expand, get_address (msg)); - } else { - strp = _select; - } + strp = sur->select; ctr = 8; } else { return ret; @@ -3735,6 +3750,9 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg } else { PBD::warning << "No fader for this strip" << endmsg; } + if (send) { + control = send->gain_control (); + } } else { PBD::warning << "Automation not available for " << path << endmsg; } @@ -3758,6 +3776,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg control->set_automation_state (ARDOUR::Touch); ret = 0; break; + case 4: + control->set_automation_state (ARDOUR::Latch); + ret = 0; + break; default: break; } @@ -4773,8 +4795,17 @@ OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { - if(s->pan_azimuth_control()) { - s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup); + boost::shared_ptr pan_control = boost::shared_ptr(); + if (sur->custom_mode == 9 && get_send (s, get_address (msg))) { + boost::shared_ptr send = get_send (s, get_address (msg)); + if (send->pan_outs() > 1) { + pan_control = send->panner_shell()->panner()->pannable()->pan_azimuth_control; + } + } else { + pan_control = s->pan_azimuth_control(); + } + if(pan_control) { + pan_control->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup); return 0; } } diff --git a/libs/surfaces/osc/osc_route_observer.cc b/libs/surfaces/osc/osc_route_observer.cc index 969cd59cc8..c22e539b3a 100644 --- a/libs/surfaces/osc/osc_route_observer.cc +++ b/libs/surfaces/osc/osc_route_observer.cc @@ -28,8 +28,12 @@ #include "ardour/monitor_control.h" #include "ardour/dB.h" #include "ardour/meter.h" +#include "ardour/panner.h" +#include "ardour/panner_shell.h" +#include "ardour/pannable.h" #include "ardour/route.h" #include "ardour/route_group.h" +#include "ardour/send.h" #include "ardour/solo_isolate_control.h" #include "osc.h" @@ -75,6 +79,7 @@ OSCRouteObserver::OSCRouteObserver (OSC& o, uint32_t ss, ArdourSurface::OSC::OSC } else { set_expand (0); } + _send = boost::shared_ptr (); } OSCRouteObserver::~OSCRouteObserver () @@ -109,6 +114,7 @@ OSCRouteObserver::refresh_strip (boost::shared_ptr new_strip, } _last_gain =-1.0; _last_trim =-1.0; + _send = boost::shared_ptr (); send_select_status (ARDOUR::Properties::selected); @@ -177,9 +183,9 @@ OSCRouteObserver::refresh_strip (boost::shared_ptr new_strip, } if (feedback[1]) { // level controls - boost::shared_ptr gain_cont = _strip->gain_control(); - gain_cont->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::gain_automation, this), OSC::instance()); - gain_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::send_gain_message, this), OSC::instance()); + _gain_control = _strip->gain_control(); + _gain_control->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::gain_automation, this), OSC::instance()); + _gain_control->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::send_gain_message, this), OSC::instance()); gain_automation (); boost::shared_ptr trim_controllable = boost::dynamic_pointer_cast(_strip->trim_control()); @@ -199,6 +205,60 @@ OSCRouteObserver::refresh_strip (boost::shared_ptr new_strip, } +void +OSCRouteObserver::refresh_send (boost::shared_ptr new_send, bool force) +{ + _init = true; + if (_tick_busy) { + Glib::usleep(100); // let tick finish + } + _last_gain =-1.0; + _last_trim =-1.0; + + send_select_status (ARDOUR::Properties::selected); + + if ((new_send == _send) && !force) { + // no change don't send feedback + _init = false; + return; + } + strip_connections.drop_connections (); + if (!_strip) { + // this strip is blank and should be cleared + clear_strip (); + return; + } + _send = new_send; + send_clear (); + _strip->DropReferences.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::no_strip, this), OSC::instance()); + as = ARDOUR::Off; + + if (feedback[0]) { // buttons are separate feedback + _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::name_changed, this, boost::lambda::_1), OSC::instance()); + name_changed (ARDOUR::Properties::name); + } + + if (feedback[1]) { // level controls + _gain_control = _send->gain_control(); + _gain_control->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::gain_automation, this), OSC::instance()); + _gain_control->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::send_gain_message, this), OSC::instance()); + gain_automation (); + + if (_send->pan_outs() > 1) { + boost::shared_ptr pan_controllable = boost::dynamic_pointer_cast(_send->panner_shell()->panner()->pannable()->pan_azimuth_control); + if (pan_controllable) { + pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::send_change_message, this, X_("/strip/pan_stereo_position"), pan_controllable), OSC::instance()); + send_change_message (X_("/strip/pan_stereo_position"), pan_controllable); + } + } else { + _osc.float_message_with_id (X_("/strip/pan_stereo_position"), ssid, 0.5, in_line, addr); + } + } + _init = false; + tick(); + +} + void OSCRouteObserver::set_expand (uint32_t expand) { @@ -243,6 +303,23 @@ OSCRouteObserver::set_link_ready (uint32_t not_ready) void OSCRouteObserver::clear_strip () +{ + send_clear (); + if (feedback[0]) { // buttons are separate feedback + _osc.text_message_with_id (X_("/strip/name"), ssid, " ", in_line, addr); + } + if (feedback[1]) { // level controls + if (gainmode) { + _osc.float_message_with_id (X_("/strip/fader"), ssid, 0, in_line, addr); + } else { + _osc.float_message_with_id (X_("/strip/gain"), ssid, -193, in_line, addr); + } + _osc.float_message_with_id (X_("/strip/pan_stereo_position"), ssid, 0.5, in_line, addr); + } +} + +void +OSCRouteObserver::send_clear () { _init = true; @@ -251,7 +328,6 @@ OSCRouteObserver::clear_strip () // all strip buttons should be off and faders 0 and etc. _osc.float_message_with_id (X_("/strip/expand"), ssid, 0, in_line, addr); if (feedback[0]) { // buttons are separate feedback - _osc.text_message_with_id (X_("/strip/name"), ssid, " ", in_line, addr); _osc.text_message_with_id (X_("/strip/group"), ssid, "none", in_line, addr); _osc.float_message_with_id (X_("/strip/mute"), ssid, 0, in_line, addr); _osc.float_message_with_id (X_("/strip/solo"), ssid, 0, in_line, addr); @@ -263,13 +339,7 @@ OSCRouteObserver::clear_strip () _osc.float_message_with_id (X_("/strip/select"), ssid, 0, in_line, addr); } if (feedback[1]) { // level controls - if (gainmode) { - _osc.float_message_with_id (X_("/strip/fader"), ssid, 0, in_line, addr); - } else { - _osc.float_message_with_id (X_("/strip/gain"), ssid, -193, in_line, addr); - } _osc.float_message_with_id (X_("/strip/trimdB"), ssid, 0, in_line, addr); - _osc.float_message_with_id (X_("/strip/pan_stereo_position"), ssid, 0.5, in_line, addr); } if (feedback[9]) { _osc.float_message_with_id (X_("/strip/signal"), ssid, 0, in_line, addr); @@ -295,6 +365,9 @@ OSCRouteObserver::tick () _tick_busy = true; if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled // the only meter here is master + /* XXXX need to add send meter for send mode or + * disable for send mode + */ float now_meter; if (_strip->peak_meter()) { now_meter = _strip->peak_meter()->meter_level(0, MeterMCP); @@ -330,13 +403,13 @@ OSCRouteObserver::tick () if (feedback[1]) { if (gain_timeout) { if (gain_timeout == 1) { - _osc.text_message_with_id (X_("/strip/name"), ssid, _strip->name(), in_line, addr); + name_changed (ARDOUR::Properties::name); } gain_timeout--; } if (as == ARDOUR::Play || as == ARDOUR::Touch) { - if(_last_gain != _strip->gain_control()->get_value()) { - _last_gain = _strip->gain_control()->get_value(); + if(_last_gain != _gain_control->get_value()) { + _last_gain = _gain_control->get_value(); send_gain_message (); } } @@ -350,9 +423,15 @@ OSCRouteObserver::name_changed (const PBD::PropertyChange& what_changed) if (!what_changed.contains (ARDOUR::Properties::name)) { return; } + string name = ""; + if (!_send) { + name = _strip->name(); + } else { + name = string_compose ("%1-Send", _strip->name()); + } if (_strip) { - _osc.text_message_with_id (X_("/strip/name"), ssid, _strip->name(), in_line, addr); + _osc.text_message_with_id (X_("/strip/name"), ssid, name, in_line, addr); } } @@ -426,22 +505,21 @@ OSCRouteObserver::send_trim_message () void OSCRouteObserver::send_gain_message () { - boost::shared_ptr controllable = _strip->gain_control(); - if (_last_gain != controllable->get_value()) { - _last_gain = controllable->get_value(); + if (_last_gain != _gain_control->get_value()) { + _last_gain = _gain_control->get_value(); } else { return; } if (gainmode) { - _osc.float_message_with_id (X_("/strip/fader"), ssid, controllable->internal_to_interface (_last_gain), in_line, addr); + _osc.float_message_with_id (X_("/strip/fader"), ssid, _gain_control->internal_to_interface (_last_gain), in_line, addr); if (gainmode == 1) { - _osc.text_message_with_id (X_("/strip/name"), ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), in_line, addr); + _osc.text_message_with_id (X_("/strip/name"), ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (_last_gain)), in_line, addr); gain_timeout = 8; } } if (!gainmode || gainmode == 2) { - if (controllable->get_value() < 1e-15) { + if (_last_gain < 1e-15) { _osc.float_message_with_id (X_("/strip/gain"), ssid, -200, in_line, addr); } else { _osc.float_message_with_id (X_("/strip/gain"), ssid, accurate_coefficient_to_dB (_last_gain), in_line, addr); @@ -457,7 +535,7 @@ OSCRouteObserver::gain_automation () path = X_("/strip/fader"); } send_gain_message (); - as = _strip->gain_control()->alist()->automation_state(); + as = _gain_control->alist()->automation_state(); string auto_name; float output = 0; switch (as) { diff --git a/libs/surfaces/osc/osc_route_observer.h b/libs/surfaces/osc/osc_route_observer.h index 2fb040bedb..587b4aaa74 100644 --- a/libs/surfaces/osc/osc_route_observer.h +++ b/libs/surfaces/osc/osc_route_observer.h @@ -45,12 +45,15 @@ class OSCRouteObserver void tick (void); void send_select_status (const PBD::PropertyChange&); void refresh_strip (boost::shared_ptr strip, bool force); + void refresh_send (boost::shared_ptr send, bool force); void set_expand (uint32_t expand); void set_link_ready (uint32_t not_ready); void clear_strip (); private: boost::shared_ptr _strip; + boost::shared_ptr _send; + boost::shared_ptr _gain_control; PBD::ScopedConnectionList strip_connections; @@ -72,6 +75,7 @@ class OSCRouteObserver bool _tick_busy; + void send_clear (); void name_changed (const PBD::PropertyChange& what_changed); void group_name (); void pi_changed (PBD::PropertyChange const&);