OSC: same fix for /select/*
[ardour.git] / libs / surfaces / osc / osc.cc
index 90989c5d18938f1304fec602f0b28d641de84aa3..9eee330949f0408e168ba035a8a9de72de55fa8c 100644 (file)
@@ -39,6 +39,7 @@
 #include "ardour/route.h"
 #include "ardour/audio_track.h"
 #include "ardour/midi_track.h"
+#include "ardour/vca.h"
 #include "ardour/monitor_control.h"
 #include "ardour/dB.h"
 #include "ardour/filesystem_paths.h"
@@ -94,7 +95,7 @@ OSC::OSC (Session& s, uint32_t port)
        , _osc_server (0)
        , _osc_unix_server (0)
        , _debugmode (Off)
-       , address_only (false)
+       , address_only (true)
        , remote_port ("8000")
        , default_banksize (0)
        , default_strip (159)
@@ -332,6 +333,7 @@ OSC::stop ()
        periodic_connection.disconnect ();
        session_connections.drop_connections ();
        cueobserver_connections.drop_connections ();
+       Glib::Threads::Mutex::Lock lm (surfaces_lock);
        // Delete any active route observers
        for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
 
@@ -530,18 +532,22 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, "/scroll_dn_1_page", "f", scroll_dn_1_page);
                REGISTER_CALLBACK (serv, "/scroll_dn_1_page", "", scroll_dn_1_page);
                REGISTER_CALLBACK (serv, "/bank_up", "", bank_up);
-               REGISTER_CALLBACK (serv, "/bank_up", "f", bank_up);
+               REGISTER_CALLBACK (serv, "/bank_up", "f", bank_delta);
                REGISTER_CALLBACK (serv, "/bank_down", "", bank_down);
                REGISTER_CALLBACK (serv, "/bank_down", "f", bank_down);
+               REGISTER_CALLBACK (serv, "/use_group", "f", use_group);
 
                // controls for "special" strips
                REGISTER_CALLBACK (serv, "/master/gain", "f", master_set_gain);
                REGISTER_CALLBACK (serv, "/master/fader", "f", master_set_fader);
+               REGISTER_CALLBACK (serv, "/master/db_delta", "f", master_delta_gain);
                REGISTER_CALLBACK (serv, "/master/mute", "i", master_set_mute);
                REGISTER_CALLBACK (serv, "/master/trimdB", "f", master_set_trim);
                REGISTER_CALLBACK (serv, "/master/pan_stereo_position", "f", master_set_pan_stereo_position);
+               REGISTER_CALLBACK (serv, "/master/select", "f", master_select);
                REGISTER_CALLBACK (serv, "/monitor/gain", "f", monitor_set_gain);
                REGISTER_CALLBACK (serv, "/monitor/fader", "f", monitor_set_fader);
+               REGISTER_CALLBACK (serv, "/monitor/db_delta", "f", monitor_delta_gain);
                REGISTER_CALLBACK (serv, "/monitor/mute", "i", monitor_set_mute);
                REGISTER_CALLBACK (serv, "/monitor/dim", "i", monitor_set_dim);
                REGISTER_CALLBACK (serv, "/monitor/mono", "i", monitor_set_mono);
@@ -558,12 +564,14 @@ OSC::register_callbacks()
                REGISTER_CALLBACK (serv, "/select/polarity", "i", sel_phase);
                REGISTER_CALLBACK (serv, "/select/gain", "f", sel_gain);
                REGISTER_CALLBACK (serv, "/select/fader", "f", sel_fader);
+               REGISTER_CALLBACK (serv, "/select/db_delta", "f", sel_dB_delta);
                REGISTER_CALLBACK (serv, "/select/trimdB", "f", sel_trim);
                REGISTER_CALLBACK (serv, "/select/pan_stereo_position", "f", sel_pan_position);
                REGISTER_CALLBACK (serv, "/select/pan_stereo_width", "f", sel_pan_width);
                REGISTER_CALLBACK (serv, "/select/send_gain", "if", sel_sendgain);
                REGISTER_CALLBACK (serv, "/select/send_fader", "if", sel_sendfader);
                REGISTER_CALLBACK (serv, "/select/send_enable", "if", sel_sendenable);
+               REGISTER_CALLBACK (serv, "/select/master_send_enable", "i", sel_master_send_enable);
                REGISTER_CALLBACK (serv, "/select/send_page", "f", sel_send_page);
                REGISTER_CALLBACK (serv, "/select/plug_page", "f", sel_plug_page);
                REGISTER_CALLBACK (serv, "/select/plugin", "f", sel_plugin);
@@ -711,7 +719,7 @@ OSC::listen_to_route (boost::shared_ptr<Stripable> strip, lo_address addr)
 
        OSCSurface *s = get_surface(addr);
        uint32_t ssid = get_sid (strip, addr);
-       OSCRouteObserver* o = new OSCRouteObserver (strip, addr, ssid, s);
+       OSCRouteObserver* o = new OSCRouteObserver (strip, ssid, s);
        route_observers.push_back (o);
 
        strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::route_lost, this, boost::weak_ptr<Stripable> (strip)), this);
@@ -956,6 +964,10 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
 
                ret = 0;
        } else
+       if (strstr (path, "/strip") && (argc != 1)) {
+               // All of the strip commands below require 1 parameter
+               PBD::warning << "OSC: Wrong number of parameters." << endmsg;
+       } else
        if (!strncmp (path, "/strip/gain/", 12) && strlen (path) > 12) {
                // in dB
                int ssid = atoi (&path[12]);
@@ -1029,6 +1041,10 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
        else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) {
                int ssid = atoi (&path[14]);
                ret = strip_gui_select (ssid, argv[0]->i, msg);
+       } else
+       if (strstr (path, "/select") && (argc != 1)) {
+               // All of the select commands below require 1 parameter
+               PBD::warning << "OSC: Wrong number of parameters." << endmsg;
        }
        else if (!strncmp (path, "/select/send_gain/", 18) && strlen (path) > 18) {
                int ssid = atoi (&path[18]);
@@ -1231,23 +1247,29 @@ OSC::routes_list (lo_message msg)
 
                        lo_message reply = lo_message_new ();
 
-                       if (s->presentation_info().flags() & PresentationInfo::AudioTrack) {
+                       if (boost::dynamic_pointer_cast<AudioTrack>(s)) {
                                lo_message_add_string (reply, "AT");
-                       } else if (s->presentation_info().flags() & PresentationInfo::MidiTrack) {
+                       } else if (boost::dynamic_pointer_cast<MidiTrack>(s)) {
                                lo_message_add_string (reply, "MT");
-                       } else if (s->presentation_info().flags() & PresentationInfo::AudioBus) {
-                               // r->feeds (session->master_out()) may make more sense
-                               if (r->direct_feeds_according_to_reality (session->master_out())) {
-                                       // this is a bus
-                                       lo_message_add_string (reply, "B");
+                       } else if (boost::dynamic_pointer_cast<VCA>(s)) {
+                               lo_message_add_string (reply, "V");
+                       } else if (s->is_master()) {
+                               lo_message_add_string (reply, "MA");
+                       } else if (s->is_monitor()) {
+                               lo_message_add_string (reply, "MO");
+                       } else if (boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
+                               if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
+                                       // r->feeds (session->master_out()) may make more sense
+                                       if (r->direct_feeds_according_to_reality (session->master_out())) {
+                                               // this is a bus
+                                               lo_message_add_string (reply, "B");
+                                       } else {
+                                               // this is an Aux out
+                                               lo_message_add_string (reply, "AX");
+                                       }
                                } else {
-                                       // this is an Aux out
-                                       lo_message_add_string (reply, "AX");
+                                       lo_message_add_string (reply, "MB");
                                }
-                       } else if (s->presentation_info().flags() & PresentationInfo::MidiBus) {
-                               lo_message_add_string (reply, "MB");
-                       } else if (s->presentation_info().flags() & PresentationInfo::VCA) {
-                               lo_message_add_string (reply, "V");
                        }
 
                        lo_message_add_string (reply, s->name().c_str());
@@ -1332,11 +1354,6 @@ OSC::get_address (lo_message msg)
 int
 OSC::refresh_surface (lo_message msg)
 {
-       if (address_only) {
-               // get rid of all surfaces and observers.
-               // needs change to only clear those for this address on all ports
-               clear_devices();
-       }
        OSCSurface *s = get_surface(get_address (msg));
        // restart all observers
        set_surface (s->bank_size, (uint32_t) s->strip_types.to_ulong(), (uint32_t) s->feedback.to_ulong(), \
@@ -1347,6 +1364,8 @@ OSC::refresh_surface (lo_message msg)
 void
 OSC::clear_devices ()
 {
+       tick = false;
+       Glib::Threads::Mutex::Lock lm (surfaces_lock);
        for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) {
 
                OSCRouteObserver* rc;
@@ -1393,6 +1412,7 @@ OSC::clear_devices ()
 
        // clear out surfaces
        _surface.clear();
+       tick = true;
 }
 
 int
@@ -1409,81 +1429,82 @@ OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc
 
 
        if (!strncmp (path, "/set_surface/feedback", 21)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = set_surface_feedback ((int)argv[0]->f, msg);
                } else {
                        ret = set_surface_feedback (argv[0]->i, msg);
                }
        }
        else if (!strncmp (path, "/set_surface/bank_size", 22)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = set_surface_bank_size ((int)argv[0]->f, msg);
                } else {
                        ret = set_surface_bank_size (argv[0]->i, msg);
                }
        }
        else if (!strncmp (path, "/set_surface/gainmode", 21)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = set_surface_gainmode ((int)argv[0]->f, msg);
                } else {
                        ret = set_surface_gainmode (argv[0]->i, msg);
                }
        }
        else if (!strncmp (path, "/set_surface/strip_types", 24)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = set_surface_strip_types ((int)argv[0]->f, msg);
                } else {
                        ret = set_surface_strip_types (argv[0]->i, msg);
                }
        }
        else if (!strncmp (path, "/set_surface/send_page_size", 27)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = sel_send_pagesize ((int)argv[0]->f, msg);
                } else {
                        ret = sel_send_pagesize (argv[0]->i, msg);
                }
        }
        else if (!strncmp (path, "/set_surface/plugin_page_size", 29)) {
-               if (argv[0]->f) {
+               if (types[0] == 'f') {
                        ret = sel_plug_pagesize ((int)argv[0]->f, msg);
                } else {
                        ret = sel_plug_pagesize (argv[0]->i, msg);
                }
        } else if (strlen(path) == 12) {
+
                // command is in /set_surface iii form
                switch (argc) {
                        case 6:
-                               if (argv[5]->f) {
+                               if (types[5] == 'f') {
                                        pi_page = (int) argv[5]->f;
                                } else {
                                        pi_page = argv[5]->i;
                                }
                        case 5:
-                               if (argv[4]->f) {
+                               if (types[4] == 'f') {
                                        se_page = (int) argv[4]->f;
                                } else {
                                        se_page = argv[4]->i;
                                }
                        case 4:
-                               if (argv[3]->f) {
+                               if (types[3] == 'f') {
                                        fadermode = (int) argv[3]->f;
                                } else {
                                        fadermode = argv[3]->i;
                                }
                        case 3:
-                               if (argv[2]->f) {
+                               if (types[2] == 'f') {
                                        feedback = (int) argv[2]->f;
                                } else {
                                        feedback = argv[2]->i;
                                }
                        case 2:
-                               if (argv[1]->f) {
+                               if (types[1] == 'f') {
                                        strip_types = (int) argv[1]->f;
                                } else {
                                        strip_types = argv[1]->i;
                                }
                        case 1:
-                               if (argv[0]->f) {
+                               if (types[0] == 'f') {
                                        bank_size = (int) argv[0]->f;
                                } else {
                                        bank_size = argv[0]->i;
@@ -1530,37 +1551,37 @@ OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc
                                                if (pp) {
                                                        pi_page = atoi (&pp[1]);
                                                } else {
-                                                       if (argv[0]->f) {
+                                                       if (types[0] == 'f') {
                                                                pi_page = (int) argv[0]->f;
-                                                       } else if (argv[0]->i) {
+                                                       } else if (types[0] == 'i') {
                                                                pi_page = argv[0]->i;
                                                        }
                                                }
                                        } else {
-                                               if (argv[0]->f) {
+                                               if (types[0] == 'f') {
                                                        se_page = (int) argv[0]->f;
-                                               } else if (argv[0]->i) {
+                                               } else if (types[0] == 'i') {
                                                        se_page = argv[0]->i;
                                                }
                                        }
                                } else {
-                                       if (argv[0]->f) {
+                                       if (types[0] == 'f') {
                                                fadermode = (int) argv[0]->f;
-                                       } else if (argv[0]->i) {
+                                       } else if (types[0] == 'i') {
                                                fadermode = argv[0]->i;
                                        }
                                }
                        } else {
-                               if (argv[0]->f) {
+                               if (types[0] == 'f') {
                                        feedback = (int) argv[0]->f;
-                               } else if (argv[0]->i) {
+                               } else if (types[0] == 'i') {
                                        feedback = argv[0]->i;
                                }
                        }
                } else {
-                       if (argv[0]->f) {
+                       if (types[0] == 'f') {
                                strip_types = (int) argv[0]->f;
-                       } else if (argv[0]->i) {
+                       } else if (types[0] == 'i') {
                                strip_types = argv[0]->i;
                        }
                }
@@ -1577,12 +1598,17 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui
        s->strip_types = strips;
        s->feedback = fb;
        s->gainmode = gm;
+       if (s->strip_types[10]) {
+               s->usegroup = PBD::Controllable::UseGroup;
+       } else {
+               s->usegroup = PBD::Controllable::NoGroup;
+       }
        s->send_page_size = se_size;
        s->plug_page_size = pi_size;
        // set bank and strip feedback
        set_bank(s->bank, msg);
 
-       global_feedback (s->feedback, get_address (msg), s->gainmode);
+       global_feedback (*s, get_address (msg));
        sel_send_pagesize (se_size, msg);
        sel_plug_pagesize (pi_size, msg);
        return 0;
@@ -1604,6 +1630,11 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg)
 {
        OSCSurface *s = get_surface(get_address (msg));
        s->strip_types = st;
+       if (s->strip_types[10]) {
+               s->usegroup = PBD::Controllable::UseGroup;
+       } else {
+               s->usegroup = PBD::Controllable::NoGroup;
+       }
 
        // set bank and strip feedback
        set_bank(s->bank, msg);
@@ -1621,7 +1652,7 @@ OSC::set_surface_feedback (uint32_t fb, lo_message msg)
        set_bank(s->bank, msg);
 
        // Set global/master feedback
-       global_feedback (s->feedback, get_address (msg), s->gainmode);
+       global_feedback (*s, get_address (msg));
        return 0;
 }
 
@@ -1635,7 +1666,7 @@ OSC::set_surface_gainmode (uint32_t gm, lo_message msg)
        set_bank(s->bank, msg);
 
        // Set global/master feedback
-       global_feedback (s->feedback, get_address (msg), s->gainmode);
+       global_feedback (*s, get_address (msg));
        return 0;
 }
 
@@ -1663,10 +1694,13 @@ OSC::get_surface (lo_address addr)
        rurl = lo_address_get_url (addr);
        r_url = rurl;
        free (rurl);
-       for (uint32_t it = 0; it < _surface.size(); ++it) {
-               //find setup for this server
-               if (!_surface[it].remote_url.find(r_url)){
-                       return &_surface[it];
+       {
+               Glib::Threads::Mutex::Lock lm (surfaces_lock);
+               for (uint32_t it = 0; it < _surface.size(); ++it) {
+                       //find setup for this server
+                       if (!_surface[it].remote_url.find(r_url)){
+                               return &_surface[it];
+                       }
                }
        }
 
@@ -1676,10 +1710,11 @@ OSC::get_surface (lo_address addr)
        s.no_clear = false;
        s.jogmode = JOG;
        s.bank = 1;
-       s.bank_size = default_banksize; // need to find out how many strips there are
-       s.strip_types = default_strip; // 159 is tracks, busses, and VCAs (no master/monitor)
+       s.bank_size = default_banksize;
+       s.strip_types = default_strip;
        s.feedback = default_feedback;
        s.gainmode = default_gainmode;
+       s.usegroup = PBD::Controllable::NoGroup;
        s.sel_obs = 0;
        s.expand = 0;
        s.expand_enable = false;
@@ -1693,7 +1728,10 @@ OSC::get_surface (lo_address addr)
        s.plugin_id = 1;
 
        s.nstrips = s.strips.size();
-       _surface.push_back (s);
+       {
+               Glib::Threads::Mutex::Lock lm (surfaces_lock);
+               _surface.push_back (s);
+       }
        // moved this down here as selection may need s.<anything to do with select> set
        if (!_select || (_select != ControlProtocol::first_selected_stripable())) {
                gui_selection_changed();
@@ -1703,24 +1741,24 @@ OSC::get_surface (lo_address addr)
        _set_bank(s.bank, addr);
 
        // Set global/master feedback
-       global_feedback (s.feedback, addr, s.gainmode);
+       global_feedback (s, addr);
 
        return &_surface[_surface.size() - 1];
 }
 
 // setup global feedback for a surface
 void
-OSC::global_feedback (bitset<32> feedback, lo_address addr, uint32_t gainmode)
+OSC::global_feedback (OSCSurface sur, lo_address addr)
 {
        // first destroy global observer for this surface
        GlobalObservers::iterator x;
        for (x = global_observers.begin(); x != global_observers.end();) {
 
-               OSCGlobalObserver* ro;
+               OSCGlobalObserver* go;
 
-               if ((ro = dynamic_cast<OSCGlobalObserver*>(*x)) != 0) {
+               if ((go = dynamic_cast<OSCGlobalObserver*>(*x)) != 0) {
 
-                       int res = strcmp(lo_address_get_url(ro->address()), lo_address_get_url(addr));
+                       int res = strcmp(lo_address_get_url(go->address()), lo_address_get_url(addr));
 
                        if (res == 0) {
                                delete *x;
@@ -1732,9 +1770,10 @@ OSC::global_feedback (bitset<32> feedback, lo_address addr, uint32_t gainmode)
                        ++x;
                }
        }
+       std::bitset<32> feedback = sur.feedback;
        if (feedback[4] || feedback[3] || feedback[5] || feedback[6]) {
                // create a new Global Observer for this surface
-               OSCGlobalObserver* o = new OSCGlobalObserver (*session, addr, gainmode, /*s->*/feedback);
+               OSCGlobalObserver* o = new OSCGlobalObserver (*session, &sur);
                global_observers.push_back (o);
        }
 }
