OSC: reworking of previous/next select
[ardour.git] / libs / surfaces / osc / osc.cc
index 7c46f5bf6c14daf727d567466e2dd5e5b15b01b1..8e7351e3f87b9b87247afca9780ab900cee3f1e4 100644 (file)
@@ -588,6 +588,10 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, X_("/select/hide"), "i", sel_hide);
                REGISTER_CALLBACK (serv, X_("/select/bus/only"), "f", sel_bus_only);
                REGISTER_CALLBACK (serv, X_("/select/bus/only"), "", sel_bus_only);
+               REGISTER_CALLBACK (serv, X_("/select/previous"), "f", sel_previous);
+               REGISTER_CALLBACK (serv, X_("/select/previous"), "", sel_previous);
+               REGISTER_CALLBACK (serv, X_("/select/next"), "f", sel_next);
+               REGISTER_CALLBACK (serv, X_("/select/next"), "", sel_next);
                REGISTER_CALLBACK (serv, X_("/select/pan_stereo_position"), "f", sel_pan_position);
                REGISTER_CALLBACK (serv, X_("/select/pan_stereo_width"), "f", sel_pan_width);
                REGISTER_CALLBACK (serv, X_("/select/send_gain"), "if", sel_sendgain);
@@ -820,6 +824,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
                set = &(link_sets[ls]);
                sur->custom_mode = set->custom_mode;
                sur->custom_strips = set->custom_strips;
+               sur->temp_mode = set->temp_mode;
                sur->temp_strips = set->temp_strips;
        }
 
