X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fosc%2Fosc.cc;h=282873053e46808025f6ee7432af6af11f0675f9;hb=c784f7096611da43db0604a7641253773d5f1515;hp=68bea263f2d75fcb99b5dbdc7402af9d6b8be6df;hpb=37aed5715b69428f86b169377f9597e563fff7df;p=ardour.git diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 68bea263f2..282873053e 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -26,7 +26,7 @@ #include #include "pbd/gstdio_compat.h" -#include +#include #include #include @@ -46,14 +46,19 @@ #include "ardour/plugin_insert.h" #include "ardour/presentation_info.h" #include "ardour/send.h" +#include "ardour/internal_send.h" #include "ardour/phase_control.h" +#include "ardour/solo_isolate_control.h" +#include "ardour/solo_safe_control.h" +#include "ardour/vca_manager.h" #include "osc_select_observer.h" #include "osc.h" #include "osc_controllable.h" #include "osc_route_observer.h" #include "osc_global_observer.h" -#include "i18n.h" +#include "osc_cue_observer.h" +#include "pbd/i18n.h" using namespace ARDOUR; using namespace std; @@ -86,8 +91,16 @@ OSC::OSC (Session& s, uint32_t port) , _shutdown (false) , _osc_server (0) , _osc_unix_server (0) - , _send_route_changes (true) , _debugmode (Off) + , address_only (false) + , remote_port ("8000") + , default_banksize (0) + , default_strip (159) + , default_feedback (0) + , default_gainmode (0) + , tick (true) + , bank_dirty (false) + , scrub_speed (0) , gui (0) { _instance = this; @@ -98,6 +111,7 @@ OSC::OSC (Session& s, uint32_t port) OSC::~OSC() { stop (); + tear_down_gui (); _instance = 0; } @@ -151,19 +165,6 @@ OSC::get_active () const return _osc_server != 0; } -int -OSC::set_feedback (bool yn) -{ - _send_route_changes = yn; - return 0; -} - -bool -OSC::get_feedback () const -{ - return _send_route_changes; -} - int OSC::start () { @@ -244,7 +245,18 @@ OSC::start () periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic)); periodic_timeout->attach (main_loop()->get_context()); - StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this, _1), this); + // catch changes to selection for GUI_select mode + StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this), this); + + // catch track reordering + // receive routes added + session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this); + // receive VCAs added + session->vca_manager().VCAAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_vca_added, this, _1), this); + // order changed + PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this); + + _select = boost::shared_ptr(); return 0; } @@ -318,6 +330,7 @@ OSC::stop () periodic_connection.disconnect (); session_connections.drop_connections (); + cueobserver_connections.drop_connections (); // Delete any active route observers for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { @@ -342,6 +355,7 @@ OSC::stop () ++x; } } + // delete select observers for (uint32_t it = 0; it < _surface.size(); ++it) { OSCSurface* sur = &_surface[it]; @@ -351,6 +365,19 @@ OSC::stop () } } +// delete cue observers + for (CueObservers::iterator x = cue_observers.begin(); x != cue_observers.end();) { + + OSCCueObserver* co; + + if ((co = dynamic_cast(*x)) != 0) { + delete *x; + x = cue_observers.erase (x); + } else { + ++x; + } + } + return 0; } @@ -382,6 +409,8 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/set_surface/bank_size", "i", set_surface_bank_size); REGISTER_CALLBACK (serv, "/set_surface/gainmode", "i", set_surface_gainmode); REGISTER_CALLBACK (serv, "/set_surface/strip_types", "i", set_surface_strip_types); + REGISTER_CALLBACK (serv, "/refresh", "", refresh_surface); + REGISTER_CALLBACK (serv, "/refresh", "f", refresh_surface); REGISTER_CALLBACK (serv, "/strip/list", "", routes_list); REGISTER_CALLBACK (serv, "/add_marker", "", add_marker); REGISTER_CALLBACK (serv, "/add_marker", "f", add_marker); @@ -393,6 +422,9 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/goto_start", "f", goto_start); REGISTER_CALLBACK (serv, "/goto_end", "", goto_end); REGISTER_CALLBACK (serv, "/goto_end", "f", goto_end); + REGISTER_CALLBACK (serv, "/scrub", "f", scrub); + REGISTER_CALLBACK (serv, "/jog", "f", jog); + REGISTER_CALLBACK (serv, "/jog/mode", "f", jog_mode); REGISTER_CALLBACK (serv, "/rewind", "", rewind); REGISTER_CALLBACK (serv, "/rewind", "f", rewind); REGISTER_CALLBACK (serv, "/ffwd", "", ffwd); @@ -427,6 +459,7 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/toggle_all_rec_enables", "f", toggle_all_rec_enables); REGISTER_CALLBACK (serv, "/all_tracks_rec_in", "f", all_tracks_rec_in); REGISTER_CALLBACK (serv, "/all_tracks_rec_out", "f", all_tracks_rec_out); + REGISTER_CALLBACK (serv, "/cancel_all_solos", "f", cancel_all_solos); REGISTER_CALLBACK (serv, "/remove_marker", "", remove_marker_at_playhead); REGISTER_CALLBACK (serv, "/remove_marker", "f", remove_marker_at_playhead); REGISTER_CALLBACK (serv, "/jump_bars", "f", jump_by_bars); @@ -449,7 +482,6 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/set_loop_range", "f", set_loop_range); REGISTER_CALLBACK (serv, "/set_session_range", "", set_session_range); REGISTER_CALLBACK (serv, "/set_session_range", "f", set_session_range); - // /toggle_monitor_* not working (comented out) REGISTER_CALLBACK (serv, "/toggle_monitor_mute", "", toggle_monitor_mute); REGISTER_CALLBACK (serv, "/toggle_monitor_mute", "f", toggle_monitor_mute); REGISTER_CALLBACK (serv, "/toggle_monitor_dim", "", toggle_monitor_dim); @@ -507,50 +539,81 @@ OSC::register_callbacks() // controls for "special" strips REGISTER_CALLBACK (serv, "/master/gain", "f", master_set_gain); - REGISTER_CALLBACK (serv, "/master/fader", "i", master_set_fader); + REGISTER_CALLBACK (serv, "/master/fader", "f", master_set_fader); 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, "/monitor/gain", "f", monitor_set_gain); - REGISTER_CALLBACK (serv, "/monitor/fader", "i", monitor_set_fader); + REGISTER_CALLBACK (serv, "/monitor/fader", "f", monitor_set_fader); + 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); // Controls for the Selected strip REGISTER_CALLBACK (serv, "/select/recenable", "i", sel_recenable); REGISTER_CALLBACK (serv, "/select/record_safe", "i", sel_recsafe); REGISTER_CALLBACK (serv, "/select/mute", "i", sel_mute); REGISTER_CALLBACK (serv, "/select/solo", "i", sel_solo); + REGISTER_CALLBACK (serv, "/select/solo_iso", "i", sel_solo_iso); + REGISTER_CALLBACK (serv, "/select/solo_safe", "i", sel_solo_safe); REGISTER_CALLBACK (serv, "/select/monitor_input", "i", sel_monitor_input); REGISTER_CALLBACK (serv, "/select/monitor_disk", "i", sel_monitor_disk); + 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/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/phase", "i", sel_phase); + 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/expand", "i", sel_expand); + REGISTER_CALLBACK (serv, "/select/pan_elevation_position", "f", sel_pan_elevation); + REGISTER_CALLBACK (serv, "/select/pan_frontback_position", "f", sel_pan_frontback); + REGISTER_CALLBACK (serv, "/select/pan_lfe_control", "f", sel_pan_lfe); + REGISTER_CALLBACK (serv, "/select/comp_enable", "f", sel_comp_enable); + REGISTER_CALLBACK (serv, "/select/comp_threshold", "f", sel_comp_threshold); + REGISTER_CALLBACK (serv, "/select/comp_speed", "f", sel_comp_speed); + REGISTER_CALLBACK (serv, "/select/comp_mode", "f", sel_comp_mode); + REGISTER_CALLBACK (serv, "/select/comp_makeup", "f", sel_comp_makeup); + REGISTER_CALLBACK (serv, "/select/eq_enable", "f", sel_eq_enable); + REGISTER_CALLBACK (serv, "/select/eq_hpf", "f", sel_eq_hpf); + REGISTER_CALLBACK (serv, "/select/eq_gain", "if", sel_eq_gain); + REGISTER_CALLBACK (serv, "/select/eq_freq", "if", sel_eq_freq); + REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q); + REGISTER_CALLBACK (serv, "/select/eq_shape", "if", sel_eq_shape); /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */ REGISTER_CALLBACK (serv, "/strip/mute", "ii", route_mute); REGISTER_CALLBACK (serv, "/strip/solo", "ii", route_solo); + REGISTER_CALLBACK (serv, "/strip/solo_iso", "ii", route_solo_iso); + REGISTER_CALLBACK (serv, "/strip/solo_safe", "ii", route_solo_safe); REGISTER_CALLBACK (serv, "/strip/recenable", "ii", route_recenable); REGISTER_CALLBACK (serv, "/strip/record_safe", "ii", route_recsafe); REGISTER_CALLBACK (serv, "/strip/monitor_input", "ii", route_monitor_input); REGISTER_CALLBACK (serv, "/strip/monitor_disk", "ii", route_monitor_disk); - REGISTER_CALLBACK (serv, "/strip/select", "ii", strip_select); - REGISTER_CALLBACK (serv, "/strip/gui_select", "ii", strip_gui_select); - REGISTER_CALLBACK (serv, "/strip/phase", "ii", strip_phase); + REGISTER_CALLBACK (serv, "/strip/expand", "ii", strip_expand); + REGISTER_CALLBACK (serv, "/strip/select", "ii", strip_gui_select); + REGISTER_CALLBACK (serv, "/strip/polarity", "ii", strip_phase); REGISTER_CALLBACK (serv, "/strip/gain", "if", route_set_gain_dB); REGISTER_CALLBACK (serv, "/strip/fader", "if", route_set_gain_fader); - REGISTER_CALLBACK (serv, "/strip/trimabs", "if", route_set_trim_abs); REGISTER_CALLBACK (serv, "/strip/trimdB", "if", route_set_trim_dB); REGISTER_CALLBACK (serv, "/strip/pan_stereo_position", "if", route_set_pan_stereo_position); REGISTER_CALLBACK (serv, "/strip/pan_stereo_width", "if", route_set_pan_stereo_width); REGISTER_CALLBACK (serv, "/strip/plugin/parameter", "iiif", route_plugin_parameter); // prints to cerr only REGISTER_CALLBACK (serv, "/strip/plugin/parameter/print", "iii", route_plugin_parameter_print); - REGISTER_CALLBACK (serv, "/strip/send/gainabs", "iif", route_set_send_gain_abs); + REGISTER_CALLBACK (serv, "/strip/plugin/activate", "ii", route_plugin_activate); + REGISTER_CALLBACK (serv, "/strip/plugin/deactivate", "ii", route_plugin_deactivate); REGISTER_CALLBACK (serv, "/strip/send/gain", "iif", route_set_send_gain_dB); REGISTER_CALLBACK (serv, "/strip/send/fader", "iif", route_set_send_fader); + REGISTER_CALLBACK (serv, "/strip/send/enable", "iif", route_set_send_enable); + REGISTER_CALLBACK(serv, "/strip/name", "is", route_rename); + REGISTER_CALLBACK(serv, "/strip/sends", "i", route_get_sends); + REGISTER_CALLBACK(serv, "/strip/receives", "i", route_get_receives); + REGISTER_CALLBACK(serv, "/strip/plugin/list", "i", route_plugin_list); + REGISTER_CALLBACK(serv, "/strip/plugin/descriptor", "ii", route_plugin_descriptor); + REGISTER_CALLBACK(serv, "/strip/plugin/reset", "ii", route_plugin_reset); /* still not-really-standardized query interface */ //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value); @@ -613,9 +676,18 @@ OSC::get_unix_server_url() return url; } +void +OSC::gui_changed () +{ + session->set_dirty(); +} + void OSC::listen_to_route (boost::shared_ptr strip, lo_address addr) { + if (!strip) { + return; + } /* avoid duplicate listens */ for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end(); ++x) { @@ -633,12 +705,19 @@ OSC::listen_to_route (boost::shared_ptr strip, lo_address addr) } OSCSurface *s = get_surface(addr); - uint32_t sid = get_sid (strip->presentation_info().order() + 1, addr); - // above is zero based add 1 - OSCRouteObserver* o = new OSCRouteObserver (strip, addr, sid, s->gainmode, s->feedback); + uint32_t ssid = get_sid (strip, addr); + OSCRouteObserver* o = new OSCRouteObserver (strip, addr, ssid, s); route_observers.push_back (o); - strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::drop_route, this, boost::weak_ptr (strip)), this); + strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::route_lost, this, boost::weak_ptr (strip)), this); +} + +void +OSC::route_lost (boost::weak_ptr wr) +{ + tick = false; + drop_route (wr); + bank_dirty = true; } void @@ -760,7 +839,7 @@ OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message m } } - lo_send_message (lo_message_get_source (msg), "#reply", reply); + lo_send_message (get_address (msg), "#reply", reply); lo_message_free (reply); } @@ -787,7 +866,24 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ current_value_query (path, len, argv, argc, msg); ret = 0; - } else if (strcmp (path, "/strip/listen") == 0) { + } else + if (!strncmp (path, "/cue/", 5)) { + + cue_parse (path, types, argv, argc, msg); + + ret = 0; + } else + if (!strncmp (path, "/access_action/", 15)) { + if (!(argc && !argv[0]->i)) { + std::string action_path = path; + + access_action (action_path.substr(15)); + std::cout << "access_action path = " << action_path.substr(15) << "\n"; + } + + ret = 0; + } else + if (strcmp (path, "/strip/listen") == 0) { cerr << "set up listener\n"; @@ -806,91 +902,133 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ break; } else { cerr << "add listener\n"; - listen_to_route (r, lo_message_get_source (msg)); + listen_to_route (r, get_address (msg)); lo_message_add_int32 (reply, argv[n]->i); } } } - lo_send_message (lo_message_get_source (msg), "#reply", reply); + lo_send_message (get_address (msg), "#reply", reply); lo_message_free (reply); ret = 0; - } else if (strcmp (path, "/strip/ignore") == 0) { + } else + if (strcmp (path, "/strip/ignore") == 0) { for (int n = 0; n < argc; ++n) { boost::shared_ptr r = session->get_remote_nth_route (argv[n]->i); if (r) { - end_listen (r, lo_message_get_source (msg)); + end_listen (r, get_address (msg)); } } ret = 0; - } else if (argc == 1 && types[0] == 'f') { // single float -- probably TouchOSC - if (!strncmp (path, "/strip/gain/", 12) && strlen (path) > 12) { - // in dB - int ssid = atoi (&path[12]); - route_set_gain_dB (ssid, argv[0]->f, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/fader/", 13) && strlen (path) > 13) { - // in fader position - int ssid = atoi (&path[13]); - route_set_gain_fader (ssid, argv[0]->f, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/trimdB/", 14) && strlen (path) > 14) { - int ssid = atoi (&path[14]); - route_set_trim_dB (ssid, argv[0]->f, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/mute/", 12) && strlen (path) > 12) { - int ssid = atoi (&path[12]); - route_mute (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/solo/", 12) && strlen (path) > 12) { - int ssid = atoi (&path[12]); - route_solo (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/monitor_input/", 21) && strlen (path) > 21) { - int ssid = atoi (&path[21]); - route_monitor_input (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/monitor_disk/", 20) && strlen (path) > 20) { - int ssid = atoi (&path[20]); - route_monitor_disk (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/recenable/", 17) && strlen (path) > 17) { - int ssid = atoi (&path[17]); - route_recenable (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/record_safe/", 19) && strlen (path) > 19) { - int ssid = atoi (&path[19]); - route_recsafe (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) { - int ssid = atoi (&path[14]); - strip_select (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } - else if (!strncmp (path, "/strip/gui_select/", 18) && strlen (path) > 18) { - int ssid = atoi (&path[18]); - strip_gui_select (ssid, argv[0]->f == 1.0, msg); - ret = 0; - } + } else + if (!strncmp (path, "/strip/gain/", 12) && strlen (path) > 12) { + // in dB + int ssid = atoi (&path[12]); + route_set_gain_dB (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/fader/", 13) && strlen (path) > 13) { + // in fader position + int ssid = atoi (&path[13]); + route_set_gain_fader (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/trimdB/", 14) && strlen (path) > 14) { + int ssid = atoi (&path[14]); + route_set_trim_dB (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/pan_stereo_position/", 27) && strlen (path) > 27) { + int ssid = atoi (&path[27]); + route_set_pan_stereo_position (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/mute/", 12) && strlen (path) > 12) { + int ssid = atoi (&path[12]); + route_mute (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/solo/", 12) && strlen (path) > 12) { + int ssid = atoi (&path[12]); + route_solo (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/monitor_input/", 21) && strlen (path) > 21) { + int ssid = atoi (&path[21]); + route_monitor_input (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/monitor_disk/", 20) && strlen (path) > 20) { + int ssid = atoi (&path[20]); + route_monitor_disk (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/recenable/", 17) && strlen (path) > 17) { + int ssid = atoi (&path[17]); + route_recenable (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/record_safe/", 19) && strlen (path) > 19) { + int ssid = atoi (&path[19]); + route_recsafe (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/expand/", 14) && strlen (path) > 14) { + int ssid = atoi (&path[14]); + strip_expand (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) { + int ssid = atoi (&path[14]); + strip_gui_select (ssid, argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/select/send_gain/", 18) && strlen (path) > 18) { + int ssid = atoi (&path[18]); + sel_sendgain (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/select/send_fader/", 19) && strlen (path) > 19) { + int ssid = atoi (&path[19]); + sel_sendfader (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/select/send_enable/", 20) && strlen (path) > 20) { + int ssid = atoi (&path[20]); + sel_sendenable (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/select/eq_gain/", 16) && strlen (path) > 16) { + int ssid = atoi (&path[16]); + sel_eq_gain (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/select/eq_freq/", 16) && strlen (path) > 16) { + int ssid = atoi (&path[16]); + sel_eq_freq (ssid, argv[0]->f , msg); + ret = 0; + } + else if (!strncmp (path, "/select/eq_q/", 13) && strlen (path) > 13) { + int ssid = atoi (&path[13]); + sel_eq_q (ssid, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/select/eq_shape/", 17) && strlen (path) > 17) { + int ssid = atoi (&path[17]); + sel_eq_shape (ssid, argv[0]->f, msg); + ret = 0; } - if ((ret && _debugmode == Unhandled)) { + if ((ret && _debugmode != Off)) { debugmsg (_("Unhandled OSC message"), path, types, argv, argc); + } else if (!ret && _debugmode == All) { + debugmsg (_("OSC"), path, types, argv, argc); } return ret; @@ -954,12 +1092,6 @@ OSC::debugmsg (const char *prefix, const char *path, const char* types, lo_arg * PBD::info << prefix << ": " << path << ss.str() << endmsg; } -void -OSC::update_clock () -{ - -} - // "Application Hook" Handlers // void OSC::session_loaded (Session& s) @@ -1046,41 +1178,67 @@ OSC::routes_list (lo_message msg) if (!session) { return; } - for (int n = 0; n < (int) session->nroutes(); ++n) { + OSCSurface *sur = get_surface(get_address (msg)); + sur->no_clear = true; - boost::shared_ptr r = session->get_remote_nth_route (n); + for (int n = 0; n < (int) sur->nstrips; ++n) { - if (r) { + boost::shared_ptr s = get_strip (n + 1, get_address (msg)); + + if (s) { + // some things need the route + boost::shared_ptr r = boost::dynamic_pointer_cast (s); lo_message reply = lo_message_new (); - if (boost::dynamic_pointer_cast(r)) { + if (s->presentation_info().flags() & PresentationInfo::AudioTrack) { lo_message_add_string (reply, "AT"); - } else if (boost::dynamic_pointer_cast(r)) { + } else if (s->presentation_info().flags() & PresentationInfo::MidiTrack) { lo_message_add_string (reply, "MT"); - } else { - lo_message_add_string (reply, "B"); + } 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 { + // this is an Aux out + lo_message_add_string (reply, "AX"); + } + } 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, r->name().c_str()); - lo_message_add_int32 (reply, r->n_inputs().n_audio()); - lo_message_add_int32 (reply, r->n_outputs().n_audio()); - lo_message_add_int32 (reply, r->muted()); - lo_message_add_int32 (reply, r->soloed()); - /* XXX Can only use order at this point */ - lo_message_add_int32 (reply, r->presentation_info().order()); - - if (boost::dynamic_pointer_cast(r) - || boost::dynamic_pointer_cast(r)) { - - boost::shared_ptr t = boost::dynamic_pointer_cast(r); - lo_message_add_int32 (reply, (int32_t) t->rec_enable_control()->get_value()); + lo_message_add_string (reply, s->name().c_str()); + if (r) { + // routes have inputs and outputs + lo_message_add_int32 (reply, r->n_inputs().n_audio()); + lo_message_add_int32 (reply, r->n_outputs().n_audio()); + } else { + // non-routes like VCAs don't + lo_message_add_int32 (reply, 0); + lo_message_add_int32 (reply, 0); + } + if (s->mute_control()) { + lo_message_add_int32 (reply, s->mute_control()->get_value()); + } else { + lo_message_add_int32 (reply, 0); + } + if (s->solo_control()) { + lo_message_add_int32 (reply, s->solo_control()->get_value()); + } else { + lo_message_add_int32 (reply, 0); + } + lo_message_add_int32 (reply, n + 1); + if (s->rec_enable_control()) { + lo_message_add_int32 (reply, s->rec_enable_control()->get_value()); } - //Automatically listen to routes listed - listen_to_route(r, lo_message_get_source (msg)); + //Automatically listen to stripables listed + listen_to_route(s, get_address (msg)); - lo_send_message (lo_message_get_source (msg), "#reply", reply); + lo_send_message (get_address (msg), "#reply", reply); lo_message_free (reply); } } @@ -1091,33 +1249,121 @@ OSC::routes_list (lo_message msg) lo_message_add_string (reply, "end_route_list"); lo_message_add_int64 (reply, session->frame_rate()); lo_message_add_int64 (reply, session->current_end_frame()); + if (session->monitor_out()) { + // this session has a monitor section + lo_message_add_int32 (reply, 1); + } else { + lo_message_add_int32 (reply, 0); + } - lo_send_message (lo_message_get_source (msg), "#reply", reply); + lo_send_message (get_address (msg), "#reply", reply); lo_message_free (reply); } +int +OSC::cancel_all_solos () +{ + session->cancel_all_solo (); + return 0; +} + +lo_address +OSC::get_address (lo_message msg) +{ + if (address_only) { + lo_address addr = lo_message_get_source (msg); + string host = lo_address_get_hostname (addr); + int protocol = lo_address_get_protocol (addr); + return lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str()); + } else { + return lo_message_get_source (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(), (uint32_t) s->gainmode, msg); + return 0; +} + +void +OSC::clear_devices () +{ + for (RouteObservers::iterator x = route_observers.begin(); x != route_observers.end();) { + + OSCRouteObserver* rc; + + if ((rc = dynamic_cast(*x)) != 0) { + delete *x; + x = route_observers.erase (x); + } else { + ++x; + } + // slow devices need time to clear buffers + usleep ((uint32_t) 10); + } + // Should maybe do global_observers too + for (GlobalObservers::iterator x = global_observers.begin(); x != global_observers.end();) { + + OSCGlobalObserver* gc; + + if ((gc = dynamic_cast(*x)) != 0) { + delete *x; + x = global_observers.erase (x); + } else { + ++x; + } + } + // delete select observers + for (uint32_t it = 0; it < _surface.size(); ++it) { + OSCSurface* sur = &_surface[it]; + OSCSelectObserver* so; + if ((so = dynamic_cast(sur->sel_obs)) != 0) { + delete so; + } + } + // delete cue observers + for (CueObservers::iterator x = cue_observers.begin(); x != cue_observers.end();) { + OSCCueObserver* co; + if ((co = dynamic_cast(*x)) != 0) { + delete co; + } else { + ++x; + } + } + + // clear out surfaces + _surface.clear(); +} + int OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, lo_message msg) { - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); s->bank_size = b_size; s->strip_types = strips; - //next line could be a call that finds out how many strips there are - s->nstrips = session->nroutes(); // need to do this for strips s->feedback = fb; s->gainmode = gm; // set bank and strip feedback set_bank(s->bank, msg); - global_feedback (s->feedback, msg, s->gainmode); + global_feedback (s->feedback, get_address (msg), s->gainmode); return 0; } int OSC::set_surface_bank_size (uint32_t bs, lo_message msg) { - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); s->bank_size = bs; // set bank and strip feedback @@ -1125,14 +1371,11 @@ OSC::set_surface_bank_size (uint32_t bs, lo_message msg) return 0; } - int OSC::set_surface_strip_types (uint32_t st, lo_message msg) { - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); s->strip_types = st; - //next line could be a call that finds out how many strips there are - s->nstrips = session->nroutes(); // need to do this for strips // set bank and strip feedback set_bank(s->bank, msg); @@ -1143,14 +1386,14 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg) int OSC::set_surface_feedback (uint32_t fb, lo_message msg) { - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); s->feedback = fb; // set bank and strip feedback set_bank(s->bank, msg); // Set global/master feedback - global_feedback (s->feedback, msg, s->gainmode); + global_feedback (s->feedback, get_address (msg), s->gainmode); return 0; } @@ -1158,14 +1401,14 @@ OSC::set_surface_feedback (uint32_t fb, lo_message msg) int OSC::set_surface_gainmode (uint32_t gm, lo_message msg) { - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); s->gainmode = gm; // set bank and strip feedback set_bank(s->bank, msg); // Set global/master feedback - global_feedback (s->feedback, msg, s->gainmode); + global_feedback (s->feedback, get_address (msg), s->gainmode); return 0; } @@ -1183,37 +1426,45 @@ OSC::get_surface (lo_address addr) return &_surface[it]; } } + // if we do this when OSC is started we get the wrong stripable + // we don't need this until we actually have a surface to deal with + if (!_select || (_select != ControlProtocol::first_selected_stripable())) { + gui_selection_changed(); + } + // No surface create one with default values OSCSurface s; s.remote_url = r_url; s.bank = 1; - s.bank_size = 0; // need to find out how many strips there are - s.nstrips = session->nroutes(); // may need to do this after MARK below - s.strip_types = 31; // 31 is tracks, busses, and VCAs (no master/monitor) - s.feedback = 0; - s.gainmode = 0; + 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.feedback = default_feedback; + s.gainmode = default_gainmode; s.sel_obs = 0; - s.surface_sel = 0; - //get sorted should go here + s.expand = 0; + s.expand_enable = false; + s.cue = false; + s.strips = get_sorted_stripables(s.strip_types, s.cue); + + s.nstrips = s.strips.size(); _surface.push_back (s); - //MARK + return &_surface[_surface.size() - 1]; } // setup global feedback for a surface void -OSC::global_feedback (bitset<32> feedback, lo_address msg, uint32_t gainmode) +OSC::global_feedback (bitset<32> feedback, lo_address addr, uint32_t gainmode) { // first destroy global observer for this surface GlobalObservers::iterator x; - for (x = global_observers.begin(); x != global_observers.end();) { OSCGlobalObserver* ro; if ((ro = dynamic_cast(*x)) != 0) { - int res = strcmp(lo_address_get_url(ro->address()), lo_address_get_url(lo_message_get_source (msg))); + int res = strcmp(lo_address_get_url(ro->address()), lo_address_get_url(addr)); if (res == 0) { delete *x; @@ -1227,12 +1478,59 @@ OSC::global_feedback (bitset<32> feedback, lo_address msg, uint32_t gainmode) } if (feedback[4] || feedback[3] || feedback[5] || feedback[6]) { // create a new Global Observer for this surface - //OSCSurface *s = get_surface (lo_message_get_source (msg)); - OSCGlobalObserver* o = new OSCGlobalObserver (*session, lo_message_get_source (msg), gainmode, /*s->*/feedback); + OSCGlobalObserver* o = new OSCGlobalObserver (*session, addr, gainmode, /*s->*/feedback); global_observers.push_back (o); } } +void +OSC::notify_routes_added (ARDOUR::RouteList &) +{ + // not sure if we need this PI change seems to cover + //recalcbanks(); +} + +void +OSC::notify_vca_added (ARDOUR::VCAList &) +{ + // not sure if we need this PI change seems to cover + //recalcbanks(); +} + +void +OSC::recalcbanks () +{ + tick = false; + bank_dirty = true; +} + +void +OSC::_recalcbanks () +{ + if (!_select || (_select != ControlProtocol::first_selected_stripable())) { + _select = ControlProtocol::first_selected_stripable(); + } + + // do a set_bank for each surface we know about. + for (uint32_t it = 0; it < _surface.size(); ++it) { + OSCSurface* sur = &_surface[it]; + // find lo_address + lo_address addr = lo_address_new_from_url (sur->remote_url.c_str()); + if (sur->cue) { + _cue_set (sur->aux, addr); + } else { + _set_bank (sur->bank, addr); + } + if (sur->no_clear) { + // This surface uses /strip/list tell it routes have changed + lo_message reply; + reply = lo_message_new (); + lo_send_message (addr, "/strip/list", reply); + lo_message_free (reply); + } + } +} + /* * This gets called not only when bank changes but also: * - bank size change @@ -1245,70 +1543,100 @@ OSC::global_feedback (bitset<32> feedback, lo_address msg, uint32_t gainmode) */ int OSC::set_bank (uint32_t bank_start, lo_message msg) +{ + return _set_bank (bank_start, get_address (msg)); +} + +// set bank is callable with either message or address +int +OSC::_set_bank (uint32_t bank_start, lo_address addr) { if (!session) { return -1; } - //StripableList strips; - //session->get_stripables (strips); // no nstripables yet if (!session->nroutes()) { return -1; } - // don't include monitor or master in count for now - uint32_t nstrips; - if (session->monitor_out ()) { - nstrips = session->nroutes() - 2; - } else { - nstrips = session->nroutes() - 1; - } - // reset local select - _strip_select (0, lo_message_get_source (msg)); - // undo all listeners for this url - for (int n = 0; n <= (int) nstrips; ++n) { - boost::shared_ptr stp = session->get_remote_nth_stripable (n, PresentationInfo::Route); + OSCSurface *s = get_surface (addr); + + // revert any expand to select + s->expand = 0; + s->expand_enable = false; + _strip_select (ControlProtocol::first_selected_stripable(), addr); + + // undo all listeners for this url + StripableList stripables; + session->get_stripables (stripables); + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + boost::shared_ptr stp = *it; if (stp) { - end_listen (stp, lo_message_get_source (msg)); + end_listen (stp, addr); } + // slow devices need time to clear buffers + usleep ((uint32_t) 10); } - OSCSurface *s = get_surface (lo_message_get_source (msg)); - uint32_t b_size; + s->strips = get_sorted_stripables(s->strip_types, s->cue); + s->nstrips = s->strips.size(); + uint32_t b_size; if (!s->bank_size) { - // no banking - b_size = nstrips; + // no banking - bank includes all stripables + b_size = s->nstrips; } else { b_size = s->bank_size; } - // Do limits checking - high end still not quite right + // Do limits checking if (bank_start < 1) bank_start = 1; - if (b_size >= nstrips) { + if (b_size >= s->nstrips) { bank_start = 1; - } else if ((bank_start > nstrips)) { - bank_start = (uint32_t)((nstrips - b_size) + 1); + } else if (bank_start > ((s->nstrips - b_size) + 1)) { + // top bank is always filled if there are enough strips for at least one bank + bank_start = (uint32_t)((s->nstrips - b_size) + 1); } - //save bank in case we have had to change it + //save bank after bank limit checks s->bank = bank_start; if (s->feedback[0] || s->feedback[1]) { - for (int n = bank_start; n < (int) (b_size + bank_start); ++n) { - // this next will eventually include strip types - boost::shared_ptr stp = session->get_remote_nth_stripable (n - 1, PresentationInfo::Route); - - if (stp) { - listen_to_route(stp, lo_message_get_source (msg)); - if (!s->feedback[10]) { - if (stp->is_selected()) { - _strip_select (n, lo_message_get_source (msg)); - } + + for (uint32_t n = bank_start; n < (min ((b_size + bank_start), s->nstrips + 1)); ++n) { + if (n <= s->strips.size()) { + boost::shared_ptr stp = s->strips[n - 1]; + + if (stp) { + listen_to_route(stp, addr); } } + // slow devices need time to clear buffers + usleep ((uint32_t) 10); + } + } + // light bankup or bankdown buttons if it is possible to bank in that direction + if (s->feedback[4] && !s->no_clear) { + lo_message reply; + reply = lo_message_new (); + if ((s->bank > (s->nstrips - s->bank_size)) || (s->nstrips < s->bank_size)) { + lo_message_add_int32 (reply, 0); + } else { + lo_message_add_int32 (reply, 1); + } + lo_send_message (addr, "/bank_up", reply); + lo_message_free (reply); + reply = lo_message_new (); + if (s->bank > 1) { + lo_message_add_int32 (reply, 1); + } else { + lo_message_add_int32 (reply, 0); } + lo_send_message (addr, "/bank_down", reply); + lo_message_free (reply); } + bank_dirty = false; + tick = true; return 0; } @@ -1318,7 +1646,7 @@ OSC::bank_up (lo_message msg) if (!session) { return -1; } - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); set_bank (s->bank + s->bank_size, msg); return 0; } @@ -1329,7 +1657,7 @@ OSC::bank_down (lo_message msg) if (!session) { return -1; } - OSCSurface *s = get_surface(lo_message_get_source (msg)); + OSCSurface *s = get_surface(get_address (msg)); if (s->bank < s->bank_size) { set_bank (1, msg); } else { @@ -1339,17 +1667,42 @@ OSC::bank_down (lo_message msg) } uint32_t -OSC::get_sid (uint32_t rid, lo_address addr) +OSC::get_sid (boost::shared_ptr strip, lo_address addr) { + if (!strip) { + return 0; + } + OSCSurface *s = get_surface(addr); - return rid - s->bank + 1; + + uint32_t b_size; + if (!s->bank_size) { + // no banking + b_size = s->nstrips; + } else { + b_size = s->bank_size; + } + + for (uint32_t n = s->bank; n < (min ((b_size + s->bank), s->nstrips + 1)); ++n) { + if (n <= s->strips.size()) { + if (strip == s->strips[n-1]) { + return n - s->bank + 1; + } + } + } + // failsafe... should never get here. + return 0; } -uint32_t -OSC::get_rid (uint32_t ssid, lo_address addr) +boost::shared_ptr +OSC::get_strip (uint32_t ssid, lo_address addr) { OSCSurface *s = get_surface(addr); - return ssid + s->bank - 2; + if (ssid && ((ssid + s->bank - 2) < s->nstrips)) { + return s->strips[ssid + s->bank - 2]; + } + // guess it is out of range + return boost::shared_ptr(); } void @@ -1363,7 +1716,7 @@ OSC::transport_frame (lo_message msg) lo_message reply = lo_message_new (); lo_message_add_int64 (reply, pos); - lo_send_message (lo_message_get_source (msg), "/transport_frame", reply); + lo_send_message (get_address (msg), "/transport_frame", reply); lo_message_free (reply); } @@ -1379,7 +1732,7 @@ OSC::transport_speed (lo_message msg) lo_message reply = lo_message_new (); lo_message_add_double (reply, ts); - lo_send_message (lo_message_get_source (msg), "/transport_speed", reply); + lo_send_message (get_address (msg), "/transport_speed", reply); lo_message_free (reply); } @@ -1395,44 +1748,210 @@ OSC::record_enabled (lo_message msg) lo_message reply = lo_message_new (); lo_message_add_int32 (reply, re); - lo_send_message (lo_message_get_source (msg), "/record_enabled", reply); + lo_send_message (get_address (msg), "/record_enabled", reply); lo_message_free (reply); } -// master and monitor calls int -OSC::master_set_gain (float dB) +OSC::scrub (float delta, lo_message msg) { if (!session) return -1; - boost::shared_ptr s = session->master_out(); - if (s) { - 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); - } + + scrub_place = session->transport_frame (); + + float speed; + + int64_t now = ARDOUR::get_microseconds (); + int64_t diff = now - scrub_time; + if (diff > 35000) { + // speed 1 (or 0 if jog wheel supports touch) + speed = delta; + } else if ((diff > 20000) && (fabs(scrub_speed) == 1)) { + // add some hysteresis to stop excess speed jumps + speed = delta; + } else { + speed = (int)(delta * 2); } - return 0; -} + scrub_time = now; + if (scrub_speed == speed) { + // Already at that speed no change + return 0; + } + scrub_speed = speed; -int -OSC::master_set_fader (uint32_t position) -{ - if (!session) return -1; - boost::shared_ptr s = session->master_out(); - if (s) { - if ((position > 799.5) && (position < 800.5)) { - s->gain_control()->set_value (1.0, PBD::Controllable::NoGroup); + if (speed > 0) { + if (speed == 1) { + session->request_transport_speed (.5); + } else { + session->request_transport_speed (1); + } + } else if (speed < 0) { + if (speed == -1) { + session->request_transport_speed (-.5); } else { - s->gain_control()->set_value (slider_position_to_gain_with_max (((float)position/1023), 2.0), PBD::Controllable::NoGroup); + session->request_transport_speed (-1); } + } else { + session->request_transport_speed (0); } + return 0; } int -OSC::master_set_trim (float dB) +OSC::jog (float delta, lo_message msg) +{ + if (!session) return -1; + + OSCSurface *s = get_surface(get_address (msg)); + + string path = "/jog/mode/name"; + switch(s->jogmode) + { + case JOG : + text_message (path, "Jog", get_address (msg)); + if (delta) { + jump_by_seconds (delta / 5); + } + break; + case SCRUB: + text_message (path, "Scrub", get_address (msg)); + scrub (delta, msg); + break; + case SHUTTLE: + text_message (path, "Shuttle", get_address (msg)); + if (delta) { + double speed = get_transport_speed (); + set_transport_speed (speed + (delta / 8)); + } else { + set_transport_speed (0); + } + break; + case SCROLL: + text_message (path, "Scroll", get_address (msg)); + if (delta > 0) { + access_action ("Editor/scroll-forward"); + } else if (delta < 0) { + access_action ("Editor/scroll-backward"); + } + break; + case TRACK: + text_message (path, "Track", get_address (msg)); + if (delta > 0) { + set_bank (s->bank + 1, msg); + } else if (delta < 0) { + set_bank (s->bank - 1, msg); + } + break; + case BANK: + text_message (path, "Bank", get_address (msg)); + if (delta > 0) { + bank_up (msg); + } else if (delta < 0) { + bank_down (msg); + } + break; + case NUDGE: + text_message (path, "Nudge", get_address (msg)); + if (delta > 0) { + access_action ("Common/nudge-playhead-forward"); + } else if (delta < 0) { + access_action ("Common/nudge-playhead-backward"); + } + break; + case MARKER: + text_message (path, "Marker", get_address (msg)); + if (delta > 0) { + next_marker (); + } else if (delta < 0) { + prev_marker (); + } + break; + default: + break; + + } + return 0; + +} + +int +OSC::jog_mode (float mode, lo_message msg) +{ + if (!session) return -1; + + OSCSurface *s = get_surface(get_address (msg)); + + switch((uint32_t)mode) + { + case JOG : + s->jogmode = JOG; + break; + case SCRUB: + s->jogmode = SCRUB; + break; + case SHUTTLE: + s->jogmode = SHUTTLE; + break; + case SCROLL: + s->jogmode = SCROLL; + break; + case TRACK: + s->jogmode = TRACK; + break; + case BANK: + s->jogmode = BANK; + break; + case NUDGE: + s->jogmode = NUDGE; + break; + case MARKER: + s->jogmode = MARKER; + break; + default: + PBD::warning << "Jog Mode: " << mode << " is not valid." << endmsg; + break; + lo_message reply = lo_message_new (); + lo_message_add_int32 (reply, s->jogmode); + lo_send_message (get_address(msg), "/jog/mode", reply); + lo_message_free (reply); + + } + jog (0, msg); + return 0; + +} + +// master and monitor calls +int +OSC::master_set_gain (float dB) +{ + if (!session) return -1; + boost::shared_ptr s = session->master_out(); + if (s) { + 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); + } + } + return 0; +} + +int +OSC::master_set_fader (float position) +{ + if (!session) return -1; + boost::shared_ptr s = session->master_out(); + if (s) { + s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup); + } + return 0; +} + +int +OSC::master_set_trim (float dB) { if (!session) return -1; boost::shared_ptr s = session->master_out(); @@ -1445,17 +1964,28 @@ OSC::master_set_trim (float dB) } int -OSC::master_set_pan_stereo_position (float position) +OSC::master_set_pan_stereo_position (float position, lo_message msg) { if (!session) return -1; + float endposition = .5; boost::shared_ptr s = session->master_out(); if (s) { if (s->pan_azimuth_control()) { - s->pan_azimuth_control()->set_value (position, PBD::Controllable::NoGroup); + s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (position), PBD::Controllable::NoGroup); + endposition = s->pan_azimuth_control()->internal_to_interface (s->pan_azimuth_control()->get_value ()); } } + OSCSurface *sur = get_surface(get_address (msg)); + + if (sur->feedback[4]) { + lo_message reply = lo_message_new (); + lo_message_add_float (reply, endposition); + + lo_send_message (get_address (msg), "/master/pan_stereo_position", reply); + lo_message_free (reply); + } return 0; } @@ -1491,17 +2021,160 @@ OSC::monitor_set_gain (float dB) } int -OSC::monitor_set_fader (uint32_t position) +OSC::monitor_set_fader (float position) { if (!session) return -1; boost::shared_ptr s = session->monitor_out(); if (s) { - if ((position > 799.5) && (position < 800.5)) { - s->gain_control()->set_value (1.0, PBD::Controllable::NoGroup); - } else { - s->gain_control()->set_value (slider_position_to_gain_with_max (((float)position/1023), 2.0), PBD::Controllable::NoGroup); + s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup); + } + return 0; +} + +int +OSC::monitor_set_mute (uint32_t state) +{ + if (!session) return -1; + + if (session->monitor_out()) { + boost::shared_ptr mon = session->monitor_out()->monitor_control(); + mon->set_cut_all (state); + } + return 0; +} + +int +OSC::monitor_set_dim (uint32_t state) +{ + if (!session) return -1; + + if (session->monitor_out()) { + boost::shared_ptr mon = session->monitor_out()->monitor_control(); + mon->set_dim_all (state); + } + return 0; +} + +int +OSC::monitor_set_mono (uint32_t state) +{ + if (!session) return -1; + + if (session->monitor_out()) { + boost::shared_ptr mon = session->monitor_out()->monitor_control(); + mon->set_mono (state); + } + return 0; +} + +int +OSC::route_get_sends(lo_message msg) { + if (!session) { + return -1; + } + + lo_arg **argv = lo_message_get_argv(msg); + + int rid = argv[0]->i; + + boost::shared_ptr strip = get_strip(rid, get_address(msg)); + if (!strip) { + return -1; + } + + boost::shared_ptr r = boost::dynamic_pointer_cast (strip); + if (!r) { + return -1; + } + + lo_message reply = lo_message_new(); + lo_message_add_int32(reply, rid); + + int i = 0; + for (;;) { + boost::shared_ptr p = r->nth_send(i++); + + if (!p) { + break; + } + + boost::shared_ptr isend = boost::dynamic_pointer_cast (p); + if (isend) { + lo_message_add_int32(reply, get_sid(isend->target_route(), get_address(msg))); + lo_message_add_string(reply, isend->name().c_str()); + lo_message_add_int32(reply, i); + boost::shared_ptr a = isend->amp(); + lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value())); + lo_message_add_int32(reply, p->active() ? 1 : 0); + } + } + // if used dedicated message path to identify this reply in async operation. + // Naming it #reply wont help the client to identify the content. + lo_send_message(get_address (msg), "/strip/sends", reply); + + lo_message_free(reply); + + return 0; +} + +int +OSC::route_get_receives(lo_message msg) { + if (!session) { + return -1; + } + + lo_arg **argv = lo_message_get_argv(msg); + + uint32_t rid = argv[0]->i; + + + boost::shared_ptr strip = get_strip(rid, get_address(msg)); + if (!strip) { + return -1; + } + + boost::shared_ptr r = boost::dynamic_pointer_cast (strip); + if (!r) { + return -1; + } + + boost::shared_ptr route_list = session->get_routes(); + + lo_message reply = lo_message_new(); + + for (RouteList::iterator i = route_list->begin(); i != route_list->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr) { + continue; + } + int j = 0; + + for (;;) { + boost::shared_ptr p = tr->nth_send(j++); + + if (!p) { + break; + } + + boost::shared_ptr isend = boost::dynamic_pointer_cast (p); + if (isend) { + if( isend->target_route()->id() == r->id()){ + boost::shared_ptr a = isend->amp(); + + lo_message_add_int32(reply, get_sid(tr, get_address(msg))); + lo_message_add_string(reply, tr->name().c_str()); + lo_message_add_int32(reply, j); + lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value())); + lo_message_add_int32(reply, p->active() ? 1 : 0); + } + } } } + + // I have used a dedicated message path to identify this reply in async operation. + // Naming it #reply wont help the client to identify the content. + lo_send_message(get_address (msg), "/strip/receives", reply); + lo_message_free(reply); return 0; } @@ -1510,72 +2183,166 @@ int OSC::route_mute (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { - s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + if (s->mute_control()) { + s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } - return 0; + return route_send_fail ("mute", ssid, 0, get_address (msg)); } int OSC::sel_mute (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_mute(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("mute", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; } + if (s) { + if (s->mute_control()) { + s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("mute", 0, get_address (msg)); } int OSC::route_solo (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + + if (s) { + if (s->solo_control()) { + s->solo_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + } + } + + return route_send_fail ("solo", ssid, 0, get_address (msg)); +} + +int +OSC::route_solo_iso (int ssid, int yn, lo_message msg) +{ + if (!session) return -1; + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + + if (s) { + if (s->solo_isolate_control()) { + s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } + + return route_send_fail ("solo_iso", ssid, 0, get_address (msg)); +} - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); +int +OSC::route_solo_safe (int ssid, int yn, lo_message msg) +{ + if (!session) return -1; + boost::shared_ptr s = get_strip (ssid, lo_message_get_source (msg)); if (s) { - s->solo_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + if (s->solo_safe_control()) { + s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } - return 0; + return route_send_fail ("solo_safe", ssid, 0, get_address (msg)); } int OSC::sel_solo (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_solo(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("solo", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->solo_control()) { + session->set_control (s->solo_control(), yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + } + } + return sel_fail ("solo", 0, get_address (msg)); +} + +int +OSC::sel_solo_iso (uint32_t yn, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->solo_isolate_control()) { + s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("solo_iso", 0, get_address (msg)); +} + +int +OSC::sel_solo_safe (uint32_t yn, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->solo_safe_control()) { + s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("solo_safe", 0, get_address (msg)); } int OSC::sel_recenable (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_recenable(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("recenable", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->rec_enable_control()) { + s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + if (s->rec_enable_control()->get_value()) { + return 0; + } + } } + return sel_fail ("recenable", 0, get_address (msg)); } int OSC::route_recenable (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { if (s->rec_enable_control()) { @@ -1585,28 +2352,50 @@ OSC::route_recenable (int ssid, int yn, lo_message msg) } } } - // hmm, not set for whatever reason tell surface - return route_send_fail ("recenable", ssid, 0, lo_message_get_source (msg)); + return route_send_fail ("recenable", ssid, 0, get_address (msg)); +} + +int +OSC::route_rename(int ssid, char *newname, lo_message msg) { + if (!session) { + return -1; + } + + boost::shared_ptr s = get_strip(ssid, get_address(msg)); + + if (s) { + s->set_name(std::string(newname)); + } + + return 0; } int OSC::sel_recsafe (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_recsafe(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("record_safe", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->rec_safe_control()) { + s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + if (s->rec_safe_control()->get_value()) { + return 0; + } + } } + return sel_fail ("record_safe", 0, get_address (msg)); } int OSC::route_recsafe (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { if (s->rec_safe_control()) { s->rec_safe_control()->set_value (yn, PBD::Controllable::UseGroup); @@ -1615,70 +2404,89 @@ OSC::route_recsafe (int ssid, int yn, lo_message msg) } } } - // hmm, not set for whatever reason tell surface - return route_send_fail ("record_safe", ssid, 0,lo_message_get_source (msg)); + return route_send_fail ("record_safe", ssid, 0,get_address (msg)); } int OSC::route_monitor_input (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { - track->monitoring_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); - } else { - route_send_fail ("monitor_input", ssid, 0, lo_message_get_source (msg)); + if (track->monitoring_control()) { + track->monitoring_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } } - return 0; + return route_send_fail ("monitor_input", ssid, 0, get_address (msg)); } int OSC::sel_monitor_input (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_monitor_input(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("monitor_input", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + boost::shared_ptr track = boost::dynamic_pointer_cast (s); + if (track) { + if (track->monitoring_control()) { + track->monitoring_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } } + return sel_fail ("monitor_input", 0, get_address (msg)); } int OSC::route_monitor_disk (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { - track->monitoring_control()->set_value (yn ? 2.0 : 0.0, PBD::Controllable::NoGroup); - } else { - route_send_fail ("monitor_disk", ssid, 0, lo_message_get_source (msg)); + if (track->monitoring_control()) { + track->monitoring_control()->set_value (yn ? 2.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } } - return 0; + return route_send_fail ("monitor_disk", ssid, 0, get_address (msg)); } int OSC::sel_monitor_disk (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_monitor_disk(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("monitor_disk", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + boost::shared_ptr track = boost::dynamic_pointer_cast (s); + if (track) { + if (track->monitoring_control()) { + track->monitoring_control()->set_value (yn ? 2.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } } + return sel_fail ("monitor_disk", 0, get_address (msg)); } @@ -1686,88 +2494,125 @@ int OSC::strip_phase (int ssid, int yn, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { - s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + if (s->phase_control()) { + s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } } - return 0; + return route_send_fail ("polarity", ssid, 0, get_address (msg)); } int OSC::sel_phase (uint32_t yn, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return strip_phase(sur->surface_sel, yn, msg); - } else { - return route_send_fail ("phase", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; } + if (s) { + if (s->phase_control()) { + s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("polarity", 0, get_address (msg)); } int -OSC::strip_select (int ssid, int yn, lo_message msg) +OSC::strip_expand (int ssid, int yn, lo_message msg) { - //ignore button release - if (!yn) return 0; + OSCSurface *sur = get_surface(get_address (msg)); + sur->expand_enable = (bool) yn; + sur->expand = ssid; + boost::shared_ptr s; + if (yn) { + s = get_strip (ssid, get_address (msg)); + } else { + s = ControlProtocol::first_selected_stripable(); + } - return _strip_select ( ssid, lo_message_get_source (msg)); + return _strip_select (s, get_address (msg)); } int -OSC::_strip_select (int ssid, lo_address addr) +OSC::_strip_select (boost::shared_ptr s, lo_address addr) { if (!session) { - route_send_fail ("select", ssid, 0, addr); return -1; } - int rid = get_rid (ssid, addr); - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); OSCSurface *sur = get_surface(addr); if (sur->sel_obs) { delete sur->sel_obs; sur->sel_obs = 0; } - sur->surface_sel = 0; - - if (s) { - sur->surface_sel = ssid; - OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, ssid, sur->gainmode, sur->feedback); + bool feedback_on = sur->feedback.to_ulong(); + if (s && feedback_on) { + OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, sur->gainmode, sur->feedback); + s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this); sur->sel_obs = sel_fb; - } else { - route_send_fail ("select", ssid, 0 , addr); + } else if (sur->expand_enable) { + sur->expand = 0; + sur->expand_enable = false; + if (_select && feedback_on) { + OSCSelectObserver* sel_fb = new OSCSelectObserver (_select, addr, sur->gainmode, sur->feedback); + _select->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this); + sur->sel_obs = sel_fb; + } + } else if (feedback_on) { + route_send_fail ("select", sur->expand, 0 , addr); + } + if (!feedback_on) { + return 0; } + //update buttons on surface int b_s = sur->bank_size; if (!b_s) { // bank size 0 means we need to know how many strips there are. b_s = sur->nstrips; } for (int i = 1; i <= b_s; i++) { - string path = "select"; - if (!sur->feedback[10]) { - path = "gui_select"; - } - if (i==(int)sur->surface_sel) { + string path = "expand"; + + if ((i == (int) sur->expand) && sur->expand_enable) { lo_message reply = lo_message_new (); if (sur->feedback[2]) { ostringstream os; - os << "/strip/" << path << "/" << ssid; + os << "/strip/" << path << "/" << i; path = os.str(); } else { ostringstream os; os << "/strip/" << path; path = os.str(); - lo_message_add_int32 (reply, ssid); + lo_message_add_int32 (reply, i); } - lo_message_add_float (reply, (float) 1); + lo_message_add_float (reply, (float) 1); - lo_send_message (addr, path.c_str(), reply); - lo_message_free (reply); - } else { - route_send_fail (path, i, 0, addr); - } + lo_send_message (addr, path.c_str(), reply); + lo_message_free (reply); + reply = lo_message_new (); + lo_message_add_float (reply, 1.0); + lo_send_message (addr, "/select/expand", reply); + lo_message_free (reply); + + } else { + lo_message reply = lo_message_new (); + lo_message_add_int32 (reply, i); + lo_message_add_float (reply, 0.0); + lo_send_message (addr, "/strip/expand", reply); + lo_message_free (reply); + } + } + if (!sur->expand_enable) { + lo_message reply = lo_message_new (); + lo_message_add_float (reply, 0.0); + lo_send_message (addr, "/select/expand", reply); + lo_message_free (reply); } return 0; @@ -1780,30 +2625,51 @@ OSC::strip_gui_select (int ssid, int yn, lo_message msg) if (!yn) return 0; if (!session) { - route_send_fail ("gui_select", ssid, 0, lo_message_get_source (msg)); return -1; } - - int rid = get_rid (ssid, lo_message_get_source (msg)); - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + OSCSurface *sur = get_surface(get_address (msg)); + sur->expand_enable = false; + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { - //SetStripableSelection ((*s)->presentation_info().order()); - SetStripableSelection (rid); //alt above may end up being better + SetStripableSelection (s); } else { - route_send_fail ("gui_select", ssid, 0, lo_message_get_source (msg)); + if ((int) (sur->feedback.to_ulong())) { + route_send_fail ("select", ssid, 0, get_address (msg)); + } } return 0; } int -OSC::route_set_gain_abs (int rid, float level, lo_message msg) +OSC::sel_expand (uint32_t state, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + sur->expand_enable = (bool) state; + if (state && sur->expand) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = ControlProtocol::first_selected_stripable(); + } + + return _strip_select (s, get_address (msg)); +} + +int +OSC::route_set_gain_abs (int ssid, float level, lo_message msg) { if (!session) return -1; - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { - s->gain_control()->set_value (level, PBD::Controllable::NoGroup); + if (s->gain_control()) { + s->gain_control()->set_value (level, PBD::Controllable::NoGroup); + } else { + return 1; + } + } else { + return 1; } return 0; @@ -1813,341 +2679,1077 @@ int OSC::route_set_gain_dB (int ssid, float dB, lo_message msg) { if (!session) { - route_send_fail ("gain", ssid, -193, lo_message_get_source (msg)); + route_send_fail ("gain", ssid, -193, get_address (msg)); return -1; } int ret; - int rid = get_rid (ssid, lo_message_get_source (msg)); if (dB < -192) { - ret = route_set_gain_abs (rid, 0.0, msg); + ret = route_set_gain_abs (ssid, 0.0, msg); } else { - ret = route_set_gain_abs (rid, dB_to_coefficient (dB), msg); + ret = route_set_gain_abs (ssid, dB_to_coefficient (dB), msg); } if (ret != 0) { - route_send_fail ("gain", ssid, -193, lo_message_get_source (msg)); + return route_send_fail ("gain", ssid, -193, get_address (msg)); } - return ret; + return 0; } int OSC::sel_gain (float val, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_set_gain_dB(sur->surface_sel, val, msg); - } else { - return route_send_fail ("gain", 0, -193, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + float abs; + if (val < -192) { + abs = 0; + } else { + abs = dB_to_coefficient (val); + } + if (s->gain_control()) { + s->gain_control()->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("gain", -193, get_address (msg)); } int OSC::route_set_gain_fader (int ssid, float pos, lo_message msg) { if (!session) { - route_send_fail ("fader", ssid, 0, lo_message_get_source (msg)); + route_send_fail ("fader", ssid, 0, get_address (msg)); return -1; } int ret; - int rid = get_rid (ssid, lo_message_get_source (msg)); - if ((pos > 799.5) && (pos < 800.5)) { - ret = route_set_gain_abs (rid, 1.0, msg); - } else { - ret = route_set_gain_abs (rid, slider_position_to_gain_with_max ((pos/1023), 2.0), msg); - } + ret = route_set_gain_abs (ssid, slider_position_to_gain_with_max (pos, 2.0), msg); if (ret != 0) { - route_send_fail ("fader", ssid, 0, lo_message_get_source (msg)); + return route_send_fail ("fader", ssid, 0, get_address (msg)); } - return ret; + return 0; } int OSC::sel_fader (float val, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_set_gain_fader(sur->surface_sel, val, msg); - } else { - return route_send_fail ("fader", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + float abs; + abs = slider_position_to_gain_with_max (val, 2.0); + if (s->gain_control()) { + s->gain_control()->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("fader", 0, get_address (msg)); } int OSC::route_set_trim_abs (int ssid, float level, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { if (s->trim_control()) { s->trim_control()->set_value (level, PBD::Controllable::NoGroup); + return 0; } } - return 0; + return -1; } int OSC::route_set_trim_dB (int ssid, float dB, lo_message msg) { - return route_set_trim_abs(ssid, dB_to_coefficient (dB), msg); + int ret; + ret = route_set_trim_abs(ssid, dB_to_coefficient (dB), msg); + if (ret != 0) { + return route_send_fail ("trimdB", ssid, 0, get_address (msg)); + } + +return 0; } int OSC::sel_trim (float val, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_set_trim_dB (sur->surface_sel, val, msg); - } else { - return route_send_fail ("trimdB", 0, 0, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->trim_control()) { + s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("trimdB", 0, get_address (msg)); } int OSC::sel_pan_position (float val, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_set_pan_stereo_position (sur->surface_sel, val, msg); - } else { - return route_send_fail ("pan_stereo_position", 0, 0.5, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; } + if (s) { + if(s->pan_azimuth_control()) { + s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("pan_stereo_position", 0.5, get_address (msg)); } int OSC::sel_pan_width (float val, lo_message msg) { - OSCSurface *sur = get_surface(lo_message_get_source (msg)); - if (sur->surface_sel) { - return route_set_pan_stereo_width (sur->surface_sel, val, msg); - } else { - return route_send_fail ("pan_stereo_width", 0, 1, lo_message_get_source (msg)); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->pan_width_control()) { + s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("pan_stereo_width", 1, get_address (msg)); } int OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { if(s->pan_azimuth_control()) { - s->pan_azimuth_control()->set_value (pos, PBD::Controllable::NoGroup); + s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), PBD::Controllable::NoGroup); + return 0; } } - return 0; - + return route_send_fail ("pan_stereo_position", ssid, 0.5, get_address (msg)); } int OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg) { if (!session) return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { if (s->pan_width_control()) { s->pan_width_control()->set_value (pos, PBD::Controllable::NoGroup); + return 0; } } - return 0; - + return route_send_fail ("pan_stereo_width", ssid, 1, get_address (msg)); } int -OSC::route_set_send_gain_abs (int ssid, int sid, float val, lo_message msg) +OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg) { if (!session) { return -1; } - int rid = get_rid (ssid, lo_message_get_source (msg)); - - boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::Route); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + float abs; + if (s) { + if (id > 0) { + --id; + } +#ifdef MIXBUS + abs = val; +#else + if (val < -192) { + abs = 0; + } else { + abs = dB_to_coefficient (val); + } +#endif + if (s->send_level_controllable (id)) { + s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } + } + return 0; +} - if (!s) { +int +OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg) +{ + if (!session) { return -1; } + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + float abs; + if (s) { - /* revert to zero-based counting */ + if (id > 0) { + --id; + } - if (sid > 0) { - --sid; + if (s->send_level_controllable (id)) { +#ifdef MIXBUS + abs = s->send_level_controllable(id)->interface_to_internal (val); +#else + abs = slider_position_to_gain_with_max (val, 2.0); +#endif + s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } } + return 0; +} - if (s->send_level_controllable (sid)) { - s->send_level_controllable (sid)->set_value (val, PBD::Controllable::NoGroup); +int +OSC::sel_sendgain (int id, float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; } - - return 0; + float abs; + if (s) { + if (id > 0) { + --id; + } +#ifdef MIXBUS + abs = val; +#else + if (val < -192) { + abs = 0; + } else { + abs = dB_to_coefficient (val); + } +#endif + if (s->send_level_controllable (id)) { + s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("send_gain", id + 1, -193, get_address (msg)); } int -OSC::route_set_send_gain_dB (int ssid, int sid, float val, lo_message msg) +OSC::sel_sendfader (int id, float val, lo_message msg) { - return route_set_send_gain_abs (ssid, sid, dB_to_coefficient (val), msg); + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + float abs; + if (s) { + + if (id > 0) { + --id; + } + + if (s->send_level_controllable (id)) { +#ifdef MIXBUS + abs = s->send_level_controllable(id)->interface_to_internal (val); +#else + abs = slider_position_to_gain_with_max (val, 2.0); +#endif + s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("send_fader", id, 0, get_address (msg)); } int -OSC::route_set_send_fader (int ssid, int sid, float pos, lo_message msg) +OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg) { if (!session) { return -1; } - int ret; - if ((pos > 799.5) && (pos < 800.5)) { - ret = route_set_send_gain_abs (ssid, sid, 1.0, msg); - } else { - ret = route_set_send_gain_abs (ssid, sid, slider_position_to_gain_with_max ((pos/1023), 2.0), msg); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + + if (s) { + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + if (s->send_enable_controllable (sid)) { + s->send_enable_controllable (sid)->set_value (val, PBD::Controllable::NoGroup); + return 0; + } + + if (s->send_level_controllable (sid)) { + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + if (!r) { + return 0; + } + boost::shared_ptr snd = boost::dynamic_pointer_cast (r->nth_send(sid)); + if (snd) { + if (val) { + snd->activate(); + } else { + snd->deactivate(); + } + } + return 0; + } + } - return ret; + + return -1; } int -OSC::route_plugin_parameter (int ssid, int piid, int par, float val, lo_message msg) +OSC::sel_sendenable (int id, float val, lo_message msg) { - if (!session) + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (id > 0) { + --id; + } + if (s->send_enable_controllable (id)) { + s->send_enable_controllable (id)->set_value (val, PBD::Controllable::NoGroup); + return 0; + } + if (s->send_level_controllable (id)) { + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + if (!r) { + // should never get here + return sel_send_fail ("send_enable", id + 1, 0, get_address (msg)); + } + boost::shared_ptr snd = boost::dynamic_pointer_cast (r->nth_send(id)); + if (snd) { + if (val) { + snd->activate(); + } else { + snd->deactivate(); + } + } + return 0; + } + } + return sel_send_fail ("send_enable", id + 1, 0, get_address (msg)); +} + +int +OSC::route_plugin_list (int ssid, lo_message msg) { + if (!session) { + return -1; + } + + boost::shared_ptr r = boost::dynamic_pointer_cast(get_strip (ssid, get_address (msg))); + + if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; + return -1; + } + int piid = 0; + + lo_message reply = lo_message_new (); + lo_message_add_int32 (reply, ssid); + + + for (;;) { + boost::shared_ptr redi = r->nth_plugin(piid); + if ( !redi ) { + break; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; + continue; + } + lo_message_add_int32 (reply, piid + 1); + + boost::shared_ptr pip = pi->plugin(); + lo_message_add_string (reply, pip->name()); + + piid++; + } + + lo_send_message (get_address (msg), "/strip/plugin/list", reply); + lo_message_free (reply); + return 0; +} + +int +OSC::route_plugin_descriptor (int ssid, int piid, lo_message msg) { + if (!session) { return -1; - int rid = get_rid (ssid, lo_message_get_source (msg)); + } - boost::shared_ptr r = session->get_remote_nth_route (rid); + boost::shared_ptr r = boost::dynamic_pointer_cast(get_strip (ssid, get_address (msg))); if (!r) { - PBD::error << "OSC: Invalid Remote Control ID '" << rid << "'" << endmsg; + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; return -1; } - boost::shared_ptr redi=r->nth_plugin (piid); + boost::shared_ptr redi = r->nth_plugin(piid - 1); if (!redi) { - PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << rid << "'" << endmsg; + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg; return -1; } boost::shared_ptr pi; if (!(pi = boost::dynamic_pointer_cast(redi))) { - PBD::error << "OSC: given processor # " << piid << " on RID '" << rid << "' is not a Plugin." << endmsg; + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; return -1; } boost::shared_ptr pip = pi->plugin(); - bool ok=false; + bool ok = false; - uint32_t controlid = pip->nth_parameter (par,ok); + 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++) { - if (!ok) { - PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "'" << endmsg; + 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 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.max_unbound ? 8 : 0; + flags |= pd.min_unbound ? 16 : 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); + } + } + } + + lo_send_message (get_address (msg), "/strip/plugin/descriptor", reply); + lo_message_free (reply); + + return 0; +} + +int +OSC::route_plugin_reset (int ssid, int piid, lo_message msg) { + if (!session) { return -1; } - if (!pip->parameter_is_input(controlid)) { - PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "' is not a control input" << endmsg; + boost::shared_ptr r = boost::dynamic_pointer_cast(get_strip (ssid, get_address (msg))); + + if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; return -1; } - ParameterDescriptor pd; - pi->plugin()->get_parameter_descriptor (controlid,pd); + boost::shared_ptr redi = r->nth_plugin(piid - 1); - if (val >= pd.lower && val <= pd.upper) { + if (!redi) { + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg; + return -1; + } - boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); - // cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n"; - c->set_value (val, PBD::Controllable::NoGroup); - } else { - PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << rid << "' is out of range" << endmsg; - PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg; + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; + return -1; } + pi->reset_parameters_to_default (); + return 0; } -//prints to cerr only int -OSC::route_plugin_parameter_print (int ssid, int piid, int par, lo_message msg) +OSC::route_plugin_parameter (int ssid, int piid, int par, float val, lo_message msg) { - if (!session) { + if (!session) return -1; - } - int rid = get_rid (ssid, lo_message_get_source (msg)); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); - boost::shared_ptr r = session->get_remote_nth_route (rid); + boost::shared_ptr r = boost::dynamic_pointer_cast (s); if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; return -1; } - boost::shared_ptr redi=r->nth_processor (piid); + boost::shared_ptr redi=r->nth_plugin (piid - 1); if (!redi) { + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg; return -1; } boost::shared_ptr pi; if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; return -1; } boost::shared_ptr pip = pi->plugin(); bool ok=false; - uint32_t controlid = pip->nth_parameter (par,ok); + uint32_t controlid = pip->nth_parameter (par - 1,ok); if (!ok) { + PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "'" << endmsg; + return -1; + } + + if (!pip->parameter_is_input(controlid)) { + PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is not a control input" << endmsg; return -1; } ParameterDescriptor pd; + pi->plugin()->get_parameter_descriptor (controlid,pd); - if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) { - boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); + if (val >= pd.lower && val <= pd.upper) { - cerr << "parameter: " << redi->describe_parameter(controlid) << "\n"; - cerr << "current value: " << c->get_value (); - cerr << "lower value: " << pd.lower << "\n"; + boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); + // cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n"; + c->set_value (val, PBD::Controllable::NoGroup); + } else { + PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is out of range" << endmsg; + PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg; + } + + return 0; +} + +//prints to cerr only +int +OSC::route_plugin_parameter_print (int ssid, int piid, int par, lo_message msg) +{ + if (!session) { + return -1; + } + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + + if (!r) { + return -1; + } + + boost::shared_ptr redi=r->nth_plugin (piid - 1); + + if (!redi) { + return -1; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + return -1; + } + + boost::shared_ptr pip = pi->plugin(); + bool ok=false; + + uint32_t controlid = pip->nth_parameter (par - 1,ok); + + if (!ok) { + return -1; + } + + ParameterDescriptor pd; + + if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) { + boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); + + cerr << "parameter: " << pd.label << "\n"; + if (c) { + cerr << "current value: " << c->get_value () << "\n"; + } else { + cerr << "current value not available, control does not exist\n"; + } + cerr << "lower value: " << pd.lower << "\n"; cerr << "upper value: " << pd.upper << "\n"; } return 0; } -void -OSC::gui_selection_changed (StripableNotificationListPtr stripables) +int +OSC::route_plugin_activate (int ssid, int piid, lo_message msg) { - boost::shared_ptr strip; + if (!session) + return -1; + boost::shared_ptr s = get_strip (ssid, lo_message_get_source (msg)); + + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + + if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; + return -1; + } - if (!stripables->empty()) { - strip = stripables->front().lock(); + boost::shared_ptr redi=r->nth_plugin (piid - 1); + + if (!redi) { + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg; + return -1; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; + return -1; + } + + boost::shared_ptr pip = pi->plugin(); + pi->activate(); + + return 0; +} + +int +OSC::route_plugin_deactivate (int ssid, int piid, lo_message msg) +{ + if (!session) + return -1; + boost::shared_ptr s = get_strip (ssid, lo_message_get_source (msg)); + + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + + if (!r) { + PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg; + return -1; + } + + boost::shared_ptr redi=r->nth_plugin (piid - 1); + + if (!redi) { + PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg; + return -1; + } + + boost::shared_ptr pi; + + if (!(pi = boost::dynamic_pointer_cast(redi))) { + PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg; + return -1; + } + + boost::shared_ptr pip = pi->plugin(); + pi->deactivate(); + + return 0; +} + +// select + +int +OSC::sel_pan_elevation (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->pan_elevation_control()) { + s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("pan_elevation_position", 0, get_address (msg)); +} + +int +OSC::sel_pan_frontback (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->pan_frontback_control()) { + s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } } + return sel_fail ("pan_frontback_position", 0.5, get_address (msg)); +} + +int +OSC::sel_pan_lfe (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->pan_lfe_control()) { + s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("pan_lfe_control", 0, get_address (msg)); +} + +// compressor control +int +OSC::sel_comp_enable (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->comp_enable_controllable()) { + s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("comp_enable", 0, get_address (msg)); +} + +int +OSC::sel_comp_threshold (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->comp_threshold_controllable()) { + s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("comp_threshold", 0, get_address (msg)); +} + +int +OSC::sel_comp_speed (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->comp_speed_controllable()) { + s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("comp_speed", 0, get_address (msg)); +} + +int +OSC::sel_comp_mode (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->comp_mode_controllable()) { + s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("comp_mode", 0, get_address (msg)); +} + +int +OSC::sel_comp_makeup (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->comp_makeup_controllable()) { + s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("comp_makeup", 0, get_address (msg)); +} + +// EQ control + +int +OSC::sel_eq_enable (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->eq_enable_controllable()) { + s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("eq_enable", 0, get_address (msg)); +} + +int +OSC::sel_eq_hpf (float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (s->eq_hpf_controllable()) { + s->eq_hpf_controllable()->set_value (s->eq_hpf_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_fail ("eq_hpf", 0, get_address (msg)); +} + +int +OSC::sel_eq_gain (int id, float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (id > 0) { + --id; + } + if (s->eq_gain_controllable (id)) { + s->eq_gain_controllable (id)->set_value (s->eq_gain_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("eq_gain", id + 1, 0, get_address (msg)); +} + +int +OSC::sel_eq_freq (int id, float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (id > 0) { + --id; + } + if (s->eq_freq_controllable (id)) { + s->eq_freq_controllable (id)->set_value (s->eq_freq_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("eq_freq", id + 1, 0, get_address (msg)); +} + +int +OSC::sel_eq_q (int id, float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (id > 0) { + --id; + } + if (s->eq_q_controllable (id)) { + s->eq_q_controllable (id)->set_value (s->eq_q_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("eq_q", id + 1, 0, get_address (msg)); +} + +int +OSC::sel_eq_shape (int id, float val, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + if (sur->expand_enable) { + s = get_strip (sur->expand, get_address (msg)); + } else { + s = _select; + } + if (s) { + if (id > 0) { + --id; + } + if (s->eq_shape_controllable (id)) { + s->eq_shape_controllable (id)->set_value (s->eq_shape_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup); + return 0; + } + } + return sel_send_fail ("eq_shape", id + 1, 0, get_address (msg)); +} + +void +OSC::gui_selection_changed () +{ + boost::shared_ptr strip = ControlProtocol::first_selected_stripable(); + if (strip) { + _select = strip; for (uint32_t it = 0; it < _surface.size(); ++it) { OSCSurface* sur = &_surface[it]; - if(!sur->feedback[10]) { - uint32_t sel_strip = strip->presentation_info().order() + 1; - if (!(sel_strip < sur->bank) && !(sel_strip >= (sur->bank + sur->bank_size))) { - lo_address addr = lo_address_new_from_url (sur->remote_url.c_str()); - _strip_select ((sel_strip - sur->bank + 1), addr); - } + if(!sur->expand_enable) { + lo_address addr = lo_address_new_from_url (sur->remote_url.c_str()); + _strip_select (strip, addr); } } } - } // timer callbacks bool OSC::periodic (void) { + if (!tick) { + Glib::usleep(100); // let flurry of signals subside + if (global_init) { + 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_init = false; + tick = true; + } + if (bank_dirty) { + _recalcbanks (); + bank_dirty = false; + tick = true; + } + } + + if (scrub_speed != 0) { + // for those jog wheels that don't have 0 on release (touch), time out. + int64_t now = ARDOUR::get_microseconds (); + int64_t diff = now - scrub_time; + if (diff > 120000) { + scrub_speed = 0; + session->request_transport_speed (0); + // locate to the place PH was at last tick + session->request_locate (scrub_place, false); + } + } + for (GlobalObservers::iterator x = global_observers.begin(); x != global_observers.end(); x++) { OSCGlobalObserver* go; @@ -2164,13 +3766,21 @@ OSC::periodic (void) ro->tick(); } } - for (uint32_t it = 0; it < _surface.size(); ++it) { + for (uint32_t it = 0; it < _surface.size(); it++) { OSCSurface* sur = &_surface[it]; OSCSelectObserver* so; if ((so = dynamic_cast(sur->sel_obs)) != 0) { so->tick(); } } + for (CueObservers::iterator x = cue_observers.begin(); x != cue_observers.end(); x++) { + + OSCCueObserver* co; + + if ((co = dynamic_cast(*x)) != 0) { + co->tick(); + } + } return true; } @@ -2195,7 +3805,7 @@ OSC::route_send_fail (string path, uint32_t ssid, float val, lo_address addr) lo_send_message (addr, str_pth.c_str(), reply); lo_message_free (reply); } - if (sur->surface_sel == ssid) { + if ((_select == get_strip (ssid, addr)) || ((sur->expand == ssid) && (sur->expand_enable))) { os.str(""); os << "/select/" << path; string sel_pth = os.str(); @@ -2208,11 +3818,69 @@ OSC::route_send_fail (string path, uint32_t ssid, float val, lo_address addr) return 0; } +int +OSC::sel_fail (string path, float val, lo_address addr) +{ + ostringstream os; + os.str(""); + os << "/select/" << path; + string sel_pth = os.str(); + lo_message reply = lo_message_new (); + lo_message_add_float (reply, (float) val); + lo_send_message (addr, sel_pth.c_str(), reply); + lo_message_free (reply); + + return 0; +} + +int +OSC::sel_send_fail (string path, uint32_t id, float val, lo_address addr) +{ + OSCSurface *sur = get_surface(addr); + + ostringstream os; + lo_message reply; + reply = lo_message_new (); + if (sur->feedback[2]) { + os << "/select/" << path << "/" << id; + } else { + os << "/select/" << path; + lo_message_add_int32 (reply, id); + } + string str_pth = os.str(); + lo_message_add_float (reply, (float) val); + + lo_send_message (addr, str_pth.c_str(), reply); + lo_message_free (reply); + + return 0; +} + XMLNode& OSC::get_state () { XMLNode& node (ControlProtocol::get_state()); - node.add_property("debugmode", (int) _debugmode); // TODO: enum2str + node.set_property ("debugmode", (int32_t) _debugmode); // TODO: enum2str + node.set_property ("address-only", address_only); + node.set_property ("remote-port", remote_port); + node.set_property ("banksize", default_banksize); + node.set_property ("striptypes", default_strip); + node.set_property ("feedback", default_feedback); + node.set_property ("gainmode", default_gainmode); + 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); + config->add_child_nocopy (*devnode); + } + node.add_child_nocopy (*config); + } return node; } @@ -2222,10 +3890,431 @@ OSC::set_state (const XMLNode& node, int version) if (ControlProtocol::set_state (node, version)) { return -1; } - XMLProperty const * p = node.property (X_("debugmode")); - if (p) { - _debugmode = OSCDebugMode (PBD::atoi(p->value ())); + int32_t debugmode; + if (node.get_property (X_("debugmode"), debugmode)) { + _debugmode = OSCDebugMode (debugmode); } + node.get_property (X_("address-only"), address_only); + node.get_property (X_("remote-port"), remote_port); + node.get_property (X_("banksize"), default_banksize); + node.get_property (X_("striptypes"), default_strip); + node.get_property (X_("feedback"), default_feedback); + node.get_property (X_("gainmode"), default_gainmode); + + 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); + + 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 (); + _surface.push_back (s); + } + } + global_init = true; + tick = false; + return 0; } + +// predicate for sort call in get_sorted_stripables +struct StripableByPresentationOrder +{ + bool operator () (const boost::shared_ptr & a, const boost::shared_ptr & b) const + { + return a->presentation_info().order() < b->presentation_info().order(); + } + + bool operator () (const Stripable & a, const Stripable & b) const + { + return a.presentation_info().order() < b.presentation_info().order(); + } + + bool operator () (const Stripable * a, const Stripable * b) const + { + return a->presentation_info().order() < b->presentation_info().order(); + } +}; + +OSC::Sorted +OSC::get_sorted_stripables(std::bitset<32> types, bool cue) +{ + Sorted sorted; + + // fetch all stripables + StripableList stripables; + + session->get_stripables (stripables); + + // Look for stripables that match bit in sur->strip_types + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + + boost::shared_ptr s = *it; + if ((!cue) && (!types[9]) && (s->presentation_info().flags() & PresentationInfo::Hidden)) { + // do nothing... skip it + } else { + + if (types[0] && (s->presentation_info().flags() & PresentationInfo::AudioTrack)) { + sorted.push_back (s); + } else + if (types[1] && (s->presentation_info().flags() & PresentationInfo::MidiTrack)) { + sorted.push_back (s); + } else + if ((s->presentation_info().flags() & PresentationInfo::AudioBus)) { + boost::shared_ptr r = boost::dynamic_pointer_cast (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); + } + } + } 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->presentation_info().flags() & PresentationInfo::Selected)) { + sorted.push_back (s); + } else + if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) { + sorted.push_back (s); + } + } + } + sort (sorted.begin(), sorted.end(), StripableByPresentationOrder()); + // Master/Monitor might be anywhere... we put them at the end - Sorry ;) + if (types[5]) { + sorted.push_back (session->master_out()); + } + if (types[6]) { + sorted.push_back (session->monitor_out()); + } + return sorted; +} + +int +OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) +{ + int ret = 1; /* unhandled */ + + if (!strncmp (path, "/cue/aux", 8)) { + // set our Aux bus + cue_set (argv[0]->i, msg); + ret = 0; + } + else if (!strncmp (path, "/cue/connect", 12)) { + // switch to next Aux bus + cue_set (0, msg); + ret = 0; + } + else if (!strncmp (path, "/cue/next_aux", 13)) { + // switch to next Aux bus + cue_next (msg); + ret = 0; + } + else if (!strncmp (path, "/cue/previous_aux", 17)) { + // switch to previous Aux bus + cue_previous (msg); + ret = 0; + } + else if (!strncmp (path, "/cue/send/fader/", 16) && strlen (path) > 16) { + int id = atoi (&path[16]); + cue_send_fader (id, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/cue/send/enable/", 17) && strlen (path) > 17) { + int id = atoi (&path[17]); + cue_send_enable (id, argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/cue/fader", 10)) { + cue_aux_fader (argv[0]->f, msg); + ret = 0; + } + else if (!strncmp (path, "/cue/mute", 9)) { + cue_aux_mute (argv[0]->f, msg); + ret = 0; + } + + if ((ret && _debugmode == Unhandled)) { + debugmsg (_("Unhandled OSC cue message"), path, types, argv, argc); + } else if ((!ret && _debugmode == All)) { + debugmsg (_("OSC cue"), path, types, argv, argc); + } + + return ret; +} + +int +OSC::cue_set (uint32_t aux, lo_message msg) +{ + return _cue_set (aux, get_address (msg)); +} + +int +OSC::_cue_set (uint32_t aux, lo_address addr) +{ + OSCSurface *s = get_surface(addr); + s->bank_size = 0; + s->strip_types = 128; + s->feedback = 0; + s->gainmode = 1; + s->cue = true; + s->aux = aux; + s->strips = get_sorted_stripables(s->strip_types, s->cue); + + s->nstrips = s->strips.size(); + // get rid of any old CueObsevers for this address + cueobserver_connections.drop_connections (); + CueObservers::iterator x; + for (x = cue_observers.begin(); x != cue_observers.end();) { + + OSCCueObserver* co; + + if ((co = dynamic_cast(*x)) != 0) { + + int res = strcmp(lo_address_get_url(co->address()), lo_address_get_url(addr)); + + if (res == 0) { + delete *x; + x = cue_observers.erase (x); + } else { + ++x; + } + } else { + ++x; + } + } + + // get a list of Auxes + for (uint32_t n = 0; n < s->nstrips; ++n) { + boost::shared_ptr stp = s->strips[n]; + if (stp) { + text_message (string_compose ("/cue/name/%1", n+1), stp->name(), addr); + if (aux == n+1) { + // aux must be at least one + // need a signal if aux vanishes + stp->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::_cue_set, this, aux, addr), this); + + // make a list of stripables with sends that go to this bus + s->sends = cue_get_sorted_stripables(stp, aux, addr); + // start cue observer + OSCCueObserver* co = new OSCCueObserver (stp, s->sends, addr); + cue_observers.push_back (co); + } + + } + } + + return 0; +} + +int +OSC::cue_next (lo_message msg) +{ + OSCSurface *s = get_surface(get_address (msg)); + if (s->aux < s->nstrips) { + cue_set (s->aux + 1, msg); + } else { + cue_set (s->nstrips, msg); + } + return 0; +} + +int +OSC::cue_previous (lo_message msg) +{ + OSCSurface *s = get_surface(get_address (msg)); + if (s->aux > 1) { + cue_set (s->aux - 1, msg); + } + return 0; +} + +boost::shared_ptr +OSC::cue_get_send (uint32_t id, lo_address addr) +{ + OSCSurface *s = get_surface(addr); + if (id && s->aux > 0 && id <= s->sends.size()) { + boost::shared_ptr r = boost::dynamic_pointer_cast (s->sends[id - 1]); + boost::shared_ptr aux = get_strip (s->aux, addr); + if (r && aux) { + return r->internal_send_for (boost::dynamic_pointer_cast (aux)); + } + } + return boost::shared_ptr(); + +} + +int +OSC::cue_aux_fader (float position, lo_message msg) +{ + if (!session) return -1; + + OSCSurface *sur = get_surface(get_address (msg)); + if (sur->cue) { + if (sur->aux) { + boost::shared_ptr s = get_strip (sur->aux, get_address (msg)); + + if (s) { + float abs; + abs = slider_position_to_gain_with_max (position, 2.0); + if (s->gain_control()) { + s->gain_control()->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } + } + } + } + return cue_float_message ("/cue/fader", 0, get_address (msg)); +} + +int +OSC::cue_aux_mute (float state, lo_message msg) +{ + if (!session) return -1; + + OSCSurface *sur = get_surface(get_address (msg)); + if (sur->cue) { + if (sur->aux) { + boost::shared_ptr s = get_strip (sur->aux, get_address (msg)); + if (s) { + if (s->mute_control()) { + s->mute_control()->set_value (state ? 1.0 : 0.0, PBD::Controllable::NoGroup); + return 0; + } + } + } + } + return cue_float_message ("/cue/mute", 0, get_address (msg)); +} + +int +OSC::cue_send_fader (uint32_t id, float val, lo_message msg) +{ + if (!session) { + return -1; + } + boost::shared_ptr s = cue_get_send (id, get_address (msg)); + float abs; + if (s) { + if (s->gain_control()) { + abs = slider_position_to_gain_with_max (val, 2.0); + s->gain_control()->set_value (abs, PBD::Controllable::NoGroup); + return 0; + } + } + return cue_float_message (string_compose ("/cue/send/fader/%1", id), 0, get_address (msg)); +} + +int +OSC::cue_send_enable (uint32_t id, float state, lo_message msg) +{ + if (!session) + return -1; + boost::shared_ptr s = cue_get_send (id, get_address (msg)); + if (s) { + if (state) { + s->activate (); + } else { + s->deactivate (); + } + return 0; + } + return cue_float_message (string_compose ("/cue/send/enable/%1", id), 0, get_address (msg)); +} + +int +OSC::cue_float_message (string path, float val, lo_address addr) +{ + + lo_message reply; + reply = lo_message_new (); + lo_message_add_float (reply, (float) val); + + lo_send_message (addr, path.c_str(), reply); + lo_message_free (reply); + + return 0; +} + +int +OSC::text_message (string path, string val, lo_address addr) +{ + + lo_message reply; + reply = lo_message_new (); + lo_message_add_string (reply, val.c_str()); + + lo_send_message (addr, path.c_str(), reply); + lo_message_free (reply); + + return 0; +} + + +// we have to have a sorted list of stripables that have sends pointed at our aux +// we can use the one in osc.cc to get an aux list +OSC::Sorted +OSC::cue_get_sorted_stripables(boost::shared_ptr aux, uint32_t id, lo_message msg) +{ + Sorted sorted; + cueobserver_connections.drop_connections (); + // fetch all stripables + StripableList stripables; + + session->get_stripables (stripables); + + // Look for stripables that have a send to aux + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + + boost::shared_ptr s = *it; + // we only want routes + boost::shared_ptr r = boost::dynamic_pointer_cast (s); + if (r) { + r->processors_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this); + boost::shared_ptr snd = r->internal_send_for (boost::dynamic_pointer_cast (aux)); + if (snd) { // test for send to aux + sorted.push_back (s); + s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::cue_set, this, id, msg), this); + } + } + + + } + sort (sorted.begin(), sorted.end(), StripableByPresentationOrder()); + + return sorted; +} +