@@ -1868,7 +1907,7 @@ OSC::_set_bank (uint32_t bank_start, lo_address addr)
                                }
                        }
                        // slow devices need time to clear buffers
-                       usleep ((uint32_t) 10);
+                       usleep ((uint32_t) 20);
                }
        }
        // light bankup or bankdown buttons if it is possible to bank in that direction
@@ -1907,6 +1946,23 @@ OSC::bank_up (lo_message msg)
        return 0;
 }
 
+int
+OSC::bank_delta (float delta, lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       OSCSurface *s = get_surface(get_address (msg));
+       uint32_t new_bank = s->bank + (s->bank_size * (int) delta);
+       if ((int)new_bank < 1) {
+               new_bank = 1;
+       }
+       if (new_bank != s->bank) {
+               set_bank (new_bank, msg);
+       }
+       return 0;
+}
+
 int
 OSC::bank_down (lo_message msg)
 {
@@ -1922,6 +1978,21 @@ OSC::bank_down (lo_message msg)
        return 0;
 }
 
+int
+OSC::use_group (float value, lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       OSCSurface *s = get_surface(get_address (msg));
+       if (value) {
+               s->usegroup = PBD::Controllable::UseGroup;
+       } else {
+               s->usegroup = PBD::Controllable::NoGroup;
+       }
+       return 0;
+}
+
 uint32_t
 OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
 {
@@ -2028,29 +2099,44 @@ OSC::_sel_plugin (int id, lo_address addr)
                // find out how many plugins we have
                bool plugs;
                int nplugs  = 0;
+               sur->plugins.clear();
                do {
                        plugs = false;
                        if (r->nth_plugin (nplugs)) {
-                               /// need to check for mixbus channel strips (and exclude them)
+                               if (r->nth_plugin(nplugs)->display_to_user()) {
+#ifdef MIXBUS
+                                       // need to check for mixbus channel strips (and exclude them)
+                                       boost::shared_ptr<Processor> proc = r->nth_plugin (nplugs);
+                                       boost::shared_ptr<PluginInsert> pi;
+                                       if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
+
+                                               if (!pi->is_channelstrip()) {
+#endif
+                                                       sur->plugins.push_back (nplugs);
+#ifdef MIXBUS
+                                               }
+                                       }
+#endif
+                               }
                                plugs = true;
                                nplugs++;
                        }
                } while (plugs);
 
                // limit plugin_id to actual plugins