@@ -859,7 +864,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        if (strcmp (path, X_("/strip/listen")) == 0) {
                if (argc <= 0) {
                        PBD::warning << "OSC: Wrong number of parameters." << endmsg;
-               } else if (sur->custom_mode && (sur->custom_mode < GroupOnly)) {
+               } else if (sur->custom_mode && !sur->temp_mode) {
                        PBD::warning << "OSC: Can't add strips with custom enabled." << endmsg;
                } else {
                        for (int n = 0; n < argc; ++n) {
@@ -882,7 +887,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        if (strcmp (path, X_("/strip/ignore")) == 0) {
                if (argc <= 0) {
                        PBD::warning << "OSC: Wrong number of parameters." << endmsg;
-               } else if (!sur->custom_mode || (sur->custom_mode >= GroupOnly)) {
+               } else if (!sur->custom_mode || sur->temp_mode) {
                        PBD::warning << "OSC: Can't remove strips without custom enabled." << endmsg;
                } else {
                        for (int n = 0; n < argc; ++n) {
@@ -1321,6 +1326,7 @@ OSC::get_surfaces ()
                PBD::info << string_compose ("\n  Surface: %1 - URL: %2  %3\n", it, sur->remote_url, port);
                PBD::info << string_compose ("  Number of strips: %1   Bank size: %2   Current Bank %3\n", sur->nstrips, sur->bank_size, sur->bank);
                PBD::info << string_compose ("  Use Custom: %1   Custom Strips: %2\n", sur->custom_mode, sur->custom_strips.size ());
+               PBD::info << string_compose ("  Temp Mode: %1   Temp Strips: %2\n", sur->temp_mode, sur->temp_strips.size ());
                bool ug = false;
                if (sur->usegroup == PBD::Controllable::UseGroup) {
                        ug = true;
@@ -1349,6 +1355,7 @@ OSC::get_surfaces ()
                PBD::info << string_compose ("  Bank size: %1   Current bank: %2   Strip Types: %3\n", set->banksize, set->bank, set->strip_types.to_ulong());
                PBD::info << string_compose ("  Auto bank sizing: %1 Linkset not ready flag: %2\n", set->autobank, set->not_ready);
                PBD::info << string_compose ("  Use Custom: %1 Number of Custom Strips: %2\n", set->custom_mode, set->custom_strips.size ());
+               PBD::info << string_compose ("  Temp Mode: %1 Number of Temp Strips: %2\n", set->temp_mode, set->temp_strips.size ());
        }
        PBD::info << endmsg;
 }
@@ -1360,7 +1367,7 @@ OSC::custom_clear (lo_message msg)
                return 0;
        }
        OSCSurface *sur = get_surface(get_address (msg), true);
-       sur->custom_mode = CusOff;
+       sur->custom_mode = 0;
        sur->custom_strips.clear ();
        sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, false, sur->custom_strips);
        sur->nstrips = sur->strips.size();
@@ -1368,7 +1375,7 @@ OSC::custom_clear (lo_message msg)
        uint32_t ls = sur->linkset;
        if (ls) {
                set = &(link_sets[ls]);
-               set->custom_mode = CusOff;
+               set->custom_mode = 0;
                set->custom_strips.clear ();
                set->strips = sur->strips;
        }
@@ -1378,11 +1385,11 @@ OSC::custom_clear (lo_message msg)
 int
 OSC::custom_mode (float state, lo_message msg)
 {
-       return _custom_mode ((OSCCustomMode) (int)state, get_address (msg));
+       return _custom_mode ((uint32_t) state, get_address (msg));
 }
 
 int
-OSC::_custom_mode (OSCCustomMode state, lo_address addr)
+OSC::_custom_mode (uint32_t state, lo_address addr)
 {
        if (!session) {
                return 0;
@@ -1399,14 +1406,14 @@ OSC::_custom_mode (OSCCustomMode state, lo_address addr)
        if (state > 0){
                if (sur->custom_strips.size () == 0) {
                        PBD::warning << "No custom strips set to enable" << endmsg;
-                       sur->custom_mode = CusOff;
+                       sur->custom_mode = 0;
                        if (ls) {
-                               set->custom_mode = CusOff;
+                               set->custom_mode = 0;
                        }
                        return -1;
                } else {
                        if (sur->bank_size) {
-                               sur->custom_mode = (OSCCustomMode) (state | 0x4);
+                               sur->custom_mode = state | 0x4;
                        } else {
                                sur->custom_mode = state;
                        }
@@ -1414,7 +1421,7 @@ OSC::_custom_mode (OSCCustomMode state, lo_address addr)
                        sur->nstrips = sur->custom_strips.size();
                }
        } else {
-               sur->custom_mode = CusOff;
+               sur->custom_mode = 0;
                sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 0, sur->custom_strips);
                sur->nstrips = sur->strips.size();
        }
@@ -1584,6 +1591,7 @@ OSC::get_linkset (uint32_t set, lo_address addr)
                        new_ls.strips = sur->strips;
                        new_ls.custom_strips = sur->custom_strips;
                        new_ls.custom_mode = sur->custom_mode;
+                       new_ls.temp_mode = sur->temp_mode;
                        new_ls.urls.resize (2);
                        link_sets[set] = new_ls;
                }
@@ -1794,48 +1802,56 @@ OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc
                                } else {
                                        linkid = argv[8]->i;
                                }
+                               [[fallthrough]];
                        case 8:
                                if (types[7] == 'f') {
                                        linkset = (int) argv[7]->f;
                                } else {
                                        linkset = argv[7]->i;
                                }
+                               [[fallthrough]];
                        case 7:
                                if (types[6] == 'f') {
                                        port = (int) argv[6]->f;
                                } else {
                                        port = argv[6]->i;
                                }
+                               [[fallthrough]];
                        case 6:
                                if (types[5] == 'f') {
                                        pi_page = (int) argv[5]->f;
                                } else {
                                        pi_page = argv[5]->i;
                                }
+                               [[fallthrough]];
                        case 5:
                                if (types[4] == 'f') {
                                        se_page = (int) argv[4]->f;
                                } else {
                                        se_page = argv[4]->i;
                                }
+                               [[fallthrough]];
                        case 4:
                                if (types[3] == 'f') {
                                        fadermode = (int) argv[3]->f;
                                } else {
                                        fadermode = argv[3]->i;
                                }
+                               [[fallthrough]];
                        case 3:
                                if (types[2] == 'f') {
                                        feedback = (int) argv[2]->f;
                                } else {
                                        feedback = argv[2]->i;
                                }
+                               [[fallthrough]];
                        case 2:
                                if (types[1] == 'f') {
                                        strip_types = (int) argv[1]->f;
                                } else {
                                        strip_types = argv[1]->i;
                                }
+                               [[fallthrough]];
                        case 1:
                                if (types[0] == 'f') {
                                        bank_size = (int) argv[0]->f;
@@ -1972,7 +1988,6 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui
        }
        OSCSurface *s = get_surface(get_address (msg), true);
        s->bank_size = b_size;
-       s->custom_mode = CusOff;
        s->strip_types = strips;
        s->feedback = fb;
        s->gainmode = gm;
@@ -1983,6 +1998,9 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui
        }
        s->send_page_size = se_size;
        s->plug_page_size = pi_size;
+       if (s->temp_mode) {
+               s->temp_mode = TempOff;
+       }
        if (s->linkset) {
                set_link (s->linkset, s->linkid, get_address (msg));
                link_strip_types (s->linkset, s->strip_types.to_ulong());
@@ -1990,6 +2008,7 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui
                // set bank and strip feedback
                strip_feedback(s, true);
                _set_bank (1, get_address (msg));
+               _strip_select (boost::shared_ptr<Stripable> (), get_address (msg));
        }
 
        global_feedback (s);
@@ -2007,7 +2026,7 @@ OSC::set_surface_bank_size (uint32_t bs, lo_message msg)
        OSCSurface *s = get_surface(get_address (msg), true);
        s->bank_size = bs;
        if (s->custom_mode && bs) {
-               s->custom_mode = (OSCCustomMode) (s->custom_mode | 0x4);
+               s->custom_mode = s->custom_mode | 0x4;
        }
        if (s->linkset) {
                set_link (s->linkset, s->linkid, get_address (msg));
@@ -2026,7 +2045,7 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg)
        }
        OSCSurface *s = get_surface(get_address (msg), true);
        s->strip_types = st;
