MSVC won't allow us to cast directly from float to an enum. We need to kludge it...
[ardour.git] / libs / surfaces / osc / osc.cc
index 6612b0da50152ac51a7a99d28f5c853f4a90991c..7c46f5bf6c14daf727d567466e2dd5e5b15b01b1 100644 (file)
@@ -29,6 +29,7 @@
 #include <glibmm.h>
 
 #include "pbd/control_math.h"
+#include "pbd/controllable.h"
 #include <pbd/convert.h>
 #include <pbd/pthread_utils.h>
 #include <pbd/file_utils.h>
@@ -45,6 +46,8 @@
 #include "ardour/dB.h"
 #include "ardour/filesystem_paths.h"
 #include "ardour/panner.h"
+#include "ardour/panner_shell.h"
+#include "ardour/pannable.h"
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
 #include "ardour/presentation_info.h"
@@ -504,6 +507,7 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, X_("/quick_snapshot_switch"), "f", quick_snapshot_switch);
                REGISTER_CALLBACK (serv, X_("/quick_snapshot_stay"), "", quick_snapshot_stay);
                REGISTER_CALLBACK (serv, X_("/quick_snapshot_stay"), "f", quick_snapshot_stay);
+               REGISTER_CALLBACK (serv, X_("/session_name"), "s", name_session);
                REGISTER_CALLBACK (serv, X_("/fit_1_track"), "", fit_1_track);
                REGISTER_CALLBACK (serv, X_("/fit_1_track"), "f", fit_1_track);
                REGISTER_CALLBACK (serv, X_("/fit_2_tracks"), "", fit_2_tracks);
@@ -568,6 +572,8 @@ OSC::register_callbacks()
                // Controls for the Selected strip
                REGISTER_CALLBACK (serv, X_("/select/recenable"), "i", sel_recenable);
                REGISTER_CALLBACK (serv, X_("/select/record_safe"), "i", sel_recsafe);
+               REGISTER_CALLBACK (serv, X_("/select/name"), "s", sel_rename);
+               REGISTER_CALLBACK (serv, X_("/select/comment"), "s", sel_comment);
                REGISTER_CALLBACK (serv, X_("/select/mute"), "i", sel_mute);
                REGISTER_CALLBACK (serv, X_("/select/solo"), "i", sel_solo);
                REGISTER_CALLBACK (serv, X_("/select/solo_iso"), "i", sel_solo_iso);
@@ -580,6 +586,8 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, X_("/select/db_delta"), "f", sel_dB_delta);
                REGISTER_CALLBACK (serv, X_("/select/trimdB"), "f", sel_trim);
                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/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);
@@ -626,6 +634,7 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, X_("/strip/polarity"), "ii", strip_phase);
                REGISTER_CALLBACK (serv, X_("/strip/gain"), "if", route_set_gain_dB);
                REGISTER_CALLBACK (serv, X_("/strip/fader"), "if", route_set_gain_fader);
+               REGISTER_CALLBACK (serv, X_("/strip/db_delta"), "if", strip_db_delta);
                REGISTER_CALLBACK (serv, X_("/strip/trimdB"), "if", route_set_trim_dB);
                REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_position"), "if", route_set_pan_stereo_position);
                REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_width"), "if", route_set_pan_stereo_width);
@@ -638,6 +647,7 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, X_("/strip/send/fader"), "iif", route_set_send_fader);
                REGISTER_CALLBACK (serv, X_("/strip/send/enable"), "iif", route_set_send_enable);
                REGISTER_CALLBACK (serv, X_("/strip/name"), "is", route_rename);
+               REGISTER_CALLBACK (serv, X_("/strip/group"), "is", strip_group);
                REGISTER_CALLBACK (serv, X_("/strip/sends"), "i", route_get_sends);
                REGISTER_CALLBACK (serv, X_("/strip/receives"), "i", route_get_receives);
                REGISTER_CALLBACK (serv, X_("/strip/plugin/list"), "i", route_plugin_list);