-               if (!nplugs) {
+               if (!sur->plugins.size()) {
                        sur->plugin_id = 0;
                        return 0;
-               } else if (nplugs < id) {
-                       sur->plugin_id = nplugs;
-               } else  if (nplugs && !id) {
+               } else if (sur->plugins.size() < (uint32_t) id) {
+                       sur->plugin_id = sur->plugins.size();
+               } else  if (sur->plugins.size() && !id) {
                        sur->plugin_id = 1;
                } else {
                        sur->plugin_id = id;
                }
 
                // we have a plugin number now get the processor
-               boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugin_id - 1);
+               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;                 
@@ -2313,7 +2399,33 @@ OSC::master_set_gain (float dB)
                if (dB < -192) {
                        s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
                } else {
-                       s->gain_control()->set_value (dB_to_coefficient (dB), PBD::Controllable::NoGroup);
+                       float abs = dB_to_coefficient (dB);
+                       float top = s->gain_control()->upper();
+                       if (abs > top) {
+                               abs = top;
+                       }
+                       s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+               }
+       }
+       return 0;
+}
+
+int
+OSC::master_delta_gain (float delta)
+{
+       if (!session) return -1;
+       boost::shared_ptr<Stripable> s = session->master_out();
+       if (s) {
+               float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
+               if (dB < -192) {
+                       s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
+               } else {
+                       float abs = dB_to_coefficient (dB);
+                       float top = s->gain_control()->upper();
+                       if (abs > top) {
+                               abs = top;
+                       }
+                       s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
                }
        }
        return 0;
@@ -2384,6 +2496,22 @@ OSC::master_set_mute (uint32_t state)
        return 0;
 }
 
