OSC: Add fake timeout based touch
authorLen Ovens <len@ovenwerks.net>
Thu, 18 May 2017 22:25:15 +0000 (15:25 -0700)
committerLen Ovens <len@ovenwerks.net>
Thu, 18 May 2017 22:32:12 +0000 (15:32 -0700)
libs/surfaces/osc/osc.cc
libs/surfaces/osc/osc.h

index ff9e8aaf90ae4eeea612c650e6b1af9fff0000d4..fc72e96d6fa65f2ac27ecb53a89e9c446f27fe53 100644 (file)
@@ -2349,6 +2349,20 @@ OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
        return ret;
 }
 
+int
+OSC::fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl)
+{
+       if (ctrl) {
+               //start touch
+               if (!ctrl->touching ()) {
+               ctrl->start_touch (ctrl->session().transport_frame());
+               }
+               _touch_timeout[ctrl] = 10;
+       }
+
+       return 0;
+}
+
 int
 OSC::route_mute (int ssid, int yn, lo_message msg)
 {
@@ -2834,6 +2848,7 @@ OSC::route_set_gain_abs (int ssid, float level, lo_message msg)
 
        if (s) {
                if (s->gain_control()) {
+                       fake_touch (s->gain_control());
                        s->gain_control()->set_value (level, PBD::Controllable::NoGroup);
                } else {
                        return 1;
@@ -2882,6 +2897,7 @@ OSC::sel_gain (float val, lo_message msg)
                        abs = dB_to_coefficient (val);
                }
                if (s->gain_control()) {
+                       fake_touch (s->gain_control());
                        s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
                        return 0;
                }
@@ -2918,6 +2934,7 @@ OSC::sel_fader (float val, lo_message msg)
                float abs;
                abs = slider_position_to_gain_with_max (val, 2.0);
                if (s->gain_control()) {
+                       fake_touch (s->gain_control());
                        s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
                        return 0;
                }
@@ -3952,6 +3969,17 @@ OSC::periodic (void)
                        co->tick();
                }
        }
+       for (FakeTouchMap::iterator x = _touch_timeout.begin(); x != _touch_timeout.end();) {
+               _touch_timeout[(*x).first] = (*x).second - 1;
+               if (!(*x).second) {
+                       boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
+                       // turn touch off
+                       ctrl->stop_touch (true, ctrl->session().transport_frame());
+                       x = _touch_timeout.erase (x);
+               } else {
+                       ++x;
+               }
+       }
        return true;
 }
 
index b87994c30eff8657ff7c583e81ff959c499a967f..3d53eef9440680fb8c23262d47501be4b018a39d 100644 (file)
@@ -110,6 +110,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
 
        typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > Sorted;
        Sorted get_sorted_stripables(std::bitset<32> types, bool cue);
+       typedef std::map<boost::shared_ptr<ARDOUR::AutomationControl>, uint32_t> FakeTouchMap;
+       FakeTouchMap _touch_timeout;
 
 // keep a surface's global setup by remote server url
        struct OSCSurface {
@@ -232,6 +234,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
 
        int set_automation (const char *path, lo_arg **argv, int argc, lo_message msg);
        int touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg);
+       int fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl);
 
        int route_get_sends (lo_message msg);
        int route_get_receives(lo_message msg);