@@ -810,6 +820,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_strips = set->temp_strips;
        }
 
        if (strstr (path, X_("/automation"))) {
@@ -848,7 +859,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) {
+               } else if (sur->custom_mode && (sur->custom_mode < GroupOnly)) {
                        PBD::warning << "OSC: Can't add strips with custom enabled." << endmsg;
                } else {
                        for (int n = 0; n < argc; ++n) {
@@ -871,7 +882,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) {
+               } else if (!sur->custom_mode || (sur->custom_mode >= GroupOnly)) {
                        PBD::warning << "OSC: Can't remove strips without custom enabled." << endmsg;
                } else {
                        for (int n = 0; n < argc; ++n) {
@@ -974,8 +985,14 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        else if (!strncmp (path, X_("/strip/select/"), 14) && strlen (path) > 14) {
                int ssid = atoi (&path[14]);
                ret = strip_gui_select (ssid, argv[0]->i, msg);
-       } else
-       if (strstr (path, X_("/select")) && (argc != 1)) {
+       }
+       else if (strstr (path, X_("/select/group"))) {
+               ret = parse_sel_group (path, types, argv, argc, msg);
+       }
+       else if (strstr (path, X_("/select/vca"))) {
+               ret = parse_sel_vca (path, types, argv, argc, msg);
+       }
+       else if (strstr (path, X_("/select")) && (argc != 1)) {
                // All of the select commands below require 1 parameter
                PBD::warning << "OSC: Wrong number of parameters." << endmsg;
        }
@@ -1343,7 +1360,7 @@ OSC::custom_clear (lo_message msg)
                return 0;
        }
        OSCSurface *sur = get_surface(get_address (msg), true);
-       sur->custom_mode = 0;
+       sur->custom_mode = CusOff;
        sur->custom_strips.clear ();
        sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, false, sur->custom_strips);
        sur->nstrips = sur->strips.size();
@@ -1351,7 +1368,7 @@ OSC::custom_clear (lo_message msg)
        uint32_t ls = sur->linkset;
        if (ls) {
                set = &(link_sets[ls]);
-               set->custom_mode = 0;
+               set->custom_mode = CusOff;
                set->custom_strips.clear ();
                set->strips = sur->strips;
        }
@@ -1360,11 +1377,17 @@ OSC::custom_clear (lo_message msg)
 
 int
 OSC::custom_mode (float state, lo_message msg)
+{
+       return _custom_mode ((OSCCustomMode) (int)state, get_address (msg));
+}
+
+int
+OSC::_custom_mode (OSCCustomMode state, lo_address addr)
 {
        if (!session) {
                return 0;
        }
-       OSCSurface *sur = get_surface(get_address (msg), true);
+       OSCSurface *sur = get_surface(addr, true);
        LinkSet *set;
        uint32_t ls = sur->linkset;
 
@@ -1376,22 +1399,22 @@ OSC::custom_mode (float state, lo_message msg)
        if (state > 0){
                if (sur->custom_strips.size () == 0) {
                        PBD::warning << "No custom strips set to enable" << endmsg;
-                       sur->custom_mode = 0;
+                       sur->custom_mode = CusOff;
                        if (ls) {
-                               set->custom_mode = 0;
+                               set->custom_mode = CusOff;
                        }
                        return -1;
                } else {
                        if (sur->bank_size) {
-                               sur->custom_mode = (uint32_t) state | 0x4;
+                               sur->custom_mode = (OSCCustomMode) (state | 0x4);
                        } else {
-                               sur->custom_mode = (uint32_t) state;
+                               sur->custom_mode = state;
                        }
                        sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips);
                        sur->nstrips = sur->custom_strips.size();
                }
        } else {
-               sur->custom_mode = 0;
+               sur->custom_mode = CusOff;
                sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 0, sur->custom_strips);
                sur->nstrips = sur->strips.size();
        }
@@ -1399,7 +1422,7 @@ OSC::custom_mode (float state, lo_message msg)
                set->custom_mode = sur->custom_mode;
                set->strips = sur->strips;
        }