+int
+OSC::master_select (lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       OSCSurface *sur = get_surface(get_address (msg));
+       sur->expand_enable = false;
+       boost::shared_ptr<Stripable> s = session->master_out();
+       if (s) {
+               SetStripableSelection (s);
+       }
+
+       return 0;
+}
+
 int
 OSC::monitor_set_gain (float dB)
 {
@@ -2394,7 +2522,33 @@ OSC::monitor_set_gain (float dB)
                if (dB < -192) {
                        s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
                } else {
-                       s->gain_control()->set_value (dB_to_coefficient (dB), PBD::Controllable::NoGroup);
+                       float abs = dB_to_coefficient (dB);
+                       float top = s->gain_control()->upper();
+                       if (abs > top) {
+                               abs = top;
+                       }
+                       s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+               }
+       }
+       return 0;
+}
+
+int
+OSC::monitor_delta_gain (float delta)
+{
+       if (!session) return -1;
+       boost::shared_ptr<Stripable> s = session->monitor_out();
+       if (s) {
+               float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
+               if (dB < -192) {
+                       s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
+               } else {
+                       float abs = dB_to_coefficient (dB);
+                       float top = s->gain_control()->upper();
+                       if (abs > top) {
+                               abs = top;
+                       }
+                       s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
                }
        }
        return 0;
@@ -2573,7 +2727,7 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg
        uint32_t ssid;
 
        if (argc) {
-               if (argv[argc - 1]->f) {
+               if (types[argc - 1] == 'f') {
                        aut = (int)argv[argc - 1]->f;
                } else {
                        aut = argv[argc - 1]->i;
@@ -2659,7 +2813,7 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
        uint32_t ssid;
 
        if (argc) {
-               if (argv[argc - 1]->f) {
+               if (types[argc - 1] == 'f') {
                        touch = (int)argv[argc - 1]->f;
                } else {
                        touch = argv[argc - 1]->i;
@@ -2707,13 +2861,11 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc,
                if (control) {
                        if (touch) {
                                //start touch
-                               if (control->automation_state() == Touch && !control->touching ()) {
-                                       control->start_touch (control->session().transport_frame());
-                               }
+                               control->start_touch (control->session().transport_frame());
                                ret = 0;
                        } else {
                                // end touch
-                               control->stop_touch (true, control->session().transport_frame());
+                               control->stop_touch (control->session().transport_frame());
                                ret = 0;
                        }
                        // just in case some crazy surface starts sending control values before touch
@@ -2746,10 +2898,11 @@ OSC::route_mute (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->mute_control()) {
-                       s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                       s->mute_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
                }
        }
@@ -2781,10 +2934,11 @@ OSC::route_solo (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->solo_control()) {
-                       s->solo_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                       s->solo_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                }
        }
 
@@ -2796,10 +2950,11 @@ OSC::route_solo_iso (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->solo_isolate_control()) {
-                       s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                       s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
                }
        }
@@ -2812,10 +2967,11 @@ OSC::route_solo_safe (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->solo_safe_control()) {
-                       s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                       s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
                }
        }
@@ -2905,10 +3061,11 @@ OSC::route_recenable (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->rec_enable_control()) {
-                       s->rec_enable_control()->set_value (yn, PBD::Controllable::UseGroup);
+                       s->rec_enable_control()->set_value (yn, sur->usegroup);
                        if (s->rec_enable_control()->get_value()) {
                                return 0;
                        }
@@ -2958,9 +3115,10 @@ OSC::route_recsafe (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
        if (s) {
                if (s->rec_safe_control()) {
-                       s->rec_safe_control()->set_value (yn, PBD::Controllable::UseGroup);
+                       s->rec_safe_control()->set_value (yn, sur->usegroup);
                        if (s->rec_safe_control()->get_value()) {
                                return 0;
                        }
@@ -2974,12 +3132,13 @@ OSC::route_monitor_input (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
                if (track) {
                        if (track->monitoring_control()) {
-                               track->monitoring_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                               track->monitoring_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                                return 0;
                        }
                }
@@ -3015,12 +3174,13 @@ OSC::route_monitor_disk (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
                if (track) {
                        if (track->monitoring_control()) {
-                               track->monitoring_control()->set_value (yn ? 2.0 : 0.0, PBD::Controllable::NoGroup);
+                               track->monitoring_control()->set_value (yn ? 2.0 : 0.0, sur->usegroup);
                                return 0;
                        }
                }
@@ -3057,10 +3217,11 @@ OSC::strip_phase (int ssid, int yn, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->phase_control()) {
-                       s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
+                       s->phase_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
                        return 0;
                }
        }
@@ -3114,7 +3275,7 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
                delete sur->sel_obs;
                sur->sel_obs = 0;
        }
-       bool feedback_on = sur->feedback.to_ulong();
+       bool feedback_on = sur->feedback[13];
        if (s && feedback_on) {
                OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, sur);
                s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
@@ -3245,11 +3406,12 @@ OSC::route_set_gain_abs (int ssid, float level, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->gain_control()) {
                        fake_touch (s->gain_control());
-                       s->gain_control()->set_value (level, PBD::Controllable::NoGroup);
+                       s->gain_control()->set_value (level, sur->usegroup);
                } else {
                        return 1;
                }
@@ -3291,12 +3453,47 @@ OSC::sel_gain (float val, lo_message msg)
        }
        if (s) {
                float abs;
-               if (val < -192) {
-                       abs = 0;
-               } else {
-                       abs = dB_to_coefficient (val);
+               if (s->gain_control()) {
+                       if (val < -192) {
+                               abs = 0;
+                       } else {
+                               abs = dB_to_coefficient (val);
+                               float top = s->gain_control()->upper();
+                               if (abs > top) {
+                                       abs = top;
+                               }
+                       }
+                       fake_touch (s->gain_control());
+                       s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+                       return 0;
                }
+       }
+       return sel_fail ("gain", -193, get_address (msg));
+}
+
+int
+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;
+       }
+       if (s) {
                if (s->gain_control()) {
+                       float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
+                       float abs;
+                       if (dB < -192) {
+                               abs = 0;
+                       } else {
+                               abs = dB_to_coefficient (dB);
+                               float top = s->gain_control()->upper();
+                               if (abs > top) {
+                                       abs = top;
+                               }
+                       }
                        fake_touch (s->gain_control());
                        s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
                        return 0;
@@ -3312,11 +3509,12 @@ OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
                return -1;
        }
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (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), PBD::Controllable::NoGroup);
+                       s->gain_control()->set_value (s->gain_control()->interface_to_internal (pos), sur->usegroup);
                } else {
                        return route_send_fail ("fader", ssid, 0, get_address (msg));
                }
@@ -3331,6 +3529,7 @@ OSC::strip_db_delta (int ssid, float delta, lo_message msg)
 {
        if (!session) return -1;
        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;
                float abs;
@@ -3338,8 +3537,12 @@ OSC::strip_db_delta (int ssid, float delta, lo_message msg)
                        abs = 0;
                } else {
                        abs = dB_to_coefficient (db);
+                       float top = s->gain_control()->upper();
+                       if (abs > top) {
+                               abs = top;
+                       }
                }
-               s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
+               s->gain_control()->set_value (abs, sur->usegroup);
                return 0;
        }
        return -1;
@@ -3370,10 +3573,11 @@ OSC::route_set_trim_abs (int ssid, float level, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->trim_control()) {
-                       s->trim_control()->set_value (level, PBD::Controllable::NoGroup);
+                       s->trim_control()->set_value (level, sur->usegroup);
                        return 0;
                }
 
@@ -3456,10 +3660,11 @@ OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (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), PBD::Controllable::NoGroup);
+                       s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup);
                        return 0;
                }
        }
