2 * Copyright (C) 2006 Paul Davis
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include "pbd/gstdio_compat.h"
31 #include "pbd/control_math.h"
32 #include <pbd/convert.h>
33 #include <pbd/pthread_utils.h>
34 #include <pbd/file_utils.h>
35 #include <pbd/failed_constructor.h>
37 #include "ardour/amp.h"
38 #include "ardour/session.h"
39 #include "ardour/route.h"
40 #include "ardour/audio_track.h"
41 #include "ardour/midi_track.h"
42 #include "ardour/vca.h"
43 #include "ardour/monitor_control.h"
44 #include "ardour/dB.h"
45 #include "ardour/filesystem_paths.h"
46 #include "ardour/panner.h"
47 #include "ardour/plugin.h"
48 #include "ardour/plugin_insert.h"
49 #include "ardour/presentation_info.h"
50 #include "ardour/profile.h"
51 #include "ardour/send.h"
52 #include "ardour/internal_send.h"
53 #include "ardour/phase_control.h"
54 #include "ardour/solo_isolate_control.h"
55 #include "ardour/solo_safe_control.h"
56 #include "ardour/vca_manager.h"
58 #include "osc_select_observer.h"
60 #include "osc_controllable.h"
61 #include "osc_route_observer.h"
62 #include "osc_global_observer.h"
63 #include "osc_cue_observer.h"
66 using namespace ARDOUR;
69 using namespace ArdourSurface;
71 #include "pbd/abstract_ui.cc" // instantiate template
73 OSC* OSC::_instance = 0;
76 static void error_callback(int num, const char *m, const char *path)
78 fprintf(stderr, "liblo server error %d in path %s: %s\n", num, path, m);
81 static void error_callback(int, const char *, const char *)
87 OSC::OSC (Session& s, uint32_t port)
88 : ControlProtocol (s, X_("Open Sound Control (OSC)"))
89 , AbstractUI<OSCUIRequest> (name())
96 , _osc_unix_server (0)
99 , remote_port ("8000")
100 , default_banksize (0)
101 , default_strip (159)
102 , default_feedback (0)
103 , default_gainmode (0)
104 , default_send_size (0)
105 , default_plugin_size (0)
108 , observer_busy (true)
114 session->Exported.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::session_exported, this, _1, _2), this);
126 OSC::request_factory (uint32_t num_requests)
128 /* AbstractUI<T>::request_buffer_factory() is a template method only
129 instantiated in this source module. To provide something visible for
130 use in the interface/descriptor, we have this static method that is
133 return request_buffer_factory (num_requests);
137 OSC::do_request (OSCUIRequest* req)
139 if (req->type == CallSlot) {
141 call_slot (MISSING_INVALIDATOR, req->the_slot);
143 } else if (req->type == Quit) {
150 OSC::set_active (bool yn)
152 if (yn != active()) {
166 return ControlProtocol::set_active (yn);
170 OSC::get_active () const
172 return _osc_server != 0;
181 /* already started */
185 for (int j=0; j < 20; ++j) {
186 snprintf(tmpstr, sizeof(tmpstr), "%d", _port);
188 //if ((_osc_server = lo_server_new_with_proto (tmpstr, LO_TCP, error_callback))) {
192 if ((_osc_server = lo_server_new (tmpstr, error_callback))) {
197 cerr << "can't get osc at port: " << _port << endl;
207 #ifdef ARDOUR_OSC_UNIX_SERVER
209 // APPEARS sluggish for now
211 // attempt to create unix socket server too
213 snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX");
214 int fd = mkstemp(tmpstr);
220 _osc_unix_server = lo_server_new (tmpstr, error_callback);
222 if (_osc_unix_server) {
223 _osc_unix_socket_path = tmpstr;
228 PBD::info << "OSC @ " << get_server_url () << endmsg;
230 std::string url_file;
232 if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
233 _osc_url_file = url_file;
234 if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) {
235 cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
239 observer_busy = false;
240 register_callbacks();
242 session_loaded (*session);
244 // lo_server_thread_add_method(_sthread, NULL, NULL, OSC::_dummy_handler, this);
246 /* startup the event loop thread */
250 // start timers for metering, timecode and heartbeat.
251 // timecode and metering run at 100
252 Glib::RefPtr<Glib::TimeoutSource> periodic_timeout = Glib::TimeoutSource::create (100); // milliseconds
253 periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
254 periodic_timeout->attach (main_loop()->get_context());
256 // catch track reordering
257 // receive routes added
258 session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this);
259 // receive VCAs added
260 session->vca_manager().VCAAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_vca_added, this, _1), this);
262 PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
264 _select = ControlProtocol::first_selected_stripable();
266 _select = session->master_out ();
275 pthread_set_name (event_loop_name().c_str());
277 if (_osc_unix_server) {
278 Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR);
279 src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server));
280 src->attach (_main_loop->get_context());
281 local_server = src->gobj();
282 g_source_ref (local_server);
286 #ifdef PLATFORM_WINDOWS
287 Glib::RefPtr<IOChannel> chan = Glib::IOChannel::create_from_win32_socket (lo_server_get_socket_fd (_osc_server));
288 Glib::RefPtr<IOSource> src = IOSource::create (chan, IO_IN|IO_HUP|IO_ERR);
290 Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_server), IO_IN|IO_HUP|IO_ERR);
292 src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_server));
293 src->attach (_main_loop->get_context());
294 remote_server = src->gobj();
295 g_source_ref (remote_server);
298 PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
299 SessionEvent::create_per_thread_pool (event_loop_name(), 128);
305 periodic_connection.disconnect ();
306 session_connections.drop_connections ();
309 observer_busy = true;
310 for (uint32_t it = 0; it < _surface.size (); ++it) {
311 OSCSurface* sur = &_surface[it];
312 surface_destroy (sur);
318 g_source_destroy (local_server);
319 g_source_unref (local_server);
324 g_source_destroy (remote_server);
325 g_source_unref (remote_server);
332 lo_server_free (_osc_server);
336 if (_osc_unix_server) {
337 lo_server_free (_osc_unix_server);
338 _osc_unix_server = 0;
341 if (!_osc_unix_socket_path.empty()) {
342 ::g_unlink (_osc_unix_socket_path.c_str());
345 if (!_osc_url_file.empty() ) {
346 ::g_unlink (_osc_url_file.c_str() );
353 OSC::surface_destroy (OSCSurface* sur)
355 OSCSelectObserver* so;
356 if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
357 so->clear_observer ();
360 PBD::ScopedConnection pc = sur->proc_connection;
365 if ((co = dynamic_cast<OSCCueObserver*>(sur->cue_obs)) != 0) {
371 OSCGlobalObserver* go;
372 if ((go = dynamic_cast<OSCGlobalObserver*>(sur->global_obs)) != 0) {
373 go->clear_observer ();
377 uint32_t st_end = sur->observers.size ();
379 for (uint32_t i = 0; i < st_end; i++) {
380 OSCRouteObserver* ro;
381 if ((ro = dynamic_cast<OSCRouteObserver*>(sur->observers[i])) != 0) {
387 sur->observers.clear();
392 OSC::register_callbacks()
397 srvs[0] = _osc_server;
398 srvs[1] = _osc_unix_server;
400 for (size_t i = 0; i < 2; ++i) {
409 #define REGISTER_CALLBACK(serv,path,types, function) lo_server_add_method (serv, path, types, OSC::_ ## function, this)
411 // Some controls have optional "f" for feedback or touchosc
412 // http://hexler.net/docs/touchosc-controls-reference
414 REGISTER_CALLBACK (serv, "/refresh", "", refresh_surface);
415 REGISTER_CALLBACK (serv, "/refresh", "f", refresh_surface);
416 REGISTER_CALLBACK (serv, "/strip/list", "", routes_list);
417 REGISTER_CALLBACK (serv, "/strip/list", "f", routes_list);
418 REGISTER_CALLBACK (serv, "/strip/custom/enable", "f", custom_enable);
419 REGISTER_CALLBACK (serv, "/strip/custom/clear", "f", custom_clear);
420 REGISTER_CALLBACK (serv, "/strip/custom/clear", "", custom_clear);
421 REGISTER_CALLBACK (serv, "/surface/list", "", surface_list);
422 REGISTER_CALLBACK (serv, "/surface/list", "f", surface_list);
423 REGISTER_CALLBACK (serv, "/add_marker", "", add_marker);
424 REGISTER_CALLBACK (serv, "/add_marker", "f", add_marker);
425 REGISTER_CALLBACK (serv, "/access_action", "s", access_action);
426 REGISTER_CALLBACK (serv, "/loop_toggle", "", loop_toggle);
427 REGISTER_CALLBACK (serv, "/loop_toggle", "f", loop_toggle);
428 REGISTER_CALLBACK (serv, "/loop_location", "ii", loop_location);
429 REGISTER_CALLBACK (serv, "/goto_start", "", goto_start);
430 REGISTER_CALLBACK (serv, "/goto_start", "f", goto_start);
431 REGISTER_CALLBACK (serv, "/goto_end", "", goto_end);
432 REGISTER_CALLBACK (serv, "/goto_end", "f", goto_end);
433 REGISTER_CALLBACK (serv, "/scrub", "f", scrub);
434 REGISTER_CALLBACK (serv, "/jog", "f", jog);
435 REGISTER_CALLBACK (serv, "/jog/mode", "f", jog_mode);
436 REGISTER_CALLBACK (serv, "/rewind", "", rewind);
437 REGISTER_CALLBACK (serv, "/rewind", "f", rewind);
438 REGISTER_CALLBACK (serv, "/ffwd", "", ffwd);
439 REGISTER_CALLBACK (serv, "/ffwd", "f", ffwd);
440 REGISTER_CALLBACK (serv, "/transport_stop", "", transport_stop);
441 REGISTER_CALLBACK (serv, "/transport_stop", "f", transport_stop);
442 REGISTER_CALLBACK (serv, "/transport_play", "", transport_play);
443 REGISTER_CALLBACK (serv, "/transport_play", "f", transport_play);
444 REGISTER_CALLBACK (serv, "/transport_frame", "", transport_sample);
445 REGISTER_CALLBACK (serv, "/transport_speed", "", transport_speed);
446 REGISTER_CALLBACK (serv, "/record_enabled", "", record_enabled);
447 REGISTER_CALLBACK (serv, "/set_transport_speed", "f", set_transport_speed);
448 // locate ii is position and bool roll
449 REGISTER_CALLBACK (serv, "/locate", "ii", locate);
450 REGISTER_CALLBACK (serv, "/save_state", "", save_state);
451 REGISTER_CALLBACK (serv, "/save_state", "f", save_state);
452 REGISTER_CALLBACK (serv, "/prev_marker", "", prev_marker);
453 REGISTER_CALLBACK (serv, "/prev_marker", "f", prev_marker);
454 REGISTER_CALLBACK (serv, "/next_marker", "", next_marker);
455 REGISTER_CALLBACK (serv, "/next_marker", "f", next_marker);
456 REGISTER_CALLBACK (serv, "/undo", "", undo);
457 REGISTER_CALLBACK (serv, "/undo", "f", undo);
458 REGISTER_CALLBACK (serv, "/redo", "", redo);
459 REGISTER_CALLBACK (serv, "/redo", "f", redo);
460 REGISTER_CALLBACK (serv, "/toggle_punch_in", "", toggle_punch_in);
461 REGISTER_CALLBACK (serv, "/toggle_punch_in", "f", toggle_punch_in);
462 REGISTER_CALLBACK (serv, "/toggle_punch_out", "", toggle_punch_out);
463 REGISTER_CALLBACK (serv, "/toggle_punch_out", "f", toggle_punch_out);
464 REGISTER_CALLBACK (serv, "/rec_enable_toggle", "", rec_enable_toggle);
465 REGISTER_CALLBACK (serv, "/rec_enable_toggle", "f", rec_enable_toggle);
466 REGISTER_CALLBACK (serv, "/toggle_all_rec_enables", "", toggle_all_rec_enables);
467 REGISTER_CALLBACK (serv, "/toggle_all_rec_enables", "f", toggle_all_rec_enables);
468 REGISTER_CALLBACK (serv, "/all_tracks_rec_in", "f", all_tracks_rec_in);
469 REGISTER_CALLBACK (serv, "/all_tracks_rec_out", "f", all_tracks_rec_out);
470 REGISTER_CALLBACK (serv, "/cancel_all_solos", "f", cancel_all_solos);
471 REGISTER_CALLBACK (serv, "/remove_marker", "", remove_marker_at_playhead);
472 REGISTER_CALLBACK (serv, "/remove_marker", "f", remove_marker_at_playhead);
473 REGISTER_CALLBACK (serv, "/jump_bars", "f", jump_by_bars);
474 REGISTER_CALLBACK (serv, "/jump_seconds", "f", jump_by_seconds);
475 REGISTER_CALLBACK (serv, "/mark_in", "", mark_in);
476 REGISTER_CALLBACK (serv, "/mark_in", "f", mark_in);
477 REGISTER_CALLBACK (serv, "/mark_out", "", mark_out);
478 REGISTER_CALLBACK (serv, "/mark_out", "f", mark_out);
479 REGISTER_CALLBACK (serv, "/toggle_click", "", toggle_click);
480 REGISTER_CALLBACK (serv, "/toggle_click", "f", toggle_click);
481 REGISTER_CALLBACK (serv, "/click/level", "f", click_level);
482 REGISTER_CALLBACK (serv, "/midi_panic", "", midi_panic);
483 REGISTER_CALLBACK (serv, "/midi_panic", "f", midi_panic);
484 REGISTER_CALLBACK (serv, "/toggle_roll", "", toggle_roll);
485 REGISTER_CALLBACK (serv, "/toggle_roll", "f", toggle_roll);
486 REGISTER_CALLBACK (serv, "/stop_forget", "", stop_forget);
487 REGISTER_CALLBACK (serv, "/stop_forget", "f", stop_forget);
488 REGISTER_CALLBACK (serv, "/set_punch_range", "", set_punch_range);
489 REGISTER_CALLBACK (serv, "/set_punch_range", "f", set_punch_range);
490 REGISTER_CALLBACK (serv, "/set_loop_range", "", set_loop_range);
491 REGISTER_CALLBACK (serv, "/set_loop_range", "f", set_loop_range);
492 REGISTER_CALLBACK (serv, "/set_session_range", "", set_session_range);
493 REGISTER_CALLBACK (serv, "/set_session_range", "f", set_session_range);
494 REGISTER_CALLBACK (serv, "/toggle_monitor_mute", "", toggle_monitor_mute);
495 REGISTER_CALLBACK (serv, "/toggle_monitor_mute", "f", toggle_monitor_mute);
496 REGISTER_CALLBACK (serv, "/toggle_monitor_dim", "", toggle_monitor_dim);
497 REGISTER_CALLBACK (serv, "/toggle_monitor_dim", "f", toggle_monitor_dim);
498 REGISTER_CALLBACK (serv, "/toggle_monitor_mono", "", toggle_monitor_mono);
499 REGISTER_CALLBACK (serv, "/toggle_monitor_mono", "f", toggle_monitor_mono);
500 REGISTER_CALLBACK (serv, "/quick_snapshot_switch", "", quick_snapshot_switch);
501 REGISTER_CALLBACK (serv, "/quick_snapshot_switch", "f", quick_snapshot_switch);
502 REGISTER_CALLBACK (serv, "/quick_snapshot_stay", "", quick_snapshot_stay);
503 REGISTER_CALLBACK (serv, "/quick_snapshot_stay", "f", quick_snapshot_stay);
504 REGISTER_CALLBACK (serv, "/fit_1_track", "", fit_1_track);
505 REGISTER_CALLBACK (serv, "/fit_1_track", "f", fit_1_track);
506 REGISTER_CALLBACK (serv, "/fit_2_tracks", "", fit_2_tracks);
507 REGISTER_CALLBACK (serv, "/fit_2_tracks", "f", fit_2_tracks);
508 REGISTER_CALLBACK (serv, "/fit_4_tracks", "", fit_4_tracks);
509 REGISTER_CALLBACK (serv, "/fit_4_tracks", "f", fit_4_tracks);
510 REGISTER_CALLBACK (serv, "/fit_8_tracks", "", fit_8_tracks);
511 REGISTER_CALLBACK (serv, "/fit_8_tracks", "f", fit_8_tracks);
512 REGISTER_CALLBACK (serv, "/fit_16_tracks", "", fit_16_tracks);
513 REGISTER_CALLBACK (serv, "/fit_16_tracks", "f", fit_16_tracks);
514 REGISTER_CALLBACK (serv, "/fit_32_tracks", "", fit_32_tracks);
515 REGISTER_CALLBACK (serv, "/fit_32_tracks", "f", fit_32_tracks);
516 REGISTER_CALLBACK (serv, "/fit_all_tracks", "", fit_all_tracks);
517 REGISTER_CALLBACK (serv, "/fit_all_tracks", "f", fit_all_tracks);
518 REGISTER_CALLBACK (serv, "/zoom_100_ms", "", zoom_100_ms);
519 REGISTER_CALLBACK (serv, "/zoom_100_ms", "f", zoom_100_ms);
520 REGISTER_CALLBACK (serv, "/zoom_1_sec", "", zoom_1_sec);
521 REGISTER_CALLBACK (serv, "/zoom_1_sec", "f", zoom_1_sec);
522 REGISTER_CALLBACK (serv, "/zoom_10_sec", "", zoom_10_sec);
523 REGISTER_CALLBACK (serv, "/zoom_10_sec", "f", zoom_10_sec);
524 REGISTER_CALLBACK (serv, "/zoom_1_min", "", zoom_1_min);
525 REGISTER_CALLBACK (serv, "/zoom_1_min", "f", zoom_1_min);
526 REGISTER_CALLBACK (serv, "/zoom_5_min", "", zoom_5_min);
527 REGISTER_CALLBACK (serv, "/zoom_5_min", "f", zoom_5_min);
528 REGISTER_CALLBACK (serv, "/zoom_10_min", "", zoom_10_min);
529 REGISTER_CALLBACK (serv, "/zoom_10_min", "f", zoom_10_min);
530 REGISTER_CALLBACK (serv, "/zoom_to_session", "", zoom_to_session);
531 REGISTER_CALLBACK (serv, "/zoom_to_session", "f", zoom_to_session);
532 REGISTER_CALLBACK (serv, "/temporal_zoom_in", "f", temporal_zoom_in);
533 REGISTER_CALLBACK (serv, "/temporal_zoom_in", "", temporal_zoom_in);
534 REGISTER_CALLBACK (serv, "/temporal_zoom_out", "", temporal_zoom_out);
535 REGISTER_CALLBACK (serv, "/temporal_zoom_out", "f", temporal_zoom_out);
536 REGISTER_CALLBACK (serv, "/scroll_up_1_track", "f", scroll_up_1_track);
537 REGISTER_CALLBACK (serv, "/scroll_up_1_track", "", scroll_up_1_track);
538 REGISTER_CALLBACK (serv, "/scroll_dn_1_track", "f", scroll_dn_1_track);
539 REGISTER_CALLBACK (serv, "/scroll_dn_1_track", "", scroll_dn_1_track);
540 REGISTER_CALLBACK (serv, "/scroll_up_1_page", "f", scroll_up_1_page);
541 REGISTER_CALLBACK (serv, "/scroll_up_1_page", "", scroll_up_1_page);
542 REGISTER_CALLBACK (serv, "/scroll_dn_1_page", "f", scroll_dn_1_page);
543 REGISTER_CALLBACK (serv, "/scroll_dn_1_page", "", scroll_dn_1_page);
544 REGISTER_CALLBACK (serv, "/bank_up", "", bank_up);
545 REGISTER_CALLBACK (serv, "/bank_up", "f", bank_delta);
546 REGISTER_CALLBACK (serv, "/bank_down", "", bank_down);
547 REGISTER_CALLBACK (serv, "/bank_down", "f", bank_down);
548 REGISTER_CALLBACK (serv, "/use_group", "f", use_group);
550 // controls for "special" strips
551 REGISTER_CALLBACK (serv, "/master/gain", "f", master_set_gain);
552 REGISTER_CALLBACK (serv, "/master/fader", "f", master_set_fader);
553 REGISTER_CALLBACK (serv, "/master/db_delta", "f", master_delta_gain);
554 REGISTER_CALLBACK (serv, "/master/mute", "i", master_set_mute);
555 REGISTER_CALLBACK (serv, "/master/trimdB", "f", master_set_trim);
556 REGISTER_CALLBACK (serv, "/master/pan_stereo_position", "f", master_set_pan_stereo_position);
557 REGISTER_CALLBACK (serv, "/master/select", "f", master_select);
558 REGISTER_CALLBACK (serv, "/monitor/gain", "f", monitor_set_gain);
559 REGISTER_CALLBACK (serv, "/monitor/fader", "f", monitor_set_fader);
560 REGISTER_CALLBACK (serv, "/monitor/db_delta", "f", monitor_delta_gain);
561 REGISTER_CALLBACK (serv, "/monitor/mute", "i", monitor_set_mute);
562 REGISTER_CALLBACK (serv, "/monitor/dim", "i", monitor_set_dim);
563 REGISTER_CALLBACK (serv, "/monitor/mono", "i", monitor_set_mono);
565 // Controls for the Selected strip
566 REGISTER_CALLBACK (serv, "/select/recenable", "i", sel_recenable);
567 REGISTER_CALLBACK (serv, "/select/record_safe", "i", sel_recsafe);
568 REGISTER_CALLBACK (serv, "/select/mute", "i", sel_mute);
569 REGISTER_CALLBACK (serv, "/select/solo", "i", sel_solo);
570 REGISTER_CALLBACK (serv, "/select/solo_iso", "i", sel_solo_iso);
571 REGISTER_CALLBACK (serv, "/select/solo_safe", "i", sel_solo_safe);
572 REGISTER_CALLBACK (serv, "/select/monitor_input", "i", sel_monitor_input);
573 REGISTER_CALLBACK (serv, "/select/monitor_disk", "i", sel_monitor_disk);
574 REGISTER_CALLBACK (serv, "/select/polarity", "i", sel_phase);
575 REGISTER_CALLBACK (serv, "/select/gain", "f", sel_gain);
576 REGISTER_CALLBACK (serv, "/select/fader", "f", sel_fader);
577 REGISTER_CALLBACK (serv, "/select/db_delta", "f", sel_dB_delta);
578 REGISTER_CALLBACK (serv, "/select/trimdB", "f", sel_trim);
579 REGISTER_CALLBACK (serv, "/select/pan_stereo_position", "f", sel_pan_position);
580 REGISTER_CALLBACK (serv, "/select/pan_stereo_width", "f", sel_pan_width);
581 REGISTER_CALLBACK (serv, "/select/send_gain", "if", sel_sendgain);
582 REGISTER_CALLBACK (serv, "/select/send_fader", "if", sel_sendfader);
583 REGISTER_CALLBACK (serv, "/select/send_enable", "if", sel_sendenable);
584 REGISTER_CALLBACK (serv, "/select/master_send_enable", "i", sel_master_send_enable);
585 REGISTER_CALLBACK (serv, "/select/send_page", "f", sel_send_page);
586 REGISTER_CALLBACK (serv, "/select/plug_page", "f", sel_plug_page);
587 REGISTER_CALLBACK (serv, "/select/plugin", "f", sel_plugin);
588 REGISTER_CALLBACK (serv, "/select/plugin/activate", "f", sel_plugin_activate);
589 REGISTER_CALLBACK (serv, "/select/expand", "i", sel_expand);
590 REGISTER_CALLBACK (serv, "/select/pan_elevation_position", "f", sel_pan_elevation);
591 REGISTER_CALLBACK (serv, "/select/pan_frontback_position", "f", sel_pan_frontback);
592 REGISTER_CALLBACK (serv, "/select/pan_lfe_control", "f", sel_pan_lfe);
593 REGISTER_CALLBACK (serv, "/select/comp_enable", "f", sel_comp_enable);
594 REGISTER_CALLBACK (serv, "/select/comp_threshold", "f", sel_comp_threshold);
595 REGISTER_CALLBACK (serv, "/select/comp_speed", "f", sel_comp_speed);
596 REGISTER_CALLBACK (serv, "/select/comp_mode", "f", sel_comp_mode);
597 REGISTER_CALLBACK (serv, "/select/comp_makeup", "f", sel_comp_makeup);
598 REGISTER_CALLBACK (serv, "/select/eq_enable", "f", sel_eq_enable);
599 REGISTER_CALLBACK (serv, "/select/eq_hpf/freq", "f", sel_eq_hpf_freq);
600 REGISTER_CALLBACK (serv, "/select/eq_hpf/enable", "f", sel_eq_hpf_enable);
601 REGISTER_CALLBACK (serv, "/select/eq_hpf/slope", "f", sel_eq_hpf_slope);
602 REGISTER_CALLBACK (serv, "/select/eq_lpf/freq", "f", sel_eq_lpf_freq);
603 REGISTER_CALLBACK (serv, "/select/eq_lpf/enable", "f", sel_eq_lpf_enable);
604 REGISTER_CALLBACK (serv, "/select/eq_lpf/slope", "f", sel_eq_lpf_slope);
605 REGISTER_CALLBACK (serv, "/select/eq_gain", "if", sel_eq_gain);
606 REGISTER_CALLBACK (serv, "/select/eq_freq", "if", sel_eq_freq);
607 REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q);
608 REGISTER_CALLBACK (serv, "/select/eq_shape", "if", sel_eq_shape);
610 /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */
611 REGISTER_CALLBACK (serv, "/strip/mute", "ii", route_mute);
612 REGISTER_CALLBACK (serv, "/strip/solo", "ii", route_solo);
613 REGISTER_CALLBACK (serv, "/strip/solo_iso", "ii", route_solo_iso);
614 REGISTER_CALLBACK (serv, "/strip/solo_safe", "ii", route_solo_safe);
615 REGISTER_CALLBACK (serv, "/strip/recenable", "ii", route_recenable);
616 REGISTER_CALLBACK (serv, "/strip/record_safe", "ii", route_recsafe);
617 REGISTER_CALLBACK (serv, "/strip/monitor_input", "ii", route_monitor_input);
618 REGISTER_CALLBACK (serv, "/strip/monitor_disk", "ii", route_monitor_disk);
619 REGISTER_CALLBACK (serv, "/strip/expand", "ii", strip_expand);
620 REGISTER_CALLBACK (serv, "/strip/select", "ii", strip_gui_select);
621 REGISTER_CALLBACK (serv, "/strip/polarity", "ii", strip_phase);
622 REGISTER_CALLBACK (serv, "/strip/gain", "if", route_set_gain_dB);
623 REGISTER_CALLBACK (serv, "/strip/fader", "if", route_set_gain_fader);
624 REGISTER_CALLBACK (serv, "/strip/trimdB", "if", route_set_trim_dB);
625 REGISTER_CALLBACK (serv, "/strip/pan_stereo_position", "if", route_set_pan_stereo_position);
626 REGISTER_CALLBACK (serv, "/strip/pan_stereo_width", "if", route_set_pan_stereo_width);
627 REGISTER_CALLBACK (serv, "/strip/plugin/parameter", "iiif", route_plugin_parameter);
628 // prints to cerr only
629 REGISTER_CALLBACK (serv, "/strip/plugin/parameter/print", "iii", route_plugin_parameter_print);
630 REGISTER_CALLBACK (serv, "/strip/plugin/activate", "ii", route_plugin_activate);
631 REGISTER_CALLBACK (serv, "/strip/plugin/deactivate", "ii", route_plugin_deactivate);
632 REGISTER_CALLBACK (serv, "/strip/send/gain", "iif", route_set_send_gain_dB);
633 REGISTER_CALLBACK (serv, "/strip/send/fader", "iif", route_set_send_fader);
634 REGISTER_CALLBACK (serv, "/strip/send/enable", "iif", route_set_send_enable);
635 REGISTER_CALLBACK(serv, "/strip/name", "is", route_rename);
636 REGISTER_CALLBACK(serv, "/strip/sends", "i", route_get_sends);
637 REGISTER_CALLBACK(serv, "/strip/receives", "i", route_get_receives);
638 REGISTER_CALLBACK(serv, "/strip/plugin/list", "i", route_plugin_list);
639 REGISTER_CALLBACK(serv, "/strip/plugin/descriptor", "ii", route_plugin_descriptor);
640 REGISTER_CALLBACK(serv, "/strip/plugin/reset", "ii", route_plugin_reset);
642 /* still not-really-standardized query interface */
643 //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value);
644 //REGISTER_CALLBACK (serv, "/ardour/set", "", set);
646 // un/register_update args= s:ctrl s:returl s:retpath
647 //lo_server_add_method(serv, "/register_update", "sss", OSC::global_register_update_handler, this);
648 //lo_server_add_method(serv, "/unregister_update", "sss", OSC::global_unregister_update_handler, this);
649 //lo_server_add_method(serv, "/register_auto_update", "siss", OSC::global_register_auto_update_handler, this);
650 //lo_server_add_method(serv, "/unregister_auto_update", "sss", OSC::_global_unregister_auto_update_handler, this);
652 /* this is a special catchall handler,
653 * register at the end so this is only called if no
654 * other handler matches (also used for debug) */
655 lo_server_add_method (serv, 0, 0, _catchall, this);
660 OSC::osc_input_handler (IOCondition ioc, lo_server srv)
667 lo_server_recv (srv);
674 OSC::get_server_url()
680 urlstr = lo_server_get_url (_osc_server);
689 OSC::get_unix_server_url()
694 if (_osc_unix_server) {
695 urlstr = lo_server_get_url (_osc_unix_server);
706 session->set_dirty();
710 OSC::current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg)
714 subpath = (char*) malloc (len-15+1);
715 memcpy (subpath, path, len-15);
716 subpath[len-15] = '\0';
718 send_current_value (subpath, argv, argc, msg);
724 OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg)
730 lo_message reply = lo_message_new ();
731 boost::shared_ptr<Route> r;
734 lo_message_add_string (reply, path);
737 lo_message_add_string (reply, "bad syntax");
740 r = session->get_remote_nth_route (id);
743 lo_message_add_string (reply, "not found");
746 if (strcmp (path, "/strip/state") == 0) {
748 if (boost::dynamic_pointer_cast<AudioTrack>(r)) {
749 lo_message_add_string (reply, "AT");
750 } else if (boost::dynamic_pointer_cast<MidiTrack>(r)) {
751 lo_message_add_string (reply, "MT");
753 lo_message_add_string (reply, "B");
756 lo_message_add_string (reply, r->name().c_str());
757 lo_message_add_int32 (reply, r->n_inputs().n_audio());
758 lo_message_add_int32 (reply, r->n_outputs().n_audio());
759 lo_message_add_int32 (reply, r->muted());
760 lo_message_add_int32 (reply, r->soloed());
762 } else if (strcmp (path, "/strip/mute") == 0) {
764 lo_message_add_int32 (reply, (float) r->muted());
766 } else if (strcmp (path, "/strip/solo") == 0) {
768 lo_message_add_int32 (reply, r->soloed());
772 OSCSurface *sur = get_surface(get_address (msg));
774 if (sur->feedback[14]) {
775 lo_send_message (get_address (msg), "/reply", reply);
777 lo_send_message (get_address (msg), "#reply", reply);
779 lo_message_free (reply);
783 OSC::_catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data)
785 return ((OSC*)user_data)->catchall (path, types, argv, argc, data);
789 OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
792 int ret = 1; /* unhandled */
794 //cerr << "Received a message, path = " << path << " types = \""
795 // << (types ? types : "NULL") << '"' << endl;
797 /* 15 for /#current_value plus 2 for /<path> */
800 OSCSurface *sur = get_surface(get_address (msg), true);
802 if (strstr (path, "/automation")) {
803 ret = set_automation (path, types, argv, argc, msg);
806 if (strstr (path, "/touch")) {
807 ret = touch_detect (path, types, argv, argc, msg);
810 if (len >= 17 && !strcmp (&path[len-15], "/#current_value")) {
811 current_value_query (path, len, argv, argc, msg);
815 if (!strncmp (path, "/cue/", 5)) {
817 ret = cue_parse (path, types, argv, argc, msg);
820 if (!strncmp (path, "/select/plugin/parameter", 24)) {
822 ret = select_plugin_parameter (path, types, argv, argc, msg);
825 if (!strncmp (path, "/access_action/", 15)) {
827 if (!(argc && !argv[0]->i)) {
828 std::string action_path = path;
830 access_action (action_path.substr(15));
835 if (strcmp (path, "/strip/listen") == 0) {
837 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
838 } else if (sur->custom_enable) {
839 PBD::warning << "OSC: Can't add strips with custom enabled." << endmsg;
841 for (int n = 0; n < argc; ++n) {
843 boost::shared_ptr<Stripable> s = get_strip (argv[n]->i, get_address (msg));
845 sur->custom_strips.push_back (s);
851 if (strcmp (path, "/strip/ignore") == 0) {
853 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
854 } else if (!sur->custom_enable) {
855 PBD::warning << "OSC: Can't remove strips without custom enabled." << endmsg;
857 for (int n = 0; n < argc; ++n) {
858 if ((uint32_t) argv[n]->i <= sur->custom_strips.size ()) {
859 sur->custom_strips[argv[n]->i - 1] = boost::shared_ptr<Stripable>();
862 ret = set_bank (sur->bank, msg);
867 if (strstr (path, "/strip") && (argc != 1)) {
868 // All of the strip commands below require 1 parameter
869 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
871 if (!strncmp (path, "/strip/gain/", 12) && strlen (path) > 12) {
873 int ssid = atoi (&path[12]);
874 ret = route_set_gain_dB (ssid, argv[0]->f, msg);
876 else if (!strncmp (path, "/strip/fader/", 13) && strlen (path) > 13) {
878 int ssid = atoi (&path[13]);
879 ret = route_set_gain_fader (ssid, argv[0]->f, msg);
881 else if (!strncmp (path, "/strip/db_delta", 15)) {
886 if (strlen (path) > 15 && argc == 1) {
887 ssid = atoi (&path[16]);
888 } else if (argc == 2) {
889 if (types[0] == 'f') {
890 ssid = (int) argv[0]->f;
898 if (types[ar_off] == 'f') {
899 delta = argv[ar_off]->f;
901 delta = (float) argv[ar_off]->i;
903 ret = strip_db_delta (ssid, delta, msg);
905 else if (!strncmp (path, "/strip/trimdB/", 14) && strlen (path) > 14) {
906 int ssid = atoi (&path[14]);
907 ret = route_set_trim_dB (ssid, argv[0]->f, msg);
909 else if (!strncmp (path, "/strip/pan_stereo_position/", 27) && strlen (path) > 27) {
910 int ssid = atoi (&path[27]);
911 ret = route_set_pan_stereo_position (ssid, argv[0]->f, msg);
913 else if (!strncmp (path, "/strip/mute/", 12) && strlen (path) > 12) {
914 int ssid = atoi (&path[12]);
915 ret = route_mute (ssid, argv[0]->i, msg);
917 else if (!strncmp (path, "/strip/solo/", 12) && strlen (path) > 12) {
918 int ssid = atoi (&path[12]);
919 ret = route_solo (ssid, argv[0]->i, msg);
921 else if (!strncmp (path, "/strip/monitor_input/", 21) && strlen (path) > 21) {
922 int ssid = atoi (&path[21]);
923 ret = route_monitor_input (ssid, argv[0]->i, msg);
925 else if (!strncmp (path, "/strip/monitor_disk/", 20) && strlen (path) > 20) {
926 int ssid = atoi (&path[20]);
927 ret = route_monitor_disk (ssid, argv[0]->i, msg);
929 else if (!strncmp (path, "/strip/recenable/", 17) && strlen (path) > 17) {
930 int ssid = atoi (&path[17]);
931 ret = route_recenable (ssid, argv[0]->i, msg);
933 else if (!strncmp (path, "/strip/record_safe/", 19) && strlen (path) > 19) {
934 int ssid = atoi (&path[19]);
935 ret = route_recsafe (ssid, argv[0]->i, msg);
937 else if (!strncmp (path, "/strip/expand/", 14) && strlen (path) > 14) {
938 int ssid = atoi (&path[14]);
939 ret = strip_expand (ssid, argv[0]->i, msg);
941 else if (!strncmp (path, "/strip/select/", 14) && strlen (path) > 14) {
942 int ssid = atoi (&path[14]);
943 ret = strip_gui_select (ssid, argv[0]->i, msg);
945 if (strstr (path, "/select") && (argc != 1)) {
946 // All of the select commands below require 1 parameter
947 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
949 else if (!strncmp (path, "/select/send_gain/", 18) && strlen (path) > 18) {
950 int ssid = atoi (&path[18]);
951 ret = sel_sendgain (ssid, argv[0]->f, msg);
953 else if (!strncmp (path, "/select/send_fader/", 19) && strlen (path) > 19) {
954 int ssid = atoi (&path[19]);
955 ret = sel_sendfader (ssid, argv[0]->f, msg);
957 else if (!strncmp (path, "/select/send_enable/", 20) && strlen (path) > 20) {
958 int ssid = atoi (&path[20]);
959 ret = sel_sendenable (ssid, argv[0]->f, msg);
961 else if (!strncmp (path, "/select/eq_gain/", 16) && strlen (path) > 16) {
962 int ssid = atoi (&path[16]);
963 ret = sel_eq_gain (ssid, argv[0]->f, msg);
965 else if (!strncmp (path, "/select/eq_freq/", 16) && strlen (path) > 16) {
966 int ssid = atoi (&path[16]);
967 ret = sel_eq_freq (ssid, argv[0]->f , msg);
969 else if (!strncmp (path, "/select/eq_q/", 13) && strlen (path) > 13) {
970 int ssid = atoi (&path[13]);
971 ret = sel_eq_q (ssid, argv[0]->f, msg);
973 else if (!strncmp (path, "/select/eq_shape/", 17) && strlen (path) > 17) {
974 int ssid = atoi (&path[17]);
975 ret = sel_eq_shape (ssid, argv[0]->f, msg);
977 else if (!strncmp (path, "/set_surface", 12)) {
978 ret = surface_parse (path, types, argv, argc, msg);
980 else if (strstr (path, "/link")) {
981 ret = parse_link (path, types, argv, argc, msg);
987 if ((ret && _debugmode != Off)) {
988 debugmsg (_("Unhandled OSC message"), path, types, argv, argc);
989 } else if (!ret && _debugmode == All) {
990 debugmsg (_("OSC"), path, types, argv, argc);
997 OSC::debugmsg (const char *prefix, const char *path, const char* types, lo_arg **argv, int argc)
999 std::stringstream ss;
1000 for (int i = 0; i < argc; ++i) {
1001 lo_type type = (lo_type)types[i];
1005 ss << "i:" << argv[i]->i;
1008 ss << "f:" << argv[i]->f;
1011 ss << "d:" << argv[i]->d;
1014 ss << "s:" << &argv[i]->s;
1017 ss << "h:" << argv[i]->h;
1020 ss << "c:" << argv[i]->s;
1051 PBD::info << prefix << ": " << path << ss.str() << endmsg;
1054 // "Application Hook" Handlers //
1056 OSC::session_loaded (Session& s)
1058 // lo_address listener = lo_address_new (NULL, "7770");
1059 // lo_send (listener, "/session/loaded", "ss", s.path().c_str(), s.name().c_str());
1063 OSC::session_exported (std::string path, std::string name)
1065 lo_address listener = lo_address_new (NULL, "7770");
1066 lo_send (listener, "/session/exported", "ss", path.c_str(), name.c_str());
1067 lo_address_free (listener);
1070 // end "Application Hook" Handlers //
1072 /* path callbacks */
1075 OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv*/, int /*argc*/, void */*data*/, void* /*user_data*/)
1080 if (argc < 3 || types == 0 || strlen (types) < 3 || types[0] != 's' || types[1] != 's' || types[2] != s) {
1084 const char *returl = argv[1]->s;
1085 lo_address addr = find_or_cache_addr (returl);
1087 const char *retpath = argv[2]->s;
1090 if (strcmp (argv[0]->s, "transport_frame") == 0) {
1093 lo_send (addr, retpath, "i", session->transport_sample());
1096 } else if (strcmp (argv[0]->s, "transport_speed") == 0) {
1099 lo_send (addr, retpath, "i", session->transport_sample());
1102 } else if (strcmp (argv[0]->s, "transport_locked") == 0) {
1105 lo_send (addr, retpath, "i", session->transport_sample());
1108 } else if (strcmp (argv[0]->s, "punch_in") == 0) {
1111 lo_send (addr, retpath, "i", session->transport_sample());
1114 } else if (strcmp (argv[0]->s, "punch_out") == 0) {
1117 lo_send (addr, retpath, "i", session->transport_sample());
1120 } else if (strcmp (argv[0]->s, "rec_enable") == 0) {
1123 lo_send (addr, retpath, "i", session->transport_sample());
1135 OSC::routes_list (lo_message msg)
1140 OSCSurface *sur = get_surface(get_address (msg), true);
1142 for (int n = 0; n < (int) sur->nstrips; ++n) {
1144 boost::shared_ptr<Stripable> s = get_strip (n + 1, get_address (msg));
1147 // some things need the route
1148 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
1150 lo_message reply = lo_message_new ();
1152 if (boost::dynamic_pointer_cast<AudioTrack>(s)) {
1153 lo_message_add_string (reply, "AT");
1154 } else if (boost::dynamic_pointer_cast<MidiTrack>(s)) {
1155 lo_message_add_string (reply, "MT");
1156 } else if (boost::dynamic_pointer_cast<VCA>(s)) {
1157 lo_message_add_string (reply, "V");
1158 } else if (s->is_master()) {
1159 lo_message_add_string (reply, "MA");
1160 } else if (s->is_monitor()) {
1161 lo_message_add_string (reply, "MO");
1162 } else if (boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
1163 if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
1164 // r->feeds (session->master_out()) may make more sense
1165 if (r->direct_feeds_according_to_reality (session->master_out())) {
1167 lo_message_add_string (reply, "B");
1169 // this is an Aux out
1170 lo_message_add_string (reply, "AX");
1173 lo_message_add_string (reply, "MB");
1177 lo_message_add_string (reply, s->name().c_str());
1179 // routes have inputs and outputs
1180 lo_message_add_int32 (reply, r->n_inputs().n_audio());
1181 lo_message_add_int32 (reply, r->n_outputs().n_audio());
1183 // non-routes like VCAs don't
1184 lo_message_add_int32 (reply, 0);
1185 lo_message_add_int32 (reply, 0);
1187 if (s->mute_control()) {
1188 lo_message_add_int32 (reply, s->mute_control()->get_value());
1190 lo_message_add_int32 (reply, 0);
1192 if (s->solo_control()) {
1193 lo_message_add_int32 (reply, s->solo_control()->get_value());
1195 lo_message_add_int32 (reply, 0);
1197 lo_message_add_int32 (reply, n + 1);
1198 if (s->rec_enable_control()) {
1199 lo_message_add_int32 (reply, s->rec_enable_control()->get_value());
1201 if (sur->feedback[14]) {
1202 lo_send_message (get_address (msg), "/reply", reply);
1204 lo_send_message (get_address (msg), "#reply", reply);
1206 lo_message_free (reply);
1210 // Send end of listing message
1211 lo_message reply = lo_message_new ();
1213 lo_message_add_string (reply, "end_route_list");
1214 lo_message_add_int64 (reply, session->sample_rate());
1215 lo_message_add_int64 (reply, session->current_end_sample());
1216 if (session->monitor_out()) {
1217 // this session has a monitor section
1218 lo_message_add_int32 (reply, 1);
1220 lo_message_add_int32 (reply, 0);
1223 if (sur->feedback[14]) {
1224 lo_send_message (get_address (msg), "/reply", reply);
1226 lo_send_message (get_address (msg), "#reply", reply);
1229 lo_message_free (reply);
1230 // send feedback for newly created control surface
1231 strip_feedback (sur, true);
1232 global_feedback (sur);
1233 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
1238 OSC::surface_list (lo_message msg)
1240 /* this function is for debugging and prints lots of
1241 * information about what surfaces Ardour knows about and their
1242 * internal parameters. It is best accessed by sending:
1243 * /surface/list from oscsend. This command does not create
1247 cerr << "List of known Surfaces: " << _surface.size() << "\n\n";
1249 Glib::Threads::Mutex::Lock lm (surfaces_lock);
1250 for (uint32_t it = 0; it < _surface.size(); it++) {
1251 OSCSurface* sur = &_surface[it];
1252 cerr << string_compose (" Surface: %1 URL: %2\n", it, sur->remote_url);
1253 cerr << string_compose (" Number of strips: %1 Bank size: %2 Current Bank %3\n", sur->nstrips, sur->bank_size, sur->bank);
1254 cerr << string_compose (" Use Custom: %1 Custom Strips: %2\n", sur->custom_enable, sur->custom_strips.size ());
1256 if (sur->usegroup == PBD::Controllable::UseGroup) {
1259 cerr << string_compose (" Strip Types: %1 Feedback: %2 no_clear: %3 gain mode: %4 use groups? %5\n", \
1260 sur->strip_types.to_ulong(), sur->feedback.to_ulong(), sur->no_clear, sur->gainmode, ug);
1261 cerr << string_compose (" using plugin: %1 of %2 plugins, with %3 params. page size: %4 page: %5\n", \
1262 sur->plugin_id, sur->plugins.size(), sur->plug_params.size(), sur->plug_page_size, sur->plug_page);
1263 cerr << string_compose (" send page size: %1 page: %2\n", sur->send_page_size, sur->send_page);
1264 cerr << string_compose (" expanded? %1 track: %2 jogmode: %3\n", sur->expand_enable, sur->expand, sur->jogmode);
1265 cerr << string_compose (" personal monitor? %1, Aux master: %2, number of sends: %3\n", sur->cue, sur->aux, sur->sends.size());
1266 cerr << string_compose (" Linkset: %1 Device Id: %2\n", sur->linkset, sur->linkid);
1268 cerr << "\nList of LinkSets " << link_sets.size() << "\n\n";
1269 std::map<uint32_t, LinkSet>::iterator it;
1270 for (it = link_sets.begin(); it != link_sets.end(); it++) {
1274 uint32_t devices = 0;
1275 LinkSet* set = &(*it).second;
1276 if (set->urls.size()) {
1277 devices = set->urls.size() - 1;
1279 cerr << string_compose (" Linkset %1 has %2 devices and sees %3 strips\n", (*it).first, devices, set->strips.size());
1280 cerr << string_compose (" Bank size: %1 Current bank: %2 Strip Types: %3\n", set->banksize, set->bank, set->strip_types.to_ulong());
1281 cerr << string_compose (" auto bank sizing: %1 linkset not ready: %2\n", set->autobank, set->not_ready);
1287 OSC::custom_clear (lo_message msg)
1292 OSCSurface *sur = get_surface(get_address (msg), true);
1293 sur->custom_enable = false;
1294 sur->custom_strips.clear ();
1295 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, false, sur->custom_strips);
1296 sur->nstrips = sur->strips.size();
1297 return set_bank (1, msg);
1301 OSC::custom_enable (float state, lo_message msg)
1306 OSCSurface *sur = get_surface(get_address (msg), true);
1308 if (sur->custom_strips.size () == 0) {
1309 PBD::warning << "No custom strips set to enable" << endmsg;
1310 sur->custom_enable = false;
1313 sur->custom_enable = true;
1314 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, true, sur->custom_strips);
1315 sur->nstrips = sur->custom_strips.size();
1316 return set_bank (1, msg);
1319 sur->custom_enable = false;
1320 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, false, sur->custom_strips);
1321 sur->nstrips = sur->strips.size();
1322 return set_bank (1, msg);
1328 OSC::cancel_all_solos ()
1330 session->cancel_all_solo ();
1335 OSC::get_address (lo_message msg)
1338 lo_address addr = lo_message_get_source (msg);
1339 string host = lo_address_get_hostname (addr);
1340 int protocol = lo_address_get_protocol (addr);
1341 return lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str());
1343 return lo_message_get_source (msg);
1348 OSC::refresh_surface (lo_message msg)
1350 OSCSurface *s = get_surface(get_address (msg), true);
1351 uint32_t bs = s->bank_size;
1352 uint32_t st = (uint32_t) s->strip_types.to_ulong();
1353 uint32_t fb = (uint32_t) s->feedback.to_ulong();
1354 uint32_t gm = (uint32_t) s->gainmode;
1355 uint32_t sp = s->send_page_size;
1356 uint32_t pp = s->plug_page_size;
1358 surface_destroy (s);
1359 // restart all observers
1360 set_surface (bs, st, fb, gm, sp, pp, msg);
1365 OSC::clear_devices ()
1368 observer_busy = true;
1369 session_connections.drop_connections ();
1370 // clear out surfaces
1371 for (uint32_t it = 0; it < _surface.size(); ++it) {
1372 OSCSurface* sur = &_surface[it];
1373 surface_destroy (sur);
1378 PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
1380 observer_busy = false;
1385 OSC::parse_link (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
1387 int ret = 1; /* unhandled */
1390 PBD::warning << "OSC: /link/* needs at least one parameter" << endmsg;
1394 if (types[argc - 1] == 'f') {
1395 data = argv[argc - 1]->f;
1397 data = argv[argc - 1]->i;
1399 if (isdigit(strrchr (path, '/')[1])) {
1400 set = atoi (&(strrchr (path, '/')[1]));
1401 } else if (argc == 2) {
1402 if (types[0] == 'f') {
1403 set = (int) argv[0]->f;
1408 PBD::warning << "OSC: wrong number of parameters." << endmsg;
1411 LinkSet *ls = get_linkset (set, get_address (msg));
1416 if (!strncmp (path, "/link/bank_size", 15)) {
1417 ls->banksize = (uint32_t) data;
1418 ls->autobank = false;
1419 ls->not_ready = link_check (set);
1420 if (ls->not_ready) {
1422 surface_link_state (ls);
1424 _set_bank (ls->bank, get_address (msg));
1428 } else if (!strncmp (path, "/link/set", 9)) {
1429 ret = set_link (set, (uint32_t) data, get_address (msg));
1436 OSC::get_linkset (uint32_t set, lo_address addr)
1438 OSCSurface *sur = get_surface(addr);
1442 // need to check if set is wanted
1443 std::map<uint32_t, LinkSet>::iterator it;
1444 it = link_sets.find(set);
1445 if (it == link_sets.end()) {
1446 // no such linkset make it
1448 new_ls.banksize = 0;
1450 new_ls.autobank = true;
1451 new_ls.not_ready = true;
1452 new_ls.strip_types = sur->strip_types;
1453 new_ls.strips = sur->strips;
1454 new_ls.urls.resize (2);
1455 link_sets[set] = new_ls;
1457 ls = &link_sets[set];
1460 // User expects this surface to be removed from any sets
1461 uint32_t oldset = sur->linkset;
1463 uint32_t oldid = sur->linkid;
1466 LinkSet *ols = &link_sets[oldset];
1468 ols->not_ready = oldid;
1469 ols->urls[oldid] = "";
1470 surface_link_state (ols);
1478 OSC::set_link (uint32_t set, uint32_t id, lo_address addr)
1480 OSCSurface *sur = get_surface(addr, true);
1483 LinkSet *ls = get_linkset (set, addr);
1484 if (ls->urls.size() <= (uint32_t) id) {
1485 ls->urls.resize ((int) id + 1);
1487 ls->urls[(uint32_t) id] = sur->remote_url;
1488 ls->not_ready = link_check (set);
1489 if (ls->not_ready) {
1490 surface_link_state (ls);
1492 _set_bank (1, addr);
1498 OSC::link_strip_types (uint32_t linkset, uint32_t striptypes)
1505 std::map<uint32_t, LinkSet>::iterator it;
1506 it = link_sets.find(linkset);
1507 if (it == link_sets.end()) {
1508 // this should never happen... but
1511 ls = &link_sets[linkset];
1512 ls->strip_types = striptypes;
1513 for (uint32_t dv = 1; dv < ls->urls.size(); dv++) {
1516 if (ls->urls[dv] != "") {
1517 string url = ls->urls[dv];
1518 su = get_surface (lo_address_new_from_url (url.c_str()), true);
1519 if (su->linkset == linkset) {
1520 su->strip_types = striptypes;
1521 if (su->strip_types[10]) {
1522 su->usegroup = PBD::Controllable::UseGroup;
1524 su->usegroup = PBD::Controllable::NoGroup;
1534 OSC::surface_link_state (LinkSet * set)
1536 for (uint32_t dv = 1; dv < set->urls.size(); dv++) {
1538 if (set->urls[dv] != "") {
1539 string url = set->urls[dv];
1540 OSCSurface *sur = get_surface (lo_address_new_from_url (url.c_str()), true);
1541 for (uint32_t i = 0; i < sur->observers.size(); i++) {
1542 sur->observers[i]->set_link_ready (set->not_ready);
1549 OSC::link_check (uint32_t set)
1556 std::map<uint32_t, LinkSet>::iterator it;
1557 it = link_sets.find(set);
1558 if (it == link_sets.end()) {
1559 // this should never happen... but
1562 ls = &link_sets[set];
1563 uint32_t bank_total = 0;
1564 for (uint32_t dv = 1; dv < ls->urls.size(); dv++) {
1567 if (ls->urls[dv] != "") {
1568 string url = ls->urls[dv];
1569 su = get_surface (lo_address_new_from_url (url.c_str()), true);
1573 if (su->linkset == set) {
1574 bank_total = bank_total + su->bank_size;
1580 ls->banksize = bank_total;
1582 if (bank_total != ls->banksize) {
1583 return ls->urls.size();
1591 OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
1593 int ret = 1; /* unhandled */
1594 OSCSurface *sur = get_surface(get_address (msg), true);
1595 int pi_page = sur->plug_page_size;
1596 int se_page = sur->send_page_size;
1597 int fadermode = sur->gainmode;
1598 int feedback = sur->feedback.to_ulong();
1599 int strip_types = sur->strip_types.to_ulong();
1600 int bank_size = sur->bank_size;
1601 int linkset = sur->linkset;
1602 int linkid = sur->linkid;
1605 if (argc == 1 && !strncmp (path, "/set_surface/feedback", 21)) {
1606 if (types[0] == 'f') {
1607 ret = set_surface_feedback ((int)argv[0]->f, msg);
1609 ret = set_surface_feedback (argv[0]->i, msg);
1612 else if (argc == 1 && !strncmp (path, "/set_surface/bank_size", 22)) {
1613 if (types[0] == 'f') {
1614 ret = set_surface_bank_size ((int)argv[0]->f, msg);
1616 ret = set_surface_bank_size (argv[0]->i, msg);
1619 else if (argc == 1 && !strncmp (path, "/set_surface/gainmode", 21)) {
1620 if (types[0] == 'f') {
1621 ret = set_surface_gainmode ((int)argv[0]->f, msg);
1623 ret = set_surface_gainmode (argv[0]->i, msg);
1626 else if (argc == 1 && !strncmp (path, "/set_surface/strip_types", 24)) {
1627 if (types[0] == 'f') {
1628 ret = set_surface_strip_types ((int)argv[0]->f, msg);
1630 ret = set_surface_strip_types (argv[0]->i, msg);
1633 else if (argc == 1 && !strncmp (path, "/set_surface/send_page_size", 27)) {
1634 if (types[0] == 'f') {
1635 ret = sel_send_pagesize ((int)argv[0]->f, msg);
1637 ret = sel_send_pagesize (argv[0]->i, msg);
1640 else if (argc == 1 && !strncmp (path, "/set_surface/plugin_page_size", 29)) {
1641 if (types[0] == 'f') {
1642 ret = sel_plug_pagesize ((int)argv[0]->f, msg);
1644 ret = sel_plug_pagesize (argv[0]->i, msg);
1646 } else if (strlen(path) == 12) {
1648 // command is in /set_surface iii form
1651 if (types[7] == 'f') {
1652 linkid = (int) argv[7]->f;
1654 linkid = argv[7]->i;
1657 if (types[6] == 'f') {
1658 linkset = (int) argv[6]->f;
1660 linkset = argv[6]->i;
1663 if (types[5] == 'f') {
1664 pi_page = (int) argv[5]->f;
1666 pi_page = argv[5]->i;
1669 if (types[4] == 'f') {
1670 se_page = (int) argv[4]->f;
1672 se_page = argv[4]->i;
1675 if (types[3] == 'f') {
1676 fadermode = (int) argv[3]->f;
1678 fadermode = argv[3]->i;
1681 if (types[2] == 'f') {
1682 feedback = (int) argv[2]->f;
1684 feedback = argv[2]->i;
1687 if (types[1] == 'f') {
1688 strip_types = (int) argv[1]->f;
1690 strip_types = argv[1]->i;
1693 if (types[0] == 'f') {
1694 bank_size = (int) argv[0]->f;
1696 bank_size = argv[0]->i;
1698 ret = set_surface (bank_size, strip_types, feedback, fadermode, se_page, pi_page, msg);
1699 if ((uint32_t) linkset != sur->linkset) {
1700 set_link (linkset, linkid, get_address (msg));
1704 // send current setup
1706 lo_message reply = lo_message_new ();
1707 lo_message_add_int32 (reply, bank_size);
1708 lo_message_add_int32 (reply, strip_types);
1709 lo_message_add_int32 (reply, feedback);
1710 lo_message_add_int32 (reply, fadermode);
1711 lo_message_add_int32 (reply, se_page);
1712 lo_message_add_int32 (reply, pi_page);
1713 lo_message_add_int32 (reply, (int) linkset);
1714 lo_message_add_int32 (reply, (int) linkid);
1715 lo_send_message (get_address (msg), "/set_surface", reply);
1716 lo_message_free (reply);
1722 PBD::warning << "OSC: Too many parameters." << endmsg;
1726 } else if (isdigit(path[13])) {
1727 // some of our parameters must be "in-lined"
1728 bank_size = atoi (&path[13]);
1729 const char * par = strstr (&path[13], "/");
1731 strip_types = atoi (&par[1]);
1732 const char * fb = strstr (&par[1], "/");
1734 feedback = atoi (&fb[1]);
1735 const char * fm = strstr (&fb[1], "/");
1737 fadermode = atoi (&fm[1]);
1738 const char * sp = strstr (&fm[1], "/");
1740 se_page = atoi (&sp[1]);
1741 const char * pp = strstr (&sp[1], "/");
1743 pi_page = atoi (&pp[1]);
1744 const char * ls = strstr (&pp[1], "/");
1746 linkset = atoi (&ls[1]);
1747 const char * li = strstr (&ls[1], "/");
1749 linkid = atoi (&li[1]);
1751 if (types[0] == 'f') {
1752 linkid = (int) argv[0]->f;
1753 } else if (types[0] == 'i') {
1754 linkid = argv[0]->i;
1758 if (types[0] == 'f') {
1759 linkset = (int) argv[0]->f;
1760 } else if (types[0] == 'i') {
1761 linkset = argv[0]->i;
1765 if (types[0] == 'f') {
1766 pi_page = (int) argv[0]->f;
1767 } else if (types[0] == 'i') {
1768 pi_page = argv[0]->i;
1772 if (types[0] == 'f') {
1773 se_page = (int) argv[0]->f;
1774 } else if (types[0] == 'i') {
1775 se_page = argv[0]->i;
1779 if (types[0] == 'f') {
1780 fadermode = (int) argv[0]->f;
1781 } else if (types[0] == 'i') {
1782 fadermode = argv[0]->i;
1786 if (types[0] == 'f') {
1787 feedback = (int) argv[0]->f;
1788 } else if (types[0] == 'i') {
1789 feedback = argv[0]->i;
1793 if (types[0] == 'f') {
1794 strip_types = (int) argv[0]->f;
1795 } else if (types[0] == 'i') {
1796 strip_types = argv[0]->i;
1799 ret = set_surface (bank_size, strip_types, feedback, fadermode, se_page, pi_page, msg);
1800 if ((uint32_t) linkset != sur->linkset) {
1801 set_link (linkset, linkid, get_address (msg));
1808 OSC::set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gm, uint32_t se_size, uint32_t pi_size, lo_message msg)
1810 if (observer_busy) {
1813 OSCSurface *s = get_surface(get_address (msg), true);
1814 s->bank_size = b_size;
1815 s->strip_types = strips;
1818 if (s->strip_types[10]) {
1819 s->usegroup = PBD::Controllable::UseGroup;
1821 s->usegroup = PBD::Controllable::NoGroup;
1823 s->send_page_size = se_size;
1824 s->plug_page_size = pi_size;
1826 set_link (s->linkset, s->linkid, get_address (msg));
1827 link_strip_types (s->linkset, s->strip_types.to_ulong());
1829 // set bank and strip feedback
1830 strip_feedback(s, true);
1831 _set_bank (1, get_address (msg));
1834 global_feedback (s);
1835 sel_send_pagesize (se_size, msg);
1836 sel_plug_pagesize (pi_size, msg);
1841 OSC::set_surface_bank_size (uint32_t bs, lo_message msg)
1843 if (observer_busy) {
1846 OSCSurface *s = get_surface(get_address (msg), true);
1849 set_link (s->linkset, s->linkid, get_address (msg));
1851 // set bank and strip feedback
1852 _set_bank (1, get_address (msg));
1858 OSC::set_surface_strip_types (uint32_t st, lo_message msg)
1860 if (observer_busy) {
1863 OSCSurface *s = get_surface(get_address (msg), true);
1864 s->strip_types = st;
1865 if (s->strip_types[10]) {
1866 s->usegroup = PBD::Controllable::UseGroup;
1868 s->usegroup = PBD::Controllable::NoGroup;
1871 link_strip_types (s->linkset, st);
1874 // set bank and strip feedback
1875 _set_bank (1, get_address (msg));
1881 OSC::set_surface_feedback (uint32_t fb, lo_message msg)
1883 if (observer_busy) {
1886 OSCSurface *s = get_surface(get_address (msg), true);
1889 strip_feedback (s, true);
1890 global_feedback (s);
1891 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
1896 OSC::set_surface_gainmode (uint32_t gm, lo_message msg)
1898 if (observer_busy) {
1901 OSCSurface *s = get_surface(get_address (msg), true);
1904 strip_feedback (s, true);
1905 global_feedback (s);
1906 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
1911 OSC::check_surface (lo_message msg)
1916 get_surface(get_address (msg));
1921 OSC::get_surface (lo_address addr , bool quiet)
1926 string host = lo_address_get_hostname (addr);
1927 int protocol = lo_address_get_protocol (addr);
1928 addr = lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str());
1931 rurl = lo_address_get_url (addr);
1935 for (uint32_t it = 0; it < _surface.size(); ++it) {
1936 //find setup for this surface
1937 if (!_surface[it].remote_url.find(r_url)){
1938 return &_surface[it];
1943 // No surface create one with default values
1945 s.remote_url = r_url;
1949 s.bank_size = default_banksize;
1950 s.observers.clear();
1953 s.strip_types = default_strip;
1954 s.feedback = default_feedback;
1955 s.gainmode = default_gainmode;
1956 s.usegroup = PBD::Controllable::NoGroup;
1957 s.custom_strips.clear ();
1958 s.custom_enable = false;
1961 s.expand_enable = false;
1965 s.strips = get_sorted_stripables(s.strip_types, s.cue, false, s.custom_strips);
1967 s.send_page_size = default_send_size;
1969 s.plug_page_size = default_plugin_size;
1974 s.nstrips = s.strips.size();
1976 _surface.push_back (s);
1980 strip_feedback (&s, true);
1981 global_feedback (&s);
1982 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
1985 return &_surface[_surface.size() - 1];
1988 // setup global feedback for a surface
1990 OSC::global_feedback (OSCSurface* sur)
1992 if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) {
1994 // create a new Global Observer for this surface
1995 OSCGlobalObserver* o = new OSCGlobalObserver (*this, *session, sur);
1996 sur->global_obs = o;
2001 OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
2003 if (sur->custom_strips.size () == 0) {
2004 sur->custom_enable = false;
2006 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_enable, sur->custom_strips);
2007 sur->nstrips = sur->strips.size();
2008 if (new_bank_size || (!sur->feedback[0] && !sur->feedback[1])) {
2009 // delete old observers
2010 for (uint32_t i = 0; i < sur->observers.size(); i++) {
2011 if (!sur->bank_size) {
2012 sur->observers[i]->clear_strip ();
2014 delete sur->observers[i];
2016 sur->observers.clear();
2018 uint32_t bank_size = sur->bank_size;
2020 bank_size = sur->nstrips;
2023 if (sur->feedback[0] || sur->feedback[1]) {
2024 for (uint32_t i = 0; i < bank_size; i++) {
2025 OSCRouteObserver* o = new OSCRouteObserver (*this, i + 1, sur);
2026 sur->observers.push_back (o);
2030 if (sur->feedback[0] || sur->feedback[1]) {
2031 for (uint32_t i = 0; i < sur->observers.size(); i++) {
2032 boost::shared_ptr<ARDOUR::Stripable> str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str()));
2033 sur->observers[i]->refresh_strip(str, true);
2041 OSC::notify_routes_added (ARDOUR::RouteList &)
2043 // not sure if we need this PI change seems to cover
2048 OSC::notify_vca_added (ARDOUR::VCAList &)
2050 // not sure if we need this PI change seems to cover
2062 OSC::_recalcbanks ()
2064 if (observer_busy) {
2068 * We have two different ways of working here:
2069 * 1) banked: The controller has a bank of strips and only can deal
2070 * with banksize strips. We start banksize observers which run until
2071 * either banksize is changed or Ardour exits.
2073 * 2) banksize is 0 or unlimited and so is the same size as the number
2074 * of strips. For a recalc, We want to tear down all strips but not send
2075 * a reset value for any of the controls and then rebuild all observers.
2076 * this is easier than detecting change in "bank" size and deleting or
2077 * adding just a few.
2080 // refresh each surface we know about.
2081 for (uint32_t it = 0; it < _surface.size(); ++it) {
2082 OSCSurface* sur = &_surface[it];
2084 lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
2086 _cue_set (sur->aux, addr);
2087 } else if (!sur->bank_size) {
2088 strip_feedback (sur, true);
2089 // This surface uses /strip/list tell it routes have changed
2091 reply = lo_message_new ();
2092 lo_send_message (addr, "/strip/list", reply);
2093 lo_message_free (reply);
2095 strip_feedback (sur, false);
2097 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
2102 OSC::set_bank (uint32_t bank_start, lo_message msg)
2104 return _set_bank (bank_start, get_address (msg));
2107 // set bank is callable with either message or address
2109 OSC::_set_bank (uint32_t bank_start, lo_address addr)
2114 if (!session->nroutes()) {
2118 OSCSurface *s = get_surface (addr, true);
2120 Sorted striplist = s->strips;
2121 uint32_t nstrips = s->nstrips;
2124 uint32_t ls = s->linkset;
2127 //we have a linkset... deal with each surface
2128 set = &(link_sets[ls]);
2129 if (set->not_ready) {
2132 uint32_t d_count = set->urls.size();
2133 set->strips = striplist;
2134 bank_start = bank_limits_check (bank_start, set->banksize, nstrips);
2135 set->bank = bank_start;
2136 uint32_t not_ready = 0;
2137 for (uint32_t dv = 1; dv < d_count; dv++) {
2139 if (set->urls[dv] != "") {
2140 string url = set->urls[dv];
2141 sur = get_surface (lo_address_new_from_url (url.c_str()));
2145 if (sur->linkset != ls) {
2150 if (!set->not_ready) {
2151 set->not_ready = not_ready;
2156 lo_address sur_addr = lo_address_new_from_url (sur->remote_url.c_str());
2158 sur->bank = bank_start;
2159 bank_start = bank_start + sur->bank_size;
2160 strip_feedback (sur, false);
2161 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), sur_addr);
2163 lo_address_free (sur_addr);
2166 surface_link_state (set);
2171 s->bank = bank_limits_check (bank_start, s->bank_size, nstrips);
2172 strip_feedback (s, true);
2173 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
2184 OSC::bank_limits_check (uint32_t bank, uint32_t size, uint32_t total)
2188 // no banking - bank includes all stripables
2193 // Do limits checking
2194 if (bank < 1) bank = 1;
2195 if (b_size >= total) {
2197 } else if (bank > ((total - b_size) + 1)) {
2198 // top bank is always filled if there are enough strips for at least one bank
2199 bank = (uint32_t)((total - b_size) + 1);
2205 OSC::bank_leds (OSCSurface* s)
2210 // light bankup or bankdown buttons if it is possible to bank in that direction
2211 lo_address addr = lo_address_new_from_url (s->remote_url.c_str());
2214 set = &(link_sets[s->linkset]);
2216 size = set->banksize;
2218 if (set->not_ready) {
2223 size = s->bank_size;
2226 if (size && (s->feedback[0] || s->feedback[1] || s->feedback[4])) {
2228 reply = lo_message_new ();
2229 if ((total <= size) || (bank > (total - size))) {
2230 lo_message_add_int32 (reply, 0);
2232 lo_message_add_int32 (reply, 1);
2234 lo_send_message (addr, "/bank_up", reply);
2235 lo_message_free (reply);
2236 reply = lo_message_new ();
2238 lo_message_add_int32 (reply, 1);
2240 lo_message_add_int32 (reply, 0);
2242 lo_send_message (addr, "/bank_down", reply);
2243 lo_message_free (reply);
2248 OSC::bank_up (lo_message msg)
2250 return bank_delta (1.0, msg);
2254 OSC::bank_delta (float delta, lo_message msg)
2259 // only do deltas of -1 0 or 1
2262 } else if (delta < 0) {
2265 // 0 key release ignore
2268 OSCSurface *s = get_surface(get_address (msg));
2269 if (!s->bank_size) {
2270 // bank size of 0 means use all strips no banking
2273 uint32_t old_bank = 0;
2274 uint32_t bank_size = 0;
2276 old_bank = link_sets[s->linkset].bank;
2277 bank_size = link_sets[s->linkset].banksize;
2280 bank_size = s->bank_size;
2282 uint32_t new_bank = old_bank + (bank_size * (int) delta);
2283 if ((int)new_bank < 1) {
2286 if (new_bank != old_bank) {
2287 set_bank (new_bank, msg);
2293 OSC::bank_down (lo_message msg)
2295 return bank_delta (-1.0, msg);
2299 OSC::use_group (float value, lo_message msg)
2304 OSCSurface *s = get_surface(get_address (msg));
2306 s->usegroup = PBD::Controllable::UseGroup;
2308 s->usegroup = PBD::Controllable::NoGroup;
2314 OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
2320 OSCSurface *s = get_surface(addr);
2323 if (!s->bank_size) {
2325 b_size = s->nstrips;
2327 b_size = s->bank_size;
2330 for (uint32_t n = s->bank; n < (min ((b_size + s->bank), s->nstrips + 1)); ++n) {
2331 if (n <= s->strips.size()) {
2332 if (strip == s->strips[n-1]) {
2333 return n - s->bank + 1;
2337 // failsafe... should never get here.
2341 boost::shared_ptr<ARDOUR::Stripable>
2342 OSC::get_strip (uint32_t ssid, lo_address addr)
2344 OSCSurface *s = get_surface(addr);
2345 if (ssid && ((ssid + s->bank - 2) < s->nstrips)) {
2346 return s->strips[ssid + s->bank - 2];
2348 // guess it is out of range
2349 return boost::shared_ptr<ARDOUR::Stripable>();
2352 // send and plugin paging commands
2354 OSC::sel_send_pagesize (uint32_t size, lo_message msg)
2356 OSCSurface *s = get_surface(get_address (msg));
2357 if (size != s->send_page_size) {
2358 s->send_page_size = size;
2359 s->sel_obs->set_send_size(size);
2365 OSC::sel_send_page (int page, lo_message msg)
2367 OSCSurface *s = get_surface(get_address (msg));
2368 uint32_t send_size = s->send_page_size;
2370 send_size = s->nsends;
2372 uint32_t max_page = (uint32_t)(s->nsends / send_size) + 1;
2373 s->send_page = s->send_page + page;
2374 if (s->send_page < 1) {
2376 } else if ((uint32_t)s->send_page > max_page) {
2377 s->send_page = max_page;
2379 s->sel_obs->set_send_page (s->send_page);
2384 OSC::sel_plug_pagesize (uint32_t size, lo_message msg)
2386 OSCSurface *s = get_surface(get_address (msg));
2387 if (size != s->plug_page_size) {
2388 s->plug_page_size = size;
2389 s->sel_obs->set_plugin_size(size);
2395 OSC::sel_plug_page (int page, lo_message msg)
2401 OSCSurface *s = get_surface(get_address (msg));
2403 new_page = s->plug_page + s->plug_page_size;
2404 if ((uint32_t) new_page > s->plug_params.size ()) {
2405 new_page = s->plug_page;
2408 new_page = s->plug_page - s->plug_page_size;
2413 if (new_page != s->plug_page) {
2414 s->plug_page = new_page;
2415 s->sel_obs->set_plugin_page(s->plug_page);
2421 OSC::sel_plugin (int delta, lo_message msg)
2426 OSCSurface *sur = get_surface(get_address (msg));
2427 return _sel_plugin (sur->plugin_id + delta, get_address (msg));
2431 OSC::_sel_plugin (int id, lo_address addr)
2433 OSCSurface *sur = get_surface(addr);
2434 boost::shared_ptr<Stripable> s = sur->select;
2436 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
2441 // find out how many plugins we have
2444 sur->plugins.clear();
2447 if (r->nth_plugin (nplugs)) {
2448 if (r->nth_plugin(nplugs)->display_to_user()) {
2450 // need to check for mixbus channel strips (and exclude them)
2451 boost::shared_ptr<Processor> proc = r->nth_plugin (nplugs);
2452 boost::shared_ptr<PluginInsert> pi;
2453 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
2455 if (!pi->is_channelstrip()) {
2457 sur->plugins.push_back (nplugs);
2468 // limit plugin_id to actual plugins
2469 if (sur->plugins.size() < 1) {
2473 sur->sel_obs->set_plugin_id(-1, 1);
2476 } else if (id < 1) {
2478 } else if (sur->plugins.size() < (uint32_t) id) {
2479 sur->plugin_id = sur->plugins.size();
2481 sur->plugin_id = id;
2484 // we have a plugin number now get the processor
2485 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
2486 boost::shared_ptr<PluginInsert> pi;
2487 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
2488 PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg;
2491 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
2493 // put only input controls into a vector
2494 sur->plug_params.clear ();
2495 uint32_t nplug_params = pip->parameter_count();
2496 for ( uint32_t ppi = 0; ppi < nplug_params; ++ppi) {
2497 uint32_t controlid = pip->nth_parameter(ppi, ok);
2501 if (pip->parameter_is_input(controlid)) {
2502 sur->plug_params.push_back (ppi);
2509 sur->sel_obs->set_plugin_id(sur->plugins[sur->plugin_id - 1], sur->plug_page);
2517 OSC::transport_sample (lo_message msg)
2522 check_surface (msg);
2523 samplepos_t pos = session->transport_sample ();
2525 lo_message reply = lo_message_new ();
2526 lo_message_add_int64 (reply, pos);
2528 lo_send_message (get_address (msg), "/transport_frame", reply);
2530 lo_message_free (reply);
2534 OSC::transport_speed (lo_message msg)
2539 check_surface (msg);
2540 double ts = session->transport_speed ();
2542 lo_message reply = lo_message_new ();
2543 lo_message_add_double (reply, ts);
2545 lo_send_message (get_address (msg), "/transport_speed", reply);
2547 lo_message_free (reply);
2551 OSC::record_enabled (lo_message msg)
2556 check_surface (msg);
2557 int re = (int)session->get_record_enabled ();
2559 lo_message reply = lo_message_new ();
2560 lo_message_add_int32 (reply, re);
2562 lo_send_message (get_address (msg), "/record_enabled", reply);
2564 lo_message_free (reply);
2568 OSC::scrub (float delta, lo_message msg)
2570 if (!session) return -1;
2571 check_surface (msg);
2573 scrub_place = session->transport_sample ();
2577 int64_t now = ARDOUR::get_microseconds ();
2578 int64_t diff = now - scrub_time;
2580 // speed 1 (or 0 if jog wheel supports touch)
2582 } else if ((diff > 20000) && (fabs(scrub_speed) == 1)) {
2583 // add some hysteresis to stop excess speed jumps
2586 speed = (int)(delta * 2);
2589 if (scrub_speed == speed) {
2590 // Already at that speed no change
2593 scrub_speed = speed;
2597 session->request_transport_speed (.5);
2599 session->request_transport_speed (9.9);
2601 } else if (speed < 0) {
2603 session->request_transport_speed (-.5);
2605 session->request_transport_speed (-1);
2608 session->request_transport_speed (0);
2615 OSC::jog (float delta, lo_message msg)
2617 if (!session) return -1;
2619 OSCSurface *s = get_surface(get_address (msg));
2621 string path = "/jog/mode/name";
2625 text_message (path, "Jog", get_address (msg));
2627 jump_by_seconds (delta / 5);
2631 text_message (path, "Scrub", get_address (msg));
2635 text_message (path, "Shuttle", get_address (msg));
2637 double speed = get_transport_speed ();
2638 set_transport_speed (speed + (delta / 8.1));
2640 set_transport_speed (0);
2644 text_message (path, "Scroll", get_address (msg));
2646 access_action ("Editor/scroll-forward");
2647 } else if (delta < 0) {
2648 access_action ("Editor/scroll-backward");
2652 text_message (path, "Track", get_address (msg));
2654 set_bank (s->bank + 1, msg);
2655 } else if (delta < 0) {
2656 set_bank (s->bank - 1, msg);
2660 text_message (path, "Bank", get_address (msg));
2663 } else if (delta < 0) {
2668 text_message (path, "Nudge", get_address (msg));
2670 access_action ("Common/nudge-playhead-forward");
2671 } else if (delta < 0) {
2672 access_action ("Common/nudge-playhead-backward");
2676 text_message (path, "Marker", get_address (msg));
2679 } else if (delta < 0) {
2692 OSC::jog_mode (float mode, lo_message msg)
2694 if (!session) return -1;
2696 OSCSurface *s = get_surface(get_address (msg));
2697 if (get_transport_speed () != 1.0) {
2698 set_transport_speed (0);
2701 switch((uint32_t)mode)
2704 text_message ("/jog/mode/name", "Jog", get_address (msg));
2708 text_message ("/jog/mode/name", "Scrub", get_address (msg));
2712 text_message ("/jog/mode/name", "Shuttle", get_address (msg));
2713 s->jogmode = SHUTTLE;
2716 text_message ("/jog/mode/name", "Scroll", get_address (msg));
2717 s->jogmode = SCROLL;
2720 text_message ("/jog/mode/name", "Track", get_address (msg));
2724 text_message ("/jog/mode/name", "Bank", get_address (msg));
2728 text_message ("/jog/mode/name", "Nudge", get_address (msg));
2732 text_message ("/jog/mode/name", "Marker", get_address (msg));
2733 s->jogmode = MARKER;
2736 PBD::warning << "Jog Mode: " << mode << " is not valid." << endmsg;
2738 lo_message reply = lo_message_new ();
2739 lo_message_add_int32 (reply, s->jogmode);
2740 lo_send_message (get_address(msg), "/jog/mode", reply);
2741 lo_message_free (reply);
2749 OSC::click_level (float position)
2751 if (!session) return -1;
2752 if (session->click_gain()->gain_control()) {
2753 session->click_gain()->gain_control()->set_value (session->click_gain()->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
2758 // master and monitor calls
2760 OSC::master_set_gain (float dB)
2762 if (!session) return -1;
2763 boost::shared_ptr<Stripable> s = session->master_out();
2766 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
2768 float abs = dB_to_coefficient (dB);
2769 float top = s->gain_control()->upper();
2773 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
2780 OSC::master_delta_gain (float delta)
2782 if (!session) return -1;
2783 boost::shared_ptr<Stripable> s = session->master_out();
2785 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
2787 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
2789 float abs = dB_to_coefficient (dB);
2790 float top = s->gain_control()->upper();
2794 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
2801 OSC::master_set_fader (float position)
2803 if (!session) return -1;
2804 boost::shared_ptr<Stripable> s = session->master_out();
2806 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
2812 OSC::master_set_trim (float dB)
2814 if (!session) return -1;
2815 boost::shared_ptr<Stripable> s = session->master_out();
2818 s->trim_control()->set_value (dB_to_coefficient (dB), PBD::Controllable::NoGroup);
2825 OSC::master_set_pan_stereo_position (float position, lo_message msg)
2827 if (!session) return -1;
2828 OSCSurface *sur = get_surface(get_address (msg));
2830 float endposition = .5;
2831 boost::shared_ptr<Stripable> s = session->master_out();
2834 if (s->pan_azimuth_control()) {
2835 s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
2836 endposition = s->pan_azimuth_control()->internal_to_interface (s->pan_azimuth_control()->get_value ());
2840 if (sur->feedback[4]) {
2841 lo_message reply = lo_message_new ();
2842 lo_message_add_float (reply, endposition);
2844 lo_send_message (get_address (msg), "/master/pan_stereo_position", reply);
2845 lo_message_free (reply);
2852 OSC::master_set_mute (uint32_t state)
2854 if (!session) return -1;
2856 boost::shared_ptr<Stripable> s = session->master_out();
2859 s->mute_control()->set_value (state, PBD::Controllable::NoGroup);
2866 OSC::master_select (lo_message msg)
2871 OSCSurface *sur = get_surface(get_address (msg));
2872 sur->expand_enable = false;
2873 boost::shared_ptr<Stripable> s = session->master_out();
2875 SetStripableSelection (s);
2882 OSC::monitor_set_gain (float dB)
2884 if (!session) return -1;
2885 boost::shared_ptr<Stripable> s = session->monitor_out();
2889 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
2891 float abs = dB_to_coefficient (dB);
2892 float top = s->gain_control()->upper();
2896 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
2903 OSC::monitor_delta_gain (float delta)
2905 if (!session) return -1;
2906 boost::shared_ptr<Stripable> s = session->monitor_out();
2908 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
2910 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
2912 float abs = dB_to_coefficient (dB);
2913 float top = s->gain_control()->upper();
2917 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
2924 OSC::monitor_set_fader (float position)
2926 if (!session) return -1;
2927 boost::shared_ptr<Stripable> s = session->monitor_out();
2929 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
2935 OSC::monitor_set_mute (uint32_t state)
2937 if (!session) return -1;
2939 if (session->monitor_out()) {
2940 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
2941 mon->set_cut_all (state);
2947 OSC::monitor_set_dim (uint32_t state)
2949 if (!session) return -1;
2951 if (session->monitor_out()) {
2952 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
2953 mon->set_dim_all (state);
2959 OSC::monitor_set_mono (uint32_t state)
2961 if (!session) return -1;
2963 if (session->monitor_out()) {
2964 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
2965 mon->set_mono (state);
2971 OSC::route_get_sends(lo_message msg) {
2976 lo_arg **argv = lo_message_get_argv(msg);
2978 int rid = argv[0]->i;
2980 boost::shared_ptr<Stripable> strip = get_strip(rid, get_address(msg));
2985 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
2990 lo_message reply = lo_message_new();
2991 lo_message_add_int32(reply, rid);
2995 boost::shared_ptr<Processor> p = r->nth_send(i++);
3001 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (p);
3003 lo_message_add_int32(reply, get_sid(isend->target_route(), get_address(msg)));
3004 lo_message_add_string(reply, isend->name().c_str());
3005 lo_message_add_int32(reply, i);
3006 boost::shared_ptr<Amp> a = isend->amp();
3007 lo_message_add_float(reply, a->gain_control()->internal_to_interface (a->gain_control()->get_value()));
3008 lo_message_add_int32(reply, p->active() ? 1 : 0);
3011 // if used dedicated message path to identify this reply in async operation.
3012 // Naming it #reply wont help the client to identify the content.
3013 lo_send_message(get_address (msg), "/strip/sends", reply);
3015 lo_message_free(reply);
3021 OSC::route_get_receives(lo_message msg) {
3026 lo_arg **argv = lo_message_get_argv(msg);
3028 uint32_t rid = argv[0]->i;
3031 boost::shared_ptr<Stripable> strip = get_strip(rid, get_address(msg));
3036 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
3041 boost::shared_ptr<RouteList> route_list = session->get_routes();
3043 lo_message reply = lo_message_new();
3044 lo_message_add_int32(reply, rid);
3046 for (RouteList::iterator i = route_list->begin(); i != route_list->end(); ++i) {
3047 boost::shared_ptr<Route> tr = boost::dynamic_pointer_cast<Route> (*i);
3054 boost::shared_ptr<Processor> p = tr->nth_send(j++);
3060 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (p);
3062 if( isend->target_route()->id() == r->id()){
3063 boost::shared_ptr<Amp> a = isend->amp();
3065 lo_message_add_int32(reply, get_sid(tr, get_address(msg)));
3066 lo_message_add_string(reply, tr->name().c_str());
3067 lo_message_add_int32(reply, j);
3068 lo_message_add_float(reply, a->gain_control()->internal_to_interface (a->gain_control()->get_value()));
3069 lo_message_add_int32(reply, p->active() ? 1 : 0);
3075 // I have used a dedicated message path to identify this reply in async operation.
3076 // Naming it #reply wont help the client to identify the content.
3077 lo_send_message(get_address (msg), "/strip/receives", reply);
3078 lo_message_free(reply);
3085 OSC::set_automation (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
3087 if (!session) return -1;
3090 OSCSurface *sur = get_surface(get_address (msg));
3091 boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
3097 if (types[argc - 1] == 'f') {
3098 aut = (int)argv[argc - 1]->f;
3100 aut = argv[argc - 1]->i;
3104 //parse path first to find stripable
3105 if (!strncmp (path, "/strip/", 7)) {
3106 // find ssid and stripable
3108 if (types[1] == 'f') {
3109 ssid = (uint32_t)argv[0]->f;
3113 strp = get_strip (ssid, get_address (msg));
3115 ssid = atoi (&(strrchr (path, '/' ))[1]);
3116 strp = get_strip (ssid, get_address (msg));
3119 } else if (!strncmp (path, "/select/", 8)) {
3120 if (sur->expand_enable && sur->expand) {
3121 strp = get_strip (sur->expand, get_address (msg));
3130 boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
3131 // other automatable controls can be added by repeating the next 6.5 lines
3132 if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
3133 if (strp->gain_control ()) {
3134 control = strp->gain_control ();
3136 PBD::warning << "No fader for this strip" << endmsg;
3139 PBD::warning << "Automation not available for " << path << endmsg;
3146 control->set_automation_state (ARDOUR::Off);
3150 control->set_automation_state (ARDOUR::Play);
3154 control->set_automation_state (ARDOUR::Write);
3158 control->set_automation_state (ARDOUR::Touch);
3171 OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
3173 if (!session) return -1;
3176 OSCSurface *sur = get_surface(get_address (msg));
3177 boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
3183 if (types[argc - 1] == 'f') {
3184 touch = (int)argv[argc - 1]->f;
3186 touch = argv[argc - 1]->i;
3190 //parse path first to find stripable
3191 if (!strncmp (path, "/strip/", 7)) {
3192 // find ssid and stripable
3194 if (types[0] == 'f') {
3195 ssid = (uint32_t)argv[0]->f;
3199 strp = get_strip (ssid, get_address (msg));
3201 ssid = atoi (&(strrchr (path, '/' ))[1]);
3202 strp = get_strip (ssid, get_address (msg));
3205 } else if (!strncmp (path, "/select/", 8)) {
3206 if (sur->expand_enable && sur->expand) {
3207 strp = get_strip (sur->expand, get_address (msg));
3216 boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
3217 // other automatable controls can be added by repeating the next 6.5 lines
3218 if ((!strncmp (&path[ctr], "fader", 5)) || (!strncmp (&path[ctr], "gain", 4))) {
3219 if (strp->gain_control ()) {
3220 control = strp->gain_control ();
3222 PBD::warning << "No fader for this strip" << endmsg;
3225 PBD::warning << "Automation not available for " << path << endmsg;
3231 control->start_touch (control->session().transport_sample());
3235 control->stop_touch (control->session().transport_sample());
3238 // just in case some crazy surface starts sending control values before touch
3239 FakeTouchMap::iterator x = _touch_timeout.find(control);
3240 if (x != _touch_timeout.end()) {
3241 _touch_timeout.erase (x);
3250 OSC::fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl)
3254 if (ctrl->automation_state() == Touch && !ctrl->touching ()) {
3255 ctrl->start_touch (ctrl->session().transport_sample());
3256 _touch_timeout[ctrl] = 10;
3264 OSC::route_mute (int ssid, int yn, lo_message msg)
3266 if (!session) return -1;
3267 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3268 OSCSurface *sur = get_surface(get_address (msg));
3271 if (s->mute_control()) {
3272 s->mute_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
3277 return float_message_with_id ("/strip/mute", ssid, 0, sur->feedback[2], get_address (msg));
3281 OSC::sel_mute (uint32_t yn, lo_message msg)
3283 OSCSurface *sur = get_surface(get_address (msg));
3284 boost::shared_ptr<Stripable> s;
3285 if (sur->expand_enable) {
3286 s = get_strip (sur->expand, get_address (msg));
3291 if (s->mute_control()) {
3292 s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3296 return float_message("/select/mute", 0, get_address (msg));
3300 OSC::route_solo (int ssid, int yn, lo_message msg)
3302 if (!session) return -1;
3303 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3304 OSCSurface *sur = get_surface(get_address (msg));
3307 if (s->solo_control()) {
3308 s->solo_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
3312 return float_message_with_id ("/strip/solo", ssid, 0, sur->feedback[2], get_address (msg));
3316 OSC::route_solo_iso (int ssid, int yn, lo_message msg)
3318 if (!session) return -1;
3319 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3320 OSCSurface *sur = get_surface(get_address (msg));
3323 if (s->solo_isolate_control()) {
3324 s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
3329 return float_message_with_id ("/strip/solo_iso", ssid, 0, sur->feedback[2], get_address (msg));
3333 OSC::route_solo_safe (int ssid, int yn, lo_message msg)
3335 if (!session) return -1;
3336 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
3337 OSCSurface *sur = get_surface(get_address (msg));
3340 if (s->solo_safe_control()) {
3341 s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
3346 return float_message_with_id ("/strip/solo_safe", ssid, 0, sur->feedback[2], get_address (msg));
3350 OSC::sel_solo (uint32_t yn, lo_message msg)
3352 OSCSurface *sur = get_surface(get_address (msg));
3353 boost::shared_ptr<Stripable> s;
3354 if (sur->expand_enable) {
3355 s = get_strip (sur->expand, get_address (msg));
3360 if (s->solo_control()) {
3361 session->set_control (s->solo_control(), yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3364 return float_message("/select/solo", 0, get_address (msg));
3368 OSC::sel_solo_iso (uint32_t yn, lo_message msg)
3370 OSCSurface *sur = get_surface(get_address (msg));
3371 boost::shared_ptr<Stripable> s;
3372 if (sur->expand_enable) {
3373 s = get_strip (sur->expand, get_address (msg));
3378 if (s->solo_isolate_control()) {
3379 s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3383 return float_message("/select/solo_iso", 0, get_address (msg));
3387 OSC::sel_solo_safe (uint32_t yn, lo_message msg)
3389 OSCSurface *sur = get_surface(get_address (msg));
3390 boost::shared_ptr<Stripable> s;
3391 if (sur->expand_enable) {
3392 s = get_strip (sur->expand, get_address (msg));
3397 if (s->solo_safe_control()) {
3398 s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3402 return float_message("/select/solo_safe", 0, get_address (msg));
3406 OSC::sel_recenable (uint32_t yn, lo_message msg)
3408 OSCSurface *sur = get_surface(get_address (msg));
3409 boost::shared_ptr<Stripable> s;
3410 if (sur->expand_enable) {
3411 s = get_strip (sur->expand, get_address (msg));
3416 if (s->rec_enable_control()) {
3417 s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3418 if (s->rec_enable_control()->get_value()) {
3423 return float_message("/select/recenable", 0, get_address (msg));
3427 OSC::route_recenable (int ssid, int yn, lo_message msg)
3429 if (!session) return -1;
3430 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3431 OSCSurface *sur = get_surface(get_address (msg));
3434 if (s->rec_enable_control()) {
3435 s->rec_enable_control()->set_value (yn, sur->usegroup);
3436 if (s->rec_enable_control()->get_value()) {
3441 return float_message_with_id ("/strip/recenable", ssid, 0, sur->feedback[2], get_address (msg));
3445 OSC::route_rename(int ssid, char *newname, lo_message msg) {
3450 boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
3453 s->set_name(std::string(newname));
3460 OSC::sel_recsafe (uint32_t yn, lo_message msg)
3462 OSCSurface *sur = get_surface(get_address (msg));
3463 boost::shared_ptr<Stripable> s;
3464 if (sur->expand_enable) {
3465 s = get_strip (sur->expand, get_address (msg));
3470 if (s->rec_safe_control()) {
3471 s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3472 if (s->rec_safe_control()->get_value()) {
3477 return float_message("/select/record_safe", 0, get_address (msg));
3481 OSC::route_recsafe (int ssid, int yn, lo_message msg)
3483 if (!session) return -1;
3484 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3485 OSCSurface *sur = get_surface(get_address (msg));
3487 if (s->rec_safe_control()) {
3488 s->rec_safe_control()->set_value (yn, sur->usegroup);
3489 if (s->rec_safe_control()->get_value()) {
3494 return float_message_with_id ("/strip/record_safe", ssid, 0, sur->feedback[2], get_address (msg));
3498 OSC::route_monitor_input (int ssid, int yn, lo_message msg)
3500 if (!session) return -1;
3501 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3502 OSCSurface *sur = get_surface(get_address (msg));
3505 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
3507 if (track->monitoring_control()) {
3508 std::bitset<32> value = track->monitoring_control()->get_value ();
3509 value[0] = yn ? 1 : 0;
3510 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
3516 return float_message_with_id ("/strip/monitor_input", ssid, 0, sur->feedback[2], get_address (msg));
3520 OSC::sel_monitor_input (uint32_t yn, lo_message msg)
3522 OSCSurface *sur = get_surface(get_address (msg));
3523 boost::shared_ptr<Stripable> s;
3524 if (sur->expand_enable) {
3525 s = get_strip (sur->expand, get_address (msg));
3530 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
3532 if (track->monitoring_control()) {
3533 std::bitset<32> value = track->monitoring_control()->get_value ();
3534 value[0] = yn ? 1 : 0;
3535 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
3540 return float_message("/select/monitor_input", 0, get_address (msg));
3544 OSC::route_monitor_disk (int ssid, int yn, lo_message msg)
3546 if (!session) return -1;
3547 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3548 OSCSurface *sur = get_surface(get_address (msg));
3551 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
3553 if (track->monitoring_control()) {
3554 std::bitset<32> value = track->monitoring_control()->get_value ();
3555 value[1] = yn ? 1 : 0;
3556 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
3562 return float_message_with_id ("/strip/monitor_disk", ssid, 0, sur->feedback[2], get_address (msg));
3566 OSC::sel_monitor_disk (uint32_t yn, lo_message msg)
3568 OSCSurface *sur = get_surface(get_address (msg));
3569 boost::shared_ptr<Stripable> s;
3570 if (sur->expand_enable) {
3571 s = get_strip (sur->expand, get_address (msg));
3576 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
3578 if (track->monitoring_control()) {
3579 std::bitset<32> value = track->monitoring_control()->get_value ();
3580 value[1] = yn ? 1 : 0;
3581 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
3586 return float_message("/select/monitor_disk", 0, get_address (msg));
3591 OSC::strip_phase (int ssid, int yn, lo_message msg)
3593 if (!session) return -1;
3594 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3595 OSCSurface *sur = get_surface(get_address (msg));
3598 if (s->phase_control()) {
3599 s->phase_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
3604 return float_message_with_id ("/strip/polarity", ssid, 0, sur->feedback[2], get_address (msg));
3608 OSC::sel_phase (uint32_t yn, lo_message msg)
3610 OSCSurface *sur = get_surface(get_address (msg));
3611 boost::shared_ptr<Stripable> s;
3612 if (sur->expand_enable) {
3613 s = get_strip (sur->expand, get_address (msg));
3618 if (s->phase_control()) {
3619 s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
3623 return float_message("/select/polarity", 0, get_address (msg));
3627 OSC::strip_expand (int ssid, int yn, lo_message msg)
3629 OSCSurface *sur = get_surface(get_address (msg));
3630 sur->expand_enable = (bool) yn;
3632 boost::shared_ptr<Stripable> s;
3634 s = get_strip (ssid, get_address (msg));
3639 return _strip_select (s, get_address (msg));
3643 OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
3648 OSCSurface *sur = get_surface(addr, true);
3650 // expand doesn't point to a stripable, turn it off and use select
3652 sur->expand_enable = false;
3653 if (ControlProtocol::first_selected_stripable()) {
3654 s = ControlProtocol::first_selected_stripable();
3656 s = session->master_out ();
3662 uint32_t nsends = 0;
3665 if (s->send_level_controllable (nsends)) {
3670 sur->nsends = nsends;
3672 s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
3674 OSCSelectObserver* so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs);
3675 if (sur->feedback[13]) {
3677 so->refresh_strip (s, nsends, true);
3679 OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, sur);
3680 sur->sel_obs = sel_fb;
3682 sur->sel_obs->set_expand (sur->expand_enable);
3683 uint32_t obs_expand = 0;
3684 if (sur->expand_enable) {
3685 obs_expand = sur->expand;
3689 for (uint32_t i = 0; i < sur->observers.size(); i++) {
3690 sur->observers[i]->set_expand (obs_expand);
3699 // need to set monitor for processor changed signal (for paging)
3700 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
3702 r->processors_changed.connect (sur->proc_connection, MISSING_INVALIDATOR, boost::bind (&OSC::processor_changed, this, addr), this);
3703 _sel_plugin (sur->plugin_id, addr);
3710 OSC::processor_changed (lo_address addr)
3712 OSCSurface *sur = get_surface (addr);
3713 _sel_plugin (sur->plugin_id, addr);
3715 sur->sel_obs->renew_sends ();
3716 sur->sel_obs->eq_restart (-1);
3721 OSC::strip_gui_select (int ssid, int yn, lo_message msg)
3723 //ignore button release
3729 OSCSurface *sur = get_surface(get_address (msg));
3730 sur->expand_enable = false;
3731 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3733 SetStripableSelection (s);
3735 if ((int) (sur->feedback.to_ulong())) {
3736 float_message_with_id ("/strip/select", ssid, 0, sur->feedback[2], get_address (msg));
3744 OSC::sel_expand (uint32_t state, lo_message msg)
3746 OSCSurface *sur = get_surface(get_address (msg));
3747 boost::shared_ptr<Stripable> s;
3748 if (state && sur->expand) {
3749 sur->expand_enable = (bool) state;
3750 s = get_strip (sur->expand, get_address (msg));
3752 sur->expand_enable = false;
3756 return _strip_select (s, get_address (msg));
3760 OSC::route_set_gain_abs (int ssid, float level, lo_message msg)
3762 if (!session) return -1;
3763 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3764 OSCSurface *sur = get_surface(get_address (msg));
3767 if (s->gain_control()) {
3768 fake_touch (s->gain_control());
3769 s->gain_control()->set_value (level, sur->usegroup);
3781 OSC::route_set_gain_dB (int ssid, float dB, lo_message msg)
3786 OSCSurface *sur = get_surface(get_address (msg));
3789 ret = route_set_gain_abs (ssid, 0.0, msg);
3791 ret = route_set_gain_abs (ssid, dB_to_coefficient (dB), msg);
3794 return float_message_with_id ("/strip/gain", ssid, -193, sur->feedback[2], get_address (msg));
3800 OSC::sel_gain (float val, lo_message msg)
3802 OSCSurface *sur = get_surface(get_address (msg));
3803 boost::shared_ptr<Stripable> s;
3804 if (sur->expand_enable) {
3805 s = get_strip (sur->expand, get_address (msg));
3811 if (s->gain_control()) {
3815 abs = dB_to_coefficient (val);
3816 float top = s->gain_control()->upper();
3821 fake_touch (s->gain_control());
3822 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3826 return float_message("/select/gain", -193, get_address (msg));
3830 OSC::sel_dB_delta (float delta, lo_message msg)
3832 OSCSurface *sur = get_surface(get_address (msg));
3833 boost::shared_ptr<Stripable> s;
3834 if (sur->expand_enable) {
3835 s = get_strip (sur->expand, get_address (msg));
3840 if (s->gain_control()) {
3841 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
3846 abs = dB_to_coefficient (dB);
3847 float top = s->gain_control()->upper();
3852 fake_touch (s->gain_control());
3853 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3857 return float_message("/select/gain", -193, get_address (msg));
3861 OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
3866 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3867 OSCSurface *sur = get_surface(get_address (msg));
3870 if (s->gain_control()) {
3871 fake_touch (s->gain_control());
3872 s->gain_control()->set_value (s->gain_control()->interface_to_internal (pos), sur->usegroup);
3874 return float_message_with_id ("/strip/fader", ssid, 0, sur->feedback[2], get_address (msg));
3877 return float_message_with_id ("/strip/fader", ssid, 0, sur->feedback[2], get_address (msg));
3883 OSC::strip_db_delta (int ssid, float delta, lo_message msg)
3885 if (!session) return -1;
3886 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3887 OSCSurface *sur = get_surface(get_address (msg));
3889 float db = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
3894 abs = dB_to_coefficient (db);
3895 float top = s->gain_control()->upper();
3900 s->gain_control()->set_value (abs, sur->usegroup);
3907 OSC::sel_fader (float val, lo_message msg)
3909 OSCSurface *sur = get_surface(get_address (msg));
3910 boost::shared_ptr<Stripable> s;
3911 if (sur->expand_enable) {
3912 s = get_strip (sur->expand, get_address (msg));
3917 if (s->gain_control()) {
3918 fake_touch (s->gain_control());
3919 s->gain_control()->set_value (s->gain_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
3923 return float_message("/select/fader", 0, get_address (msg));
3927 OSC::route_set_trim_abs (int ssid, float level, lo_message msg)
3929 if (!session) return -1;
3930 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
3931 OSCSurface *sur = get_surface(get_address (msg));
3934 if (s->trim_control()) {
3935 s->trim_control()->set_value (level, sur->usegroup);
3945 OSC::route_set_trim_dB (int ssid, float dB, lo_message msg)
3947 OSCSurface *sur = get_surface(get_address (msg));
3949 ret = route_set_trim_abs(ssid, dB_to_coefficient (dB), msg);
3951 return float_message_with_id ("/strip/trimdB", ssid, 0, sur->feedback[2], get_address (msg));
3958 OSC::sel_trim (float val, lo_message msg)
3960 OSCSurface *sur = get_surface(get_address (msg));
3961 boost::shared_ptr<Stripable> s;
3962 if (sur->expand_enable) {
3963 s = get_strip (sur->expand, get_address (msg));
3968 if (s->trim_control()) {
3969 s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup);
3973 return float_message("/select/trimdB", 0, get_address (msg));
3977 OSC::sel_pan_position (float val, lo_message msg)
3979 OSCSurface *sur = get_surface(get_address (msg));
3980 boost::shared_ptr<Stripable> s;
3981 if (sur->expand_enable) {
3982 s = get_strip (sur->expand, get_address (msg));
3987 if(s->pan_azimuth_control()) {
3988 s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
3992 return float_message("/select/pan_stereo_position", 0.5, get_address (msg));
3996 OSC::sel_pan_width (float val, lo_message msg)
3998 OSCSurface *sur = get_surface(get_address (msg));
3999 boost::shared_ptr<Stripable> s;
4000 if (sur->expand_enable) {
4001 s = get_strip (sur->expand, get_address (msg));
4006 if (s->pan_width_control()) {
4007 s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
4011 return float_message("/select/pan_stereo_width", 1, get_address (msg));
4015 OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
4017 if (!session) return -1;
4018 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4019 OSCSurface *sur = get_surface(get_address (msg));
4022 if(s->pan_azimuth_control()) {
4023 s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup);
4028 return float_message_with_id ("/strip/pan_stereo_position", ssid, 0.5, sur->feedback[2], get_address (msg));
4032 OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg)
4034 if (!session) return -1;
4035 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4036 OSCSurface *sur = get_surface(get_address (msg));
4039 if (s->pan_width_control()) {
4040 s->pan_width_control()->set_value (pos, sur->usegroup);
4045 return float_message_with_id ("/strip/pan_stereo_width", ssid, 1, sur->feedback[2], get_address (msg));
4049 OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg)
4054 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4055 OSCSurface *sur = get_surface(get_address (msg));
4067 abs = dB_to_coefficient (val);
4070 if (s->send_level_controllable (id)) {
4071 s->send_level_controllable (id)->set_value (abs, sur->usegroup);
4079 OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg)
4084 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4085 OSCSurface *sur = get_surface(get_address (msg));
4093 if (s->send_level_controllable (id)) {
4094 abs = s->send_level_controllable(id)->interface_to_internal (val);
4095 s->send_level_controllable (id)->set_value (abs, sur->usegroup);
4103 OSC::sel_sendgain (int id, float val, lo_message msg)
4105 OSCSurface *sur = get_surface(get_address (msg));
4106 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
4107 return float_message_with_id ("/select/send_gain", id, -193, sur->feedback[2], get_address (msg));
4109 boost::shared_ptr<Stripable> s;
4110 if (sur->expand_enable) {
4111 s = get_strip (sur->expand, get_address (msg));
4127 abs = dB_to_coefficient (val);
4130 if (sur->send_page_size) {
4131 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
4133 if (s->send_level_controllable (send_id)) {
4134 s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
4138 return float_message_with_id ("/select/send_gain", id, -193, sur->feedback[2], get_address (msg));
4142 OSC::sel_sendfader (int id, float val, lo_message msg)
4144 OSCSurface *sur = get_surface(get_address (msg));
4145 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
4146 return float_message_with_id ("/select/send_fader", id, 0, sur->feedback[2], get_address (msg));
4148 boost::shared_ptr<Stripable> s;
4149 if (sur->expand_enable) {
4150 s = get_strip (sur->expand, get_address (msg));
4161 if (sur->send_page_size) {
4162 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
4165 if (s->send_level_controllable (send_id)) {
4166 abs = s->send_level_controllable(send_id)->interface_to_internal (val);
4167 s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
4171 return float_message_with_id ("/select/send_fader", id, 0, sur->feedback[2], get_address (msg));
4175 OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
4180 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4181 OSCSurface *sur = get_surface(get_address (msg));
4185 /* revert to zero-based counting */
4191 if (s->send_enable_controllable (sid)) {
4192 s->send_enable_controllable (sid)->set_value (val, sur->usegroup);
4196 if (s->send_level_controllable (sid)) {
4197 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4201 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(sid));
4218 OSC::sel_sendenable (int id, float val, lo_message msg)
4220 OSCSurface *sur = get_surface(get_address (msg));
4221 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
4222 return float_message_with_id ("/select/send_enable", id, 0, sur->feedback[2], get_address (msg));
4224 boost::shared_ptr<Stripable> s;
4225 if (sur->expand_enable) {
4226 s = get_strip (sur->expand, get_address (msg));
4235 if (sur->send_page_size) {
4236 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
4238 if (s->send_enable_controllable (send_id)) {
4239 s->send_enable_controllable (send_id)->set_value (val, PBD::Controllable::NoGroup);
4242 if (s->send_level_controllable (send_id)) {
4243 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4245 // should never get here
4246 return float_message_with_id ("/select/send_enable", id, 0, sur->feedback[2], get_address (msg));
4248 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(send_id));
4259 return float_message_with_id ("/select/send_enable", id, 0, sur->feedback[2], get_address (msg));
4263 OSC::sel_master_send_enable (int state, lo_message msg)
4265 OSCSurface *sur = get_surface(get_address (msg));
4266 boost::shared_ptr<Stripable> s;
4267 if (sur->expand_enable) {
4268 s = get_strip (sur->expand, get_address (msg));
4273 if (s->master_send_enable_controllable ()) {
4274 s->master_send_enable_controllable()->set_value (state, PBD::Controllable::NoGroup);
4278 return float_message ("/select/master_send_enable", 0, get_address(msg));
4282 OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) {
4283 OSCSurface *sur = get_surface(get_address (msg));
4285 uint32_t piid = sur->plugin_id;
4290 // change parameter in already selected plugin
4291 if (types[0] == 'f') {
4292 paid = (int) argv[0]->f;
4297 } else if (argc == 3) {
4298 if (types[0] == 'f') {
4299 piid = (int) argv[0]->f;
4303 _sel_plugin (piid, get_address (msg));
4304 if (types[1] == 'f') {
4305 paid = (int) argv[1]->f;
4310 } else if (argc > 3) {
4311 PBD::warning << "OSC: Too many parameters: " << argc << endmsg;
4315 const char * par = strstr (&path[25], "/");
4317 piid = atoi (&path[25]);
4318 _sel_plugin (piid, msg);
4319 paid = atoi (&par[1]);
4321 // we have plugin id too
4324 paid = atoi (&path[25]);
4328 PBD::warning << "OSC: Must have parameters." << endmsg;
4331 if (!piid || piid > sur->plugins.size ()) {
4332 return float_message_with_id ("/select/plugin/parameter", paid, 0, sur->feedback[2], get_address (msg));
4334 if (sur->plug_page_size && (paid > (int)sur->plug_page_size)) {
4335 return float_message_with_id ("/select/plugin/parameter", paid, 0, sur->feedback[2], get_address (msg));
4337 boost::shared_ptr<Stripable> s = sur->select;
4338 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
4343 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
4344 boost::shared_ptr<PluginInsert> pi;
4345 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
4348 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4349 // paid is paged parameter convert to absolute
4350 int parid = paid + (int)sur->plug_page - 1;
4351 if (parid > (int) sur->plug_params.size ()) {
4352 if (sur->feedback[13]) {
4353 float_message_with_id ("/select/plugin/parameter", paid, 0, sur->feedback[2], get_address (msg));
4359 uint32_t controlid = pip->nth_parameter(sur->plug_params[parid - 1], ok);
4363 ParameterDescriptor pd;
4364 pip->get_parameter_descriptor(controlid, pd);
4365 if ( pip->parameter_is_input(controlid) || pip->parameter_is_control(controlid) ) {
4366 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
4368 if (pd.integer_step && pd.upper == 1) {
4369 if (c->get_value () && value < 1.0) {
4370 c->set_value (0, PBD::Controllable::NoGroup);
4371 } else if (!c->get_value () && value) {
4372 c->set_value (1, PBD::Controllable::NoGroup);
4375 c->set_value (c->interface_to_internal (value), PBD::Controllable::NoGroup);
4384 OSC::sel_plugin_activate (float state, lo_message msg)
4389 OSCSurface *sur = get_surface(get_address (msg));
4390 boost::shared_ptr<Stripable> s = sur->select;
4392 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4395 boost::shared_ptr<Processor> redi=r->nth_plugin (sur->plugins[sur->plugin_id -1]);
4397 boost::shared_ptr<PluginInsert> pi;
4398 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4408 float_message ("/select/plugin/activate", 0, get_address (msg));
4409 PBD::warning << "OSC: Select has no Plugin." << endmsg;
4414 OSC::route_plugin_list (int ssid, lo_message msg) {
4419 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
4422 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4427 lo_message reply = lo_message_new ();
4428 lo_message_add_int32 (reply, ssid);
4432 boost::shared_ptr<Processor> redi = r->nth_plugin(piid);
4437 boost::shared_ptr<PluginInsert> pi;
4439 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4440 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4443 lo_message_add_int32 (reply, piid + 1);
4445 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4446 lo_message_add_string (reply, pip->name());
4447 lo_message_add_int32(reply, redi->enabled() ? 1 : 0);
4452 lo_send_message (get_address (msg), "/strip/plugin/list", reply);
4453 lo_message_free (reply);
4458 OSC::route_plugin_descriptor (int ssid, int piid, lo_message msg) {
4463 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
4466 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4470 boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
4473 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
4477 boost::shared_ptr<PluginInsert> pi;
4479 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4480 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4484 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4487 for ( uint32_t ppi = 0; ppi < pip->parameter_count(); ppi++) {
4489 uint32_t controlid = pip->nth_parameter(ppi, ok);
4493 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
4495 lo_message reply = lo_message_new();
4496 lo_message_add_int32 (reply, ssid);
4497 lo_message_add_int32 (reply, piid);
4499 lo_message_add_int32 (reply, ppi + 1);
4500 ParameterDescriptor pd;
4501 pi->plugin()->get_parameter_descriptor(controlid, pd);
4502 lo_message_add_string (reply, pd.label.c_str());
4504 // I've combined those binary descriptor parts in a bit-field to reduce lilo message elements
4506 flags |= pd.enumeration ? 1 : 0;
4507 flags |= pd.integer_step ? 2 : 0;
4508 flags |= pd.logarithmic ? 4 : 0;
4509 flags |= pd.sr_dependent ? 32 : 0;
4510 flags |= pd.toggled ? 64 : 0;
4511 flags |= pip->parameter_is_input(controlid) ? 0x80 : 0;
4513 std::string param_desc = pi->plugin()->describe_parameter(Evoral::Parameter(PluginAutomation, 0, controlid));
4514 flags |= (param_desc == X_("hidden")) ? 0x100 : 0;
4515 lo_message_add_int32 (reply, flags);
4517 switch(pd.datatype) {
4518 case ARDOUR::Variant::BEATS:
4519 lo_message_add_string(reply, _("BEATS"));
4521 case ARDOUR::Variant::BOOL:
4522 lo_message_add_string(reply, _("BOOL"));
4524 case ARDOUR::Variant::DOUBLE:
4525 lo_message_add_string(reply, _("DOUBLE"));
4527 case ARDOUR::Variant::FLOAT:
4528 lo_message_add_string(reply, _("FLOAT"));
4530 case ARDOUR::Variant::INT:
4531 lo_message_add_string(reply, _("INT"));
4533 case ARDOUR::Variant::LONG:
4534 lo_message_add_string(reply, _("LONG"));
4536 case ARDOUR::Variant::NOTHING:
4537 lo_message_add_string(reply, _("NOTHING"));
4539 case ARDOUR::Variant::PATH:
4540 lo_message_add_string(reply, _("PATH"));
4542 case ARDOUR::Variant::STRING:
4543 lo_message_add_string(reply, _("STRING"));
4545 case ARDOUR::Variant::URI:
4546 lo_message_add_string(reply, _("URI"));
4549 lo_message_add_string(reply, _("UNKNOWN"));
4552 lo_message_add_float (reply, pd.lower);
4553 lo_message_add_float (reply, pd.upper);
4554 lo_message_add_string (reply, pd.print_fmt.c_str());
4555 if ( pd.scale_points ) {
4556 lo_message_add_int32 (reply, pd.scale_points->size());
4557 for ( ARDOUR::ScalePoints::const_iterator i = pd.scale_points->begin(); i != pd.scale_points->end(); ++i) {
4558 lo_message_add_float (reply, i->second);
4559 lo_message_add_string (reply, ((std::string)i->first).c_str());
4563 lo_message_add_int32 (reply, 0);
4566 lo_message_add_double (reply, c->get_value());
4569 lo_message_add_double (reply, 0);
4572 lo_send_message (get_address (msg), "/strip/plugin/descriptor", reply);
4573 lo_message_free (reply);
4576 lo_message reply = lo_message_new ();
4577 lo_message_add_int32 (reply, ssid);
4578 lo_message_add_int32 (reply, piid);
4579 lo_send_message (get_address (msg), "/strip/plugin/descriptor_end", reply);
4580 lo_message_free (reply);
4586 OSC::route_plugin_reset (int ssid, int piid, lo_message msg) {
4591 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
4594 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4598 boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
4601 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
4605 boost::shared_ptr<PluginInsert> pi;
4607 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4608 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4612 pi->reset_parameters_to_default ();
4618 OSC::route_plugin_parameter (int ssid, int piid, int par, float val, lo_message msg)
4622 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4624 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4627 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4631 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
4634 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
4638 boost::shared_ptr<PluginInsert> pi;
4640 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4641 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4645 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4648 uint32_t controlid = pip->nth_parameter (par - 1,ok);
4651 PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "'" << endmsg;
4655 if (!pip->parameter_is_input(controlid)) {
4656 PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is not a control input" << endmsg;
4660 ParameterDescriptor pd;
4661 pi->plugin()->get_parameter_descriptor (controlid,pd);
4663 if (val >= pd.lower && val <= pd.upper) {
4665 boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
4666 // cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n";
4667 c->set_value (val, PBD::Controllable::NoGroup);
4669 PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is out of range" << endmsg;
4670 PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg;
4676 //prints to cerr only
4678 OSC::route_plugin_parameter_print (int ssid, int piid, int par, lo_message msg)
4683 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4685 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4691 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
4697 boost::shared_ptr<PluginInsert> pi;
4699 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4703 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4706 uint32_t controlid = pip->nth_parameter (par - 1,ok);
4712 ParameterDescriptor pd;
4714 if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) {
4715 boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
4717 cerr << "parameter: " << pd.label << "\n";
4719 cerr << "current value: " << c->get_value () << "\n";
4721 cerr << "current value not available, control does not exist\n";
4723 cerr << "lower value: " << pd.lower << "\n";
4724 cerr << "upper value: " << pd.upper << "\n";
4731 OSC::route_plugin_activate (int ssid, int piid, lo_message msg)
4735 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
4737 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4740 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4744 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
4747 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
4751 boost::shared_ptr<PluginInsert> pi;
4753 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4754 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4758 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4765 OSC::route_plugin_deactivate (int ssid, int piid, lo_message msg)
4769 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
4771 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
4774 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
4778 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
4781 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
4785 boost::shared_ptr<PluginInsert> pi;
4787 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
4788 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
4792 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
4801 OSC::sel_pan_elevation (float val, lo_message msg)
4803 OSCSurface *sur = get_surface(get_address (msg));
4804 boost::shared_ptr<Stripable> s;
4805 if (sur->expand_enable) {
4806 s = get_strip (sur->expand, get_address (msg));
4811 if (s->pan_elevation_control()) {
4812 s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
4816 return float_message("/select/pan_elevation_position", 0, get_address (msg));
4820 OSC::sel_pan_frontback (float val, lo_message msg)
4822 OSCSurface *sur = get_surface(get_address (msg));
4823 boost::shared_ptr<Stripable> s;
4824 if (sur->expand_enable) {
4825 s = get_strip (sur->expand, get_address (msg));
4830 if (s->pan_frontback_control()) {
4831 s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
4835 return float_message("/select/pan_frontback_position", 0.5, get_address (msg));
4839 OSC::sel_pan_lfe (float val, lo_message msg)
4841 OSCSurface *sur = get_surface(get_address (msg));
4842 boost::shared_ptr<Stripable> s;
4843 if (sur->expand_enable) {
4844 s = get_strip (sur->expand, get_address (msg));
4849 if (s->pan_lfe_control()) {
4850 s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
4854 return float_message("/select/pan_lfe_control", 0, get_address (msg));
4857 // compressor control
4859 OSC::sel_comp_enable (float val, lo_message msg)
4861 OSCSurface *sur = get_surface(get_address (msg));
4862 boost::shared_ptr<Stripable> s;
4863 if (sur->expand_enable) {
4864 s = get_strip (sur->expand, get_address (msg));
4869 if (s->comp_enable_controllable()) {
4870 s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4874 return float_message("/select/comp_enable", 0, get_address (msg));
4878 OSC::sel_comp_threshold (float val, lo_message msg)
4880 OSCSurface *sur = get_surface(get_address (msg));
4881 boost::shared_ptr<Stripable> s;
4882 if (sur->expand_enable) {
4883 s = get_strip (sur->expand, get_address (msg));
4888 if (s->comp_threshold_controllable()) {
4889 s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4893 return float_message("/select/comp_threshold", 0, get_address (msg));
4897 OSC::sel_comp_speed (float val, lo_message msg)
4899 OSCSurface *sur = get_surface(get_address (msg));
4900 boost::shared_ptr<Stripable> s;
4901 if (sur->expand_enable) {
4902 s = get_strip (sur->expand, get_address (msg));
4907 if (s->comp_speed_controllable()) {
4908 s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4912 return float_message("/select/comp_speed", 0, get_address (msg));
4916 OSC::sel_comp_mode (float val, lo_message msg)
4918 OSCSurface *sur = get_surface(get_address (msg));
4919 boost::shared_ptr<Stripable> s;
4920 if (sur->expand_enable) {
4921 s = get_strip (sur->expand, get_address (msg));
4926 if (s->comp_mode_controllable()) {
4927 s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4931 return float_message("/select/comp_mode", 0, get_address (msg));
4935 OSC::sel_comp_makeup (float val, lo_message msg)
4937 OSCSurface *sur = get_surface(get_address (msg));
4938 boost::shared_ptr<Stripable> s;
4939 if (sur->expand_enable) {
4940 s = get_strip (sur->expand, get_address (msg));
4945 if (s->comp_makeup_controllable()) {
4946 s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4950 return float_message("/select/comp_makeup", 0, get_address (msg));
4956 OSC::sel_eq_enable (float val, lo_message msg)
4958 OSCSurface *sur = get_surface(get_address (msg));
4959 boost::shared_ptr<Stripable> s;
4960 if (sur->expand_enable) {
4961 s = get_strip (sur->expand, get_address (msg));
4966 if (s->eq_enable_controllable()) {
4967 s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
4971 return float_message("/select/eq_enable", 0, get_address (msg));
4975 OSC::sel_eq_hpf_freq (float val, lo_message msg)
4977 OSCSurface *sur = get_surface(get_address (msg));
4978 boost::shared_ptr<Stripable> s;
4979 if (sur->expand_enable) {
4980 s = get_strip (sur->expand, get_address (msg));
4985 if (s->filter_freq_controllable(true)) {
4986 s->filter_freq_controllable(true)->set_value (s->filter_freq_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
4990 return float_message("/select/eq_hpf/freq", 0, get_address (msg));
4994 OSC::sel_eq_lpf_freq (float val, lo_message msg)
4996 OSCSurface *sur = get_surface(get_address (msg));
4997 boost::shared_ptr<Stripable> s;
4998 if (sur->expand_enable) {
4999 s = get_strip (sur->expand, get_address (msg));
5004 if (s->filter_freq_controllable(false)) {
5005 s->filter_freq_controllable(false)->set_value (s->filter_freq_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
5009 return float_message("/select/eq_lpf/freq", 0, get_address (msg));
5013 OSC::sel_eq_hpf_enable (float val, lo_message msg)
5015 OSCSurface *sur = get_surface(get_address (msg));
5016 boost::shared_ptr<Stripable> s;
5017 if (sur->expand_enable) {
5018 s = get_strip (sur->expand, get_address (msg));
5023 if (s->filter_enable_controllable(true)) {
5024 s->filter_enable_controllable(true)->set_value (s->filter_enable_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
5028 return float_message("/select/eq_hpf/enable", 0, get_address (msg));
5032 OSC::sel_eq_lpf_enable (float val, lo_message msg)
5034 OSCSurface *sur = get_surface(get_address (msg));
5035 boost::shared_ptr<Stripable> s;
5036 if (sur->expand_enable) {
5037 s = get_strip (sur->expand, get_address (msg));
5042 if (s->filter_enable_controllable(false)) {
5043 s->filter_enable_controllable(false)->set_value (s->filter_enable_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
5047 return float_message("/select/eq_lpf/enable", 0, get_address (msg));
5051 OSC::sel_eq_hpf_slope (float val, lo_message msg)
5053 OSCSurface *sur = get_surface(get_address (msg));
5054 boost::shared_ptr<Stripable> s;
5055 if (sur->expand_enable) {
5056 s = get_strip (sur->expand, get_address (msg));
5061 if (s->filter_slope_controllable(true)) {
5062 s->filter_slope_controllable(true)->set_value (s->filter_slope_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
5066 return float_message("/select/eq_hpf/slope", 0, get_address (msg));
5070 OSC::sel_eq_lpf_slope (float val, lo_message msg)
5072 OSCSurface *sur = get_surface(get_address (msg));
5073 boost::shared_ptr<Stripable> s;
5074 if (sur->expand_enable) {
5075 s = get_strip (sur->expand, get_address (msg));
5080 if (s->filter_slope_controllable(false)) {
5081 s->filter_slope_controllable(false)->set_value (s->filter_slope_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
5085 return float_message("/select/eq_lpf/slope", 0, get_address (msg));
5089 OSC::sel_eq_gain (int id, float val, lo_message msg)
5091 OSCSurface *sur = get_surface(get_address (msg));
5092 boost::shared_ptr<Stripable> s;
5093 if (sur->expand_enable) {
5094 s = get_strip (sur->expand, get_address (msg));
5102 if (s->eq_gain_controllable (id)) {
5103 s->eq_gain_controllable (id)->set_value (s->eq_gain_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
5107 return float_message_with_id ("/select/eq_gain", id + 1, 0, sur->feedback[2], get_address (msg));
5111 OSC::sel_eq_freq (int id, float val, lo_message msg)
5113 OSCSurface *sur = get_surface(get_address (msg));
5114 boost::shared_ptr<Stripable> s;
5115 if (sur->expand_enable) {
5116 s = get_strip (sur->expand, get_address (msg));
5124 if (s->eq_freq_controllable (id)) {
5125 s->eq_freq_controllable (id)->set_value (s->eq_freq_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
5129 return float_message_with_id ("/select/eq_freq", id + 1, 0, sur->feedback[2], get_address (msg));
5133 OSC::sel_eq_q (int id, float val, lo_message msg)
5135 OSCSurface *sur = get_surface(get_address (msg));
5136 boost::shared_ptr<Stripable> s;
5137 if (sur->expand_enable) {
5138 s = get_strip (sur->expand, get_address (msg));
5146 if (s->eq_q_controllable (id)) {
5147 s->eq_q_controllable (id)->set_value (s->eq_q_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
5151 return float_message_with_id ("/select/eq_q", id + 1, 0, sur->feedback[2], get_address (msg));
5155 OSC::sel_eq_shape (int id, float val, lo_message msg)
5157 OSCSurface *sur = get_surface(get_address (msg));
5158 boost::shared_ptr<Stripable> s;
5159 if (sur->expand_enable) {
5160 s = get_strip (sur->expand, get_address (msg));
5168 if (s->eq_shape_controllable (id)) {
5169 s->eq_shape_controllable (id)->set_value (s->eq_shape_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
5173 return float_message_with_id ("/select/eq_shape", id + 1, 0, sur->feedback[2], get_address (msg));
5178 OSC::periodic (void)
5180 if (observer_busy) {
5184 Glib::usleep(100); // let flurry of signals subside
5186 for (uint32_t it = 0; it < _surface.size(); it++) {
5187 OSCSurface* sur = &_surface[it];
5188 global_feedback (sur);
5190 global_init = false;
5201 if (scrub_speed != 0) {
5202 // for those jog wheels that don't have 0 on release (touch), time out.
5203 int64_t now = ARDOUR::get_microseconds ();
5204 int64_t diff = now - scrub_time;
5205 if (diff > 120000) {
5207 session->request_transport_speed (0);
5208 // locate to the place PH was at last tick
5209 session->request_locate (scrub_place, false);
5212 for (uint32_t it = 0; it < _surface.size(); it++) {
5213 OSCSurface* sur = &_surface[it];
5214 OSCSelectObserver* so;
5215 if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
5219 if ((co = dynamic_cast<OSCCueObserver*>(sur->cue_obs)) != 0) {
5222 OSCGlobalObserver* go;
5223 if ((go = dynamic_cast<OSCGlobalObserver*>(sur->global_obs)) != 0) {
5226 for (uint32_t i = 0; i < sur->observers.size(); i++) {
5227 OSCRouteObserver* ro;
5228 if ((ro = dynamic_cast<OSCRouteObserver*>(sur->observers[i])) != 0) {
5234 for (FakeTouchMap::iterator x = _touch_timeout.begin(); x != _touch_timeout.end();) {
5235 _touch_timeout[(*x).first] = (*x).second - 1;
5237 boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
5239 ctrl->stop_touch (ctrl->session().transport_sample());
5240 _touch_timeout.erase (x++);
5251 XMLNode& node (ControlProtocol::get_state());
5252 node.set_property ("debugmode", (int32_t) _debugmode); // TODO: enum2str
5253 node.set_property ("address-only", address_only);
5254 node.set_property ("remote-port", remote_port);
5255 node.set_property ("banksize", default_banksize);
5256 node.set_property ("striptypes", default_strip);
5257 node.set_property ("feedback", default_feedback);
5258 node.set_property ("gainmode", default_gainmode);
5259 node.set_property ("send-page-size", default_send_size);
5260 node.set_property ("plug-page-size", default_plugin_size);
5265 OSC::set_state (const XMLNode& node, int version)
5267 if (ControlProtocol::set_state (node, version)) {
5271 if (node.get_property (X_("debugmode"), debugmode)) {
5272 _debugmode = OSCDebugMode (debugmode);
5275 node.get_property (X_("address-only"), address_only);
5276 node.get_property (X_("remote-port"), remote_port);
5277 node.get_property (X_("banksize"), default_banksize);
5278 node.get_property (X_("striptypes"), default_strip);
5279 node.get_property (X_("feedback"), default_feedback);
5280 node.get_property (X_("gainmode"), default_gainmode);
5281 node.get_property (X_("send-page-size"), default_send_size);
5282 node.get_property (X_("plugin-page-size"), default_plugin_size);
5290 // predicate for sort call in get_sorted_stripables
5291 struct StripableByPresentationOrder
5293 bool operator () (const boost::shared_ptr<Stripable> & a, const boost::shared_ptr<Stripable> & b) const
5295 return a->presentation_info().order() < b->presentation_info().order();
5298 bool operator () (const Stripable & a, const Stripable & b) const
5300 return a.presentation_info().order() < b.presentation_info().order();
5303 bool operator () (const Stripable * a, const Stripable * b) const
5305 return a->presentation_info().order() < b->presentation_info().order();
5310 OSC::get_sorted_stripables(std::bitset<32> types, bool cue, bool custom, Sorted my_list)
5313 StripableList stripables;
5315 // fetch all stripables
5316 session->get_stripables (stripables);
5319 uint32_t nstps = my_list.size ();
5320 boost::shared_ptr<Stripable> s;
5321 for (uint32_t i = 0; i < nstps; i++) {
5322 bool exists = false;
5324 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
5325 boost::shared_ptr<Stripable> sl = *it;
5332 my_list[i] = boost::shared_ptr<Stripable>();
5337 // Look for stripables that match bit in sur->strip_types
5338 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
5340 boost::shared_ptr<Stripable> s = *it;
5341 if ((!cue) && (!types[9]) && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
5342 // do nothing... skip it
5343 } else if (types[8] && (s->is_selected())) {
5344 sorted.push_back (s);
5345 } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
5346 sorted.push_back (s);
5347 } else if (s->is_master() || s->is_monitor() || s->is_auditioner()) {
5348 // do nothing for these either (we add them later)
5350 if (types[0] && boost::dynamic_pointer_cast<AudioTrack>(s)) {
5351 sorted.push_back (s);
5352 } else if (types[1] && boost::dynamic_pointer_cast<MidiTrack>(s)) {
5353 sorted.push_back (s);
5354 } else if (types[4] && boost::dynamic_pointer_cast<VCA>(s)) {
5355 sorted.push_back (s);
5358 if (types[2] && Profile->get_mixbus() && s->mixbus()) {
5359 sorted.push_back (s);
5361 if (types[7] && boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
5362 if (Profile->get_mixbus() && !s->mixbus()) {
5363 sorted.push_back (s);
5367 if ((types[2] || types[3] || types[7]) && boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
5368 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
5369 if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
5370 // note some older sessions will show midibuses as busses
5371 if (r->direct_feeds_according_to_reality (session->master_out())) {
5374 sorted.push_back (s);
5377 // this is an Aux out
5379 sorted.push_back (s);
5382 } else if (types[3]) {
5383 sorted.push_back (s);
5388 sort (sorted.begin(), sorted.end(), StripableByPresentationOrder());
5389 // Master/Monitor might be anywhere... we put them at the end - Sorry ;)
5391 sorted.push_back (session->master_out());
5394 if (session->monitor_out()) {
5395 sorted.push_back (session->monitor_out());
5402 OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
5404 OSCSurface *s = get_surface(get_address (msg), true);
5408 if (types[0] == 'f') {
5410 } else if (types[0] == 'i') {
5411 value = (float) argv[0]->i;
5414 int ret = 1; /* unhandled */
5415 if (!strncmp (path, "/cue/aux", 8)) {
5419 ret = cue_set ((uint32_t) value, msg);
5425 else if (!strncmp (path, "/cue/connect", 12)) {
5426 // Connect to default Aux bus
5427 if ((!argc) || argv[0]->f || argv[0]->i) {
5428 ret = cue_set (1, msg);
5433 else if (!strncmp (path, "/cue/next_aux", 13)) {
5434 // switch to next Aux bus
5435 if ((!argc) || argv[0]->f || argv[0]->i) {
5436 ret = cue_next (msg);
5441 else if (!strncmp (path, "/cue/previous_aux", 17)) {
5442 // switch to previous Aux bus
5443 if ((!argc) || argv[0]->f || argv[0]->i) {
5444 ret = cue_previous (msg);
5449 else if (!strncmp (path, "/cue/send/fader/", 16) && strlen (path) > 16) {
5451 int id = atoi (&path[16]);
5452 ret = cue_send_fader (id, value, msg);
5455 else if (!strncmp (path, "/cue/send/enable/", 17) && strlen (path) > 17) {
5457 int id = atoi (&path[17]);
5458 ret = cue_send_enable (id, value, msg);
5461 else if (!strncmp (path, "/cue/fader", 10)) {
5463 ret = cue_aux_fader (value, msg);
5466 else if (!strncmp (path, "/cue/mute", 9)) {
5468 ret = cue_aux_mute (value, msg);
5476 OSC::cue_set (uint32_t aux, lo_message msg)
5479 return _cue_set (aux, get_address (msg));
5483 OSC::_cue_set (uint32_t aux, lo_address addr)
5486 OSCSurface *s = get_surface(addr, true);
5488 s->strip_types = 128;
5492 s->strips = get_sorted_stripables(s->strip_types, s->cue, false, s->custom_strips);
5494 s->nstrips = s->strips.size();
5498 } else if (aux > s->nstrips) {
5502 // get a list of Auxes
5503 for (uint32_t n = 0; n < s->nstrips; ++n) {
5504 boost::shared_ptr<Stripable> stp = s->strips[n];
5506 text_message (string_compose ("/cue/name/%1", n+1), stp->name(), addr);
5508 // aux must be at least one
5510 stp->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::_cue_set, this, aux, addr), this);
5511 // make a list of stripables with sends that go to this bus
5512 s->sends = cue_get_sorted_stripables(stp, aux, addr);
5514 s->cue_obs->refresh_strip (stp, s->sends, true);
5516 // start cue observer
5517 OSCCueObserver* co = new OSCCueObserver (*this, s);
5530 OSC::cue_next (lo_message msg)
5532 OSCSurface *s = get_surface(get_address (msg), true);
5536 ret = cue_set (1, msg);
5538 if (s->aux < s->nstrips) {
5539 ret = cue_set (s->aux + 1, msg);
5541 ret = cue_set (s->nstrips, msg);
5547 OSC::cue_previous (lo_message msg)
5549 OSCSurface *s = get_surface(get_address (msg), true);
5552 ret = cue_set (1, msg);
5555 ret = cue_set (s->aux - 1, msg);
5557 ret = cue_set (1, msg);
5562 boost::shared_ptr<Send>
5563 OSC::cue_get_send (uint32_t id, lo_address addr)
5565 OSCSurface *s = get_surface(addr, true);
5566 if (id && s->aux > 0 && id <= s->sends.size()) {
5567 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s->sends[id - 1]);
5568 boost::shared_ptr<Stripable> aux = get_strip (s->aux, addr);
5570 return r->internal_send_for (boost::dynamic_pointer_cast<Route> (aux));
5573 return boost::shared_ptr<Send>();
5578 OSC::cue_aux_fader (float position, lo_message msg)
5580 if (!session) return -1;
5582 OSCSurface *sur = get_surface(get_address (msg), true);
5585 boost::shared_ptr<Stripable> s = get_strip (sur->aux, get_address (msg));
5588 if (s->gain_control()) {
5589 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
5595 float_message ("/cue/fader", 0, get_address (msg));
5600 OSC::cue_aux_mute (float state, lo_message msg)
5602 if (!session) return -1;
5604 OSCSurface *sur = get_surface(get_address (msg), true);
5607 boost::shared_ptr<Stripable> s = get_strip (sur->aux, get_address (msg));
5609 if (s->mute_control()) {
5610 s->mute_control()->set_value (state ? 1.0 : 0.0, PBD::Controllable::NoGroup);
5616 float_message ("/cue/mute", 0, get_address (msg));
5621 OSC::cue_send_fader (uint32_t id, float val, lo_message msg)
5626 boost::shared_ptr<Send> s = cue_get_send (id, get_address (msg));
5628 if (s->gain_control()) {
5629 s->gain_control()->set_value (s->gain_control()->interface_to_internal(val), PBD::Controllable::NoGroup);
5633 float_message (string_compose ("/cue/send/fader/%1", id), 0, get_address (msg));
5638 OSC::cue_send_enable (uint32_t id, float state, lo_message msg)
5642 boost::shared_ptr<Send> s = cue_get_send (id, get_address (msg));
5651 float_message (string_compose ("/cue/send/enable/%1", id), 0, get_address (msg));
5655 // generic send message
5657 OSC::float_message (string path, float val, lo_address addr)
5661 reply = lo_message_new ();
5662 lo_message_add_float (reply, (float) val);
5664 lo_send_message (addr, path.c_str(), reply);
5665 lo_message_free (reply);
5671 OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool in_line, lo_address addr)
5673 lo_message msg = lo_message_new ();
5675 path = string_compose ("%1/%2", path, ssid);
5677 lo_message_add_int32 (msg, ssid);
5679 lo_message_add_float (msg, value);
5681 lo_send_message (addr, path.c_str(), msg);
5682 lo_message_free (msg);
5687 OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_line, lo_address addr)
5689 lo_message msg = lo_message_new ();
5691 path = string_compose ("%1/%2", path, ssid);
5693 lo_message_add_int32 (msg, ssid);
5695 lo_message_add_int32 (msg, value);
5697 lo_send_message (addr, path.c_str(), msg);
5698 lo_message_free (msg);
5703 OSC::text_message (string path, string val, lo_address addr)
5707 reply = lo_message_new ();
5708 lo_message_add_string (reply, val.c_str());
5710 lo_send_message (addr, path.c_str(), reply);
5711 lo_message_free (reply);
5717 OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr)
5719 lo_message msg = lo_message_new ();
5721 path = string_compose ("%1/%2", path, ssid);
5723 lo_message_add_int32 (msg, ssid);
5726 lo_message_add_string (msg, val.c_str());
5728 lo_send_message (addr, path.c_str(), msg);
5729 lo_message_free (msg);
5733 // we have to have a sorted list of stripables that have sends pointed at our aux
5734 // we can use the one in osc.cc to get an aux list
5736 OSC::cue_get_sorted_stripables(boost::shared_ptr<Stripable> aux, uint32_t id, lo_message msg)
5739 // fetch all stripables
5740 StripableList stripables;
5742 session->get_stripables (stripables);
5744 // Look for stripables that have a send to aux
5745 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
5747 boost::shared_ptr<Stripable> s = *it;
5748 // we only want routes
5749 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5751 r->processors_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
5752 boost::shared_ptr<Send> snd = r->internal_send_for (boost::dynamic_pointer_cast<Route> (aux));
5753 if (snd) { // test for send to aux
5754 sorted.push_back (s);
5755 s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::cue_set, this, id, msg), this);
5761 sort (sorted.begin(), sorted.end(), StripableByPresentationOrder());