-       return set_bank (1, msg);
+       return _set_bank (1, addr);
 }
 
 int
@@ -1949,9 +1972,7 @@ 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;
-       if (s->custom_mode && b_size) {
-               s->custom_mode = s->custom_mode | 0x4;
-       }
+       s->custom_mode = CusOff;
        s->strip_types = strips;
        s->feedback = fb;
        s->gainmode = gm;
@@ -1986,7 +2007,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 = s->custom_mode | 0x4;
+               s->custom_mode = (OSCCustomMode) (s->custom_mode | 0x4);
        }
        if (s->linkset) {
                set_link (s->linkset, s->linkid, get_address (msg));
@@ -2005,6 +2026,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;
        if (s->strip_types[10]) {
                s->usegroup = PBD::Controllable::UseGroup;
        } else {
@@ -2146,7 +2168,7 @@ OSC::get_surface (lo_address addr , bool quiet)
        s.gainmode = default_gainmode;
        s.usegroup = PBD::Controllable::NoGroup;
        s.custom_strips.clear ();
-       s.custom_mode = 0;
+       s.custom_mode = CusOff;
        s.sel_obs = 0;
        s.expand = 0;
        s.expand_enable = false;
@@ -2204,11 +2226,13 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
                }
                sur->custom_mode = set->custom_mode;
                sur->custom_strips = set->custom_strips;
+               sur->temp_strips = set->temp_strips;
        }
-       if (sur->custom_strips.size () == 0) {
-               sur->custom_mode = 0;
+       if (sur->custom_mode < GroupOnly) {
+               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);
        }
-       sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips);
        sur->nstrips = sur->strips.size();
        if (ls) {
                set->strips = sur->strips;
@@ -2233,6 +2257,14 @@ 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) {
+                                       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) {
+                                               o->refresh_send (send, true);
+                                       }
+                               }
+
                        }
                }
        } else {
@@ -2240,6 +2272,12 @@ 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) {
+                                       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);
+                                       }
+                               }
                        }
                }
        }
@@ -2344,17 +2382,25 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
                set->bank = bank_start;
                uint32_t not_ready = 0;
                for (uint32_t dv = 1; dv < d_count; dv++) {
-                       OSCSurface *sur;
                        if (set->urls[dv] != "") {
                                string url = set->urls[dv];
-                               sur = get_surface (lo_address_new_from_url (url.c_str()));
+                               OSCSurface *sur = get_surface (lo_address_new_from_url (url.c_str()));
+                               if (sur->linkset != ls) {
+                                       set->urls[dv] = "";
+                                       not_ready = dv;
+                               } else {
+                                       lo_address sur_addr = lo_address_new_from_url (sur->remote_url.c_str());
+
+                                       sur->bank = bank_start;
+                                       bank_start = bank_start + sur->bank_size;
+                                       strip_feedback (sur, false);
+                                       _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), sur_addr);
+                                       bank_leds (sur);
+                                       lo_address_free (sur_addr);
+                               }
                        } else {
                                not_ready = dv;
                        }
-                       if (sur->linkset != ls) {
-                               set->urls[dv] = "";
-                               not_ready = dv;
-                       }
                        if (not_ready) {
                                if (!set->not_ready) {
                                        set->not_ready = not_ready;
@@ -2362,14 +2408,6 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
                                set->bank = 1;
                                break;
                        }
-                       lo_address sur_addr = lo_address_new_from_url (sur->remote_url.c_str());
-
-                       sur->bank = bank_start;
-                       bank_start = bank_start + sur->bank_size;
-                       strip_feedback (sur, false);
-                       _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), sur_addr);
-                       bank_leds (sur);
-                       lo_address_free (sur_addr);
                }
                if (not_ready) {
                        surface_link_state (set);
@@ -2519,6 +2557,335 @@ OSC::use_group (float value, lo_message msg)
        return 0;
 }
 