@@ -3472,10 +3677,11 @@ OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg)
 {
        if (!session) return -1;
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
                if (s->pan_width_control()) {
-                       s->pan_width_control()->set_value (pos, PBD::Controllable::NoGroup);
+                       s->pan_width_control()->set_value (pos, sur->usegroup);
                        return 0;
                }
        }
@@ -3490,6 +3696,7 @@ OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg)
                return -1;
        }
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
        float abs;
        if (s) {
                if (id > 0) {
@@ -3505,7 +3712,7 @@ OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg)
                }
 #endif
                if (s->send_level_controllable (id)) {
-                       s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+                       s->send_level_controllable (id)->set_value (abs, sur->usegroup);
                        return 0;
                }
        }
@@ -3519,6 +3726,7 @@ OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg)
                return -1;
        }
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
        float abs;
        if (s) {
 
@@ -3528,7 +3736,7 @@ OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg)
 
                if (s->send_level_controllable (id)) {
                        abs = s->send_level_controllable(id)->interface_to_internal (val);
-                       s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
+                       s->send_level_controllable (id)->set_value (abs, sur->usegroup);
                        return 0;
                }
        }
@@ -3549,7 +3757,7 @@ OSC::sel_sendgain (int id, float val, lo_message msg)
                s = _select;
        }
        float abs;
