OSC: reduce feedback noise for surfaces using /strip/list
authorLen Ovens <len@ovenwerks.net>
Mon, 27 Mar 2017 04:16:45 +0000 (21:16 -0700)
committerLen Ovens <len@ovenwerks.net>
Mon, 27 Mar 2017 04:16:45 +0000 (21:16 -0700)
libs/surfaces/osc/osc.cc
libs/surfaces/osc/osc_route_observer.cc
libs/surfaces/osc/osc_route_observer.h

index e5bcb4ed0a804f5a48b125dd0b070c3dfefbf47d..26477f3cbad09c02a98c8ace67f575c25213583c 100644 (file)
@@ -702,7 +702,7 @@ OSC::listen_to_route (boost::shared_ptr<Stripable> strip, lo_address addr)
 
        OSCSurface *s = get_surface(addr);
        uint32_t ssid = get_sid (strip, addr);
-       OSCRouteObserver* o = new OSCRouteObserver (strip, addr, ssid, s->gainmode, s->feedback);
+       OSCRouteObserver* o = new OSCRouteObserver (strip, addr, ssid, s);
        route_observers.push_back (o);
 
        strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::route_lost, this, boost::weak_ptr<Stripable> (strip)), this);
@@ -1231,8 +1231,8 @@ OSC::routes_list (lo_message msg)
                                lo_message_add_int32 (reply, s->rec_enable_control()->get_value());
                        }
 
-                       //Automatically listen to routes listed
-                       listen_to_route(r, get_address (msg));
+                       //Automatically listen to stripables listed
+                       listen_to_route(s, get_address (msg));
 
                        lo_send_message (get_address (msg), "#reply", reply);
                        lo_message_free (reply);
@@ -1583,7 +1583,7 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
                // top bank is always filled if there are enough strips for at least one bank
                bank_start = (uint32_t)((s->nstrips - b_size) + 1);
        }
-       //save bank in case we have had to change it
+       //save bank after bank limit checks
        s->bank = bank_start;
 
        if (s->feedback[0] || s->feedback[1]) {
@@ -1601,8 +1601,7 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
                }
        }
        // light bankup or bankdown buttons if it is possible to bank in that direction
-       if (s->feedback[4]) {
-               // these two messages could be bundled
+       if (s->feedback[4] && !s->no_clear) {
                lo_message reply;
                reply = lo_message_new ();
                if ((s->bank > (s->nstrips - s->bank_size)) || (s->nstrips < s->bank_size)) {
@@ -1924,7 +1923,8 @@ OSC::route_get_sends(lo_message msg) {
                        lo_message_add_int32(reply, p->active() ? 1 : 0);
                }
        }
-       // if used dedicated message path to identify this reply in async operation. Naming it #reply wont help the client to identify the content.
+       // if used dedicated message path to identify this reply in async operation.
+       // Naming it #reply wont help the client to identify the content.
        lo_send_message(get_address (msg), "/strip/sends", reply);
 
        lo_message_free(reply);
@@ -1986,7 +1986,8 @@ OSC::route_get_receives(lo_message msg) {
                }
        }
 
-       // I have used a dedicated message path to identify this reply in async operation. Naming it #reply wont help the client to identify the content.
+       // I have used a dedicated message path to identify this reply in async operation.
+       // Naming it #reply wont help the client to identify the content.
        lo_send_message(get_address (msg), "/strip/receives", reply);
        lo_message_free(reply);
        return 0;
index e22444e4c557695928a6b177c34cce4263b2dee0..dc7677c33171e2a3865a60f06fc0eabcfacbdfeb 100644 (file)
@@ -35,13 +35,14 @@ using namespace PBD;
 using namespace ARDOUR;
 using namespace ArdourSurface;
 
-OSCRouteObserver::OSCRouteObserver (boost::shared_ptr<Stripable> s, lo_address a, uint32_t ss, uint32_t gm, std::bitset<32> fb)
+OSCRouteObserver::OSCRouteObserver (boost::shared_ptr<Stripable> s, lo_address a, uint32_t ss, ArdourSurface::OSC::OSCSurface* su)
        : _strip (s)
        ,ssid (ss)
-       ,gainmode (gm)
-       ,feedback (fb)
+       ,sur (su)
 {
        addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
+       gainmode = sur->gainmode;
+       feedback = sur->feedback;
 
        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());
@@ -101,6 +102,12 @@ OSCRouteObserver::~OSCRouteObserver ()
 {
 
        strip_connections.drop_connections ();
+       if (sur->no_clear) {
+               // some surfaces destroy their own strips and don't need the extra noise
+               lo_address_free (addr);
+               return;
+       }
+
        // all strip buttons should be off and faders 0 and etc.
        clear_strip ("/strip/expand", 0);
        if (feedback[0]) { // buttons are separate feedback
index 321dc7ce21e879e9a2ed4dbf4e75b5d48347a59f..ef9bfb7ba2cf52d8e1e458240a5e5001092261d8 100644 (file)
 #include "pbd/stateful.h"
 #include "ardour/types.h"
 
+#include "osc.h"
+
 class OSCRouteObserver
 {
 
   public:
-       OSCRouteObserver (boost::shared_ptr<ARDOUR::Stripable>, lo_address addr, uint32_t sid, uint32_t gainmode, std::bitset<32> feedback);
+       OSCRouteObserver (boost::shared_ptr<ARDOUR::Stripable>, lo_address addr, uint32_t sid, ArdourSurface::OSC::OSCSurface* sur);
        ~OSCRouteObserver ();
 
        boost::shared_ptr<ARDOUR::Stripable> strip () const { return _strip; }
@@ -52,6 +54,7 @@ class OSCRouteObserver
        uint32_t ssid;
        uint32_t gainmode;
        std::bitset<32> feedback;
+       ArdourSurface::OSC::OSCSurface* sur;
        float _last_meter;
        uint32_t gain_timeout;
        uint32_t trim_timeout;