+// this gets called for anything that starts with /select/group
+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;
+       }
+       int ret = 1; /* unhandled */
+       if (s) {
+               if (!strncmp (path, X_("/select/group"), 13)) {
+                       if (argc == 1) {
+                               if (types[0] == 's') {
+                                       return strip_select_group (s, &argv[0]->s);
+                               }
+                       }
+               }
+               boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+               if (!rt) {
+                       PBD::warning << "OSC: VCAs can not be part of a group." << endmsg;
+                       return ret;
+               }
+               RouteGroup *rg = rt->route_group();
+               if (!rg) {
+                       PBD::warning << "OSC: This strip is not part of a group." << endmsg;
+               }
+               float value = 0;
+               if (argc == 1) {
+                       if (types[0] == 'f') {
+                               value = (uint32_t) argv[0]->f;
+                       } else if (types[0] == 'i') {
+                               value = (uint32_t) argv[0]->i;
+                       }
+               }
+               if (!strncmp (path, X_("/select/group/only"), 18)) {
+                       if (!rg) {
+                               return ret;
+                       }
+                       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;
+                               set_bank (1, msg);
+                               ret = 0;
+                       } else {
+                               // key off is ignored
+                               ret = 0;
+                       }
+               }
+               else if (!strncmp (path, X_("/select/group/enable"), 20)) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_active (value, this);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/enable"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/gain")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_gain ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/gain"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/relative")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_relative ((bool) value, this);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/relative"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/mute")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_mute ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/mute"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/solo")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_solo ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/solo"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/recenable")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_recenable ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/recenable"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/select")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_select ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/select"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/active")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_route_active ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/active"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/color")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_color ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/color"), 0, get_address (msg));
+                       }
+               }
+               else if (strcmp (path, X_("/select/group/monitoring")) == 0) {
+                       if (rg) {
+                               if (argc == 1) {
+                                       rg->set_monitoring ((bool) value);
+                                       ret = 0;
+                               }
+                       } else {
+                               int_message (X_("/select/group/monitoring"), 0, get_address (msg));
+                       }
+               }
+       }
+       return ret;
+ }
+
+// this gets called for anything that starts with /select/vca
+int
+OSC::parse_sel_vca (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;
+       }
+       int ret = 1; /* unhandled */
+       if (s) {
+               string svalue = "";
+               uint32_t ivalue = 1024;
+               if (strcmp (path, X_("/select/vca")) == 0) {
+                       if (argc == 2) {
+                               if (types[0] == 's') {
+                                       svalue = &argv[0]->s;
+                                       if (types[1] == 'i') {
+                                               ivalue = argv[1]->i;
+                                       } else if (types[1] == 'f') {
+                                               ivalue = (uint32_t) argv[1]->f;
+                                       } else {
+                                               return 1;
+                                       }
+                                       boost::shared_ptr<VCA> vca = get_vca_by_name (svalue);
+                                       if (vca) {
+                                               boost::shared_ptr<Slavable> slv = boost::dynamic_pointer_cast<Slavable> (s);
+                                               if (ivalue) {
+                                                       slv->assign (vca);
+                                               } else {
+                                                       slv->unassign (vca);
+                                               }
+                                               ret = 0;
+                                       }
+                               }
+                       } else {
+                               PBD::warning << "OSC: setting a vca needs both the vca name and it's state" << endmsg;
+                       }
+               }
+               else if (!strncmp (path, X_("/select/vca/only"), 16)) {
+                       if (argc == 1) {
+                               if (types[0] == 'f') {
+                                       ivalue = (uint32_t) argv[0]->f;
+                               } else if (types[0] == 'i') {
+                                       ivalue = (uint32_t) argv[0]->i;
+                               }
+                       }
+                       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;
+                                       set_bank (1, msg);
+                                       ret = 0;
+                               } else {
+                                       // key off is ignored
+                                       ret = 0;
+                               }
+                       } else {
+                               PBD::warning << "OSC: Select is not a VCA right now" << endmsg;
+                       }
+               }
+       }
+       return ret;
+}
+
+boost::shared_ptr<VCA>
+OSC::get_vca_by_name (std::string vname)
+{
+       StripableList stripables;
+       session->get_stripables (stripables);
+       for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
+               boost::shared_ptr<Stripable> s = *it;
+               boost::shared_ptr<VCA> v = boost::dynamic_pointer_cast<VCA> (s);
+               if (v) {
+                       if (vname == v->name()) {
+                               return v;
+                       }
+               }
+       }
+       return boost::shared_ptr<VCA>();
+}
+
+int
+OSC::sel_bus_only (lo_message msg)
+{
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s = sur->select;
+       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()) {
+                               // 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->custom_mode = BusOnly;
+                               set_bank (1, msg);
+                               return 0;
+                       }
+               }
+       }
+       return 1;
+}
+
+boost::shared_ptr<Send>
+OSC::get_send (boost::shared_ptr<Stripable> st, lo_address addr)
+{
+       OSCSurface *sur = get_surface(addr);
+       boost::shared_ptr<Stripable> s = sur->select;
+       if (st && s && (st != s)) {
+               boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+               boost::shared_ptr<Route> rst = boost::dynamic_pointer_cast<Route> (st);
+               //find what send number feeds s
+               return rst->internal_send_for (rt);
+       }
+       return boost::shared_ptr<Send> ();
+}
+
+int
+OSC::name_session (char *n, lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       string new_name = n;
+       char illegal = Session::session_name_is_legal (new_name);
+
+       if (illegal) {
+               PBD::warning  << (string_compose (_("To ensure compatibility with various systems\n"
+                                   "session names may not contain a '%1' character"), illegal)) << endmsg;
+               return -1;
+       }
+       switch (session->rename (new_name)) {
+               case -1:
+                       PBD::warning  << (_("That name is already in use by another directory/folder. Please try again.")) << endmsg;
+                       break;
+               case 0:
+                       return 0;
+                       break;
+               default:
+                       PBD::warning  << (_("Renaming this session failed.\nThings could be seriously messed up at this point")) << endmsg;
+                       break;
+       }
+       return -1;
+}
+
 uint32_t
 OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
 {
@@ -2928,13 +3295,24 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg)
 
        switch (types[0]) {
                case 's':
-                       for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
-                               if ((*l)->is_mark ()) {
-                                       if (strcmp (&argv[0]->s, (*l)->name().c_str()) == 0) {
-                                               session->request_locate ((*l)->start (), false);
-                                               return 0;
+                       {
+                               Location *cur_mark = 0;
+                               for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
+                                       if ((*l)->is_mark ()) {
+                                               if (strcmp (&argv[0]->s, (*l)->name().c_str()) == 0) {
+                                                       session->request_locate ((*l)->start (), false);
+                                                       return 0;
+                                               } else if ((*l)->start () == session->transport_sample()) {
+                                                       cur_mark = (*l);
+                                               }
                                        }
                                }
+                               if (cur_mark) {
+                                       cur_mark->set_name (&argv[0]->s);
+                                       return 0;
+                               }
+                               PBD::warning << string_compose ("Marker: \"%1\" - does not exist", &argv[0]->s) << endmsg;
+                               return -1;
                        }
                        break;
                case 'i':
@@ -2975,7 +3353,6 @@ OSC::group_list (lo_message msg)
 int
 OSC::send_group_list (lo_address addr)
 {
-               //std::list<RouteGroup*> const & route_groups () const {
        lo_message reply;
        reply = lo_message_new ();
 
@@ -3338,6 +3715,7 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg
        uint32_t ctr = 0;
        uint32_t aut = 0;
        uint32_t ssid;
+       boost::shared_ptr<Send> send = boost::shared_ptr<Send> ();
 
        if (argc) {
                if (types[argc - 1] == 'f') {
@@ -3361,13 +3739,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg
                        ssid = atoi (&(strrchr (path, '/' ))[1]);
                        strp = get_strip (ssid, get_address (msg));
                }
+               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;
@@ -3381,6 +3756,9 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg
                        } else {
                                PBD::warning << "No fader for this strip" << endmsg;
                        }
+                       if (send) {
+                               control = send->gain_control ();
+                       }
                } else {
                        PBD::warning << "Automation not available for " << path << endmsg;
                }
@@ -3404,6 +3782,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg
                                        control->set_automation_state (ARDOUR::Touch);
                                        ret = 0;
                                        break;
+                               case 4:
+                                       control->set_automation_state (ARDOUR::Latch);
+                                       ret = 0;
+                                       break;
                                default:
                                        break;
                        }
@@ -3421,6 +3803,7 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
        int ret = 1;
        OSCSurface *sur = get_surface(get_address (msg));
        boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
+       boost::shared_ptr<Send> send = boost::shared_ptr<Send> ();
        uint32_t ctr = 0;
        uint32_t touch = 0;
        uint32_t ssid;
@@ -3447,6 +3830,7 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
                        ssid = atoi (&(strrchr (path, '/' ))[1]);
                        strp = get_strip (ssid, get_address (msg));
                }