-       s->custom_mode = CusOff;
+       s->temp_mode = TempOff;
        if (s->strip_types[10]) {
                s->usegroup = PBD::Controllable::UseGroup;
        } else {
@@ -2035,9 +2054,10 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg)
        if (s->linkset) {
                link_strip_types (s->linkset, st);
        }
-
        // set bank and strip feedback
-       _set_bank (1, get_address (msg));
+       strip_feedback(s, false);
+       set_bank (1, msg);
+       _strip_select (boost::shared_ptr<Stripable> (), get_address (msg));
        return 0;
 }
 
@@ -2119,7 +2139,9 @@ OSC::set_surface_port (uint32_t po, lo_message msg)
                                                it++;
                                        }
                                }
-                               refresh_surface (msg);
+                               if (sur->feedback.to_ulong()) {
+                                       refresh_surface (msg);
+                               }
                                return 0;
                        }
                }
@@ -2168,10 +2190,12 @@ OSC::get_surface (lo_address addr , bool quiet)
        s.gainmode = default_gainmode;
        s.usegroup = PBD::Controllable::NoGroup;
        s.custom_strips.clear ();
-       s.custom_mode = CusOff;
+       s.custom_mode = 0;
+       s.temp_mode = TempOff;
        s.sel_obs = 0;
        s.expand = 0;
        s.expand_enable = false;
+       s.expand_strip = boost::shared_ptr<Stripable> ();
        s.cue = false;
        s.aux = 0;
        s.cue_obs = 0;
@@ -2203,7 +2227,9 @@ void
 OSC::global_feedback (OSCSurface* sur)
 {
        OSCGlobalObserver* o = sur->global_obs;
-       delete o;
+       if (o) {
+               delete o;
+       }
        if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) {
 
                // create a new Global Observer for this surface
@@ -2226,9 +2252,10 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
                }
                sur->custom_mode = set->custom_mode;
                sur->custom_strips = set->custom_strips;
+               sur->temp_mode = set->temp_mode;
                sur->temp_strips = set->temp_strips;
        }
