periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
periodic_timeout->attach (main_loop()->get_context());
- // 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);
len = strlen (path);
if (strstr (path, "/automation")) {
- ret = set_automation (path, len, argv, argc, msg);
+ ret = set_automation (path, argv, argc, msg);
+
+ } else
+ if (strstr (path, "/touch")) {
+ ret = touch_detect (path, argv, argc, msg);
} else
if (len >= 17 && !strcmp (&path[len-15], "/#current_value")) {
} else
if (!strncmp (path, "/access_action/", 15)) {
+ check_surface (msg);
if (!(argc && !argv[0]->i)) {
std::string action_path = path;
ret = 0;
} else
if (strcmp (path, "/strip/listen") == 0) {
+ check_surface (msg);
cerr << "set up listener\n";
} else
if (strcmp (path, "/strip/ignore") == 0) {
+ check_surface (msg);
for (int n = 0; n < argc; ++n) {
int ssid = atoi (&path[17]);
ret = sel_eq_shape (ssid, argv[0]->f, msg);
}
+ if (ret) {
+ check_surface (msg);
+ }
if ((ret && _debugmode != Off)) {
debugmsg (_("Unhandled OSC message"), path, types, argv, argc);
return 0;
}
+int
+OSC::check_surface (lo_message msg)
+{
+ if (!session) {
+ return -1;
+ }
+ get_surface(get_address (msg));
+ return 0;
+}
+
OSC::OSCSurface *
OSC::get_surface (lo_address addr)
{
// No surface create one with default values
OSCSurface s;
s.remote_url = r_url;
+ s.no_clear = false;
+ s.jogmode = JOG;
s.bank = 1;
s.bank_size = default_banksize; // need to find out how many strips there are
s.strip_types = default_strip; // 159 is tracks, busses, and VCAs (no master/monitor)
s.expand = 0;
s.expand_enable = false;
s.cue = false;
+ s.aux = 0;
s.strips = get_sorted_stripables(s.strip_types, s.cue);
s.nstrips = s.strips.size();
if (!session) {
return;
}
+ check_surface (msg);
framepos_t pos = session->transport_frame ();
lo_message reply = lo_message_new ();
if (!session) {
return;
}
+ check_surface (msg);
double ts = session->transport_speed ();
lo_message reply = lo_message_new ();
if (!session) {
return;
}
+ check_surface (msg);
int re = (int)session->get_record_enabled ();
lo_message reply = lo_message_new ();
OSC::scrub (float delta, lo_message msg)
{
if (!session) return -1;
+ check_surface (msg);
scrub_place = session->transport_frame ();
OSC::master_set_pan_stereo_position (float position, lo_message msg)
{
if (!session) return -1;
+ OSCSurface *sur = get_surface(get_address (msg));
float endposition = .5;
boost::shared_ptr<Stripable> s = session->master_out();
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 ();
// strip calls
int
-OSC::set_automation (const char *path, size_t len, lo_arg **argv, int argc, lo_message msg)
+OSC::set_automation (const char *path, lo_arg **argv, int argc, lo_message msg)
{
if (!session) return -1;
uint32_t ctr = 0;
uint32_t aut = 0;
+ if (argc) {
+ if (argv[argc - 1]->f) {
+ aut = (int)argv[argc - 1]->f;
+ } else {
+ aut = argv[argc - 1]->i;
+ }
+ }
+
//parse path first to find stripable
if (!strncmp (path, "/strip/", 7)) {
// find ssid and stripable
if (argc > 1) {
strp = get_strip (argv[0]->i, get_address (msg));
- if (argv[1]->f) {
- aut = (int)argv[1]->f;
- } else {
- aut = argv[1]->i;
- }
} else {
uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
strp = get_strip (ssid, get_address (msg));
- if (argv[0]->f) {
- aut = (int)argv[0]->f;
- } else {
- aut = argv[0]->i;
- }
}
ctr = 7;
} else if (!strncmp (path, "/select/", 8)) {
} else {
strp = ControlProtocol::first_selected_stripable();
}
- if (argv[0]->f) {
- aut = (int)argv[0]->f;
+ ctr = 8;
+ } else {
+ return ret;
+ }
+ if (strp) {
+ boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
+ // other automatable controls can be added by repeating the next 6.5 lines
+ if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
+ if (strp->gain_control ()) {
+ control = strp->gain_control ();
+ } else {
+ PBD::warning << "No fader for this strip" << endmsg;
+ }
+ } else {
+ PBD::warning << "Automation not available for " << path << endmsg;
+ }
+
+ if (control) {
+
+ switch (aut) {
+ case 0:
+ control->set_automation_state (ARDOUR::Off);
+ ret = 0;
+ break;
+ case 1:
+ control->set_automation_state (ARDOUR::Play);
+ ret = 0;
+ break;
+ case 2:
+ control->set_automation_state (ARDOUR::Write);
+ ret = 0;
+ break;
+ case 3:
+ control->set_automation_state (ARDOUR::Touch);
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
+int
+OSC::touch_detect (const char *path, lo_arg **argv, int argc, lo_message msg)
+{
+ if (!session) return -1;
+
+ int ret = 1;
+ OSCSurface *sur = get_surface(get_address (msg));
+ boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
+ uint32_t ctr = 0;
+ uint32_t touch = 0;
+
+ if (argc) {
+ if (argv[argc - 1]->f) {
+ touch = (int)argv[argc - 1]->f;
+ } else {
+ touch = argv[argc - 1]->i;
+ }
+ }
+
+ //parse path first to find stripable
+ if (!strncmp (path, "/strip/", 7)) {
+ // find ssid and stripable
+ if (argc > 1) {
+ strp = get_strip (argv[0]->i, get_address (msg));
+ } else {
+ uint32_t ssid = atoi (&(strrchr (path, '/' ))[1]);
+ strp = get_strip (ssid, get_address (msg));
+ }
+ ctr = 7;
+ } else if (!strncmp (path, "/select/", 8)) {
+ if (sur->expand_enable && sur->expand) {
+ strp = get_strip (sur->expand, get_address (msg));
} else {
- aut = argv[0]->i;
+ strp = ControlProtocol::first_selected_stripable();
}
ctr = 8;
} else {
return ret;
}
if (strp) {
+ boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
+ // other automatable controls can be added by repeating the next 6.5 lines
if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
if (strp->gain_control ()) {
- switch (aut) {
- case 0:
- strp->gain_control()->set_automation_state (ARDOUR::Off);
- ret = 0;
- break;
- case 1:
- strp->gain_control()->set_automation_state (ARDOUR::Play);
- ret = 0;
- break;
- case 2:
- strp->gain_control()->set_automation_state (ARDOUR::Write);
- ret = 0;
- break;
- case 3:
- strp->gain_control()->set_automation_state (ARDOUR::Touch);
- ret = 0;
- break;
- default:
- break;
+ control = strp->gain_control ();
+ } else {
+ PBD::warning << "No fader for this strip" << endmsg;
+ }
+ } else {
+ PBD::warning << "Automation not available for " << path << endmsg;
+ }
+
+ if (control) {
+ if (touch) {
+ //start touch
+ if (control->automation_state() == Touch && !control->touching ()) {
+ control->start_touch (control->session().transport_frame());
}
+ } else {
+ // end touch
+ control->stop_touch (true, control->session().transport_frame());
+ }
+ // just in case some crazy surface starts sending control values before touch
+ FakeTouchMap::iterator x = _touch_timeout.find(control);
+ if (x != _touch_timeout.end()) {
+ _touch_timeout.erase (x);
}
}
}
return ret;
}
+int
+OSC::fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl)
+{
+ if (ctrl) {
+ //start touch
+ if (ctrl->automation_state() == Touch && !ctrl->touching ()) {
+ ctrl->start_touch (ctrl->session().transport_frame());
+ _touch_timeout[ctrl] = 10;
+ }
+ }
+
+ return 0;
+}
+
int
OSC::route_mute (int ssid, int yn, lo_message msg)
{
if (s) {
if (s->gain_control()) {
+ fake_touch (s->gain_control());
s->gain_control()->set_value (level, PBD::Controllable::NoGroup);
} else {
return 1;
abs = dB_to_coefficient (val);
}
if (s->gain_control()) {
+ fake_touch (s->gain_control());
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
}
float abs;
abs = slider_position_to_gain_with_max (val, 2.0);
if (s->gain_control()) {
+ fake_touch (s->gain_control());
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
}
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);
+ 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);
return 0;
}
}
return sel_fail ("eq_hpf", 0, get_address (msg));
}
+// need to add two more filter controls
int
OSC::sel_eq_gain (int id, float val, lo_message msg)
co->tick();
}
}
+ for (FakeTouchMap::iterator x = _touch_timeout.begin(); x != _touch_timeout.end();) {
+ _touch_timeout[(*x).first] = (*x).second - 1;
+ if (!(*x).second) {
+ boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
+ // turn touch off
+ ctrl->stop_touch (true, ctrl->session().transport_frame());
+ _touch_timeout.erase (x++);
+ } else {
+ x++;
+ }
+ }
return true;
}
s.expand_enable = false;
s.strips = get_sorted_stripables (s.strip_types, s.cue);
s.nstrips = s.strips.size ();
+ s.no_clear = false;
+ s.jogmode = JOG;
+ s.cue = false;
+ s.aux = 0;
_surface.push_back (s);
}
}