+               send = get_send (strp, get_address (msg));
                ctr = 7;
        } else if (!strncmp (path, X_("/select/"), 8)) {
                if (sur->expand_enable && sur->expand) {
@@ -3467,6 +3851,9 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
                        } else {
                                PBD::warning << "No fader for this strip" << endmsg;
                        }
+                       if (send) {
+                               control = send->gain_control ();
+                       }
                } else {
                        PBD::warning << "Automation not available for " << path << endmsg;
                }
@@ -3514,6 +3901,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/mute"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->mute_control()) {
                        s->mute_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
@@ -3550,6 +3940,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/solo"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->solo_control()) {
                        s->solo_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                }
@@ -3566,6 +3959,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/solo_iso"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->solo_isolate_control()) {
                        s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
@@ -3583,6 +3979,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/solo_safe"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->solo_safe_control()) {
                        s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
@@ -3677,6 +4076,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/recenable"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->rec_enable_control()) {
                        s->rec_enable_control()->set_value (yn, sur->usegroup);
                        if (s->rec_enable_control()->get_value()) {
@@ -3688,18 +4090,146 @@ OSC::route_recenable (int ssid, int yn, lo_message msg)
 }
 
 int
-OSC::route_rename(int ssid, char *newname, lo_message msg) {
-    if (!session) {
-        return -1;
-    }
+OSC::route_rename (int ssid, char *newname, lo_message msg) {
+       if (!session) {
+               return -1;
+       }
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
 
-    boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
+       if (s) {
+               if ((sur->custom_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;
+               }
+               s->set_name(std::string(newname));
+       }
 
-    if (s) {
-        s->set_name(std::string(newname));
-    }
+       return 0;
+}
+
+int
+OSC::sel_rename (char *newname, lo_message msg) {
+       if (!session) {
+               return -1;
+       }
+
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               s->set_name(std::string(newname));
+       }
 
-    return 0;
+       return 0;
+}
+
+int
+OSC::sel_comment (char *newcomment, lo_message msg) {
+       if (!session) {
+               return -1;
+       }
+
+       OSCSurface *sur = get_surface(get_address (msg));
+       boost::shared_ptr<Stripable> s;
+       if (sur->expand_enable) {
+               s = get_strip (sur->expand, get_address (msg));
+       } else {
+               s = _select;
+       }
+       if (s) {
+               boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+               if (!rt) {
+                       PBD::warning << "OSC: can not set comment on VCAs." << endmsg;
+                       return -1;
+               }
+               rt->set_comment (newcomment, this);
+       }
+
+       return 0;
+}
+
+int
+OSC::strip_group (int ssid, char *group, lo_message msg) {
+       if (!session) {
+               return -1;
+       }
+       boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
+       return strip_select_group (s, group);
+}
+
+int
+OSC::sel_group (char *group, lo_message msg) {
+       if (!session) {
+               return -1;
+       }
+       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;
+       }
+       return strip_select_group (s, group);
+}
+
+int
+OSC::strip_select_group (boost::shared_ptr<Stripable> s, char *group)
+{
+       string grp = group;
+       if (grp == "" || grp == " ") {
+                       grp = "none";
+               }
+
+       if (s) {
+               boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
+               if (!rt) {
+                       PBD::warning << "OSC: VCAs can not be part of a group." << endmsg;
+                       return -1;
+               }
+               RouteGroup *rg = rt->route_group();
+               RouteGroup* new_rg = session->route_group_by_name (grp);
+               if (rg) {
+                       string old_group = rg->name();
+                       if (grp == "none") {
+                               if (rg->size () == 1) {
+                                       session->remove_route_group (*rg);
+                               } else {
+                                       rg->remove (rt);
+                               }
+                       } else if (grp != old_group) {
+                               if (new_rg) {
+                                       // group exists switch to it
+                                       if (rg->size () == 1) {
+                                               session->remove_route_group (rg);
+                                       } else {
+                                               rg->remove (rt);
+                                       }
+                                       new_rg->add (rt);
+                               } else {
+                                       rg->set_name (grp);
+                               }
+                       } else {
+                               return 0;
+                       }
+               } else {
+                       if (grp == "none") {
+                               return 0;
+                       } else if (new_rg) {
+                               new_rg->add (rt);
+                       } else {
+                               // create new group with this strip in it
+                               RouteGroup* new_rg = new RouteGroup (*session, grp);
+                               session->add_route_group (new_rg);
+                               new_rg->add (rt);
+                       }
+               }
+       }
+       return 0;
 }
 
 int
