OSC: Further fixes so multiple controls can touch at once.
[ardour.git] / libs / surfaces / osc / osc.cc
index 282873053e46808025f6ee7432af6af11f0675f9..70b02a7501c324e83cd3f053283c434bfd0591ef 100644 (file)
@@ -245,9 +245,6 @@ OSC::start ()
        periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
        periodic_timeout->attach (main_loop()->get_context());
 
-       // catch changes to selection for GUI_select mode
-       StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this), this);
-
        // catch track reordering
        // receive routes added
        session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this);
@@ -862,6 +859,14 @@ 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);
+
+       } else
+       if (strstr (path, "/touch")) {
+               ret = touch_detect (path, argv, argc, msg);
+
+       } else
        if (len >= 17 && !strcmp (&path[len-15], "/#current_value")) {
                current_value_query (path, len, argv, argc, msg);
                ret = 0;
@@ -869,21 +874,21 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        } else
        if (!strncmp (path, "/cue/", 5)) {
 
-               cue_parse (path, types, argv, argc, msg);
+               ret = cue_parse (path, types, argv, argc, msg);
 
-               ret = 0;
        } else
        if (!strncmp (path, "/access_action/", 15)) {
+               check_surface (msg);
                if (!(argc && !argv[0]->i)) {
                        std::string action_path = path;
 
                        access_action (action_path.substr(15));
-                       std::cout << "access_action path = " << action_path.substr(15) << "\n";
                }
 
                ret = 0;
        } else
        if (strcmp (path, "/strip/listen") == 0) {
+               check_surface (msg);
 
                cerr << "set up listener\n";
 
@@ -915,6 +920,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
 
        } else
        if (strcmp (path, "/strip/ignore") == 0) {
+               check_surface (msg);
 
                for (int n = 0; n < argc; ++n) {
 
@@ -930,99 +936,83 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        if (!strncmp (path, "/strip/gain/", 12) && strlen (path) > 12) {
                // in dB
                int ssid = atoi (&path[12]);
-               route_set_gain_dB (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = route_set_gain_dB (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/strip/fader/", 13) && strlen (path) > 13) {
                // in fader position
                int ssid = atoi (&path[13]);
-               route_set_gain_fader (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = route_set_gain_fader (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/strip/trimdB/", 14) && strlen (path) > 14) {
                int ssid = atoi (&path[14]);
-               route_set_trim_dB (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = route_set_trim_dB (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/strip/pan_stereo_position/", 27) && strlen (path) > 27) {
                int ssid = atoi (&path[27]);
-               route_set_pan_stereo_position (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = route_set_pan_stereo_position (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/strip/mute/", 12) && strlen (path) > 12) {
                int ssid = atoi (&path[12]);
-               route_mute (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_mute (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/solo/", 12) && strlen (path) > 12) {
                int ssid = atoi (&path[12]);
-               route_solo (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_solo (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/monitor_input/", 21) && strlen (path) > 21) {
                int ssid = atoi (&path[21]);
-               route_monitor_input (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_monitor_input (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/monitor_disk/", 20) && strlen (path) > 20) {
                int ssid = atoi (&path[20]);
-               route_monitor_disk (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_monitor_disk (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/recenable/", 17) && strlen (path) > 17) {
                int ssid = atoi (&path[17]);
-               route_recenable (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_recenable (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/record_safe/", 19) && strlen (path) > 19) {
                int ssid = atoi (&path[19]);
-               route_recsafe (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = route_recsafe (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/expand/", 14) && strlen (path) > 14) {
                int ssid = atoi (&path[14]);
-               strip_expand (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = strip_expand (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) {
                int ssid = atoi (&path[14]);
-               strip_gui_select (ssid, argv[0]->i, msg);
-               ret = 0;
+               ret = strip_gui_select (ssid, argv[0]->i, msg);
        }
        else if (!strncmp (path, "/select/send_gain/", 18) && strlen (path) > 18) {
                int ssid = atoi (&path[18]);
-               sel_sendgain (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_sendgain (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/select/send_fader/", 19) && strlen (path) > 19) {
                int ssid = atoi (&path[19]);
-               sel_sendfader (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_sendfader (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/select/send_enable/", 20) && strlen (path) > 20) {
                int ssid = atoi (&path[20]);
-               sel_sendenable (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_sendenable (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/select/eq_gain/", 16) && strlen (path) > 16) {
                int ssid = atoi (&path[16]);
-               sel_eq_gain (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_eq_gain (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/select/eq_freq/", 16) && strlen (path) > 16) {
                int ssid = atoi (&path[16]);
-               sel_eq_freq (ssid, argv[0]->f , msg);
-               ret = 0;
+               ret = sel_eq_freq (ssid, argv[0]->f , msg);
        }
        else if (!strncmp (path, "/select/eq_q/", 13) && strlen (path) > 13) {
                int ssid = atoi (&path[13]);
-               sel_eq_q (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_eq_q (ssid, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/select/eq_shape/", 17) && strlen (path) > 17) {
                int ssid = atoi (&path[17]);
-               sel_eq_shape (ssid, argv[0]->f, msg);
-               ret = 0;
+               ret = sel_eq_shape (ssid, argv[0]->f, msg);
+       }
+       if (ret) {
+               check_surface (msg);
        }
 
        if ((ret && _debugmode != Off)) {
@@ -1335,7 +1325,8 @@ OSC::clear_devices ()
        for (CueObservers::iterator x = cue_observers.begin(); x != cue_observers.end();) {
                OSCCueObserver* co;
                if ((co = dynamic_cast<OSCCueObserver*>(*x)) != 0) {
-                       delete co;
+                       delete *x;
+                       x = cue_observers.erase (x);
                } else {
                        ++x;
                }
@@ -1412,11 +1403,27 @@ OSC::set_surface_gainmode (uint32_t gm, lo_message msg)
        return 0;
 }
 
+int
+OSC::check_surface (lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       get_surface(get_address (msg));
+       return 0;
+}
+
 OSC::OSCSurface *
 OSC::get_surface (lo_address addr)
 {
        string r_url;
        char * rurl;
+       if (address_only) {
+               string host = lo_address_get_hostname (addr);
+               int protocol = lo_address_get_protocol (addr);
+               addr = lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str());
+       }
+
        rurl = lo_address_get_url (addr);
        r_url = rurl;
        free (rurl);
@@ -1435,6 +1442,8 @@ OSC::get_surface (lo_address addr)
        // No surface create one with default values
        OSCSurface s;
        s.remote_url = r_url;
+       s.no_clear = false;
+       s.jogmode = JOG;
        s.bank = 1;
        s.bank_size = default_banksize; // need to find out how many strips there are
        s.strip_types = default_strip; // 159 is tracks, busses, and VCAs (no master/monitor)
@@ -1444,11 +1453,18 @@ OSC::get_surface (lo_address addr)
        s.expand = 0;
        s.expand_enable = false;
        s.cue = false;
+       s.aux = 0;
        s.strips = get_sorted_stripables(s.strip_types, s.cue);
 
        s.nstrips = s.strips.size();
        _surface.push_back (s);
 
+       // set bank and strip feedback
+       _set_bank(s.bank, addr);
+
+       // Set global/master feedback
+       global_feedback (s.feedback, addr, s.gainmode);
+
        return &_surface[_surface.size() - 1];
 }
 
@@ -1711,6 +1727,7 @@ OSC::transport_frame (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        framepos_t pos = session->transport_frame ();
 
        lo_message reply = lo_message_new ();
@@ -1727,6 +1744,7 @@ OSC::transport_speed (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        double ts = session->transport_speed ();
 
        lo_message reply = lo_message_new ();
@@ -1743,6 +1761,7 @@ OSC::record_enabled (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        int re = (int)session->get_record_enabled ();
 
        lo_message reply = lo_message_new ();
@@ -1757,6 +1776,7 @@ int
 OSC::scrub (float delta, lo_message msg)
 {
        if (!session) return -1;
+       check_surface (msg);
 
        scrub_place = session->transport_frame ();
 
@@ -1967,6 +1987,7 @@ int
 OSC::master_set_pan_stereo_position (float position, lo_message msg)
 {
        if (!session) return -1;
+       OSCSurface *sur = get_surface(get_address (msg));
 
        float endposition = .5;
        boost::shared_ptr<Stripable> s = session->master_out();
@@ -1977,7 +1998,6 @@ OSC::master_set_pan_stereo_position (float position, lo_message msg)
                        endposition = s->pan_azimuth_control()->internal_to_interface (s->pan_azimuth_control()->get_value ());
                }
        }
-       OSCSurface *sur = get_surface(get_address (msg));
 
        if (sur->feedback[4]) {
                lo_message reply = lo_message_new ();
@@ -2179,6 +2199,174 @@ OSC::route_get_receives(lo_message msg) {
 }
 
 // strip calls
+
+int
+OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
+{
+       if (!session) return -1;
+
+       int ret = 1;
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
+       uint32_t ctr = 0;
+       uint32_t aut = 0;
+
+       if (argc) {
+               if (argv[argc - 1]->f) {
+                       aut = (int)argv[argc - 1]->f;
+               } else {
+                       aut = argv[argc - 1]->i;
+               }
+       }
+
+       //parse path first to find stripable
+       if (!strncmp (path, "/strip/", 7)) {
+               // find ssid and stripable
+               if (argc > 1) {
+                       strp = get_strip (argv[0]->i, get_address (msg));
+               } else {
+                       uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
+                       strp = get_strip (ssid, get_address (msg));
+               }
+               ctr = 7;
+       } else if (!strncmp (path, "/select/", 8)) {
+               if (sur->expand_enable && sur->expand) {
+                       strp = get_strip (sur->expand, get_address (msg));
+               } else {
+                       strp = ControlProtocol::first_selected_stripable();
+               }
+               ctr = 8;
+       } else {
+               return ret;
+       }
+       if (strp) {
+               boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
+               // other automatable controls can be added by repeating the next 6.5 lines
+               if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
+                       if (strp->gain_control ()) {
+                               control = strp->gain_control ();
+                       } else {
+                               PBD::warning << "No fader for this strip" << endmsg;
+                       }
+               } else {
+                       PBD::warning << "Automation not available for " << path << endmsg;
+               }
+
+               if (control) {
+
+                       switch (aut) {
+                               case 0:
+                                       control->set_automation_state (ARDOUR::Off);
+                                       ret = 0;
+                                       break;
+                               case 1:
+                                       control->set_automation_state (ARDOUR::Play);
+                                       ret = 0;
+                                       break;
+                               case 2:
+                                       control->set_automation_state (ARDOUR::Write);
+                                       ret = 0;
+                                       break;
+                               case 3:
+                                       control->set_automation_state (ARDOUR::Touch);
+                                       ret = 0;
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+int
+OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
+{
+       if (!session) return -1;
+
+       int ret = 1;
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
+       uint32_t ctr = 0;
+       uint32_t touch = 0;
+
+       if (argc) {
+               if (argv[argc - 1]->f) {
+                       touch = (int)argv[argc - 1]->f;
+               } else {
+                       touch = argv[argc - 1]->i;
+               }
+       }
+
+       //parse path first to find stripable
+       if (!strncmp (path, "/strip/", 7)) {
+               // find ssid and stripable
+               if (argc > 1) {
+                       strp = get_strip (argv[0]->i, get_address (msg));
+               } else {
+                       uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
+                       strp = get_strip (ssid, get_address (msg));
+               }
+               ctr = 7;
+       } else if (!strncmp (path, "/select/", 8)) {
+               if (sur->expand_enable && sur->expand) {
+                       strp = get_strip (sur->expand, get_address (msg));
+               } else {
+                       strp = ControlProtocol::first_selected_stripable();
+               }
+               ctr = 8;
+       } else {
+               return ret;
+       }
+       if (strp) {
+               boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
+               // other automatable controls can be added by repeating the next 6.5 lines
+               if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
+                       if (strp->gain_control ()) {
+                               control = strp->gain_control ();
+                       } else {
+                               PBD::warning << "No fader for this strip" << endmsg;
+                       }
+               } else {
+                       PBD::warning << "Automation not available for " << path << endmsg;
+               }
+
+               if (control) {
+                       if (touch) {
+                               //start touch
+                               if (control->automation_state() == Touch && !control->touching ()) {
+                                       control->start_touch (control->session().transport_frame());
+                               }
+                       } else {
+                               // end touch
+                               control->stop_touch (true, control->session().transport_frame());
+                       }
+                       // just in case some crazy surface starts sending control values before touch
+                       FakeTouchMap::iterator x = _touch_timeout.find(control);
+                       if (x != _touch_timeout.end()) {
+                               _touch_timeout.erase (x);
+                       }
+               }
+       }
+
+       return ret;
+}
+
+int
+OSC::fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl)
+{
+       if (ctrl) {
+               //start touch
+               if (ctrl->automation_state() == Touch && !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)
 {
@@ -2664,6 +2852,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;
@@ -2712,6 +2901,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;
                }
@@ -2748,6 +2938,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;
                }
@@ -3603,13 +3794,14 @@ OSC::sel_eq_hpf (float val, lo_message msg)
                s = _select;
        }
        if (s) {
-               if (s->eq_hpf_controllable()) {
-                       s->eq_hpf_controllable()->set_value (s->eq_hpf_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
+               if (s->filter_freq_controllable(true)) {
+                       s->filter_freq_controllable(true)->set_value (s->filter_freq_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
                        return 0;
                }
        }
        return sel_fail ("eq_hpf", 0, get_address (msg));
 }
+// need to add two more filter controls
 
 int
 OSC::sel_eq_gain (int id, float val, lo_message msg)
@@ -3781,6 +3973,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());
+                       _touch_timeout.erase (x++);
+               } else {
+                       x++;
+               }
+       }
        return true;
 }
 
@@ -3931,6 +4134,10 @@ OSC::set_state (const XMLNode& node, int version)
                        s.expand_enable = false;
                        s.strips = get_sorted_stripables (s.strip_types, s.cue);
                        s.nstrips = s.strips.size ();
+                       s.no_clear = false;
+                       s.jogmode = JOG;
+                       s.cue = false;
+                       s.aux = 0;
                        _surface.push_back (s);
                }
        }
@@ -3997,17 +4204,13 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue)
                                                sorted.push_back (s);
                                        }
                                }
-                       } else
-                       if (types[3] && (s->presentation_info().flags() & PresentationInfo::MidiBus)) {
+                       } else if (types[3] && (s->presentation_info().flags() & PresentationInfo::MidiBus)) {
                                sorted.push_back (s);
-                       } else
-                       if (types[4] && (s->presentation_info().flags() & PresentationInfo::VCA)) {
+                       } else if (types[4] && (s->presentation_info().flags() & PresentationInfo::VCA)) {
                                sorted.push_back (s);
-                       } else
-                       if (types[8] && (s->presentation_info().flags() & PresentationInfo::Selected)) {
+                       } else if (types[8] && (s->is_selected())) {
                                sorted.push_back (s);
-                       } else
-                       if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
+                       } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
                                sorted.push_back (s);
                        }
                }
@@ -4030,47 +4233,39 @@ OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo
 
        if (!strncmp (path, "/cue/aux", 8)) {
                // set our Aux bus
-               cue_set (argv[0]->i, msg);
-               ret = 0;
+               ret = cue_set (argv[0]->i, msg);
        }
        else if (!strncmp (path, "/cue/connect", 12)) {
-               // switch to next Aux bus
-               cue_set (0, msg);
-               ret = 0;
+               // Connect to default Aux bus
+               if ((!argc) || argv[0]->i) {
+                       ret = cue_set (1, msg);
+               }
        }
        else if (!strncmp (path, "/cue/next_aux", 13)) {
                // switch to next Aux bus
-               cue_next (msg);
-               ret = 0;
+               if ((!argc) || argv[0]->i) {
+                       ret = cue_next (msg);
+               }
        }
        else if (!strncmp (path, "/cue/previous_aux", 17)) {
                // switch to previous Aux bus
-               cue_previous (msg);
-               ret = 0;
+               if ((!argc) || argv[0]->i) {
+                       ret = cue_previous (msg);
+               }
        }
        else if (!strncmp (path, "/cue/send/fader/", 16) && strlen (path) > 16) {
                int id = atoi (&path[16]);
-               cue_send_fader (id, argv[0]->f, msg);
-               ret = 0;
+               ret = cue_send_fader (id, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/cue/send/enable/", 17) && strlen (path) > 17) {
                int id = atoi (&path[17]);
-               cue_send_enable (id, argv[0]->f, msg);
-               ret = 0;
+               ret = cue_send_enable (id, argv[0]->f, msg);
        }
        else if (!strncmp (path, "/cue/fader", 10)) {
-               cue_aux_fader (argv[0]->f, msg);
-               ret = 0;
+               ret = cue_aux_fader (argv[0]->f, msg);
        }
        else if (!strncmp (path, "/cue/mute", 9)) {
-               cue_aux_mute (argv[0]->f, msg);
-               ret = 0;
-       }
-
-       if ((ret && _debugmode == Unhandled)) {
-               debugmsg (_("Unhandled OSC cue message"), path, types, argv, argc);
-       } else if ((!ret && _debugmode == All)) {
-               debugmsg (_("OSC cue"), path, types, argv, argc);
+               ret = cue_aux_mute (argv[0]->f, msg);
        }
 
        return ret;
@@ -4085,18 +4280,26 @@ OSC::cue_set (uint32_t aux, lo_message msg)
 int
 OSC::_cue_set (uint32_t aux, lo_address addr)
 {
+       int ret = 1;
        OSCSurface *s = get_surface(addr);
        s->bank_size = 0;
        s->strip_types = 128;
        s->feedback = 0;
        s->gainmode = 1;
        s->cue = true;
-       s->aux = aux;
        s->strips = get_sorted_stripables(s->strip_types, s->cue);
 
        s->nstrips = s->strips.size();
+
+       if (aux < 1) {
+               aux = 1;
+       } else if (aux > s->nstrips) {
+               aux = s->nstrips;
+       }
+       s->aux = aux;
+
        // get rid of any old CueObsevers for this address
-       cueobserver_connections.drop_connections ();
+       //cueobserver_connections.drop_connections ();
        CueObservers::iterator x;
        for (x = cue_observers.begin(); x != cue_observers.end();) {
 
@@ -4132,34 +4335,44 @@ OSC::_cue_set (uint32_t aux, lo_address addr)
                                // start cue observer
                                OSCCueObserver* co = new OSCCueObserver (stp, s->sends, addr);
                                cue_observers.push_back (co);
+                               ret = 0;
                        }
 
                }
        }
 
-       return 0;
+       return ret;
 }
 
 int
 OSC::cue_next (lo_message msg)
 {
        OSCSurface *s = get_surface(get_address (msg));
+       int ret = 1;
+
+       if (!s->cue) {
+               ret = cue_set (1, msg);
+       }
        if (s->aux < s->nstrips) {
-               cue_set (s->aux + 1, msg);
+               ret = cue_set (s->aux + 1, msg);
        } else {
-               cue_set (s->nstrips, msg);
+               ret = cue_set (s->nstrips, msg);
        }
-       return 0;
+       return ret;
 }
 
 int
 OSC::cue_previous (lo_message msg)
 {
        OSCSurface *s = get_surface(get_address (msg));
+       int ret = 1;
+       if (!s->cue) {
+               ret = cue_set (1, msg);
+       }
        if (s->aux > 1) {
-               cue_set (s->aux - 1, msg);
+               ret = cue_set (s->aux - 1, msg);
        }
-       return 0;
+       return ret;
 }
 
 boost::shared_ptr<Send>
@@ -4197,7 +4410,8 @@ OSC::cue_aux_fader (float position, lo_message msg)
                        }
                }
        }
-       return cue_float_message ("/cue/fader", 0, get_address (msg));
+       cue_float_message ("/cue/fader", 0, get_address (msg));
+       return -1;
 }
 
 int
@@ -4217,7 +4431,8 @@ OSC::cue_aux_mute (float state, lo_message msg)
                        }
                }
        }
-       return cue_float_message ("/cue/mute", 0, get_address (msg));
+       cue_float_message ("/cue/mute", 0, get_address (msg));
+       return -1;
 }
 
 int
@@ -4235,7 +4450,8 @@ OSC::cue_send_fader (uint32_t id, float val, lo_message msg)
                        return 0;
                }
        }
-       return cue_float_message (string_compose ("/cue/send/fader/%1", id), 0, get_address (msg));
+       cue_float_message (string_compose ("/cue/send/fader/%1", id), 0, get_address (msg));
+       return -1;
 }
 
 int
@@ -4252,7 +4468,8 @@ OSC::cue_send_enable (uint32_t id, float state, lo_message msg)
                }
                return 0;
        }
-       return cue_float_message (string_compose ("/cue/send/enable/%1", id), 0, get_address (msg));
+       cue_float_message (string_compose ("/cue/send/enable/%1", id), 0, get_address (msg));
+       return -1;
 }
 
 int