-       int send_id;
+       int send_id = 0;
        if (s) {
                if (id > 0) {
                        send_id = id - 1;
@@ -3588,7 +3796,7 @@ OSC::sel_sendfader (int id, float val, lo_message msg)
                s = _select;
        }
        float abs;
-       int send_id;
+       int send_id = 0;
        if (s) {
 
                if (id > 0) {
@@ -3614,6 +3822,7 @@ OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
                return -1;
        }
        boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
+       OSCSurface *sur = get_surface(get_address (msg));
 
        if (s) {
 
@@ -3624,7 +3833,7 @@ OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
                }
 
                if (s->send_enable_controllable (sid)) {
-                       s->send_enable_controllable (sid)->set_value (val, PBD::Controllable::NoGroup);
+                       s->send_enable_controllable (sid)->set_value (val, sur->usegroup);
                        return 0;
                }
 
@@ -3662,7 +3871,7 @@ OSC::sel_sendenable (int id, float val, lo_message msg)
        } else {
                s = _select;
        }
-       int send_id;
+       int send_id = 0;
        if (s) {
                if (id > 0) {
                        send_id = id - 1;
@@ -3694,6 +3903,25 @@ OSC::sel_sendenable (int id, float val, lo_message msg)
        return sel_send_fail ("send_enable", id, 0, get_address (msg));
 }
 
+int
+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;
+       }
+       if (s) {
+               if (s->master_send_enable_controllable ()) {
+                       s->master_send_enable_controllable()->set_value (state, PBD::Controllable::NoGroup);
+                       return 0;
+               }
+       }
+       return cue_float_message ("/select/master_send_enable", 0, get_address(msg));
+}
+
 int
 OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) {
        OSCSurface *sur = get_surface(get_address (msg));
@@ -3704,20 +3932,20 @@ OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv
                // no inline args
                if (argc == 2) {
                        // change parameter in already selected plugin
-                       if (argv[0]->f) {
+                       if (types[0]  == 'f') {
                                paid = (int) argv[0]->f;
                        } else {
                                paid = argv[0]->i;
                        }
                        value = argv[1]->f;
                } else if (argc == 3) {
-                       if (argv[0]->f) {
+                       if (types[0] == 'f') {
                                piid = (int) argv[0]->f;
                        } else {
                                piid = argv[0]->i;
                        }
                        _sel_plugin (piid, get_address (msg));
-                       if (argv[1]->f) {
+                       if (types[1] == 'f') {
                                paid = (int) argv[1]->f;
                        } else {
                                paid = argv[1]->i;
@@ -3763,7 +3991,7 @@ OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv
                return 1;
        }
 
-       boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugin_id - 1);
+       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))) {
                return 1;
@@ -3837,6 +4065,7 @@ OSC::route_plugin_list (int ssid, lo_message msg) {
 
                boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
                lo_message_add_string (reply, pip->name());
+               lo_message_add_int32(reply, redi->enabled() ? 1 : 0);
 
                piid++;
        }
@@ -3876,58 +4105,99 @@ OSC::route_plugin_descriptor (int ssid, int piid, lo_message msg) {
        boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
        bool ok = false;
 
-       lo_message reply = lo_message_new();
-       lo_message_add_int32 (reply, ssid);
-       lo_message_add_int32 (reply, piid);
-       lo_message_add_string (reply, pip->name());
        for ( uint32_t ppi = 0; ppi < pip->parameter_count(); ppi++) {
 
                uint32_t controlid = pip->nth_parameter(ppi, ok);
                if (!ok) {
                        continue;
                }
-               if ( pip->parameter_is_input(controlid) || pip->parameter_is_control(controlid) ) {
-                       boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
-
-                               lo_message_add_int32 (reply, ppi + 1);
-                               ParameterDescriptor pd;
-                               pi->plugin()->get_parameter_descriptor(controlid, pd);
-                               lo_message_add_string (reply, pd.label.c_str());
-
-                               // I've combined those binary descriptor parts in a bit-field to reduce lilo message elements
-                               int flags = 0;
-                               flags |= pd.enumeration ? 1 : 0;
-                               flags |= pd.integer_step ? 2 : 0;
-                               flags |= pd.logarithmic ? 4 : 0;
-                               flags |= pd.sr_dependent ? 32 : 0;
-                               flags |= pd.toggled ? 64 : 0;
-                               flags |= c != NULL ? 128 : 0; // bit 7 indicates in input control
-                               lo_message_add_int32 (reply, flags);
-
-                               lo_message_add_int32 (reply, pd.datatype);
-                               lo_message_add_float (reply, pd.lower);
-                               lo_message_add_float (reply, pd.upper);
-                               lo_message_add_string (reply, pd.print_fmt.c_str());
-                               if ( pd.scale_points ) {
-                                       lo_message_add_int32 (reply, pd.scale_points->size());
-                                       for ( ARDOUR::ScalePoints::const_iterator i = pd.scale_points->begin(); i != pd.scale_points->end(); ++i) {
-                                               lo_message_add_int32 (reply, i->second);
-                                               lo_message_add_string (reply, ((std::string)i->first).c_str());
-                                       }
-                               }
-                               else {
-                                       lo_message_add_int32 (reply, 0);
-                               }
-                               if ( c ) {
-                                       lo_message_add_double (reply, c->get_value());
-                               }
-                               else {
-                                       lo_message_add_double (reply, 0);
+               boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
+
+               lo_message reply = lo_message_new();
+               lo_message_add_int32 (reply, ssid);
+               lo_message_add_int32 (reply, piid);
+
+               lo_message_add_int32 (reply, ppi + 1);
+               ParameterDescriptor pd;
+               pi->plugin()->get_parameter_descriptor(controlid, pd);
+               lo_message_add_string (reply, pd.label.c_str());
+
+               // I've combined those binary descriptor parts in a bit-field to reduce lilo message elements
+               int flags = 0;
+               flags |= pd.enumeration ? 1 : 0;
+               flags |= pd.integer_step ? 2 : 0;
+               flags |= pd.logarithmic ? 4 : 0;
+               flags |= pd.sr_dependent ? 32 : 0;
+               flags |= pd.toggled ? 64 : 0;
+               flags |= pip->parameter_is_input(controlid) ? 0x80 : 0;
+
+               std::string param_desc = pi->plugin()->describe_parameter(Evoral::Parameter(PluginAutomation, 0, controlid));
+               flags |= (param_desc == X_("hidden")) ? 0x100 : 0;
+               lo_message_add_int32 (reply, flags);
+
+               switch(pd.datatype) {
+                       case ARDOUR::Variant::BEATS:
+                               lo_message_add_string(reply, _("BEATS"));
+                               break;
+                       case ARDOUR::Variant::BOOL:
+                               lo_message_add_string(reply, _("BOOL"));
+                               break;
+                       case ARDOUR::Variant::DOUBLE:
+                               lo_message_add_string(reply, _("DOUBLE"));
+                               break;
+                       case ARDOUR::Variant::FLOAT:
+                               lo_message_add_string(reply, _("FLOAT"));
+                               break;
+                       case ARDOUR::Variant::INT:
+                               lo_message_add_string(reply, _("INT"));
+                               break;
+                       case ARDOUR::Variant::LONG:
+                               lo_message_add_string(reply, _("LONG"));
+                               break;
+                       case ARDOUR::Variant::NOTHING:
+                               lo_message_add_string(reply, _("NOTHING"));
+                               break;
+                       case ARDOUR::Variant::PATH:
+                               lo_message_add_string(reply, _("PATH"));
+                               break;
+                       case ARDOUR::Variant::STRING:
+                               lo_message_add_string(reply, _("STRING"));
+                               break;
+                       case ARDOUR::Variant::URI:
+                               lo_message_add_string(reply, _("URI"));
+                               break;
+                       default:
+                               lo_message_add_string(reply, _("UNKNOWN"));
+                               break;
+               }
+               lo_message_add_float (reply, pd.lower);
+               lo_message_add_float (reply, pd.upper);
+               lo_message_add_string (reply, pd.print_fmt.c_str());
+               if ( pd.scale_points ) {
+                       lo_message_add_int32 (reply, pd.scale_points->size());
+                       for ( ARDOUR::ScalePoints::const_iterator i = pd.scale_points->begin(); i != pd.scale_points->end(); ++i) {
+                               lo_message_add_float (reply, i->second);
+                               lo_message_add_string (reply, ((std::string)i->first).c_str());
                        }
                }
+               else {
+                       lo_message_add_int32 (reply, 0);
+               }
+               if ( c ) {
+                       lo_message_add_double (reply, c->get_value());
+               }
+               else {
+                       lo_message_add_double (reply, 0);
+               }
+
+               lo_send_message (get_address (msg), "/strip/plugin/descriptor", reply);
+               lo_message_free (reply);
        }
 
-       lo_send_message (get_address (msg), "/strip/plugin/descriptor", reply);
+       lo_message reply = lo_message_new ();
+       lo_message_add_int32 (reply, ssid);
+       lo_message_add_int32 (reply, piid);
+       lo_send_message (get_address (msg), "/strip/plugin/descriptor_end", reply);
        lo_message_free (reply);
 
        return 0;
@@ -4548,10 +4818,11 @@ OSC::periodic (void)
        if (!tick) {
                Glib::usleep(100); // let flurry of signals subside
                if (global_init) {
+                       Glib::Threads::Mutex::Lock lm (surfaces_lock);
                        for (uint32_t it = 0; it < _surface.size(); it++) {
                                OSCSurface* sur = &_surface[it];
                                lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
-                               global_feedback (sur->feedback, addr, sur->gainmode);
+                               global_feedback (*sur, addr);
                        }
                        global_init = false;
                        tick = true;
@@ -4611,7 +4882,7 @@ OSC::periodic (void)
                if (!(*x).second) {
                        boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
                        // turn touch off
-                       ctrl->stop_touch (true, ctrl->session().transport_frame());
+                       ctrl->stop_touch (ctrl->session().transport_frame());
                        _touch_timeout.erase (x++);
                } else {
                        x++;
@@ -4705,25 +4976,6 @@ OSC::get_state ()
        node.set_property ("gainmode", default_gainmode);
        node.set_property ("send-page-size", default_send_size);
        node.set_property ("plug-page-size", default_plugin_size);
-       if (_surface.size()) {
-               XMLNode* config = new XMLNode (X_("Configurations"));
-               for (uint32_t it = 0; it < _surface.size(); ++it) {
-                       OSCSurface* sur = &_surface[it];
-                       XMLNode* devnode = new XMLNode (X_("Configuration"));
-                       devnode->set_property (X_("url"), sur->remote_url);
-                       devnode->set_property (X_("bank-size"), sur->bank_size);
-                       devnode->set_property (X_("strip-types"), (uint64_t)sur->strip_types.to_ulong());
-                       devnode->set_property (X_("feedback"), (uint64_t)sur->feedback.to_ulong());
-                       devnode->set_property (X_("gainmode"), sur->gainmode);
-                       devnode->set_property (X_("send-page-size"), sur->send_page_size);
-                       devnode->set_property (X_("plug-page-size"), sur->plug_page_size);
-                       devnode->set_property (X_("no-clear"), sur->no_clear);
-                       devnode->set_property (X_("cue"), sur->cue);
-                       devnode->set_property (X_("aux"), sur->aux);
-                       config->add_child_nocopy (*devnode);
-               }
-               node.add_child_nocopy (*config);
-       }
        return node;
 }
 
@@ -4747,44 +4999,6 @@ OSC::set_state (const XMLNode& node, int version)
        node.get_property (X_("send-page-size"), default_send_size);
        node.get_property (X_("plugin-page-size"), default_plugin_size);
 
-       XMLNode* cnode = node.child (X_("Configurations"));
-
-       if (cnode) {
-               XMLNodeList const& devices = cnode->children();
-               for (XMLNodeList::const_iterator d = devices.begin(); d != devices.end(); ++d) {
-                       OSCSurface s;
-                       if (!(*d)->get_property (X_("url"), s.remote_url)) {
-                               continue;
-                       }
-
-                       bank_dirty = true;
-
-                       (*d)->get_property (X_("bank-size"), s.bank_size);
-
-                       uint64_t bits;
-                       if ((*d)->get_property (X_ ("strip-types"), bits)) {
-                               s.strip_types = bits;
-                       }
-                       if ((*d)->get_property (X_("feedback"), bits)) {
-                               s.feedback = bits;
-                       }
-                       (*d)->get_property (X_("gainmode"), s.gainmode);
-
-                       (*d)->get_property (X_("send-page-size"), s.send_page_size);
-                       (*d)->get_property (X_("plug-page-size"), s.plug_page_size);
-                       (*d)->get_property (X_("no-clear"), s.no_clear);
-                       (*d)->get_property (X_("cue"), s.cue);
-                       (*d)->get_property (X_("aux"), s.aux);
-                       s.bank = 1;
-                       s.sel_obs = 0;
-                       s.expand = 0;
-                       s.expand_enable = false;
-                       s.strips = get_sorted_stripables (s.strip_types, s.cue);
-                       s.nstrips = s.strips.size ();
-                       s.jogmode = JOG;
-                       _surface.push_back (s);
-               }
-       }
        global_init = true;
        tick = false;
 
@@ -4814,10 +5028,9 @@ OSC::Sorted
 OSC::get_sorted_stripables(std::bitset<32> types, bool cue)
 {
        Sorted sorted;
-
-       // fetch all stripables
        StripableList stripables;
 
+       // fetch all stripables
        session->get_stripables (stripables);
 
        // Look for stripables that match bit in sur->strip_types
@@ -4826,46 +5039,49 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue)
                boost::shared_ptr<Stripable> s = *it;
                if ((!cue) && (!types[9]) && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
                        // do nothing... skip it
+               } else if (types[8] && (s->is_selected())) {
+                       sorted.push_back (s);
+               } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
+                       sorted.push_back (s);
+               } else if (s->is_master() || s->is_monitor() || s->is_auditioner()) {
+                       // do nothing for these either (we add them later)
                } else {
-
-                       if (types[0] && (s->presentation_info().flags() & PresentationInfo::AudioTrack)) {
+                       if (types[0] && boost::dynamic_pointer_cast<AudioTrack>(s)) {
+                               sorted.push_back (s);
+                       } else if (types[1] && boost::dynamic_pointer_cast<MidiTrack>(s)) {
+                               sorted.push_back (s);
+                       } else if (types[4] && boost::dynamic_pointer_cast<VCA>(s)) {
                                sorted.push_back (s);
                        } else
-                       if (types[1] && (s->presentation_info().flags() & PresentationInfo::MidiTrack)) {
+#ifdef MIXBUS
+                       if (types[2] && Profile->get_mixbus() && s->mixbus()) {
                                sorted.push_back (s);
                        } else
-                       if ((s->presentation_info().flags() & PresentationInfo::AudioBus)) {
-                               boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
-                               // r->feeds (session->master_out()) may make more sense
-                               if (r->direct_feeds_according_to_reality (session->master_out())) {
-                                       // this is a bus
-                                       if (types[2]) {
-                                               sorted.push_back (s);
-                                       }
-                               } else {
-                                       // this is an Aux out
-                                       if (types[7]) {
-                                               sorted.push_back (s);
-                                       }
+                       if (types[7] && boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
+                               if (Profile->get_mixbus() && !s->mixbus()) {
+                                       sorted.push_back (s);
                                }
-                       } else if (types[3] && (s->presentation_info().flags() & PresentationInfo::MidiBus)) {
-                               sorted.push_back (s);
-                       } else if (types[4] && (s->presentation_info().flags() & PresentationInfo::VCA)) {
-                               sorted.push_back (s);
-                       } else if (types[8] && (s->is_selected())) {
-                               sorted.push_back (s);
-                       } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
-                               sorted.push_back (s);
-                       }
-#ifdef MIXBUS
-                       else if (types[2]) {
-                               if (Profile->get_mixbus()) {
-                                       if (s->mixbus()) {
-                                               sorted.push_back (s);
+                       } else
+#endif
+                       if ((types[2] || types[3] || types[7]) && boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
+                               boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
+                               if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
+                                       // note some older sessions will show midibuses as busses
+                                       if (r->direct_feeds_according_to_reality (session->master_out())) {
+                                               // this is a bus
+                                               if (types[2]) {
+                                                       sorted.push_back (s);
+                                               }
+                                       } else {
+                                               // this is an Aux out
+                                               if (types[7]) {
+                                                       sorted.push_back (s);
+                                               }
                                        }
+                               } else if (types[3]) {
+                                               sorted.push_back (s);
                                }
                        }
-#endif
                }
        }
        sort (sorted.begin(), sorted.end(), StripableByPresentationOrder());
@@ -4874,7 +5090,9 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue)
                sorted.push_back (session->master_out());
        }
        if (types[6]) {
-               sorted.push_back (session->monitor_out());
+               if (session->monitor_out()) {
+                       sorted.push_back (session->monitor_out());
+               }
        }
        return sorted;
 }
@@ -4886,24 +5104,34 @@ OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo
 
        if (!strncmp (path, "/cue/aux", 8)) {
                // set our Aux bus
-               ret = cue_set (argv[0]->i, msg);
+               if (argv[0]->f) {
+                       ret = cue_set (argv[0]->f, msg);
+               } else {
+                       ret = 0;
+               }
        }
        else if (!strncmp (path, "/cue/connect", 12)) {
                // Connect to default Aux bus
-               if ((!argc) || argv[0]->i) {
+               if ((!argc) || argv[0]->f) {
                        ret = cue_set (1, msg);
+               } else {
+                       ret = 0;
                }
        }
        else if (!strncmp (path, "/cue/next_aux", 13)) {
                // switch to next Aux bus
-               if ((!argc) || argv[0]->i) {
+               if ((!argc) || argv[0]->f) {
                        ret = cue_next (msg);
+               } else {
+                       ret = 0;
                }
        }
        else if (!strncmp (path, "/cue/previous_aux", 17)) {
                // switch to previous Aux bus
-               if ((!argc) || argv[0]->i) {
+               if ((!argc) || argv[0]->f) {
                        ret = cue_previous (msg);
+               } else {
+                       ret = 0;
                }
        }
        else if (!strncmp (path, "/cue/send/fader/", 16) && strlen (path) > 16) {