@@ -3730,6 +4260,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/record_safe"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->rec_safe_control()) {
                        s->rec_safe_control()->set_value (yn, sur->usegroup);
                        if (s->rec_safe_control()->get_value()) {
@@ -3748,6 +4281,9 @@ 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)) {
+                       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);
                if (track) {
                        if (track->monitoring_control()) {
@@ -3794,6 +4330,9 @@ 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)) {
+                       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);
                if (track) {
                        if (track->monitoring_control()) {
@@ -3841,6 +4380,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/polarity"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->phase_control()) {
                        s->phase_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
@@ -3873,24 +4415,38 @@ int
 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)) {
+                       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));
+               }
+       }
        sur->expand_enable = (bool) yn;
        sur->expand = ssid;
-       boost::shared_ptr<Stripable> s;
+       boost::shared_ptr<Stripable> sel;
        if (yn) {
-               s = get_strip (ssid, get_address (msg));
+               sel = get_strip (ssid, get_address (msg));
        } else {
-               s = _select;
+               sel = _select;
        }
 
-       return _strip_select (s, get_address (msg));
+       return _strip_select (sel, get_address (msg));
 }
 
 int
 OSC::strip_hide (int ssid, int state, 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)) {
+                       return float_message_with_id (X_("/strip/hide"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (state != s->is_hidden ()) {
                        s->presentation_info().set_hidden ((bool) state);
                }
@@ -3905,6 +4461,7 @@ 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;
        if (!s) {
                // expand doesn't point to a stripable, turn it off and use select
                sur->expand = 0;
@@ -3916,7 +4473,12 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                }
                        _select = s;
        }
-       sur->select = s;
+       if (s != old_sel) {
+               sur->select = s;
+               if (sur->custom_mode >= GroupOnly) {
+                       _custom_mode (CusOff, addr);
+               }
+       }
        bool sends;
        uint32_t nsends  = 0;
        do {
@@ -3935,7 +4497,7 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                if (so != 0) {
                        so->refresh_strip (s, nsends, sur->gainmode, true);
                } else {
-                       OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, sur);
+                       OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, *session, sur);
                        sur->sel_obs = sel_fb;
                }
                sur->sel_obs->set_expand (sur->expand_enable);
@@ -3987,9 +4549,12 @@ OSC::strip_gui_select (int ssid, int yn, lo_message msg)
                return -1;
        }
        OSCSurface *sur = get_surface(get_address (msg));