-       if (sur->custom_mode < GroupOnly) {
+       if (!sur->temp_mode) {
                sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips);
        } else {
                sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
@@ -2257,7 +2284,7 @@ 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 == BusOnly) {
+                               if (sur->temp_mode == BusOnly) {
                                        boost::shared_ptr<ARDOUR::Stripable> str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str()));
                                        boost::shared_ptr<ARDOUR::Send> send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str()));
                                        if (send) {
@@ -2272,7 +2299,7 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
                        for (uint32_t i = 0; i < sur->observers.size(); i++) {
                                boost::shared_ptr<ARDOUR::Stripable> 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 == BusOnly) {
+                               if (sur->temp_mode == BusOnly) {
                                        boost::shared_ptr<ARDOUR::Send> send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str()));
                                        if (send) {
                                                sur->observers[i]->refresh_send (send, true);
@@ -2562,12 +2589,7 @@ int
 OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int argc, 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;
-       }
+       boost::shared_ptr<Stripable> s = sur->select;
        int ret = 1; /* unhandled */
        if (s) {
                if (!strncmp (path, X_("/select/group"), 13)) {
@@ -2600,16 +2622,9 @@ OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int ar
                        }
                        if ((argc == 1 && value) || !argc) {
                                // fill sur->strips with routes from this group and hit bank1
-                               sur->temp_strips.clear();
-                               boost::shared_ptr<RouteList> rl = rg->route_list();
-                               for (RouteList::iterator it = rl->begin(); it != rl->end(); ++it) {
-                                       boost::shared_ptr<Route> r = *it;
-                                       boost::shared_ptr<Stripable> s = boost::dynamic_pointer_cast<Stripable> (r);
-                                       sur->temp_strips.push_back(s);
-                               }
-                               sur->custom_mode = GroupOnly;
+                               sur->temp_mode = GroupOnly;
+                               ret = set_temp_mode (get_address (msg));
                                set_bank (1, msg);
-                               ret = 0;
                        } else {
                                // key off is ignored
                                ret = 0;
@@ -2725,11 +2740,7 @@ OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc
 {
        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;
-       }
+       s = sur->select;
        int ret = 1; /* unhandled */
        if (s) {
                string svalue = "";
@@ -2771,19 +2782,9 @@ OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc
                        boost::shared_ptr<VCA> vca = boost::dynamic_pointer_cast<VCA> (s);
                        if (vca) {
                                if ((argc == 1 && ivalue) || !argc) {
-                                       sur->temp_strips.clear();
-                                       StripableList stripables;
-                                       session->get_stripables (stripables);
-                                       for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
-                                               boost::shared_ptr<Stripable> st = *it;
-                                               if (st->slaved_to (vca)) {
-                                                       sur->temp_strips.push_back(st);
-                                               }
-                                       }
-                                       sur->temp_strips.push_back(s);
-                                       sur->custom_mode = VCAOnly;
+                                       sur->temp_mode = VCAOnly;
+                                       ret = set_temp_mode (get_address (msg));
                                        set_bank (1, msg);
-                                       ret = 0;
                                } else {
                                        // key off is ignored
                                        ret = 0;
@@ -2821,27 +2822,117 @@ OSC::sel_bus_only (lo_message msg)
        if (s) {
                boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
                if (rt) {
-                       if (!rt->is_track () && rt->can_solo () && rt->fed_by().size()) {
+                       if (!rt->is_track () && rt->can_solo ()) {
                                // this is a bus, but not master, monitor or audition
+                               sur->temp_mode = BusOnly;
+                               set_temp_mode (get_address (msg));
+                               set_bank (1, msg);
+                               return 0;
+                       }
+               }
+       }
+       return 1;
+}
+
+int
+OSC::set_temp_mode (lo_address addr)
+{
+       bool ret = 1;
+       OSCSurface *sur = get_surface(addr);
+       boost::shared_ptr<Stripable> s = sur->select;
+       if (s) {
+               if (sur->temp_mode == GroupOnly) {
+                       boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+                       if (rt) {
+                               RouteGroup *rg = rt->route_group();
+                               if (rg) {
+                                       sur->temp_strips.clear();
+                                       boost::shared_ptr<RouteList> rl = rg->route_list();
+                                       for (RouteList::iterator it = rl->begin(); it != rl->end(); ++it) {
+                                               boost::shared_ptr<Route> r = *it;
+                                               boost::shared_ptr<Stripable> st = boost::dynamic_pointer_cast<Stripable> (r);
+                                               sur->temp_strips.push_back(st);
+                                       }
+                                       sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
+                                       sur->nstrips = sur->temp_strips.size();
+                                       LinkSet *set;
+                                       uint32_t ls = sur->linkset;
+                                       if (ls) {
+                                               set = &(link_sets[ls]);
+                                               set->temp_mode = GroupOnly;
+                                               set->temp_strips.clear ();
+                                               set->temp_strips = sur->temp_strips;
+                                               set->strips = sur->strips;
+                                       }
+                                       ret = 0;
+                               }
+                       }
+               } else if (sur->temp_mode == VCAOnly) {
+                       boost::shared_ptr<VCA> vca = boost::dynamic_pointer_cast<VCA> (s);
+                       if (vca) {
                                sur->temp_strips.clear();
                                StripableList stripables;
                                session->get_stripables (stripables);
                                for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
                                        boost::shared_ptr<Stripable> st = *it;
-                                       boost::shared_ptr<Route> ri = boost::dynamic_pointer_cast<Route> (st);
-                                       bool sends = true;
-                                       if (ri && ri->direct_feeds_according_to_graph (rt, &sends)) {
+                                       if (st->slaved_to (vca)) {
                                                sur->temp_strips.push_back(st);
                                        }
                                }
                                sur->temp_strips.push_back(s);
-                               sur->custom_mode = BusOnly;
-                               set_bank (1, msg);
-                               return 0;
+                               sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
+                               sur->nstrips = sur->temp_strips.size();
+                               LinkSet *set;
+                               uint32_t ls = sur->linkset;
+                               if (ls) {
+                                       set = &(link_sets[ls]);
+                                       set->temp_mode = VCAOnly;
+                                       set->temp_strips.clear ();
+                                       set->temp_strips = sur->temp_strips;
+                                       set->strips = sur->strips;
+                               }
+                               ret = 0;
                        }
+               } else if (sur->temp_mode == BusOnly) {
+                       boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+                       if (rt) {
+                               if (!rt->is_track () && rt->can_solo ()) {
+                                       // this is a bus, but not master, monitor or audition
+                                       sur->temp_strips.clear();
+                                       StripableList stripables;
+                                       session->get_stripables (stripables);
+                                       for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
+                                               boost::shared_ptr<Stripable> st = *it;
+                                               boost::shared_ptr<Route> ri = boost::dynamic_pointer_cast<Route> (st);
+                                               bool sends = true;
+                                               if (ri && ri->direct_feeds_according_to_graph (rt, &sends)) {
+                                                       sur->temp_strips.push_back(st);
+                                               }
+                                       }
+                                       sur->temp_strips.push_back(s);
+                                       sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
+                                       sur->nstrips = sur->temp_strips.size();
+                                       LinkSet *set;
+                                       uint32_t ls = sur->linkset;
+                                       if (ls) {
+                                               set = &(link_sets[ls]);
+                                               set->temp_mode = BusOnly;
+                                               set->temp_strips.clear ();
+                                               set->temp_strips = sur->temp_strips;
+                                               set->strips = sur->strips;
+                                       }
+                                       ret = 0;
+                               }
+                       }
+               } else if (sur->temp_mode == TempOff) {
+                       sur->temp_mode = TempOff;
+                       ret = 0;
                }
        }
-       return 1;
+       if (ret) {
+               sur->temp_mode = TempOff;
+       }
+       return ret;
 }
 
 boost::shared_ptr<Send>
@@ -2910,7 +3001,7 @@ OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
                        }
                }
        }
-       // failsafe... should never get here.
+       // strip not in current bank
        return 0;
 }
 
@@ -3061,7 +3152,7 @@ OSC::_sel_plugin (int id, lo_address addr)
                boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
                boost::shared_ptr<PluginInsert> pi;
                if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
