OSC: Some surfaces may use float for ssid. Accept this too.
[ardour.git] / libs / surfaces / osc / osc.cc
index e48d97324d3f21791149c1e4d3fcf9ce872e1ccc..4818f9340c9a47c23a4e8a0aba9282c41aa337c1 100644 (file)
@@ -575,7 +575,12 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, "/select/comp_mode", "f", sel_comp_mode);
                REGISTER_CALLBACK (serv, "/select/comp_makeup", "f", sel_comp_makeup);
                REGISTER_CALLBACK (serv, "/select/eq_enable", "f", sel_eq_enable);
-               REGISTER_CALLBACK (serv, "/select/eq_hpf", "f", sel_eq_hpf);
+               REGISTER_CALLBACK (serv, "/select/eq_hpf/freq", "f", sel_eq_hpf_freq);
+               REGISTER_CALLBACK (serv, "/select/eq_hpf/enable", "f", sel_eq_hpf_enable);
+               REGISTER_CALLBACK (serv, "/select/eq_hpf/slope", "f", sel_eq_hpf_slope);
+               REGISTER_CALLBACK (serv, "/select/eq_lpf/freq", "f", sel_eq_lpf_freq);
+               REGISTER_CALLBACK (serv, "/select/eq_lpf/enable", "f", sel_eq_lpf_enable);
+               REGISTER_CALLBACK (serv, "/select/eq_lpf/slope", "f", sel_eq_lpf_slope);
                REGISTER_CALLBACK (serv, "/select/eq_gain", "if", sel_eq_gain);
                REGISTER_CALLBACK (serv, "/select/eq_freq", "if", sel_eq_freq);
                REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q);
@@ -861,11 +866,11 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        len = strlen (path);
 
        if (strstr (path, "/automation")) {
-               ret = set_automation (path, argv, argc, msg);
+               ret = set_automation (path, types, argv, argc, msg);
 
        } else
        if (strstr (path, "/touch")) {
-               ret = touch_detect (path, argv, argc, msg);
+               ret = touch_detect (path, types, argv, argc, msg);
 
        } else
        if (len >= 17 && !strcmp (&path[len-15], "/#current_value")) {
@@ -2202,7 +2207,7 @@ OSC::route_get_receives(lo_message msg) {
 // strip calls
 
 int
-OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
+OSC::set_automation (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
 {
        if (!session) return -1;
 
@@ -2211,6 +2216,7 @@ OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
        boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
        uint32_t ctr = 0;
        uint32_t aut = 0;
+       uint32_t ssid;
 
        if (argc) {
                if (argv[argc - 1]->f) {
@@ -2224,9 +2230,14 @@ OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
        if (!strncmp (path, "/strip/", 7)) {
                // find ssid and stripable
                if (argc > 1) {
-                       strp = get_strip (argv[0]->i, get_address (msg));
+                       if (types[1] == 'f') {
+                               ssid = (uint32_t)argv[0]->f;
+                       } else {
+                               ssid = argv[0]->i;
+                       }
+                       strp = get_strip (ssid, get_address (msg));
                } else {
-                       uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
+                       ssid = atoi (&(strrchr (path, '/' ))[1]);
                        strp = get_strip (ssid, get_address (msg));
                }
                ctr = 7;
@@ -2282,7 +2293,7 @@ OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
 }
 
 int
-OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
+OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
 {
        if (!session) return -1;
 
@@ -2291,6 +2302,7 @@ OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
        boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
        uint32_t ctr = 0;
        uint32_t touch = 0;
+       uint32_t ssid;
 
        if (argc) {
                if (argv[argc - 1]->f) {
@@ -2304,9 +2316,14 @@ OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
        if (!strncmp (path, "/strip/", 7)) {
                // find ssid and stripable
                if (argc > 1) {
-                       strp = get_strip (argv[0]->i, get_address (msg));
+                       if (types[1] == 'f') {
+                               ssid = (uint32_t)argv[0]->f;
+                       } else {
+                               ssid = argv[0]->i;
+                       }
+                       strp = get_strip (ssid, get_address (msg));
                } else {
-                       uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
+                       ssid = atoi (&(strrchr (path, '/' ))[1]);
                        strp = get_strip (ssid, get_address (msg));
                }
                ctr = 7;
@@ -2338,10 +2355,12 @@ OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
                                //start touch
                                if (control->automation_state() == Touch && !control->touching ()) {
                                        control->start_touch (control->session().transport_frame());
+                                       ret = 0;
                                }
                        } else {
                                // end touch
                                control->stop_touch (true, control->session().transport_frame());
+                               ret = 0;
                        }
                        // just in case some crazy surface starts sending control values before touch
                        FakeTouchMap::iterator x = _touch_timeout.find(control);
@@ -3785,7 +3804,7 @@ OSC::sel_eq_enable (float val, lo_message msg)
 }
 
 int
-OSC::sel_eq_hpf (float val, lo_message msg)
+OSC::sel_eq_hpf_freq (float val, lo_message msg)
 {
        OSCSurface *sur = get_surface(get_address (msg));
        boost::shared_ptr<Stripable> s;
@@ -3800,9 +3819,103 @@ OSC::sel_eq_hpf (float val, lo_message msg)
                        return 0;
                }
        }
-       return sel_fail ("eq_hpf", 0, get_address (msg));
+       return sel_fail ("eq_hpf/freq", 0, get_address (msg));
+}
+
+int
+OSC::sel_eq_lpf_freq (float val, lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               if (s->filter_freq_controllable(false)) {
+                       s->filter_freq_controllable(false)->set_value (s->filter_freq_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return sel_fail ("eq_lpf/freq", 0, get_address (msg));
+}
+
+int
+OSC::sel_eq_hpf_enable (float val, lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               if (s->filter_enable_controllable(true)) {
+                       s->filter_enable_controllable(true)->set_value (s->filter_enable_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return sel_fail ("eq_hpf/enable", 0, get_address (msg));
+}
+
+int
+OSC::sel_eq_lpf_enable (float val, lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               if (s->filter_enable_controllable(false)) {
+                       s->filter_enable_controllable(false)->set_value (s->filter_enable_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return sel_fail ("eq_lpf/enable", 0, get_address (msg));
+}
+
+int
+OSC::sel_eq_hpf_slope (float val, lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               if (s->filter_slope_controllable(true)) {
+                       s->filter_slope_controllable(true)->set_value (s->filter_slope_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return sel_fail ("eq_hpf/slope", 0, get_address (msg));
+}
+
+int
+OSC::sel_eq_lpf_slope (float val, lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               if (s->filter_slope_controllable(false)) {
+                       s->filter_slope_controllable(false)->set_value (s->filter_slope_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return sel_fail ("eq_lpf/slope", 0, get_address (msg));
 }
-// need to add two more filter controls
 
 int
 OSC::sel_eq_gain (int id, float val, lo_message msg)