-       sur->expand_enable = false;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        if (s) {
+               if ((sur->custom_mode == BusOnly) && (s != sur->select)) {
+                       return -1;
+               }
+               sur->expand_enable = false;
                SetStripableSelection (s);
        } else {
                if ((int) (sur->feedback.to_ulong())) {
@@ -4025,19 +4590,25 @@ OSC::route_set_gain_dB (int ssid, float dB, lo_message msg)
        OSCSurface *sur = get_surface(get_address (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))) {
+                       gain_control = get_send(s, get_address (msg))->gain_control();
+               } else {
+                       gain_control = s->gain_control();
+               }
                float abs;
-               if (s->gain_control()) {
+               if (gain_control) {
                        if (dB < -192) {
                                abs = 0;
                        } else {
                                abs = dB_to_coefficient (dB);
-                               float top = s->gain_control()->upper();
+                               float top = gain_control->upper();
                                if (abs > top) {
                                        abs = top;
                                }
                        }
-                       fake_touch (s->gain_control());
-                       s->gain_control()->set_value (abs, sur->usegroup);
+                       fake_touch (gain_control);
+                       gain_control->set_value (abs, sur->usegroup);
                        return 0;
                }
        }
@@ -4049,11 +4620,7 @@ OSC::sel_gain (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) {
                float abs;
                if (s->gain_control()) {
@@ -4079,11 +4646,7 @@ OSC::sel_dB_delta (float delta, 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()) {
                        float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
@@ -4115,9 +4678,15 @@ OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if (s->gain_control()) {
-                       fake_touch (s->gain_control());
-                       s->gain_control()->set_value (s->gain_control()->interface_to_internal (pos), sur->usegroup);
+               boost::shared_ptr<GainControl> gain_control;
+               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+                       gain_control = get_send(s, get_address (msg))->gain_control();
+               } else {
+                       gain_control = s->gain_control();
+               }
+               if (gain_control) {
+                       fake_touch (gain_control);
+                       gain_control->set_value (gain_control->interface_to_internal (pos), sur->usegroup);
                } else {
                        return float_message_with_id (X_("/strip/fader"), ssid, 0, sur->feedback[2], get_address (msg));
                }
@@ -4134,18 +4703,24 @@ OSC::strip_db_delta (int ssid, float delta, lo_message msg)
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
        OSCSurface *sur = get_surface(get_address (msg));
        if (s) {
-               float db = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
+               boost::shared_ptr<GainControl> gain_control;
+               if (sur->custom_mode == BusOnly && get_send (s, get_address (msg))) {
+                       gain_control = get_send(s, get_address (msg))->gain_control();
+               } else {
+                       gain_control = s->gain_control();
+               }
+               float db = accurate_coefficient_to_dB (gain_control->get_value()) + delta;
                float abs;
                if (db < -192) {
                        abs = 0;
                } else {
                        abs = dB_to_coefficient (db);
-                       float top = s->gain_control()->upper();
+                       float top = gain_control->upper();
                        if (abs > top) {
                                abs = top;
                        }
                }
-               s->gain_control()->set_value (abs, sur->usegroup);
+               gain_control->set_value (abs, sur->usegroup);
                return 0;
        }
        return -1;
@@ -4179,6 +4754,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/trimdB"), ssid, 0, sur->feedback[2], get_address (msg));
+               }
                if (s->trim_control()) {
                        s->trim_control()->set_value (level, sur->usegroup);
                        return 0;
@@ -4285,8 +4863,17 @@ OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
        OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
-               if(s->pan_azimuth_control()) {
-                       s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup);
+               boost::shared_ptr<PBD::Controllable> pan_control = boost::shared_ptr<PBD::Controllable>();
+               if (sur->custom_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;
+                       }
+               } else {
+                       pan_control = s->pan_azimuth_control();
+               }
+               if(pan_control) {
+                       pan_control->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup);
                        return 0;
                }
        }
@@ -4302,6 +4889,9 @@ 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)) {
+                       return float_message_with_id (X_("/strip/pan_stereo_width"), ssid, 1, sur->feedback[2], get_address (msg));
+               }
                if (s->pan_width_control()) {
                        s->pan_width_control()->set_value (pos, sur->usegroup);
                        return 0;