-                       PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg;                 
+                       PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg;
                        return 1;
                }
                boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
@@ -3833,11 +3924,7 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
                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;
@@ -3901,7 +3988,7 @@ OSC::route_mute (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/mute"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->mute_control()) {
@@ -3918,11 +4005,7 @@ OSC::sel_mute (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->mute_control()) {
                        s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -3940,7 +4023,7 @@ OSC::route_solo (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/solo"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->solo_control()) {
@@ -3959,7 +4042,7 @@ OSC::route_solo_iso (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/solo_iso"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->solo_isolate_control()) {
@@ -3979,7 +4062,7 @@ OSC::route_solo_safe (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/solo_safe"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->solo_safe_control()) {
@@ -3996,11 +4079,7 @@ OSC::sel_solo (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->solo_control()) {
                        session->set_control (s->solo_control(), yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4014,11 +4093,7 @@ OSC::sel_solo_iso (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->solo_isolate_control()) {
                        s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4033,11 +4108,7 @@ OSC::sel_solo_safe (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->solo_safe_control()) {
                        s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4052,11 +4123,7 @@ OSC::sel_recenable (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->rec_enable_control()) {
                        s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4076,7 +4143,7 @@ OSC::route_recenable (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/recenable"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->rec_enable_control()) {
@@ -4098,7 +4165,7 @@ OSC::route_rename (int ssid, char *newname, lo_message msg) {
        boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        text_message_with_id (X_("/strip/name"), ssid, string_compose ("%1-Send", s->name()), sur->feedback[2], get_address(msg));
                        return 1;
                }
@@ -4116,11 +4183,7 @@ OSC::sel_rename (char *newname, 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;
-       }
+       s = sur->select;
        if (s) {
                s->set_name(std::string(newname));
        }
@@ -4136,11 +4199,7 @@ OSC::sel_comment (char *newcomment, 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;
-       }
+       s = sur->select;
        if (s) {
                boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
                if (!rt) {
@@ -4169,11 +4228,7 @@ OSC::sel_group (char *group, 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;
-       }
+       s = sur->select;
        return strip_select_group (s, group);
 }
 
@@ -4237,11 +4292,7 @@ OSC::sel_recsafe (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->rec_safe_control()) {
                        s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4260,7 +4311,7 @@ OSC::route_recsafe (int ssid, int yn, lo_message msg)
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        OSCSurface *sur = get_surface(get_address (msg));
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/record_safe"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->rec_safe_control()) {
@@ -4281,7 +4332,7 @@ OSC::route_monitor_input (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/monitor_input"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
@@ -4303,11 +4354,7 @@ OSC::sel_monitor_input (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
                if (track) {
@@ -4330,7 +4377,7 @@ OSC::route_monitor_disk (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/monitor_disk"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
@@ -4352,11 +4399,7 @@ OSC::sel_monitor_disk (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
                if (track) {
@@ -4380,7 +4423,7 @@ OSC::strip_phase (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/polarity"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->phase_control()) {
@@ -4397,11 +4440,7 @@ OSC::sel_phase (uint32_t yn, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->phase_control()) {
                        s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
@@ -4417,12 +4456,14 @@ OSC::strip_expand (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly)/* && (s != sur->select)*/) {
                        uint32_t val = 0;
                        if (ssid == (int) sur->expand) {
                                val = 1;
                        }
                        return float_message_with_id (X_("/strip/expand"), ssid, val, sur->feedback[2], get_address (msg));
+               } else {
+                       sur->expand_strip = s;
                }
        }
        sur->expand_enable = (bool) yn;
@@ -4431,7 +4472,7 @@ OSC::strip_expand (int ssid, int yn, lo_message msg)
        if (yn) {
                sel = get_strip (ssid, get_address (msg));
        } else {
-               sel = _select;
+               sel = boost::shared_ptr<Stripable> ();
        }
 
        return _strip_select (sel, get_address (msg));
@@ -4444,7 +4485,7 @@ OSC::strip_hide (int ssid, int state, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/hide"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (state != s->is_hidden ()) {
@@ -4461,9 +4502,23 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                return -1;
        }
        OSCSurface *sur = get_surface(addr, true);
-       boost::shared_ptr<Stripable> old_sel = sur->select;
+       boost::weak_ptr<Stripable> o_sel = sur->select;
+       boost::shared_ptr<Stripable> old_sel= o_sel.lock ();
+       boost::weak_ptr<Stripable> o_expand = sur->expand_strip;
+       boost::shared_ptr<Stripable> old_expand= o_expand.lock ();
+
+       // we got a null strip check that old strips are valid
+       if (!s) {
+               if (old_expand && sur->expand_enable) {
+                       sur->expand = get_sid (old_expand, addr);
+                       if (sur->strip_types[11] || sur->expand) {
+                               s = old_expand;
+                       } else {
+                               sur->expand_strip = boost::shared_ptr<Stripable> ();
+                       }
+               }
+       }
        if (!s) {
-               // expand doesn't point to a stripable, turn it off and use select
                sur->expand = 0;
                sur->expand_enable = false;
                if (ControlProtocol::first_selected_stripable()) {
@@ -4471,13 +4526,10 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                } else {
                        s = session->master_out ();
                }
-                       _select = s;
+               _select = s;
        }
        if (s != old_sel) {
                sur->select = s;
-               if (sur->custom_mode >= GroupOnly) {
-                       _custom_mode (CusOff, addr);
-               }
        }
        bool sends;
        uint32_t nsends  = 0;
@@ -4501,8 +4553,16 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                        sur->sel_obs = sel_fb;
                }
                sur->sel_obs->set_expand (sur->expand_enable);
+       } else {
+               if (so != 0) {
+                       delete so;
+                       sur->sel_obs = 0;
+               }
+       }
+       if (sur->feedback[0] || sur->feedback[1]) {
                uint32_t obs_expand = 0;
                if (sur->expand_enable) {
+                       sur->expand = get_sid (s, addr);
                        obs_expand = sur->expand;
                } else {
                        obs_expand = 0;
@@ -4510,10 +4570,14 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                for (uint32_t i = 0; i < sur->observers.size(); i++) {
                        sur->observers[i]->set_expand (obs_expand);
                }
-       } else {
-               if (so != 0) {
-                       delete so;
-                       sur->sel_obs = 0;
+       }
+       if (s != old_sel) {
+               if (sur->temp_mode) {
+                       set_temp_mode (addr);
+                       if (sur->temp_mode > GroupOnly) {
+                               sur->bank = 1;
+                               strip_feedback (sur, false);
+                       }
                }
        }
        // need to set monitor for processor changed signal (for paging)
@@ -4551,7 +4615,7 @@ OSC::strip_gui_select (int ssid, int yn, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return -1;
                }
                sur->expand_enable = false;
@@ -4570,17 +4634,93 @@ OSC::sel_expand (uint32_t state, lo_message msg)
 {
        OSCSurface *sur = get_surface(get_address (msg));
        boost::shared_ptr<Stripable> s;
-       if (state && sur->expand) {
+       if (!sur->expand_strip) {
+               state = 0;
+               float_message (X_("/select/expand"), 0.0, get_address (msg));
+       }
+       if (state) {
                sur->expand_enable = (bool) state;
-               s = get_strip (sur->expand, get_address (msg));
+               s = boost::shared_ptr<Stripable> ();
        } else {
                sur->expand_enable = false;
-               s = _select;
+               s = boost::shared_ptr<Stripable> ();
        }
 
        return _strip_select (s, get_address (msg));
 }
 
+int
+OSC::sel_previous (lo_message msg)
+{
+       return sel_delta (-1, msg);
+}
+
+int
+OSC::sel_next (lo_message msg)
+{
+       return sel_delta (1, msg);
+}
+
+int
+OSC::sel_delta (int delta, lo_message msg)
+{
+       if (!delta) {
+               return 0;
+       }
+       OSCSurface *sur = get_surface(get_address (msg));
+       Sorted sel_strips;
+       if (sur->temp_mode < VCAOnly) {
+               sel_strips = sur->strips;
+       } else if (sur->temp_mode == VCAOnly) {
+               sel_strips = get_sorted_stripables(16, false, 0, sur->strips);
+       } else if (sur->temp_mode == BusOnly) {
+               sel_strips = get_sorted_stripables(132, false, 0, sur->strips);
+       } else {
+               return -1;
+       }
+       // the current selected strip _should_ be in sel_strips
+       uint32_t nstps = sel_strips.size ();
+       if (!nstps) {
+               return -1;
+       }
+       boost::shared_ptr<Stripable> new_sel = boost::shared_ptr<Stripable> ();
+       boost::weak_ptr<Stripable> o_sel = sur->select;
+       boost::shared_ptr<Stripable> old_sel= o_sel.lock ();
+       for (uint32_t i = 0; i < nstps; i++) {
+               if (old_sel == sel_strips[i]) {
+                       if (i && delta < 0) {
+                               // i is > 0 and delta is -1
+                               new_sel = sel_strips[i - 1];
+                       } else if ((i + 1) < nstps && delta > 0) {
+                               // i is at least 1 less than greatest and delta = 1
+                               new_sel = sel_strips[i + 1];
+                       } else if ((i + 1) >= nstps && delta > 0) {
+                               // i is greatest strip and delta 1
+                               new_sel = sel_strips[0];
+                       } else if (!i && delta < 0) {
+                               // i = 0 and delta -1
+                               new_sel = sel_strips[nstps - 1];
+                       } else {
+                               // should not happen
+                               return -1;
+                       }
+               }
+       }
+       if (!new_sel) {
+               // our selected strip has vanished use the first one
+               new_sel = sel_strips[0];
+       }
+       if (new_sel) {
+               if (!sur->expand_enable) {
+                       SetStripableSelection (new_sel);
+               } else {
+                       _strip_select (new_sel, get_address (msg));
+               }
+               return 0;
+       }
+       return -1;
+}
+
 int
 OSC::route_set_gain_dB (int ssid, float dB, lo_message msg)
 {
@@ -4591,7 +4731,7 @@ OSC::route_set_gain_dB (int ssid, float dB, lo_message msg)
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        if (s) {
                boost::shared_ptr<GainControl> gain_control;
-               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+               if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
                        gain_control = get_send(s, get_address (msg))->gain_control();
                } else {
                        gain_control = s->gain_control();
@@ -4679,7 +4819,7 @@ OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
 
        if (s) {
                boost::shared_ptr<GainControl> gain_control;
-               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+               if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
                        gain_control = get_send(s, get_address (msg))->gain_control();
                } else {
                        gain_control = s->gain_control();
@@ -4704,7 +4844,7 @@ OSC::strip_db_delta (int ssid, float delta, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
        if (s) {
                boost::shared_ptr<GainControl> gain_control;
-               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+               if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
                        gain_control = get_send(s, get_address (msg))->gain_control();
                } else {
                        gain_control = s->gain_control();
@@ -4731,11 +4871,7 @@ OSC::sel_fader (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->gain_control()) {
                        fake_touch (s->gain_control());
@@ -4754,7 +4890,7 @@ OSC::route_set_trim_abs (int ssid, float level, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/trimdB"), ssid, 0, sur->feedback[2], get_address (msg));
                }
                if (s->trim_control()) {
@@ -4785,11 +4921,7 @@ OSC::sel_trim (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->trim_control()) {
                        s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup);
@@ -4804,11 +4936,7 @@ OSC::sel_hide (uint32_t state, 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;
-       }
+       s = sur->select;
        if (s) {
                if (state != s->is_hidden ()) {
                        s->presentation_info().set_hidden ((bool) state);
@@ -4822,11 +4950,7 @@ OSC::sel_pan_position (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;
-       }
+       s = sur->select;
        if (s) {
                if(s->pan_azimuth_control()) {
                        s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -4841,11 +4965,7 @@ OSC::sel_pan_width (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->pan_width_control()) {
                        s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -4864,7 +4984,7 @@ OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
 
        if (s) {
                boost::shared_ptr<PBD::Controllable> pan_control = boost::shared_ptr<PBD::Controllable>();
-               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+               if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
                        boost::shared_ptr<ARDOUR::Send> send = get_send (s, get_address (msg));
                        if (send->pan_outs() > 1) {
                                pan_control = send->panner_shell()->panner()->pannable()->pan_azimuth_control;
@@ -4889,7 +5009,7 @@ OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+               if ((sur->temp_mode == BusOnly) && (s != sur->select)) {
                        return float_message_with_id (X_("/strip/pan_stereo_width"), ssid, 1, sur->feedback[2], get_address (msg));
                }
                if (s->pan_width_control()) {
@@ -4963,11 +5083,7 @@ OSC::sel_sendgain (int id, float val, lo_message msg)
                return float_message_with_id (X_("/select/send_gain"), id, -193, sur->feedback[2], get_address (msg));
        }
        boost::shared_ptr<Stripable> s;
-       if (sur->expand_enable) {
-               s = get_strip (sur->expand, get_address (msg));
-       } else {
-               s = _select;
-       }
+       s = sur->select;
        float abs;
        int send_id = 0;
        if (s) {
@@ -5002,11 +5118,7 @@ OSC::sel_sendfader (int id, float val, lo_message msg)
                return float_message_with_id (X_("/select/send_fader"), id, 0, sur->feedback[2], get_address (msg));
        }
        boost::shared_ptr<Stripable> s;
-       if (sur->expand_enable) {
-               s = get_strip (sur->expand, get_address (msg));
-       } else {
-               s = _select;
-       }
+       s = sur->select;
        float abs;
        int send_id = 0;
        if (s) {
@@ -5078,11 +5190,7 @@ OSC::sel_sendenable (int id, float val, lo_message msg)
                return float_message_with_id (X_("/select/send_enable"), id, 0, sur->feedback[2], get_address (msg));
        }
        boost::shared_ptr<Stripable> s;
-       if (sur->expand_enable) {
-               s = get_strip (sur->expand, get_address (msg));
-       } else {
-               s = _select;
-       }
+       s = sur->select;
        int send_id = 0;
        if (s) {
                if (id > 0) {
@@ -5120,11 +5228,7 @@ OSC::sel_master_send_enable (int state, 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;
-       }
+       s = sur->select;
        if (s) {
                if (s->master_send_enable_controllable ()) {
                        s->master_send_enable_controllable()->set_value (state, PBD::Controllable::NoGroup);
@@ -5660,11 +5764,7 @@ OSC::sel_pan_elevation (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->pan_elevation_control()) {
                        s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5679,11 +5779,7 @@ OSC::sel_pan_frontback (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->pan_frontback_control()) {
                        s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5698,11 +5794,7 @@ OSC::sel_pan_lfe (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->pan_lfe_control()) {
                        s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5718,11 +5810,7 @@ OSC::sel_comp_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;
-       }
+       s = sur->select;
        if (s) {
                if (s->comp_enable_controllable()) {
                        s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5737,11 +5825,7 @@ OSC::sel_comp_threshold (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->comp_threshold_controllable()) {
                        s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5756,11 +5840,7 @@ OSC::sel_comp_speed (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->comp_speed_controllable()) {
                        s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5775,11 +5855,7 @@ OSC::sel_comp_mode (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->comp_mode_controllable()) {
                        s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5794,11 +5870,7 @@ OSC::sel_comp_makeup (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;
-       }
+       s = sur->select;
        if (s) {
                if (s->comp_makeup_controllable()) {
                        s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5815,11 +5887,7 @@ OSC::sel_eq_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;
-       }
+       s = sur->select;
        if (s) {
                if (s->eq_enable_controllable()) {
                        s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
@@ -5834,11 +5902,7 @@ OSC::sel_eq_hpf_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;
-       }
+       s = sur->select;
        if (s) {
                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);
@@ -5853,11 +5917,7 @@ 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;
-       }
+       s = sur->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);
@@ -5872,11 +5932,7 @@ 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;
-       }
+       s = sur->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);
@@ -5891,11 +5947,7 @@ 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;
-       }
+       s = sur->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);
@@ -5910,11 +5962,7 @@ 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;
-       }
+       s = sur->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);
@@ -5929,11 +5977,7 @@ 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;
-       }
+       s = sur->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);
@@ -5948,11 +5992,7 @@ OSC::sel_eq_gain (int id, 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;
-       }
+       s = sur->select;
        if (s) {
                if (id > 0) {
                        --id;
@@ -5970,11 +6010,7 @@ OSC::sel_eq_freq (int id, 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;
-       }
+       s = sur->select;
        if (s) {
                if (id > 0) {
                        --id;
@@ -5992,11 +6028,7 @@ OSC::sel_eq_q (int id, 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;
-       }
+       s = sur->select;
        if (s) {
                if (id > 0) {
                        --id;
@@ -6014,11 +6046,7 @@ OSC::sel_eq_shape (int id, 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;
-       }
+       s = sur->select;
        if (s) {
                if (id > 0) {
                        --id;
@@ -6532,13 +6560,16 @@ OSC::cue_send_enable (uint32_t id, float state, lo_message msg)
 int
 OSC::float_message (string path, float val, lo_address addr)
 {
+       _lo_lock.lock ();
 
        lo_message reply;
        reply = lo_message_new ();
        lo_message_add_float (reply, (float) val);
 
        lo_send_message (addr, path.c_str(), reply);
+       Glib::usleep(1);
        lo_message_free (reply);
+       _lo_lock.unlock ();
 
        return 0;
 }
@@ -6546,6 +6577,7 @@ OSC::float_message (string path, float val, lo_address addr)
 int
 OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool in_line, lo_address addr)
 {
+       _lo_lock.lock ();
        lo_message msg = lo_message_new ();
        if (in_line) {
                path = string_compose ("%1/%2", path, ssid);
@@ -6555,20 +6587,25 @@ OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool i
        lo_message_add_float (msg, value);
 
        lo_send_message (addr, path.c_str(), msg);
+       Glib::usleep(1);
        lo_message_free (msg);
+       _lo_lock.unlock ();
        return 0;
 }
 
 int
 OSC::int_message (string path, int val, lo_address addr)
 {
+       _lo_lock.lock ();
 
        lo_message reply;
        reply = lo_message_new ();
        lo_message_add_int32 (reply, (float) val);
 
        lo_send_message (addr, path.c_str(), reply);
+       Glib::usleep(1);
        lo_message_free (reply);
+       _lo_lock.unlock ();
 
        return 0;
 }
@@ -6576,6 +6613,7 @@ OSC::int_message (string path, int val, lo_address addr)
 int
 OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_line, lo_address addr)
 {
+       _lo_lock.lock ();
        lo_message msg = lo_message_new ();
        if (in_line) {
                path = string_compose ("%1/%2", path, ssid);
@@ -6585,20 +6623,25 @@ OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_li
        lo_message_add_int32 (msg, value);
 
        lo_send_message (addr, path.c_str(), msg);
+       Glib::usleep(1);
        lo_message_free (msg);
+       _lo_lock.unlock ();
        return 0;
 }
 
 int
 OSC::text_message (string path, string val, lo_address addr)
 {
+       _lo_lock.lock ();
 
        lo_message reply;
        reply = lo_message_new ();
        lo_message_add_string (reply, val.c_str());
 
        lo_send_message (addr, path.c_str(), reply);
+       Glib::usleep(1);
        lo_message_free (reply);
+       _lo_lock.unlock ();
 
        return 0;
 }
@@ -6606,6 +6649,7 @@ OSC::text_message (string path, string val, lo_address addr)
 int
 OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr)
 {
+       _lo_lock.lock ();
        lo_message msg = lo_message_new ();
        if (in_line) {
                path = string_compose ("%1/%2", path, ssid);
@@ -6616,7 +6660,9 @@ OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, boo
        lo_message_add_string (msg, val.c_str());
 
        lo_send_message (addr, path.c_str(), msg);
+       Glib::usleep(1);
        lo_message_free (msg);
+       _lo_lock.unlock ();
        return 0;
 }