X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fosc%2Fosc.cc;h=08b8fb9c185ea31a48282eed2c586f74565f1c95;hb=9b2612f68615d1b3f80fce732e4a13f5e50ee87d;hp=24eb8df024a3456060216eafd4f559735d397811;hpb=f1dc45c7f2f1148008f8d01c2577bcfcd25cbe66;p=ardour.git diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 24eb8df024..08b8fb9c18 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -29,6 +29,7 @@ #include #include "pbd/control_math.h" +#include "pbd/controllable.h" #include #include #include @@ -45,6 +46,8 @@ #include "ardour/dB.h" #include "ardour/filesystem_paths.h" #include "ardour/panner.h" +#include "ardour/panner_shell.h" +#include "ardour/pannable.h" #include "ardour/plugin.h" #include "ardour/plugin_insert.h" #include "ardour/presentation_info.h" @@ -99,7 +102,7 @@ OSC::OSC (Session& s, uint32_t port) , address_only (true) , remote_port ("8000") , default_banksize (0) - , default_strip (159) + , default_strip (31) , default_feedback (0) , default_gainmode (0) , default_send_size (0) @@ -583,6 +586,10 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, X_("/select/db_delta"), "f", sel_dB_delta); REGISTER_CALLBACK (serv, X_("/select/trimdB"), "f", sel_trim); REGISTER_CALLBACK (serv, X_("/select/hide"), "i", sel_hide); + REGISTER_CALLBACK (serv, X_("/select/previous"), "f", sel_previous); + REGISTER_CALLBACK (serv, X_("/select/previous"), "", sel_previous); + REGISTER_CALLBACK (serv, X_("/select/next"), "f", sel_next); + REGISTER_CALLBACK (serv, X_("/select/next"), "", sel_next); REGISTER_CALLBACK (serv, X_("/select/pan_stereo_position"), "f", sel_pan_position); REGISTER_CALLBACK (serv, X_("/select/pan_stereo_width"), "f", sel_pan_width); REGISTER_CALLBACK (serv, X_("/select/send_gain"), "if", sel_sendgain); @@ -613,6 +620,7 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, X_("/select/eq_freq"), "if", sel_eq_freq); REGISTER_CALLBACK (serv, X_("/select/eq_q"), "if", sel_eq_q); REGISTER_CALLBACK (serv, X_("/select/eq_shape"), "if", sel_eq_shape); + REGISTER_CALLBACK (serv, X_("/select/add_personal_send"), "s", sel_new_personal_send); /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */ REGISTER_CALLBACK (serv, X_("/strip/mute"), "ii", route_mute); @@ -629,6 +637,7 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, X_("/strip/polarity"), "ii", strip_phase); REGISTER_CALLBACK (serv, X_("/strip/gain"), "if", route_set_gain_dB); REGISTER_CALLBACK (serv, X_("/strip/fader"), "if", route_set_gain_fader); + REGISTER_CALLBACK (serv, X_("/strip/db_delta"), "if", strip_db_delta); REGISTER_CALLBACK (serv, X_("/strip/trimdB"), "if", route_set_trim_dB); REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_position"), "if", route_set_pan_stereo_position); REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_width"), "if", route_set_pan_stereo_width); @@ -814,7 +823,9 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ set = &(link_sets[ls]); sur->custom_mode = set->custom_mode; sur->custom_strips = set->custom_strips; + sur->temp_mode = set->temp_mode; sur->temp_strips = set->temp_strips; + sur->temp_master = set->temp_master; } if (strstr (path, X_("/automation"))) { @@ -824,6 +835,10 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ if (strstr (path, X_("/touch"))) { ret = touch_detect (path, types, argv, argc, msg); + } else + if (strstr (path, X_("/spill"))) { + ret = spill (path, types, argv, argc, msg); + } else if (len >= 17 && !strcmp (&path[len-15], X_("/#current_value"))) { current_value_query (path, len, argv, argc, msg); @@ -853,7 +868,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ if (strcmp (path, X_("/strip/listen")) == 0) { if (argc <= 0) { PBD::warning << "OSC: Wrong number of parameters." << endmsg; - } else if (sur->custom_mode) { + } else if (sur->custom_mode && !sur->temp_mode) { PBD::warning << "OSC: Can't add strips with custom enabled." << endmsg; } else { for (int n = 0; n < argc; ++n) { @@ -876,7 +891,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_ if (strcmp (path, X_("/strip/ignore")) == 0) { if (argc <= 0) { PBD::warning << "OSC: Wrong number of parameters." << endmsg; - } else if (!sur->custom_mode) { + } else if (!sur->custom_mode || sur->temp_mode) { PBD::warning << "OSC: Can't remove strips without custom enabled." << endmsg; } else { for (int n = 0; n < argc; ++n) { @@ -1315,6 +1330,7 @@ OSC::get_surfaces () PBD::info << string_compose ("\n Surface: %1 - URL: %2 %3\n", it, sur->remote_url, port); PBD::info << string_compose (" Number of strips: %1 Bank size: %2 Current Bank %3\n", sur->nstrips, sur->bank_size, sur->bank); PBD::info << string_compose (" Use Custom: %1 Custom Strips: %2\n", sur->custom_mode, sur->custom_strips.size ()); + PBD::info << string_compose (" Temp Mode: %1 Temp Strips: %2\n", sur->temp_mode, sur->temp_strips.size ()); bool ug = false; if (sur->usegroup == PBD::Controllable::UseGroup) { ug = true; @@ -1343,6 +1359,7 @@ OSC::get_surfaces () PBD::info << string_compose (" Bank size: %1 Current bank: %2 Strip Types: %3\n", set->banksize, set->bank, set->strip_types.to_ulong()); PBD::info << string_compose (" Auto bank sizing: %1 Linkset not ready flag: %2\n", set->autobank, set->not_ready); PBD::info << string_compose (" Use Custom: %1 Number of Custom Strips: %2\n", set->custom_mode, set->custom_strips.size ()); + PBD::info << string_compose (" Temp Mode: %1 Number of Temp Strips: %2\n", set->temp_mode, set->temp_strips.size ()); } PBD::info << endmsg; } @@ -1371,11 +1388,17 @@ OSC::custom_clear (lo_message msg) int OSC::custom_mode (float state, lo_message msg) +{ + return _custom_mode ((uint32_t) state, get_address (msg)); +} + +int +OSC::_custom_mode (uint32_t state, lo_address addr) { if (!session) { return 0; } - OSCSurface *sur = get_surface(get_address (msg), true); + OSCSurface *sur = get_surface(addr, true); LinkSet *set; uint32_t ls = sur->linkset; @@ -1384,6 +1407,7 @@ OSC::custom_mode (float state, lo_message msg) sur->custom_mode = set->custom_mode; sur->custom_strips = set->custom_strips; } + sur->temp_mode = TempOff; if (state > 0){ if (sur->custom_strips.size () == 0) { PBD::warning << "No custom strips set to enable" << endmsg; @@ -1394,9 +1418,9 @@ OSC::custom_mode (float state, lo_message msg) return -1; } else { if (sur->bank_size) { - sur->custom_mode = (uint32_t) state | 0x4; + sur->custom_mode = state | 0x4; } else { - sur->custom_mode = (uint32_t) state; + sur->custom_mode = state; } sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips); sur->nstrips = sur->custom_strips.size(); @@ -1409,8 +1433,9 @@ OSC::custom_mode (float state, lo_message msg) if (ls) { set->custom_mode = sur->custom_mode; set->strips = sur->strips; + set->temp_mode = sur->temp_mode; } - return set_bank (1, msg); + return _set_bank (1, addr); } int @@ -1572,6 +1597,7 @@ OSC::get_linkset (uint32_t set, lo_address addr) new_ls.strips = sur->strips; new_ls.custom_strips = sur->custom_strips; new_ls.custom_mode = sur->custom_mode; + new_ls.temp_mode = sur->temp_mode; new_ls.urls.resize (2); link_sets[set] = new_ls; } @@ -1631,6 +1657,7 @@ OSC::link_strip_types (uint32_t linkset, uint32_t striptypes) } ls = &link_sets[linkset]; ls->strip_types = striptypes; + ls->temp_mode = TempOff; for (uint32_t dv = 1; dv < ls->urls.size(); dv++) { OSCSurface *su; @@ -1818,6 +1845,7 @@ OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc } else { feedback = argv[2]->i; } + // [[fallthrough]]; old compiler doesn't like case 2: if (types[1] == 'f') { strip_types = (int) argv[1]->f; @@ -1960,9 +1988,6 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui } OSCSurface *s = get_surface(get_address (msg), true); s->bank_size = b_size; - if (s->custom_mode && b_size) { - s->custom_mode = s->custom_mode | 0x4; - } s->strip_types = strips; s->feedback = fb; s->gainmode = gm; @@ -1973,6 +1998,9 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui } s->send_page_size = se_size; s->plug_page_size = pi_size; + if (s->temp_mode) { + s->temp_mode = TempOff; + } if (s->linkset) { set_link (s->linkset, s->linkid, get_address (msg)); link_strip_types (s->linkset, s->strip_types.to_ulong()); @@ -1980,6 +2008,7 @@ OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, ui // set bank and strip feedback strip_feedback(s, true); _set_bank (1, get_address (msg)); + _strip_select (boost::shared_ptr (), get_address (msg)); } global_feedback (s); @@ -2016,6 +2045,7 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg) } OSCSurface *s = get_surface(get_address (msg), true); s->strip_types = st; + s->temp_mode = TempOff; if (s->strip_types[10]) { s->usegroup = PBD::Controllable::UseGroup; } else { @@ -2024,9 +2054,10 @@ OSC::set_surface_strip_types (uint32_t st, lo_message msg) if (s->linkset) { link_strip_types (s->linkset, st); } - // set bank and strip feedback - _set_bank (1, get_address (msg)); + strip_feedback(s, false); + set_bank (1, msg); + _strip_select (boost::shared_ptr (), get_address (msg)); return 0; } @@ -2108,7 +2139,9 @@ OSC::set_surface_port (uint32_t po, lo_message msg) it++; } } - refresh_surface (msg); + if (sur->feedback.to_ulong()) { + refresh_surface (msg); + } return 0; } } @@ -2158,9 +2191,11 @@ OSC::get_surface (lo_address addr , bool quiet) s.usegroup = PBD::Controllable::NoGroup; s.custom_strips.clear (); s.custom_mode = 0; + s.temp_mode = TempOff; s.sel_obs = 0; s.expand = 0; s.expand_enable = false; + s.expand_strip = boost::shared_ptr (); s.cue = false; s.aux = 0; s.cue_obs = 0; @@ -2192,7 +2227,9 @@ void OSC::global_feedback (OSCSurface* sur) { OSCGlobalObserver* o = sur->global_obs; - delete o; + if (o) { + delete o; + } if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) { // create a new Global Observer for this surface @@ -2215,9 +2252,11 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) } sur->custom_mode = set->custom_mode; sur->custom_strips = set->custom_strips; + sur->temp_mode = set->temp_mode; sur->temp_strips = set->temp_strips; + sur->temp_master = set->temp_master; } - if (sur->custom_mode < 7) { + if (!sur->temp_mode) { sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips); } else { sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips); @@ -2246,6 +2285,14 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) for (uint32_t i = 0; i < bank_size; i++) { OSCRouteObserver* o = new OSCRouteObserver (*this, i + 1, sur); sur->observers.push_back (o); + if (sur->temp_mode == BusOnly) { + boost::shared_ptr str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str())); + boost::shared_ptr send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str())); + if (send) { + o->refresh_send (send, true); + } + } + } } } else { @@ -2253,6 +2300,12 @@ OSC::strip_feedback (OSCSurface* sur, bool new_bank_size) for (uint32_t i = 0; i < sur->observers.size(); i++) { boost::shared_ptr str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str())); sur->observers[i]->refresh_strip(str, true); + if (sur->temp_mode == BusOnly) { + boost::shared_ptr send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str())); + if (send) { + sur->observers[i]->refresh_send (send, true); + } + } } } } @@ -2537,12 +2590,7 @@ int OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) { OSCSurface *sur = get_surface(get_address (msg)); - boost::shared_ptr s; - if (sur->expand_enable) { - s = get_strip (sur->expand, get_address (msg)); - } else { - s = _select; - } + boost::shared_ptr s = sur->select; int ret = 1; /* unhandled */ if (s) { if (!strncmp (path, X_("/select/group"), 13)) { @@ -2560,7 +2608,6 @@ OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int ar RouteGroup *rg = rt->route_group(); if (!rg) { PBD::warning << "OSC: This strip is not part of a group." << endmsg; - return ret; } float value = 0; if (argc == 1) { @@ -2571,61 +2618,103 @@ OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int ar } } if (!strncmp (path, X_("/select/group/enable"), 20)) { - if (argc == 1) { - rg->set_active (value, this); - ret = 0; + if (rg) { + if (argc == 1) { + rg->set_active (value, this); + ret = 0; + } + } else { + int_message (X_("/select/group/enable"), 0, get_address (msg)); } } - else if (!strncmp (path, X_("/select/group/only"), 18)) { - if ((argc == 1 && value) || !argc) { - // fill sur->strips with routes from this group and hit bank1 - sur->temp_strips.clear(); - boost::shared_ptr rl = rg->route_list(); - for (RouteList::iterator it = rl->begin(); it != rl->end(); ++it) { - boost::shared_ptr r = *it; - boost::shared_ptr s = boost::dynamic_pointer_cast (r); - sur->temp_strips.push_back(s); + else if (strcmp (path, X_("/select/group/gain")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_gain ((bool) value); + ret = 0; } - sur->custom_mode = 7; - set_bank (1, msg); - ret = 0; } else { - // key off is ignored - ret = 0; + int_message (X_("/select/group/gain"), 0, get_address (msg)); } } - else if (!strncmp (path, X_("/select/group/sharing"), 21)) { - if (argc == 9) { - if (rg->is_gain() != (bool) argv[0]->i) { - rg->set_gain ((bool) argv[0]->i); - } - if (rg->is_relative() != (bool) argv[1]->i) { - rg->set_relative ((bool) argv[1]->i, this); + else if (strcmp (path, X_("/select/group/relative")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_relative ((bool) value, this); + ret = 0; } - if (rg->is_mute() != (bool) argv[2]->i) { - rg->set_mute ((bool) argv[2]->i); + } else { + int_message (X_("/select/group/relative"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/mute")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_mute ((bool) value); + ret = 0; } - if (rg->is_solo() != (bool) argv[3]->i) { - rg->set_solo ((bool) argv[3]->i); + } else { + int_message (X_("/select/group/mute"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/solo")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_solo ((bool) value); + ret = 0; } - if (rg->is_recenable() != (bool) argv[4]->i) { - rg->set_recenable ((bool) argv[4]->i); + } else { + int_message (X_("/select/group/solo"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/recenable")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_recenable ((bool) value); + ret = 0; } - if (rg->is_select() != (bool) argv[5]->i) { - rg->set_select ((bool) argv[5]->i); + } else { + int_message (X_("/select/group/recenable"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/select")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_select ((bool) value); + ret = 0; } - if (rg->is_route_active() != (bool) argv[6]->i) { - rg->set_route_active ((bool) argv[6]->i); + } else { + int_message (X_("/select/group/select"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/active")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_route_active ((bool) value); + ret = 0; } - if (rg->is_color() != (bool) argv[7]->i) { - rg->set_color ((bool) argv[7]->i); + } else { + int_message (X_("/select/group/active"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/color")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_color ((bool) value); + ret = 0; } - if (rg->is_monitoring() != (bool) argv[8]->i) { - rg->set_monitoring ((bool) argv[8]->i); + } else { + int_message (X_("/select/group/color"), 0, get_address (msg)); + } + } + else if (strcmp (path, X_("/select/group/monitoring")) == 0) { + if (rg) { + if (argc == 1) { + rg->set_monitoring ((bool) value); + ret = 0; } - ret = 0; } else { - PBD::warning << "OSC: Sharing can only be set if all 9 parameters are sent." << endmsg; + int_message (X_("/select/group/monitoring"), 0, get_address (msg)); } } } @@ -2638,13 +2727,10 @@ OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc { OSCSurface *sur = get_surface(get_address (msg)); boost::shared_ptr s; - if (sur->expand_enable) { - s = get_strip (sur->expand, get_address (msg)); - } else { - s = _select; - } + s = sur->select; int ret = 1; /* unhandled */ if (s) { + boost::shared_ptr slv = boost::dynamic_pointer_cast (s); string svalue = ""; uint32_t ivalue = 1024; if (strcmp (path, X_("/select/vca")) == 0) { @@ -2660,7 +2746,6 @@ OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc } boost::shared_ptr vca = get_vca_by_name (svalue); if (vca) { - boost::shared_ptr slv = boost::dynamic_pointer_cast (s); if (ivalue) { slv->assign (vca); } else { @@ -2673,39 +2758,25 @@ OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc PBD::warning << "OSC: setting a vca needs both the vca name and it's state" << endmsg; } } - else if (!strncmp (path, X_("/select/vca/only"), 16)) { + else if (!strncmp (path, X_("/select/vca/toggle"), 18)) { if (argc == 1) { - if (types[0] == 'f') { - ivalue = (uint32_t) argv[0]->f; - } else if (types[0] == 'i') { - ivalue = (uint32_t) argv[0]->i; - } - } - // first check that we are a vca - boost::shared_ptr vca = boost::dynamic_pointer_cast (s); - if (vca) { - if ((argc == 1 && ivalue) || !argc) { - // fill sur->strips with routes from this group and hit bank1 - sur->temp_strips.clear(); - StripableList stripables; - session->get_stripables (stripables); - for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { - boost::shared_ptr st = *it; - if (st->slaved_to (vca)) { - sur->temp_strips.push_back(st); - } + if (types[0] == 's') { + svalue = &argv[0]->s; + string v_name = svalue.substr (0, svalue.rfind (" [")); + boost::shared_ptr vca = get_vca_by_name (v_name); + if (s->slaved_to (vca)) { + slv->unassign (vca); + } else { + slv->assign (vca); } - sur->temp_strips.push_back(s); - sur->custom_mode = 7; - set_bank (1, msg); ret = 0; } else { - // key off is ignored - ret = 0; + PBD::warning << "OSC: toggling needs the vca name as a string" << endmsg; } } else { - PBD::warning << "OSC: Select is not a VCA right now" << endmsg; + PBD::warning << "OSC: toggling a vca needs the vca name" << endmsg; } + } } return ret; @@ -2718,8 +2789,6 @@ OSC::get_vca_by_name (std::string vname) session->get_stripables (stripables); for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { boost::shared_ptr s = *it; - - // we only want VCAs boost::shared_ptr v = boost::dynamic_pointer_cast (s); if (v) { if (vname == v->name()) { @@ -2730,6 +2799,120 @@ OSC::get_vca_by_name (std::string vname) return boost::shared_ptr(); } +int +OSC::set_temp_mode (lo_address addr) +{ + bool ret = 1; + OSCSurface *sur = get_surface(addr); + boost::shared_ptr s = sur->temp_master; + if (s) { + if (sur->temp_mode == GroupOnly) { + boost::shared_ptr rt = boost::dynamic_pointer_cast (s); + if (rt) { + RouteGroup *rg = rt->route_group(); + if (rg) { + sur->temp_strips.clear(); + boost::shared_ptr rl = rg->route_list(); + for (RouteList::iterator it = rl->begin(); it != rl->end(); ++it) { + boost::shared_ptr r = *it; + boost::shared_ptr st = boost::dynamic_pointer_cast (r); + sur->temp_strips.push_back(st); + } + // check if this group feeds a bus or is slaved + boost::shared_ptr mstr = boost::shared_ptr (); + if (rg->has_control_master()) { + boost::shared_ptr vca = session->vca_manager().vca_by_number (rg->group_master_number()); + if (vca) { + mstr = boost::dynamic_pointer_cast (vca); + } + } else if (rg->has_subgroup()) { + boost::shared_ptr sgr = rg->subgroup_bus().lock(); + if (sgr) { + mstr = boost::dynamic_pointer_cast (sgr); + } + } + if (mstr) { + sur->temp_strips.push_back(mstr); + } + sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips); + sur->nstrips = sur->temp_strips.size(); + ret = 0; + } + } + } else if (sur->temp_mode == VCAOnly) { + boost::shared_ptr vca = boost::dynamic_pointer_cast (s); + if (vca) { + sur->temp_strips.clear(); + StripableList stripables; + session->get_stripables (stripables); + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + boost::shared_ptr st = *it; + if (st->slaved_to (vca)) { + sur->temp_strips.push_back(st); + } + } + sur->temp_strips.push_back(s); + sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips); + sur->nstrips = sur->temp_strips.size(); + ret = 0; + } + } else if (sur->temp_mode == BusOnly) { + boost::shared_ptr rt = boost::dynamic_pointer_cast (s); + if (rt) { + if (!rt->is_track () && rt->can_solo ()) { + // this is a bus, but not master, monitor or audition + sur->temp_strips.clear(); + StripableList stripables; + session->get_stripables (stripables, PresentationInfo::AllStripables); + for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) { + boost::shared_ptr st = *it; + boost::shared_ptr ri = boost::dynamic_pointer_cast (st); + bool sends = true; + if (ri && ri->direct_feeds_according_to_graph (rt, &sends)) { + sur->temp_strips.push_back(st); + } + } + sur->temp_strips.push_back(s); + sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips); + sur->nstrips = sur->temp_strips.size(); + ret = 0; + } + } + } else if (sur->temp_mode == TempOff) { + sur->temp_mode = TempOff; + ret = 0; + } + } + LinkSet *set; + uint32_t ls = sur->linkset; + if (ls) { + set = &(link_sets[ls]); + set->temp_mode = sur->temp_mode; + set->temp_strips.clear (); + set->temp_strips = sur->temp_strips; + set->temp_master = sur->temp_master; + set->strips = sur->strips; + } + if (ret) { + sur->temp_mode = TempOff; + } + return ret; +} + +boost::shared_ptr +OSC::get_send (boost::shared_ptr st, lo_address addr) +{ + OSCSurface *sur = get_surface(addr); + boost::shared_ptr s = sur->temp_master; + if (st && s && (st != s)) { + boost::shared_ptr rt = boost::dynamic_pointer_cast (s); + boost::shared_ptr rst = boost::dynamic_pointer_cast (st); + //find what send number feeds s + return rst->internal_send_for (rt); + } + return boost::shared_ptr (); +} + int OSC::name_session (char *n, lo_message msg) { @@ -2782,7 +2965,7 @@ OSC::get_sid (boost::shared_ptr strip, lo_address addr) } } } - // failsafe... should never get here. + // strip not in current bank return 0; } @@ -2933,7 +3116,7 @@ OSC::_sel_plugin (int id, lo_address addr) boost::shared_ptr proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]); boost::shared_ptr pi; if (!(pi = boost::dynamic_pointer_cast(proc))) { - PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg; + PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg; return 1; } boost::shared_ptr pip = pi->plugin(); @@ -3587,6 +3770,7 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg uint32_t ctr = 0; uint32_t aut = 0; uint32_t ssid; + boost::shared_ptr send = boost::shared_ptr (); if (argc) { if (types[argc - 1] == 'f') { @@ -3610,13 +3794,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg ssid = atoi (&(strrchr (path, '/' ))[1]); strp = get_strip (ssid, get_address (msg)); } + send = get_send (strp, get_address (msg)); ctr = 7; } else if (!strncmp (path, X_("/select/"), 8)) { - if (sur->expand_enable && sur->expand) { - strp = get_strip (sur->expand, get_address (msg)); - } else { - strp = _select; - } + strp = sur->select; ctr = 8; } else { return ret; @@ -3630,6 +3811,9 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg } else { PBD::warning << "No fader for this strip" << endmsg; } + if (send) { + control = send->gain_control (); + } } else { PBD::warning << "Automation not available for " << path << endmsg; } @@ -3653,6 +3837,10 @@ OSC::set_automation (const char *path, const char* types, lo_arg **argv, int arg control->set_automation_state (ARDOUR::Touch); ret = 0; break; + case 4: + control->set_automation_state (ARDOUR::Latch); + ret = 0; + break; default: break; } @@ -3670,6 +3858,7 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, int ret = 1; OSCSurface *sur = get_surface(get_address (msg)); boost::shared_ptr strp = boost::shared_ptr(); + boost::shared_ptr send = boost::shared_ptr (); uint32_t ctr = 0; uint32_t touch = 0; uint32_t ssid; @@ -3696,13 +3885,10 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, ssid = atoi (&(strrchr (path, '/' ))[1]); strp = get_strip (ssid, get_address (msg)); } + send = get_send (strp, get_address (msg)); ctr = 7; } else if (!strncmp (path, X_("/select/"), 8)) { - if (sur->expand_enable && sur->expand) { - strp = get_strip (sur->expand, get_address (msg)); - } else { - strp = _select; - } + strp = sur->select; ctr = 8; } else { return ret; @@ -3716,6 +3902,9 @@ OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, } else { PBD::warning << "No fader for this strip" << endmsg; } + if (send) { + control = send->gain_control (); + } } else { PBD::warning << "Automation not available for " << path << endmsg; } @@ -3755,6 +3944,104 @@ OSC::fake_touch (boost::shared_ptr ctrl) return 0; } +int +OSC::spill (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) +{ + /* + * spill should have the form of: + * /select/spill (may have i or f keypress/release) + * /strip/spill i (may have keypress and i may be inline) + */ + if (!session || argc > 1) return -1; + + int ret = 1; + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr strp = boost::shared_ptr(); + uint32_t value = 0; + OSCTempMode new_mode = TempOff; + + if (argc) { + if (types[0] == 'f') { + value = (int)argv[0]->f; + } else { + value = argv[0]->i; + } + if (!value) { + // key release ignore + return 0; + } + } + + //parse path first to find stripable + if (!strncmp (path, X_("/strip/"), 7)) { + /* + * we don't know if value is press or ssid + * so we have to check if the last / has an int after it first + * if not then we use value + */ + uint32_t ssid = 0; + ssid = atoi (&(strrchr (path, '/' ))[1]); + if (!ssid) { + ssid = value; + } + strp = get_strip (ssid, get_address (msg)); + } else if (!strncmp (path, X_("/select/"), 8)) { + strp = sur->select; + } else { + return ret; + } + if (strp) { + boost::shared_ptr rt = boost::dynamic_pointer_cast (strp); + boost::shared_ptr v = boost::dynamic_pointer_cast (strp); + if (strstr (path, X_("/vca")) || v) { + //strp must be a VCA + if (v) { + new_mode = VCAOnly; + } else { + return ret; + } + } else + if (strstr (path, X_("/group"))) { + //strp must be in a group + if (rt) { + RouteGroup *rg = rt->route_group(); + if (rg) { + new_mode = GroupOnly; + } else { + return ret; + } + } + } else + if (strstr (path, X_("/bus"))) { + //strp must be a bus with either sends or no inputs + if (rt) { + if (!rt->is_track () && rt->can_solo ()) { + new_mode = BusOnly; + } + } + } else { + // decide by auto + // vca should never get here + if (rt->is_track ()) { + if (rt->route_group()) { + new_mode = GroupOnly; + } + } else if (!rt->is_track () && rt->can_solo ()) { + new_mode = BusOnly; + } + } + if (new_mode) { + sur->temp_mode = new_mode; + sur->temp_master = strp; + set_temp_mode (get_address (msg)); + set_bank (1, msg); + return 0; + } + + } + return ret; +} + int OSC::route_mute (int ssid, int yn, lo_message msg) { @@ -3763,6 +4050,9 @@ OSC::route_mute (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/mute"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->mute_control()) { s->mute_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup); return 0; @@ -3777,11 +4067,7 @@ OSC::sel_mute (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; - } + s = sur->select; if (s) { if (s->mute_control()) { s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -3799,6 +4085,9 @@ OSC::route_solo (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/solo"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->solo_control()) { s->solo_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup); } @@ -3815,6 +4104,9 @@ OSC::route_solo_iso (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/solo_iso"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->solo_isolate_control()) { s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup); return 0; @@ -3832,6 +4124,9 @@ OSC::route_solo_safe (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/solo_safe"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->solo_safe_control()) { s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup); return 0; @@ -3846,11 +4141,7 @@ OSC::sel_solo (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; - } + s = sur->select; if (s) { if (s->solo_control()) { session->set_control (s->solo_control(), yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -3864,11 +4155,7 @@ 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; - } + s = sur->select; if (s) { if (s->solo_isolate_control()) { s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -3883,11 +4170,7 @@ 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; - } + s = sur->select; if (s) { if (s->solo_safe_control()) { s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -3902,11 +4185,7 @@ OSC::sel_recenable (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; - } + s = sur->select; if (s) { if (s->rec_enable_control()) { s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -3926,6 +4205,9 @@ OSC::route_recenable (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/recenable"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->rec_enable_control()) { s->rec_enable_control()->set_value (yn, sur->usegroup); if (s->rec_enable_control()->get_value()) { @@ -3941,10 +4223,14 @@ OSC::route_rename (int ssid, char *newname, lo_message msg) { if (!session) { return -1; } - + OSCSurface *sur = get_surface(get_address (msg)); boost::shared_ptr s = get_strip(ssid, get_address(msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + text_message_with_id (X_("/strip/name"), ssid, string_compose ("%1-Send", s->name()), sur->feedback[2], get_address(msg)); + return 1; + } s->set_name(std::string(newname)); } @@ -3959,11 +4245,7 @@ OSC::sel_rename (char *newname, 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; - } + s = sur->select; if (s) { s->set_name(std::string(newname)); } @@ -3979,11 +4261,7 @@ OSC::sel_comment (char *newcomment, 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; - } + s = sur->select; if (s) { boost::shared_ptr rt = boost::dynamic_pointer_cast (s); if (!rt) { @@ -3996,6 +4274,67 @@ OSC::sel_comment (char *newcomment, lo_message msg) { return 0; } +int +OSC::sel_new_personal_send (char *foldback, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s; + s = sur->select; + boost::shared_ptr rt = boost::shared_ptr (); + if (s) { + rt = boost::dynamic_pointer_cast (s); + if (!rt) { + PBD::warning << "OSC: can not send from VCAs." << endmsg; + return -1; + } + } + /* if a foldbackbus called foldback exists use it + * other wise create create it. Then create a foldback send from + * this route to that bus. + */ + string foldbackbus = foldback; + string foldback_name = foldbackbus; + if (foldbackbus.find ("- monitor") == string::npos) { + foldback_name = string_compose ("%1 - monitor", foldbackbus); + } + boost::shared_ptr lsn_rt = session->route_by_name (foldback_name); + if (!lsn_rt) { + // doesn't exist but check if raw name does and is foldbackbus + boost::shared_ptr raw_rt = session->route_by_name (foldbackbus); + if (raw_rt && raw_rt->is_foldbackbus()) { + lsn_rt = raw_rt; + } else { + // create the foldbackbus + RouteList list = session->new_audio_route (2, 2, 0, 1, foldback_name, PresentationInfo::FoldbackBus, (uint32_t) -1); + lsn_rt = *(list.begin()); + lsn_rt->presentation_info().set_hidden (true); + session->set_dirty(); + } + } + if (lsn_rt) { + //boost::shared_ptr rt_send = ; + if (rt && (lsn_rt != rt)) { + // make sure there isn't one already + bool s_only = true; + if (!rt->feeds (lsn_rt, &s_only)) { + // create send + rt->add_foldback_send (lsn_rt); + //boost::shared_ptr snd = rt->internal_send_for (aux); + session->dirty (); + return 0; + } else { + PBD::warning << "OSC: new_send - duplicate send, ignored." << endmsg; + } + } else { + PBD::warning << "OSC: new_send - can't send to self." << endmsg; + } + } else { + PBD::warning << "OSC: new_send - no FoldbackBus to send to." << endmsg; + } + + return -1; +} + int OSC::strip_group (int ssid, char *group, lo_message msg) { if (!session) { @@ -4012,11 +4351,7 @@ OSC::sel_group (char *group, 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; - } + s = sur->select; return strip_select_group (s, group); } @@ -4080,11 +4415,7 @@ OSC::sel_recsafe (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; - } + s = sur->select; if (s) { if (s->rec_safe_control()) { s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -4103,6 +4434,9 @@ OSC::route_recsafe (int ssid, int yn, lo_message msg) boost::shared_ptr s = get_strip (ssid, get_address (msg)); OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/record_safe"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->rec_safe_control()) { s->rec_safe_control()->set_value (yn, sur->usegroup); if (s->rec_safe_control()->get_value()) { @@ -4121,6 +4455,9 @@ OSC::route_monitor_input (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/monitor_input"), ssid, 0, sur->feedback[2], get_address (msg)); + } boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { if (track->monitoring_control()) { @@ -4140,11 +4477,7 @@ OSC::sel_monitor_input (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; - } + s = sur->select; if (s) { boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { @@ -4167,6 +4500,9 @@ OSC::route_monitor_disk (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/monitor_disk"), ssid, 0, sur->feedback[2], get_address (msg)); + } boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { if (track->monitoring_control()) { @@ -4186,11 +4522,7 @@ OSC::sel_monitor_disk (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; - } + s = sur->select; if (s) { boost::shared_ptr track = boost::dynamic_pointer_cast (s); if (track) { @@ -4214,6 +4546,9 @@ OSC::strip_phase (int ssid, int yn, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/polarity"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->phase_control()) { s->phase_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup); return 0; @@ -4228,11 +4563,7 @@ OSC::sel_phase (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; - } + s = sur->select; if (s) { if (s->phase_control()) { s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup); @@ -4246,24 +4577,32 @@ int OSC::strip_expand (int ssid, int yn, lo_message msg) { OSCSurface *sur = get_surface(get_address (msg)); + boost::shared_ptr s = get_strip (ssid, get_address (msg)); + if (s) { + sur->expand_strip = s; + } sur->expand_enable = (bool) yn; sur->expand = ssid; - boost::shared_ptr s; + boost::shared_ptr sel; if (yn) { - s = get_strip (ssid, get_address (msg)); + sel = get_strip (ssid, get_address (msg)); } else { - s = _select; + sel = boost::shared_ptr (); } - return _strip_select (s, get_address (msg)); + return _strip_select (sel, get_address (msg)); } int OSC::strip_hide (int ssid, int state, lo_message msg) { boost::shared_ptr s = get_strip (ssid, get_address (msg)); + OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/hide"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (state != s->is_hidden ()) { s->presentation_info().set_hidden ((bool) state); } @@ -4278,8 +4617,23 @@ OSC::_strip_select (boost::shared_ptr s, lo_address addr) return -1; } OSCSurface *sur = get_surface(addr, true); + boost::weak_ptr o_sel = sur->select; + boost::shared_ptr old_sel= o_sel.lock (); + boost::weak_ptr o_expand = sur->expand_strip; + boost::shared_ptr old_expand= o_expand.lock (); + + // we got a null strip check that old strips are valid + if (!s) { + if (old_expand && sur->expand_enable) { + sur->expand = get_sid (old_expand, addr); + if (sur->strip_types[11] || sur->expand) { + s = old_expand; + } else { + sur->expand_strip = boost::shared_ptr (); + } + } + } if (!s) { - // expand doesn't point to a stripable, turn it off and use select sur->expand = 0; sur->expand_enable = false; if (ControlProtocol::first_selected_stripable()) { @@ -4287,9 +4641,11 @@ OSC::_strip_select (boost::shared_ptr s, lo_address addr) } else { s = session->master_out (); } - _select = s; + _select = s; + } + if (s != old_sel) { + sur->select = s; } - sur->select = s; bool sends; uint32_t nsends = 0; do { @@ -4312,8 +4668,16 @@ OSC::_strip_select (boost::shared_ptr s, lo_address addr) sur->sel_obs = sel_fb; } sur->sel_obs->set_expand (sur->expand_enable); + } else { + if (so != 0) { + delete so; + sur->sel_obs = 0; + } + } + if (sur->feedback[0] || sur->feedback[1]) { uint32_t obs_expand = 0; if (sur->expand_enable) { + sur->expand = get_sid (s, addr); obs_expand = sur->expand; } else { obs_expand = 0; @@ -4321,11 +4685,6 @@ OSC::_strip_select (boost::shared_ptr s, lo_address addr) for (uint32_t i = 0; i < sur->observers.size(); i++) { sur->observers[i]->set_expand (obs_expand); } - } else { - if (so != 0) { - delete so; - sur->sel_obs = 0; - } } // need to set monitor for processor changed signal (for paging) string address = lo_address_get_url (addr); @@ -4360,9 +4719,9 @@ OSC::strip_gui_select (int ssid, int yn, lo_message msg) return -1; } OSCSurface *sur = get_surface(get_address (msg)); - sur->expand_enable = false; boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { + sur->expand_enable = false; SetStripableSelection (s); } else { if ((int) (sur->feedback.to_ulong())) { @@ -4378,17 +4737,86 @@ OSC::sel_expand (uint32_t state, lo_message msg) { OSCSurface *sur = get_surface(get_address (msg)); boost::shared_ptr s; - if (state && sur->expand) { + if (!sur->expand_strip) { + state = 0; + float_message (X_("/select/expand"), 0.0, get_address (msg)); + } + if (state) { sur->expand_enable = (bool) state; - s = get_strip (sur->expand, get_address (msg)); + s = boost::shared_ptr (); } else { sur->expand_enable = false; - s = _select; + s = boost::shared_ptr (); } return _strip_select (s, get_address (msg)); } +int +OSC::sel_previous (lo_message msg) +{ + return sel_delta (-1, msg); +} + +int +OSC::sel_next (lo_message msg) +{ + return sel_delta (1, msg); +} + +int +OSC::sel_delta (int delta, lo_message msg) +{ + if (!delta) { + return 0; + } + OSCSurface *sur = get_surface(get_address (msg)); + Sorted sel_strips; + sel_strips = sur->strips; + // the current selected strip _should_ be in sel_strips + uint32_t nstps = sel_strips.size (); + if (!nstps) { + return -1; + } + boost::shared_ptr new_sel = boost::shared_ptr (); + boost::weak_ptr o_sel = sur->select; + boost::shared_ptr old_sel= o_sel.lock (); + for (uint32_t i = 0; i < nstps; i++) { + if (old_sel == sel_strips[i]) { + if (i && delta < 0) { + // i is > 0 and delta is -1 + new_sel = sel_strips[i - 1]; + } else if ((i + 1) < nstps && delta > 0) { + // i is at least 1 less than greatest and delta = 1 + new_sel = sel_strips[i + 1]; + } else if ((i + 1) >= nstps && delta > 0) { + // i is greatest strip and delta 1 + new_sel = sel_strips[0]; + } else if (!i && delta < 0) { + // i = 0 and delta -1 + new_sel = sel_strips[nstps - 1]; + } else { + // should not happen + return -1; + } + } + } + if (!new_sel) { + // our selected strip has vanished use the first one + new_sel = sel_strips[0]; + } + if (new_sel) { + if (!sur->expand_enable) { + SetStripableSelection (new_sel); + } else { + sur->expand_strip = new_sel; + _strip_select (new_sel, get_address (msg)); + } + return 0; + } + return -1; +} + int OSC::route_set_gain_dB (int ssid, float dB, lo_message msg) { @@ -4398,19 +4826,25 @@ OSC::route_set_gain_dB (int ssid, float dB, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); boost::shared_ptr s = get_strip (ssid, get_address (msg)); if (s) { + boost::shared_ptr gain_control; + if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) { + gain_control = get_send(s, get_address (msg))->gain_control(); + } else { + gain_control = s->gain_control(); + } float abs; - if (s->gain_control()) { + if (gain_control) { if (dB < -192) { abs = 0; } else { abs = dB_to_coefficient (dB); - float top = s->gain_control()->upper(); + float top = gain_control->upper(); if (abs > top) { abs = top; } } - fake_touch (s->gain_control()); - s->gain_control()->set_value (abs, sur->usegroup); + fake_touch (gain_control); + gain_control->set_value (abs, sur->usegroup); return 0; } } @@ -4422,11 +4856,7 @@ OSC::sel_gain (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; - } + s = sur->select; if (s) { float abs; if (s->gain_control()) { @@ -4452,11 +4882,7 @@ OSC::sel_dB_delta (float delta, 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; - } + s = sur->select; if (s) { if (s->gain_control()) { float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta; @@ -4488,9 +4914,15 @@ OSC::route_set_gain_fader (int ssid, float pos, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { - if (s->gain_control()) { - fake_touch (s->gain_control()); - s->gain_control()->set_value (s->gain_control()->interface_to_internal (pos), sur->usegroup); + boost::shared_ptr gain_control; + if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) { + gain_control = get_send(s, get_address (msg))->gain_control(); + } else { + gain_control = s->gain_control(); + } + if (gain_control) { + fake_touch (gain_control); + gain_control->set_value (gain_control->interface_to_internal (pos), sur->usegroup); } else { return float_message_with_id (X_("/strip/fader"), ssid, 0, sur->feedback[2], get_address (msg)); } @@ -4507,18 +4939,24 @@ OSC::strip_db_delta (int ssid, float delta, lo_message msg) boost::shared_ptr s = get_strip (ssid, get_address (msg)); OSCSurface *sur = get_surface(get_address (msg)); if (s) { - float db = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta; + boost::shared_ptr gain_control; + if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) { + gain_control = get_send(s, get_address (msg))->gain_control(); + } else { + gain_control = s->gain_control(); + } + float db = accurate_coefficient_to_dB (gain_control->get_value()) + delta; float abs; if (db < -192) { abs = 0; } else { abs = dB_to_coefficient (db); - float top = s->gain_control()->upper(); + float top = gain_control->upper(); if (abs > top) { abs = top; } } - s->gain_control()->set_value (abs, sur->usegroup); + gain_control->set_value (abs, sur->usegroup); return 0; } return -1; @@ -4529,11 +4967,7 @@ OSC::sel_fader (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; - } + s = sur->select; if (s) { if (s->gain_control()) { fake_touch (s->gain_control()); @@ -4552,6 +4986,9 @@ OSC::route_set_trim_abs (int ssid, float level, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/trimdB"), ssid, 0, sur->feedback[2], get_address (msg)); + } if (s->trim_control()) { s->trim_control()->set_value (level, sur->usegroup); return 0; @@ -4580,11 +5017,7 @@ OSC::sel_trim (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; - } + s = sur->select; if (s) { if (s->trim_control()) { s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup); @@ -4599,11 +5032,7 @@ OSC::sel_hide (uint32_t state, 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; - } + s = sur->select; if (s) { if (state != s->is_hidden ()) { s->presentation_info().set_hidden ((bool) state); @@ -4617,11 +5046,7 @@ OSC::sel_pan_position (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; - } + s = sur->select; if (s) { if(s->pan_azimuth_control()) { s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -4636,11 +5061,7 @@ OSC::sel_pan_width (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; - } + s = sur->select; if (s) { if (s->pan_width_control()) { s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -4658,8 +5079,17 @@ OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { - if(s->pan_azimuth_control()) { - s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup); + boost::shared_ptr pan_control = boost::shared_ptr(); + if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) { + boost::shared_ptr send = get_send (s, get_address (msg)); + if (send->pan_outs() > 1) { + pan_control = send->panner_shell()->panner()->pannable()->pan_azimuth_control; + } + } else { + pan_control = s->pan_azimuth_control(); + } + if(pan_control) { + pan_control->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup); return 0; } } @@ -4675,6 +5105,9 @@ OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg) OSCSurface *sur = get_surface(get_address (msg)); if (s) { + if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) { + return float_message_with_id (X_("/strip/pan_stereo_width"), ssid, 1, sur->feedback[2], get_address (msg)); + } if (s->pan_width_control()) { s->pan_width_control()->set_value (pos, sur->usegroup); return 0; @@ -4746,11 +5179,7 @@ OSC::sel_sendgain (int id, float val, lo_message msg) return float_message_with_id (X_("/select/send_gain"), id, -193, sur->feedback[2], get_address (msg)); } boost::shared_ptr s; - if (sur->expand_enable) { - s = get_strip (sur->expand, get_address (msg)); - } else { - s = _select; - } + s = sur->select; float abs; int send_id = 0; if (s) { @@ -4785,11 +5214,7 @@ OSC::sel_sendfader (int id, float val, lo_message msg) return float_message_with_id (X_("/select/send_fader"), id, 0, sur->feedback[2], get_address (msg)); } boost::shared_ptr s; - if (sur->expand_enable) { - s = get_strip (sur->expand, get_address (msg)); - } else { - s = _select; - } + s = sur->select; float abs; int send_id = 0; if (s) { @@ -4861,11 +5286,7 @@ OSC::sel_sendenable (int id, float val, lo_message msg) return float_message_with_id (X_("/select/send_enable"), id, 0, sur->feedback[2], get_address (msg)); } boost::shared_ptr s; - if (sur->expand_enable) { - s = get_strip (sur->expand, get_address (msg)); - } else { - s = _select; - } + s = sur->select; int send_id = 0; if (s) { if (id > 0) { @@ -4903,11 +5324,7 @@ OSC::sel_master_send_enable (int state, 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; - } + s = sur->select; if (s) { if (s->master_send_enable_controllable ()) { s->master_send_enable_controllable()->set_value (state, PBD::Controllable::NoGroup); @@ -5443,11 +5860,7 @@ 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; - } + s = sur->select; if (s) { if (s->pan_elevation_control()) { s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5462,11 +5875,7 @@ 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; - } + s = sur->select; if (s) { if (s->pan_frontback_control()) { s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5481,11 +5890,7 @@ 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; - } + s = sur->select; if (s) { if (s->pan_lfe_control()) { s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5501,11 +5906,7 @@ 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; - } + s = sur->select; if (s) { if (s->comp_enable_controllable()) { s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5520,11 +5921,7 @@ 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; - } + s = sur->select; if (s) { if (s->comp_threshold_controllable()) { s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5539,11 +5936,7 @@ 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; - } + s = sur->select; if (s) { if (s->comp_speed_controllable()) { s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5558,11 +5951,7 @@ 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; - } + s = sur->select; if (s) { if (s->comp_mode_controllable()) { s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5577,11 +5966,7 @@ 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; - } + s = sur->select; if (s) { if (s->comp_makeup_controllable()) { s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5598,11 +5983,7 @@ 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; - } + s = sur->select; if (s) { if (s->eq_enable_controllable()) { s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5617,11 +5998,7 @@ OSC::sel_eq_hpf_freq (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; - } + s = sur->select; if (s) { if (s->filter_freq_controllable(true)) { s->filter_freq_controllable(true)->set_value (s->filter_freq_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5636,11 +6013,7 @@ OSC::sel_eq_lpf_freq (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; - } + s = sur->select; if (s) { if (s->filter_freq_controllable(false)) { s->filter_freq_controllable(false)->set_value (s->filter_freq_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5655,11 +6028,7 @@ OSC::sel_eq_hpf_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; - } + s = sur->select; if (s) { if (s->filter_enable_controllable(true)) { s->filter_enable_controllable(true)->set_value (s->filter_enable_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5674,11 +6043,7 @@ OSC::sel_eq_lpf_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; - } + s = sur->select; if (s) { if (s->filter_enable_controllable(false)) { s->filter_enable_controllable(false)->set_value (s->filter_enable_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5693,11 +6058,7 @@ OSC::sel_eq_hpf_slope (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; - } + s = sur->select; if (s) { if (s->filter_slope_controllable(true)) { s->filter_slope_controllable(true)->set_value (s->filter_slope_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5712,11 +6073,7 @@ OSC::sel_eq_lpf_slope (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; - } + s = sur->select; if (s) { if (s->filter_slope_controllable(false)) { s->filter_slope_controllable(false)->set_value (s->filter_slope_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup); @@ -5731,11 +6088,7 @@ 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; - } + s = sur->select; if (s) { if (id > 0) { --id; @@ -5753,11 +6106,7 @@ 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; - } + s = sur->select; if (s) { if (id > 0) { --id; @@ -5775,11 +6124,7 @@ 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; - } + s = sur->select; if (s) { if (id > 0) { --id; @@ -5797,11 +6142,7 @@ 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; - } + s = sur->select; if (s) { if (id > 0) { --id; @@ -5955,7 +6296,7 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sor StripableList custom_list; // fetch all stripables - session->get_stripables (stripables); + session->get_stripables (stripables, PresentationInfo::AllStripables); if (custom) { uint32_t nstps = my_list.size (); // check each custom strip to see if it still exists @@ -6008,31 +6349,23 @@ OSC::get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sor sorted.push_back (s); } else if (types[4] && boost::dynamic_pointer_cast(s)) { sorted.push_back (s); + } else if (s->is_foldbackbus()) { + if (types[7]) { + sorted.push_back (s); + } } else #ifdef MIXBUS if (types[2] && Profile->get_mixbus() && s->mixbus()) { sorted.push_back (s); } else - if (types[7] && boost::dynamic_pointer_cast(s) && !boost::dynamic_pointer_cast(s)) { - if (Profile->get_mixbus() && !s->mixbus()) { - sorted.push_back (s); - } - } else #endif - if ((types[2] || types[3] || types[7]) && boost::dynamic_pointer_cast(s) && !boost::dynamic_pointer_cast(s)) { + if (boost::dynamic_pointer_cast(s) && !boost::dynamic_pointer_cast(s)) { boost::shared_ptr r = boost::dynamic_pointer_cast(s); if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) { // note some older sessions will show midibuses as busses - if (r->direct_feeds_according_to_reality (session->master_out())) { - // this is a bus - if (types[2]) { - sorted.push_back (s); - } - } else { - // this is an Aux out - if (types[7]) { - sorted.push_back (s); - } + // this is a bus + if (types[2]) { + sorted.push_back (s); } } else if (types[3]) { sorted.push_back (s); @@ -6081,6 +6414,16 @@ OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo } } } + else if (!strncmp (path, X_("/cue/connect_aux"), 16)) { + // Create new Aux bus + string dest = ""; + if (argc == 1 && types[0] == 's') { + dest = &argv[0]->s; + ret = cue_connect_aux (dest, msg); + } else { + PBD::warning << "OSC: connect_aux has wrong number or type of parameters." << endmsg; + } + } else if (!strncmp (path, X_("/cue/connect"), 12)) { // Connect to default Aux bus if ((!argc) || argv[0]->f || argv[0]->i) { @@ -6089,6 +6432,38 @@ OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo ret = 0; } } + else if (!strncmp (path, X_("/cue/new_aux"), 12)) { + // Create new Aux bus + string name = ""; + string dest_1 = ""; + string dest_2 = ""; + if (argc == 3 && types[0] == 's' && types[1] == 's' && types[2] == 's') { + name = &argv[0]->s; + dest_1 = &argv[1]->s; + dest_2 = &argv[2]->s; + ret = cue_new_aux (name, dest_1, dest_2, msg); + } else if (argc == 2 && types[0] == 's' && types[1] == 's') { + name = &argv[0]->s; + dest_1 = &argv[1]->s; + dest_2 = dest_1; + ret = cue_new_aux (name, dest_1, dest_2, msg); + } else if (argc == 1 && types[0] == 's') { + name = &argv[0]->s; + ret = cue_new_aux (name, dest_1, dest_2, msg); + } else { + PBD::warning << "OSC: new_aux has wrong number or type of parameters." << endmsg; + } + } + else if (!strncmp (path, X_("/cue/new_send"), 13)) { + // Create new send to aux + string rt_name = ""; + if (argc == 1 && types[0] == 's') { + rt_name = &argv[0]->s; + ret = cue_new_send (rt_name, msg); + } else { + PBD::warning << "OSC: new_send has wrong number or type of parameters." << endmsg; + } + } else if (!strncmp (path, X_("/cue/next_aux"), 13)) { // switch to next Aux bus if ((!argc) || argv[0]->f || argv[0]->i) { @@ -6151,7 +6526,10 @@ OSC::_cue_set (uint32_t aux, lo_address addr) s->strips = get_sorted_stripables(s->strip_types, s->cue, false, s->custom_strips); s->nstrips = s->strips.size(); - + if (!s->nstrips) { + surface_destroy (s); + return 0; + } if (aux < 1) { aux = 1; } else if (aux > s->nstrips) { @@ -6185,6 +6563,95 @@ OSC::_cue_set (uint32_t aux, lo_address addr) return ret; } +int +OSC::cue_new_aux (string name, string dest_1, string dest_2, lo_message msg) +{ + // create a new bus named name - monitor + RouteList list; + boost::shared_ptr aux; + name = string_compose ("%1 - monitor", name); + list = session->new_audio_route (2, 2, 0, 1, name, PresentationInfo::FoldbackBus, (uint32_t) -1); + aux = *(list.begin()); + if (aux) { + boost::shared_ptr r = boost::dynamic_pointer_cast(aux); + if (dest_1.size()) { + if (atoi( dest_1.c_str())) { + dest_1 = string_compose ("system:playback_%1", dest_1); + } + if (atoi( dest_2.c_str())) { + dest_2 = string_compose ("system:playback_%1", dest_2); + } + PortSet& ports = r->output()->ports (); + PortSet::iterator i = ports.begin(); + ++i; + r->output ()->connect (*(ports.begin()), dest_1, this); + r->output ()->connect (*(i), dest_2, this); + } + cue_set ((uint32_t) -1, msg); + session->set_dirty(); + return 0; + } + return -1; +} + +int +OSC::cue_new_send (string rt_name, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg), true); + if (sur->cue) { + boost::shared_ptr aux = boost::dynamic_pointer_cast (get_strip (sur->aux, get_address(msg))); + if (aux) { + boost::shared_ptr rt_send = session->route_by_name (rt_name); + if (rt_send && (aux != rt_send)) { + // make sure there isn't one already + bool s_only = true; + if (!rt_send->feeds (aux, &s_only)) { + // create send + rt_send->add_foldback_send (aux); + boost::shared_ptr snd = rt_send->internal_send_for (aux); + session->dirty (); + return 0; + } else { + PBD::warning << "OSC: new_send - duplicate send, ignored." << endmsg; + } + } else { + PBD::warning << "OSC: new_send - route doesn't exist or is aux." << endmsg; + } + } else { + PBD::warning << "OSC: new_send - No Aux to send to." << endmsg; + } + } else { + PBD::warning << "OSC: new_send - monitoring not set, select aux first." << endmsg; + } + return 1; +} + +int +OSC::cue_connect_aux (std::string dest, lo_message msg) +{ + OSCSurface *sur = get_surface(get_address (msg), true); + int ret = 1; + if (sur->cue) { + boost::shared_ptr rt = boost::dynamic_pointer_cast (get_strip (sur->aux, get_address(msg))); + if (rt) { + if (dest.size()) { + rt->output()->disconnect (this); + if (atoi( dest.c_str())) { + dest = string_compose ("system:playback_%1", dest); + } + PortSet& ports = rt->output()->ports (); + rt->output ()->connect (*(ports.begin()), dest, this); + session->set_dirty(); + ret = 0; + } + } + } + if (ret) { + PBD::warning << "OSC: cannot connect, no Aux bus chosen." << endmsg; + } + return ret; +} + int OSC::cue_next (lo_message msg) { @@ -6315,13 +6782,16 @@ OSC::cue_send_enable (uint32_t id, float state, lo_message msg) int OSC::float_message (string path, float val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_float (reply, (float) val); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6329,6 +6799,7 @@ OSC::float_message (string path, float val, lo_address addr) int OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6338,20 +6809,25 @@ OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool i lo_message_add_float (msg, value); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } int OSC::int_message (string path, int val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_int32 (reply, (float) val); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6359,6 +6835,7 @@ OSC::int_message (string path, int val, lo_address addr) int OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6368,20 +6845,25 @@ OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_li lo_message_add_int32 (msg, value); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } int OSC::text_message (string path, string val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_string (reply, val.c_str()); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6389,6 +6871,7 @@ OSC::text_message (string path, string val, lo_address addr) int OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6399,7 +6882,9 @@ OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, boo lo_message_add_string (msg, val.c_str()); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } @@ -6412,24 +6897,15 @@ OSC::cue_get_sorted_stripables(boost::shared_ptr aux, uint32_t id, lo // 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); - } + session->get_stripables (stripables, PresentationInfo::MixerStripables); + boost::shared_ptr aux_rt = boost::dynamic_pointer_cast (aux); + Route::FedBy fed_by = aux_rt->fed_by(); + for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) { + if (i->sends_only) { + boost::shared_ptr s (i->r.lock()); + 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());