2 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2014 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2012-2016 Tim Mayberry <mojofunk@gmail.com>
6 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
7 * Copyright (C) 2015-2016 Ben Loftis <ben@harrisonconsoles.com>
8 * Copyright (C) 2015-2018 John Emmas <john@creativepost.co.uk>
9 * Copyright (C) 2015 Johannes Mueller <github@johannes-mueller.org>
10 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include "pbd/gstdio_compat.h"
38 #include "pbd/control_math.h"
39 #include "pbd/controllable.h"
40 #include <pbd/convert.h>
41 #include <pbd/pthread_utils.h>
42 #include <pbd/file_utils.h>
43 #include <pbd/failed_constructor.h>
45 #include "ardour/amp.h"
46 #include "ardour/session.h"
47 #include "ardour/route.h"
48 #include "ardour/route_group.h"
49 #include "ardour/audio_track.h"
50 #include "ardour/midi_track.h"
51 #include "ardour/vca.h"
52 #include "ardour/monitor_control.h"
53 #include "ardour/dB.h"
54 #include "ardour/filesystem_paths.h"
55 #include "ardour/panner.h"
56 #include "ardour/panner_shell.h"
57 #include "ardour/pannable.h"
58 #include "ardour/plugin.h"
59 #include "ardour/plugin_insert.h"
60 #include "ardour/presentation_info.h"
61 #include "ardour/profile.h"
62 #include "ardour/send.h"
63 #include "ardour/internal_send.h"
64 #include "ardour/phase_control.h"
65 #include "ardour/solo_isolate_control.h"
66 #include "ardour/solo_safe_control.h"
67 #include "ardour/vca_manager.h"
69 #include "osc_select_observer.h"
71 #include "osc_controllable.h"
72 #include "osc_route_observer.h"
73 #include "osc_global_observer.h"
74 #include "osc_cue_observer.h"
77 using namespace ARDOUR;
80 using namespace ArdourSurface;
82 #include "pbd/abstract_ui.cc" // instantiate template
84 OSC* OSC::_instance = 0;
87 static void error_callback(int num, const char *m, const char *path)
89 fprintf(stderr, "liblo server error %d in path %s: %s\n", num, path, m);
92 static void error_callback(int, const char *, const char *)
98 OSC::OSC (Session& s, uint32_t port)
99 : ControlProtocol (s, X_("Open Sound Control (OSC)"))
100 , AbstractUI<OSCUIRequest> (name())
107 , _osc_unix_server (0)
109 , address_only (true)
110 , remote_port ("8000")
111 , default_banksize (0)
113 , default_feedback (0)
114 , default_gainmode (0)
115 , default_send_size (0)
116 , default_plugin_size (0)
119 , observer_busy (true)
125 session->Exported.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::session_exported, this, _1, _2), this);
137 OSC::request_factory (uint32_t num_requests)
139 /* AbstractUI<T>::request_buffer_factory() is a template method only
140 instantiated in this source module. To provide something visible for
141 use in the interface/descriptor, we have this static method that is
144 return request_buffer_factory (num_requests);
148 OSC::do_request (OSCUIRequest* req)
150 if (req->type == CallSlot) {
152 call_slot (MISSING_INVALIDATOR, req->the_slot);
154 } else if (req->type == Quit) {
161 OSC::set_active (bool yn)
163 if (yn != active()) {
177 return ControlProtocol::set_active (yn);
181 OSC::get_active () const
183 return _osc_server != 0;
192 /* already started */
196 for (int j=0; j < 20; ++j) {
197 snprintf(tmpstr, sizeof(tmpstr), "%d", _port);
199 //if ((_osc_server = lo_server_new_with_proto (tmpstr, LO_TCP, error_callback))) {
203 if ((_osc_server = lo_server_new (tmpstr, error_callback))) {
208 cerr << "can't get osc at port: " << _port << endl;
218 #ifdef ARDOUR_OSC_UNIX_SERVER
220 // APPEARS sluggish for now
222 // attempt to create unix socket server too
224 snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX");
225 int fd = mkstemp(tmpstr);
231 _osc_unix_server = lo_server_new (tmpstr, error_callback);
233 if (_osc_unix_server) {
234 _osc_unix_socket_path = tmpstr;
239 PBD::info << "OSC @ " << get_server_url () << endmsg;
241 std::string url_file;
243 if (find_file (ardour_config_search_path(), "osc_url", url_file)) {
244 _osc_url_file = url_file;
245 if (g_file_set_contents (_osc_url_file.c_str(), get_server_url().c_str(), -1, NULL)) {
246 cerr << "Couldn't write '" << _osc_url_file << "'" <<endl;
250 observer_busy = false;
251 register_callbacks();
253 session_loaded (*session);
255 // lo_server_thread_add_method(_sthread, NULL, NULL, OSC::_dummy_handler, this);
257 /* startup the event loop thread */
261 // start timers for metering, timecode and heartbeat.
262 // timecode and metering run at 100
263 Glib::RefPtr<Glib::TimeoutSource> periodic_timeout = Glib::TimeoutSource::create (100); // milliseconds
264 periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
265 periodic_timeout->attach (main_loop()->get_context());
267 // catch track reordering
268 // receive routes added
269 session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this);
270 // receive VCAs added
271 session->vca_manager().VCAAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_vca_added, this, _1), this);
273 PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
275 _select = ControlProtocol::first_selected_stripable();
277 _select = session->master_out ();
286 pthread_set_name (event_loop_name().c_str());
288 if (_osc_unix_server) {
289 Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR);
290 src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server));
291 src->attach (_main_loop->get_context());
292 local_server = src->gobj();
293 g_source_ref (local_server);
297 #ifdef PLATFORM_WINDOWS
298 Glib::RefPtr<IOChannel> chan = Glib::IOChannel::create_from_win32_socket (lo_server_get_socket_fd (_osc_server));
299 Glib::RefPtr<IOSource> src = IOSource::create (chan, IO_IN|IO_HUP|IO_ERR);
301 Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_server), IO_IN|IO_HUP|IO_ERR);
303 src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_server));
304 src->attach (_main_loop->get_context());
305 remote_server = src->gobj();
306 g_source_ref (remote_server);
309 PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
310 SessionEvent::create_per_thread_pool (event_loop_name(), 128);
316 periodic_connection.disconnect ();
317 session_connections.drop_connections ();
320 observer_busy = true;
321 for (uint32_t it = 0; it < _surface.size (); ++it) {
322 OSCSurface* sur = &_surface[it];
323 surface_destroy (sur);
329 g_source_destroy (local_server);
330 g_source_unref (local_server);
335 g_source_destroy (remote_server);
336 g_source_unref (remote_server);
343 lo_server_free (_osc_server);
347 if (_osc_unix_server) {
348 lo_server_free (_osc_unix_server);
349 _osc_unix_server = 0;
352 if (!_osc_unix_socket_path.empty()) {
353 ::g_unlink (_osc_unix_socket_path.c_str());
356 if (!_osc_url_file.empty() ) {
357 ::g_unlink (_osc_url_file.c_str() );
364 OSC::surface_destroy (OSCSurface* sur)
366 OSCSelectObserver* so;
367 if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
368 so->clear_observer ();
371 PBD::ScopedConnection pc = sur->proc_connection;
376 if ((co = dynamic_cast<OSCCueObserver*>(sur->cue_obs)) != 0) {
382 OSCGlobalObserver* go;
383 if ((go = dynamic_cast<OSCGlobalObserver*>(sur->global_obs)) != 0) {
384 go->clear_observer ();
388 uint32_t st_end = sur->observers.size ();
390 for (uint32_t i = 0; i < st_end; i++) {
391 OSCRouteObserver* ro;
392 if ((ro = dynamic_cast<OSCRouteObserver*>(sur->observers[i])) != 0) {
398 sur->observers.clear();
403 OSC::register_callbacks()
408 srvs[0] = _osc_server;
409 srvs[1] = _osc_unix_server;
411 for (size_t i = 0; i < 2; ++i) {
420 #define REGISTER_CALLBACK(serv,path,types, function) lo_server_add_method (serv, path, types, OSC::_ ## function, this)
422 // Some controls have optional "f" for feedback or touchosc
423 // http://hexler.net/docs/touchosc-controls-reference
425 REGISTER_CALLBACK (serv, X_("/refresh"), "", refresh_surface);
426 REGISTER_CALLBACK (serv, X_("/refresh"), "f", refresh_surface);
427 REGISTER_CALLBACK (serv, X_("/strip/list"), "", routes_list);
428 REGISTER_CALLBACK (serv, X_("/strip/list"), "f", routes_list);
429 REGISTER_CALLBACK (serv, X_("/group/list"), "", group_list);
430 REGISTER_CALLBACK (serv, X_("/group/list"), "f", group_list);
431 REGISTER_CALLBACK (serv, X_("/strip/custom/mode"), "f", custom_mode);
432 REGISTER_CALLBACK (serv, X_("/strip/custom/clear"), "f", custom_clear);
433 REGISTER_CALLBACK (serv, X_("/strip/custom/clear"), "", custom_clear);
434 REGISTER_CALLBACK (serv, X_("/surface/list"), "", surface_list);
435 REGISTER_CALLBACK (serv, X_("/surface/list"), "f", surface_list);
436 REGISTER_CALLBACK (serv, X_("/add_marker"), "", add_marker);
437 REGISTER_CALLBACK (serv, X_("/add_marker"), "f", add_marker);
438 REGISTER_CALLBACK (serv, X_("/access_action"), "s", access_action);
439 REGISTER_CALLBACK (serv, X_("/loop_toggle"), "", loop_toggle);
440 REGISTER_CALLBACK (serv, X_("/loop_toggle"), "f", loop_toggle);
441 REGISTER_CALLBACK (serv, X_("/loop_location"), "ii", loop_location);
442 REGISTER_CALLBACK (serv, X_("/goto_start"), "", goto_start);
443 REGISTER_CALLBACK (serv, X_("/goto_start"), "f", goto_start);
444 REGISTER_CALLBACK (serv, X_("/goto_end"), "", goto_end);
445 REGISTER_CALLBACK (serv, X_("/goto_end"), "f", goto_end);
446 REGISTER_CALLBACK (serv, X_("/scrub"), "f", scrub);
447 REGISTER_CALLBACK (serv, X_("/jog"), "f", jog);
448 REGISTER_CALLBACK (serv, X_("/jog/mode"), "f", jog_mode);
449 REGISTER_CALLBACK (serv, X_("/rewind"), "", rewind);
450 REGISTER_CALLBACK (serv, X_("/rewind"), "f", rewind);
451 REGISTER_CALLBACK (serv, X_("/ffwd"), "", ffwd);
452 REGISTER_CALLBACK (serv, X_("/ffwd"), "f", ffwd);
453 REGISTER_CALLBACK (serv, X_("/transport_stop"), "", transport_stop);
454 REGISTER_CALLBACK (serv, X_("/transport_stop"), "f", transport_stop);
455 REGISTER_CALLBACK (serv, X_("/transport_play"), "", transport_play);
456 REGISTER_CALLBACK (serv, X_("/transport_play"), "f", transport_play);
457 REGISTER_CALLBACK (serv, X_("/transport_frame"), "", transport_sample);
458 REGISTER_CALLBACK (serv, X_("/transport_speed"), "", transport_speed);
459 REGISTER_CALLBACK (serv, X_("/record_enabled"), "", record_enabled);
460 REGISTER_CALLBACK (serv, X_("/set_transport_speed"), "f", set_transport_speed);
461 // locate ii is position and bool roll
462 REGISTER_CALLBACK (serv, X_("/locate"), "ii", locate);
463 REGISTER_CALLBACK (serv, X_("/save_state"), "", save_state);
464 REGISTER_CALLBACK (serv, X_("/save_state"), "f", save_state);
465 REGISTER_CALLBACK (serv, X_("/prev_marker"), "", prev_marker);
466 REGISTER_CALLBACK (serv, X_("/prev_marker"), "f", prev_marker);
467 REGISTER_CALLBACK (serv, X_("/next_marker"), "", next_marker);
468 REGISTER_CALLBACK (serv, X_("/next_marker"), "f", next_marker);
469 REGISTER_CALLBACK (serv, X_("/undo"), "", undo);
470 REGISTER_CALLBACK (serv, X_("/undo"), "f", undo);
471 REGISTER_CALLBACK (serv, X_("/redo"), "", redo);
472 REGISTER_CALLBACK (serv, X_("/redo"), "f", redo);
473 REGISTER_CALLBACK (serv, X_("/toggle_punch_in"), "", toggle_punch_in);
474 REGISTER_CALLBACK (serv, X_("/toggle_punch_in"), "f", toggle_punch_in);
475 REGISTER_CALLBACK (serv, X_("/toggle_punch_out"), "", toggle_punch_out);
476 REGISTER_CALLBACK (serv, X_("/toggle_punch_out"), "f", toggle_punch_out);
477 REGISTER_CALLBACK (serv, X_("/rec_enable_toggle"), "", rec_enable_toggle);
478 REGISTER_CALLBACK (serv, X_("/rec_enable_toggle"), "f", rec_enable_toggle);
479 REGISTER_CALLBACK (serv, X_("/toggle_all_rec_enables"), "", toggle_all_rec_enables);
480 REGISTER_CALLBACK (serv, X_("/toggle_all_rec_enables"), "f", toggle_all_rec_enables);
481 REGISTER_CALLBACK (serv, X_("/all_tracks_rec_in"), "f", all_tracks_rec_in);
482 REGISTER_CALLBACK (serv, X_("/all_tracks_rec_out"), "f", all_tracks_rec_out);
483 REGISTER_CALLBACK (serv, X_("/cancel_all_solos"), "f", cancel_all_solos);
484 REGISTER_CALLBACK (serv, X_("/remove_marker"), "", remove_marker_at_playhead);
485 REGISTER_CALLBACK (serv, X_("/remove_marker"), "f", remove_marker_at_playhead);
486 REGISTER_CALLBACK (serv, X_("/jump_bars"), "f", jump_by_bars);
487 REGISTER_CALLBACK (serv, X_("/jump_seconds"), "f", jump_by_seconds);
488 REGISTER_CALLBACK (serv, X_("/mark_in"), "", mark_in);
489 REGISTER_CALLBACK (serv, X_("/mark_in"), "f", mark_in);
490 REGISTER_CALLBACK (serv, X_("/mark_out"), "", mark_out);
491 REGISTER_CALLBACK (serv, X_("/mark_out"), "f", mark_out);
492 REGISTER_CALLBACK (serv, X_("/toggle_click"), "", toggle_click);
493 REGISTER_CALLBACK (serv, X_("/toggle_click"), "f", toggle_click);
494 REGISTER_CALLBACK (serv, X_("/click/level"), "f", click_level);
495 REGISTER_CALLBACK (serv, X_("/midi_panic"), "", midi_panic);
496 REGISTER_CALLBACK (serv, X_("/midi_panic"), "f", midi_panic);
497 REGISTER_CALLBACK (serv, X_("/toggle_roll"), "", toggle_roll);
498 REGISTER_CALLBACK (serv, X_("/toggle_roll"), "f", toggle_roll);
499 REGISTER_CALLBACK (serv, X_("/stop_forget"), "", stop_forget);
500 REGISTER_CALLBACK (serv, X_("/stop_forget"), "f", stop_forget);
501 REGISTER_CALLBACK (serv, X_("/set_punch_range"), "", set_punch_range);
502 REGISTER_CALLBACK (serv, X_("/set_punch_range"), "f", set_punch_range);
503 REGISTER_CALLBACK (serv, X_("/set_loop_range"), "", set_loop_range);
504 REGISTER_CALLBACK (serv, X_("/set_loop_range"), "f", set_loop_range);
505 REGISTER_CALLBACK (serv, X_("/set_session_range"), "", set_session_range);
506 REGISTER_CALLBACK (serv, X_("/set_session_range"), "f", set_session_range);
507 REGISTER_CALLBACK (serv, X_("/toggle_monitor_mute"), "", toggle_monitor_mute);
508 REGISTER_CALLBACK (serv, X_("/toggle_monitor_mute"), "f", toggle_monitor_mute);
509 REGISTER_CALLBACK (serv, X_("/toggle_monitor_dim"), "", toggle_monitor_dim);
510 REGISTER_CALLBACK (serv, X_("/toggle_monitor_dim"), "f", toggle_monitor_dim);
511 REGISTER_CALLBACK (serv, X_("/toggle_monitor_mono"), "", toggle_monitor_mono);
512 REGISTER_CALLBACK (serv, X_("/toggle_monitor_mono"), "f", toggle_monitor_mono);
513 REGISTER_CALLBACK (serv, X_("/quick_snapshot_switch"), "", quick_snapshot_switch);
514 REGISTER_CALLBACK (serv, X_("/quick_snapshot_switch"), "f", quick_snapshot_switch);
515 REGISTER_CALLBACK (serv, X_("/quick_snapshot_stay"), "", quick_snapshot_stay);
516 REGISTER_CALLBACK (serv, X_("/quick_snapshot_stay"), "f", quick_snapshot_stay);
517 REGISTER_CALLBACK (serv, X_("/session_name"), "s", name_session);
518 REGISTER_CALLBACK (serv, X_("/fit_1_track"), "", fit_1_track);
519 REGISTER_CALLBACK (serv, X_("/fit_1_track"), "f", fit_1_track);
520 REGISTER_CALLBACK (serv, X_("/fit_2_tracks"), "", fit_2_tracks);
521 REGISTER_CALLBACK (serv, X_("/fit_2_tracks"), "f", fit_2_tracks);
522 REGISTER_CALLBACK (serv, X_("/fit_4_tracks"), "", fit_4_tracks);
523 REGISTER_CALLBACK (serv, X_("/fit_4_tracks"), "f", fit_4_tracks);
524 REGISTER_CALLBACK (serv, X_("/fit_8_tracks"), "", fit_8_tracks);
525 REGISTER_CALLBACK (serv, X_("/fit_8_tracks"), "f", fit_8_tracks);
526 REGISTER_CALLBACK (serv, X_("/fit_16_tracks"), "", fit_16_tracks);
527 REGISTER_CALLBACK (serv, X_("/fit_16_tracks"), "f", fit_16_tracks);
528 REGISTER_CALLBACK (serv, X_("/fit_32_tracks"), "", fit_32_tracks);
529 REGISTER_CALLBACK (serv, X_("/fit_32_tracks"), "f", fit_32_tracks);
530 REGISTER_CALLBACK (serv, X_("/fit_all_tracks"), "", fit_all_tracks);
531 REGISTER_CALLBACK (serv, X_("/fit_all_tracks"), "f", fit_all_tracks);
532 REGISTER_CALLBACK (serv, X_("/zoom_100_ms"), "", zoom_100_ms);
533 REGISTER_CALLBACK (serv, X_("/zoom_100_ms"), "f", zoom_100_ms);
534 REGISTER_CALLBACK (serv, X_("/zoom_1_sec"), "", zoom_1_sec);
535 REGISTER_CALLBACK (serv, X_("/zoom_1_sec"), "f", zoom_1_sec);
536 REGISTER_CALLBACK (serv, X_("/zoom_10_sec"), "", zoom_10_sec);
537 REGISTER_CALLBACK (serv, X_("/zoom_10_sec"), "f", zoom_10_sec);
538 REGISTER_CALLBACK (serv, X_("/zoom_1_min"), "", zoom_1_min);
539 REGISTER_CALLBACK (serv, X_("/zoom_1_min"), "f", zoom_1_min);
540 REGISTER_CALLBACK (serv, X_("/zoom_5_min"), "", zoom_5_min);
541 REGISTER_CALLBACK (serv, X_("/zoom_5_min"), "f", zoom_5_min);
542 REGISTER_CALLBACK (serv, X_("/zoom_10_min"), "", zoom_10_min);
543 REGISTER_CALLBACK (serv, X_("/zoom_10_min"), "f", zoom_10_min);
544 REGISTER_CALLBACK (serv, X_("/zoom_to_session"), "", zoom_to_session);
545 REGISTER_CALLBACK (serv, X_("/zoom_to_session"), "f", zoom_to_session);
546 REGISTER_CALLBACK (serv, X_("/temporal_zoom_in"), "f", temporal_zoom_in);
547 REGISTER_CALLBACK (serv, X_("/temporal_zoom_in"), "", temporal_zoom_in);
548 REGISTER_CALLBACK (serv, X_("/temporal_zoom_out"), "", temporal_zoom_out);
549 REGISTER_CALLBACK (serv, X_("/temporal_zoom_out"), "f", temporal_zoom_out);
550 REGISTER_CALLBACK (serv, X_("/scroll_up_1_track"), "f", scroll_up_1_track);
551 REGISTER_CALLBACK (serv, X_("/scroll_up_1_track"), "", scroll_up_1_track);
552 REGISTER_CALLBACK (serv, X_("/scroll_dn_1_track"), "f", scroll_dn_1_track);
553 REGISTER_CALLBACK (serv, X_("/scroll_dn_1_track"), "", scroll_dn_1_track);
554 REGISTER_CALLBACK (serv, X_("/scroll_up_1_page"), "f", scroll_up_1_page);
555 REGISTER_CALLBACK (serv, X_("/scroll_up_1_page"), "", scroll_up_1_page);
556 REGISTER_CALLBACK (serv, X_("/scroll_dn_1_page"), "f", scroll_dn_1_page);
557 REGISTER_CALLBACK (serv, X_("/scroll_dn_1_page"), "", scroll_dn_1_page);
558 REGISTER_CALLBACK (serv, X_("/bank_up"), "", bank_up);
559 REGISTER_CALLBACK (serv, X_("/bank_up"), "f", bank_delta);
560 REGISTER_CALLBACK (serv, X_("/bank_down"), "", bank_down);
561 REGISTER_CALLBACK (serv, X_("/bank_down"), "f", bank_down);
562 REGISTER_CALLBACK (serv, X_("/use_group"), "f", use_group);
564 // controls for "special" strips
565 REGISTER_CALLBACK (serv, X_("/master/gain"), "f", master_set_gain);
566 REGISTER_CALLBACK (serv, X_("/master/fader"), "f", master_set_fader);
567 REGISTER_CALLBACK (serv, X_("/master/db_delta"), "f", master_delta_gain);
568 REGISTER_CALLBACK (serv, X_("/master/mute"), "i", master_set_mute);
569 REGISTER_CALLBACK (serv, X_("/master/trimdB"), "f", master_set_trim);
570 REGISTER_CALLBACK (serv, X_("/master/pan_stereo_position"), "f", master_set_pan_stereo_position);
571 REGISTER_CALLBACK (serv, X_("/master/select"), "f", master_select);
572 REGISTER_CALLBACK (serv, X_("/monitor/gain"), "f", monitor_set_gain);
573 REGISTER_CALLBACK (serv, X_("/monitor/fader"), "f", monitor_set_fader);
574 REGISTER_CALLBACK (serv, X_("/monitor/db_delta"), "f", monitor_delta_gain);
575 REGISTER_CALLBACK (serv, X_("/monitor/mute"), "i", monitor_set_mute);
576 REGISTER_CALLBACK (serv, X_("/monitor/dim"), "i", monitor_set_dim);
577 REGISTER_CALLBACK (serv, X_("/monitor/mono"), "i", monitor_set_mono);
579 // Controls for the Selected strip
580 REGISTER_CALLBACK (serv, X_("/select/recenable"), "i", sel_recenable);
581 REGISTER_CALLBACK (serv, X_("/select/record_safe"), "i", sel_recsafe);
582 REGISTER_CALLBACK (serv, X_("/select/name"), "s", sel_rename);
583 REGISTER_CALLBACK (serv, X_("/select/comment"), "s", sel_comment);
584 REGISTER_CALLBACK (serv, X_("/select/mute"), "i", sel_mute);
585 REGISTER_CALLBACK (serv, X_("/select/solo"), "i", sel_solo);
586 REGISTER_CALLBACK (serv, X_("/select/solo_iso"), "i", sel_solo_iso);
587 REGISTER_CALLBACK (serv, X_("/select/solo_safe"), "i", sel_solo_safe);
588 REGISTER_CALLBACK (serv, X_("/select/monitor_input"), "i", sel_monitor_input);
589 REGISTER_CALLBACK (serv, X_("/select/monitor_disk"), "i", sel_monitor_disk);
590 REGISTER_CALLBACK (serv, X_("/select/polarity"), "i", sel_phase);
591 REGISTER_CALLBACK (serv, X_("/select/gain"), "f", sel_gain);
592 REGISTER_CALLBACK (serv, X_("/select/fader"), "f", sel_fader);
593 REGISTER_CALLBACK (serv, X_("/select/db_delta"), "f", sel_dB_delta);
594 REGISTER_CALLBACK (serv, X_("/select/trimdB"), "f", sel_trim);
595 REGISTER_CALLBACK (serv, X_("/select/hide"), "i", sel_hide);
596 REGISTER_CALLBACK (serv, X_("/select/previous"), "f", sel_previous);
597 REGISTER_CALLBACK (serv, X_("/select/previous"), "", sel_previous);
598 REGISTER_CALLBACK (serv, X_("/select/next"), "f", sel_next);
599 REGISTER_CALLBACK (serv, X_("/select/next"), "", sel_next);
600 REGISTER_CALLBACK (serv, X_("/select/pan_stereo_position"), "f", sel_pan_position);
601 REGISTER_CALLBACK (serv, X_("/select/pan_stereo_width"), "f", sel_pan_width);
602 REGISTER_CALLBACK (serv, X_("/select/send_gain"), "if", sel_sendgain);
603 REGISTER_CALLBACK (serv, X_("/select/send_fader"), "if", sel_sendfader);
604 REGISTER_CALLBACK (serv, X_("/select/send_enable"), "if", sel_sendenable);
605 REGISTER_CALLBACK (serv, X_("/select/master_send_enable"), "i", sel_master_send_enable);
606 REGISTER_CALLBACK (serv, X_("/select/send_page"), "f", sel_send_page);
607 REGISTER_CALLBACK (serv, X_("/select/plug_page"), "f", sel_plug_page);
608 REGISTER_CALLBACK (serv, X_("/select/plugin"), "f", sel_plugin);
609 REGISTER_CALLBACK (serv, X_("/select/plugin/activate"), "f", sel_plugin_activate);
610 REGISTER_CALLBACK (serv, X_("/select/expand"), "i", sel_expand);
611 REGISTER_CALLBACK (serv, X_("/select/pan_elevation_position"), "f", sel_pan_elevation);
612 REGISTER_CALLBACK (serv, X_("/select/pan_frontback_position"), "f", sel_pan_frontback);
613 REGISTER_CALLBACK (serv, X_("/select/pan_lfe_control"), "f", sel_pan_lfe);
614 REGISTER_CALLBACK (serv, X_("/select/comp_enable"), "f", sel_comp_enable);
615 REGISTER_CALLBACK (serv, X_("/select/comp_threshold"), "f", sel_comp_threshold);
616 REGISTER_CALLBACK (serv, X_("/select/comp_speed"), "f", sel_comp_speed);
617 REGISTER_CALLBACK (serv, X_("/select/comp_mode"), "f", sel_comp_mode);
618 REGISTER_CALLBACK (serv, X_("/select/comp_makeup"), "f", sel_comp_makeup);
619 REGISTER_CALLBACK (serv, X_("/select/eq_enable"), "f", sel_eq_enable);
620 REGISTER_CALLBACK (serv, X_("/select/eq_hpf/freq"), "f", sel_eq_hpf_freq);
621 REGISTER_CALLBACK (serv, X_("/select/eq_hpf/enable"), "f", sel_eq_hpf_enable);
622 REGISTER_CALLBACK (serv, X_("/select/eq_hpf/slope"), "f", sel_eq_hpf_slope);
623 REGISTER_CALLBACK (serv, X_("/select/eq_lpf/freq"), "f", sel_eq_lpf_freq);
624 REGISTER_CALLBACK (serv, X_("/select/eq_lpf/enable"), "f", sel_eq_lpf_enable);
625 REGISTER_CALLBACK (serv, X_("/select/eq_lpf/slope"), "f", sel_eq_lpf_slope);
626 REGISTER_CALLBACK (serv, X_("/select/eq_gain"), "if", sel_eq_gain);
627 REGISTER_CALLBACK (serv, X_("/select/eq_freq"), "if", sel_eq_freq);
628 REGISTER_CALLBACK (serv, X_("/select/eq_q"), "if", sel_eq_q);
629 REGISTER_CALLBACK (serv, X_("/select/eq_shape"), "if", sel_eq_shape);
630 REGISTER_CALLBACK (serv, X_("/select/add_personal_send"), "s", sel_new_personal_send);
632 /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */
633 REGISTER_CALLBACK (serv, X_("/strip/mute"), "ii", route_mute);
634 REGISTER_CALLBACK (serv, X_("/strip/solo"), "ii", route_solo);
635 REGISTER_CALLBACK (serv, X_("/strip/solo_iso"), "ii", route_solo_iso);
636 REGISTER_CALLBACK (serv, X_("/strip/solo_safe"), "ii", route_solo_safe);
637 REGISTER_CALLBACK (serv, X_("/strip/recenable"), "ii", route_recenable);
638 REGISTER_CALLBACK (serv, X_("/strip/record_safe"), "ii", route_recsafe);
639 REGISTER_CALLBACK (serv, X_("/strip/monitor_input"), "ii", route_monitor_input);
640 REGISTER_CALLBACK (serv, X_("/strip/monitor_disk"), "ii", route_monitor_disk);
641 REGISTER_CALLBACK (serv, X_("/strip/expand"), "ii", strip_expand);
642 REGISTER_CALLBACK (serv, X_("/strip/hide"), "ii", strip_hide);
643 REGISTER_CALLBACK (serv, X_("/strip/select"), "ii", strip_gui_select);
644 REGISTER_CALLBACK (serv, X_("/strip/polarity"), "ii", strip_phase);
645 REGISTER_CALLBACK (serv, X_("/strip/gain"), "if", route_set_gain_dB);
646 REGISTER_CALLBACK (serv, X_("/strip/fader"), "if", route_set_gain_fader);
647 REGISTER_CALLBACK (serv, X_("/strip/db_delta"), "if", strip_db_delta);
648 REGISTER_CALLBACK (serv, X_("/strip/trimdB"), "if", route_set_trim_dB);
649 REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_position"), "if", route_set_pan_stereo_position);
650 REGISTER_CALLBACK (serv, X_("/strip/pan_stereo_width"), "if", route_set_pan_stereo_width);
651 REGISTER_CALLBACK (serv, X_("/strip/plugin/parameter"), "iiif", route_plugin_parameter);
652 // prints to cerr only
653 REGISTER_CALLBACK (serv, X_("/strip/plugin/parameter/print"), "iii", route_plugin_parameter_print);
654 REGISTER_CALLBACK (serv, X_("/strip/plugin/activate"), "ii", route_plugin_activate);
655 REGISTER_CALLBACK (serv, X_("/strip/plugin/deactivate"), "ii", route_plugin_deactivate);
656 REGISTER_CALLBACK (serv, X_("/strip/send/gain"), "iif", route_set_send_gain_dB);
657 REGISTER_CALLBACK (serv, X_("/strip/send/fader"), "iif", route_set_send_fader);
658 REGISTER_CALLBACK (serv, X_("/strip/send/enable"), "iif", route_set_send_enable);
659 REGISTER_CALLBACK (serv, X_("/strip/name"), "is", route_rename);
660 REGISTER_CALLBACK (serv, X_("/strip/group"), "is", strip_group);
661 REGISTER_CALLBACK (serv, X_("/strip/sends"), "i", route_get_sends);
662 REGISTER_CALLBACK (serv, X_("/strip/receives"), "i", route_get_receives);
663 REGISTER_CALLBACK (serv, X_("/strip/plugin/list"), "i", route_plugin_list);
664 REGISTER_CALLBACK (serv, X_("/strip/plugin/descriptor"), "ii", route_plugin_descriptor);
665 REGISTER_CALLBACK (serv, X_("/strip/plugin/reset"), "ii", route_plugin_reset);
667 /* still not-really-standardized query interface */
668 //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value);
669 //REGISTER_CALLBACK (serv, "/ardour/set", "", set);
671 // un/register_update args= s:ctrl s:returl s:retpath
672 //lo_server_add_method(serv, "/register_update", "sss", OSC::global_register_update_handler, this);
673 //lo_server_add_method(serv, "/unregister_update", "sss", OSC::global_unregister_update_handler, this);
674 //lo_server_add_method(serv, "/register_auto_update", "siss", OSC::global_register_auto_update_handler, this);
675 //lo_server_add_method(serv, "/unregister_auto_update", "sss", OSC::_global_unregister_auto_update_handler, this);
677 /* this is a special catchall handler,
678 * register at the end so this is only called if no
679 * other handler matches (also used for debug) */
680 lo_server_add_method (serv, 0, 0, _catchall, this);
685 OSC::osc_input_handler (IOCondition ioc, lo_server srv)
688 lo_server_recv (srv);
691 if (ioc & ~(IO_IN|IO_PRI)) {
699 OSC::get_server_url()
705 urlstr = lo_server_get_url (_osc_server);
714 OSC::get_unix_server_url()
719 if (_osc_unix_server) {
720 urlstr = lo_server_get_url (_osc_unix_server);
731 session->set_dirty();
735 OSC::current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg)
739 subpath = (char*) malloc (len-15+1);
740 memcpy (subpath, path, len-15);
741 subpath[len-15] = '\0';
743 send_current_value (subpath, argv, argc, msg);
749 OSC::send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg)
755 lo_message reply = lo_message_new ();
756 boost::shared_ptr<Route> r;
759 lo_message_add_string (reply, path);
762 lo_message_add_string (reply, "bad syntax");
765 r = session->get_remote_nth_route (id);
768 lo_message_add_string (reply, "not found");
771 if (strcmp (path, X_("/strip/state")) == 0) {
773 if (boost::dynamic_pointer_cast<AudioTrack>(r)) {
774 lo_message_add_string (reply, "AT");
775 } else if (boost::dynamic_pointer_cast<MidiTrack>(r)) {
776 lo_message_add_string (reply, "MT");
778 lo_message_add_string (reply, "B");
781 lo_message_add_string (reply, r->name().c_str());
782 lo_message_add_int32 (reply, r->n_inputs().n_audio());
783 lo_message_add_int32 (reply, r->n_outputs().n_audio());
784 lo_message_add_int32 (reply, r->muted());
785 lo_message_add_int32 (reply, r->soloed());
787 } else if (strcmp (path, X_("/strip/mute")) == 0) {
789 lo_message_add_int32 (reply, (float) r->muted());
791 } else if (strcmp (path, X_("/strip/solo")) == 0) {
793 lo_message_add_int32 (reply, r->soloed());
797 OSCSurface *sur = get_surface(get_address (msg));
799 if (sur->feedback[14]) {
800 lo_send_message (get_address (msg), X_("/reply"), reply);
802 lo_send_message (get_address (msg), X_("#reply"), reply);
804 lo_message_free (reply);
808 OSC::_catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data)
810 return ((OSC*)user_data)->catchall (path, types, argv, argc, data);
814 OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
817 int ret = 1; /* unhandled */
819 //cerr << "Received a message, path = " << path << " types = \""
820 // << (types ? types : "NULL") << '"' << endl;
822 /* 15 for /#current_value plus 2 for /<path> */
825 OSCSurface *sur = get_surface(get_address (msg), true);
827 uint32_t ls = sur->linkset;
830 set = &(link_sets[ls]);
831 sur->custom_mode = set->custom_mode;
832 sur->custom_strips = set->custom_strips;
833 sur->temp_mode = set->temp_mode;
834 sur->temp_strips = set->temp_strips;
835 sur->temp_master = set->temp_master;
838 if (strstr (path, X_("/automation"))) {
839 ret = set_automation (path, types, argv, argc, msg);
842 if (strstr (path, X_("/touch"))) {
843 ret = touch_detect (path, types, argv, argc, msg);
846 if (strstr (path, X_("/spill"))) {
847 ret = spill (path, types, argv, argc, msg);
850 if (len >= 17 && !strcmp (&path[len-15], X_("/#current_value"))) {
851 current_value_query (path, len, argv, argc, msg);
855 if (!strncmp (path, X_("/cue/"), 5)) {
857 ret = cue_parse (path, types, argv, argc, msg);
860 if (!strncmp (path, X_("/select/plugin/parameter"), 24)) {
862 ret = select_plugin_parameter (path, types, argv, argc, msg);
865 if (!strncmp (path, X_("/access_action/"), 15)) {
867 if (!(argc && !argv[0]->i)) {
868 std::string action_path = path;
870 access_action (action_path.substr(15));
875 if (strcmp (path, X_("/strip/listen")) == 0) {
877 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
878 } else if (sur->custom_mode && !sur->temp_mode) {
879 PBD::warning << "OSC: Can't add strips with custom enabled." << endmsg;
881 for (int n = 0; n < argc; ++n) {
882 boost::shared_ptr<Stripable> s = boost::shared_ptr<Stripable>();
883 if (types[n] == 'f') {
884 s = get_strip ((uint32_t) argv[n]->f, get_address (msg));
885 } else if (types[n] == 'i') {
886 s = get_strip (argv[n]->i, get_address (msg));
889 sur->custom_strips.push_back (s);
893 set->custom_strips = sur->custom_strips;
898 if (strcmp (path, X_("/strip/ignore")) == 0) {
900 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
901 } else if (!sur->custom_mode || sur->temp_mode) {
902 PBD::warning << "OSC: Can't remove strips without custom enabled." << endmsg;
904 for (int n = 0; n < argc; ++n) {
906 if (types[n] == 'f') {
907 st_no = (uint32_t) argv[n]->f;
908 } else if (types[n] == 'i') {
909 st_no = (uint32_t) argv[n]->i;
911 if (st_no && st_no <= sur->custom_strips.size ()) {
912 sur->custom_strips[argv[n]->i - 1] = boost::shared_ptr<Stripable>();
916 set->custom_strips = sur->custom_strips;
918 ret = set_bank (sur->bank, msg);
923 if (strstr (path, X_("/strip")) && (argc != 1)) {
924 // All of the strip commands below require 1 parameter
925 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
927 if (!strncmp (path, X_("/strip/gain/"), 12) && strlen (path) > 12) {
929 int ssid = atoi (&path[12]);
930 ret = route_set_gain_dB (ssid, argv[0]->f, msg);
932 else if (!strncmp (path, X_("/strip/fader/"), 13) && strlen (path) > 13) {
934 int ssid = atoi (&path[13]);
935 ret = route_set_gain_fader (ssid, argv[0]->f, msg);
937 else if (!strncmp (path, X_("/strip/db_delta"), 15)) {
942 if (strlen (path) > 15 && argc == 1) {
943 ssid = atoi (&path[16]);
944 } else if (argc == 2) {
945 if (types[0] == 'f') {
946 ssid = (int) argv[0]->f;
954 if (types[ar_off] == 'f') {
955 delta = argv[ar_off]->f;
957 delta = (float) argv[ar_off]->i;
959 ret = strip_db_delta (ssid, delta, msg);
961 else if (!strncmp (path, X_("/strip/trimdB/"), 14) && strlen (path) > 14) {
962 int ssid = atoi (&path[14]);
963 ret = route_set_trim_dB (ssid, argv[0]->f, msg);
965 else if (!strncmp (path, X_("/strip/pan_stereo_position/"), 27) && strlen (path) > 27) {
966 int ssid = atoi (&path[27]);
967 ret = route_set_pan_stereo_position (ssid, argv[0]->f, msg);
969 else if (!strncmp (path, X_("/strip/mute/"), 12) && strlen (path) > 12) {
970 int ssid = atoi (&path[12]);
971 ret = route_mute (ssid, argv[0]->i, msg);
973 else if (!strncmp (path, X_("/strip/solo/"), 12) && strlen (path) > 12) {
974 int ssid = atoi (&path[12]);
975 ret = route_solo (ssid, argv[0]->i, msg);
977 else if (!strncmp (path, X_("/strip/monitor_input/"), 21) && strlen (path) > 21) {
978 int ssid = atoi (&path[21]);
979 ret = route_monitor_input (ssid, argv[0]->i, msg);
981 else if (!strncmp (path, X_("/strip/monitor_disk/"), 20) && strlen (path) > 20) {
982 int ssid = atoi (&path[20]);
983 ret = route_monitor_disk (ssid, argv[0]->i, msg);
985 else if (!strncmp (path, X_("/strip/recenable/"), 17) && strlen (path) > 17) {
986 int ssid = atoi (&path[17]);
987 ret = route_recenable (ssid, argv[0]->i, msg);
989 else if (!strncmp (path, X_("/strip/record_safe/"), 19) && strlen (path) > 19) {
990 int ssid = atoi (&path[19]);
991 ret = route_recsafe (ssid, argv[0]->i, msg);
993 else if (!strncmp (path, X_("/strip/expand/"), 14) && strlen (path) > 14) {
994 int ssid = atoi (&path[14]);
995 ret = strip_expand (ssid, argv[0]->i, msg);
997 else if (!strncmp (path, X_("/strip/hide/"), 12) && strlen (path) > 12) {
998 int ssid = atoi (&path[12]);
999 ret = strip_hide (ssid, argv[0]->i, msg);
1001 else if (!strncmp (path, X_("/strip/select/"), 14) && strlen (path) > 14) {
1002 int ssid = atoi (&path[14]);
1003 ret = strip_gui_select (ssid, argv[0]->i, msg);
1005 else if (strstr (path, X_("/select/group"))) {
1006 ret = parse_sel_group (path, types, argv, argc, msg);
1008 else if (strstr (path, X_("/select/vca"))) {
1009 ret = parse_sel_vca (path, types, argv, argc, msg);
1011 else if (strstr (path, X_("/select")) && (argc != 1)) {
1012 // All of the select commands below require 1 parameter
1013 PBD::warning << "OSC: Wrong number of parameters." << endmsg;
1015 else if (!strncmp (path, X_("/select/send_gain/"), 18) && strlen (path) > 18) {
1016 int ssid = atoi (&path[18]);
1017 ret = sel_sendgain (ssid, argv[0]->f, msg);
1019 else if (!strncmp (path, X_("/select/send_fader/"), 19) && strlen (path) > 19) {
1020 int ssid = atoi (&path[19]);
1021 ret = sel_sendfader (ssid, argv[0]->f, msg);
1023 else if (!strncmp (path, X_("/select/send_enable/"), 20) && strlen (path) > 20) {
1024 int ssid = atoi (&path[20]);
1025 ret = sel_sendenable (ssid, argv[0]->f, msg);
1027 else if (!strncmp (path, X_("/select/eq_gain/"), 16) && strlen (path) > 16) {
1028 int ssid = atoi (&path[16]);
1029 ret = sel_eq_gain (ssid, argv[0]->f, msg);
1031 else if (!strncmp (path, X_("/select/eq_freq/"), 16) && strlen (path) > 16) {
1032 int ssid = atoi (&path[16]);
1033 ret = sel_eq_freq (ssid, argv[0]->f , msg);
1035 else if (!strncmp (path, X_("/select/eq_q/"), 13) && strlen (path) > 13) {
1036 int ssid = atoi (&path[13]);
1037 ret = sel_eq_q (ssid, argv[0]->f, msg);
1039 else if (!strncmp (path, X_("/select/eq_shape/"), 17) && strlen (path) > 17) {
1040 int ssid = atoi (&path[17]);
1041 ret = sel_eq_shape (ssid, argv[0]->f, msg);
1043 else if (!strncmp (path, X_("/marker"), 7)) {
1044 ret = set_marker (types, argv, argc, msg);
1046 else if (!strncmp (path, X_("/set_surface"), 12)) {
1047 ret = surface_parse (path, types, argv, argc, msg);
1049 else if (strstr (path, X_("/link"))) {
1050 ret = parse_link (path, types, argv, argc, msg);
1053 check_surface (msg);
1056 if ((ret && _debugmode != Off)) {
1057 debugmsg (_("Unhandled OSC message"), path, types, argv, argc);
1058 } else if (!ret && _debugmode == All) {
1059 debugmsg (_("OSC"), path, types, argv, argc);
1066 OSC::debugmsg (const char *prefix, const char *path, const char* types, lo_arg **argv, int argc)
1068 std::stringstream ss;
1069 for (int i = 0; i < argc; ++i) {
1070 lo_type type = (lo_type)types[i];
1074 ss << "i:" << argv[i]->i;
1077 ss << "f:" << argv[i]->f;
1080 ss << "d:" << argv[i]->d;
1083 ss << "s:" << &argv[i]->s;
1086 ss << "h:" << argv[i]->h;
1089 ss << "c:" << argv[i]->s;
1120 PBD::info << prefix << ": " << path << ss.str() << endmsg;
1123 // "Application Hook" Handlers //
1125 OSC::session_loaded (Session& s)
1127 // lo_address listener = lo_address_new (NULL, "7770");
1128 // lo_send (listener, "/session/loaded", "ss", s.path().c_str(), s.name().c_str());
1132 OSC::session_exported (std::string path, std::string name)
1134 lo_address listener = lo_address_new (NULL, "7770");
1135 lo_send (listener, X_("/session/exported"), "ss", path.c_str(), name.c_str());
1136 lo_address_free (listener);
1139 // end "Application Hook" Handlers //
1141 /* path callbacks */
1144 OSC::current_value (const char */*path*/, const char */*types*/, lo_arg **/*argv*/, int /*argc*/, void */*data*/, void* /*user_data*/)
1149 if (argc < 3 || types == 0 || strlen (types) < 3 || types[0] != 's' || types[1] != 's' || types[2] != s) {
1153 const char *returl = argv[1]->s;
1154 lo_address addr = find_or_cache_addr (returl);
1156 const char *retpath = argv[2]->s;
1159 if (strcmp (argv[0]->s, X_("transport_frame")) == 0) {
1162 lo_send (addr, retpath, "i", session->transport_sample());
1165 } else if (strcmp (argv[0]->s, X_("transport_speed")) == 0) {
1168 lo_send (addr, retpath, "i", session->transport_sample());
1171 } else if (strcmp (argv[0]->s, X_("transport_locked")) == 0) {
1174 lo_send (addr, retpath, "i", session->transport_sample());
1177 } else if (strcmp (argv[0]->s, X_("punch_in")) == 0) {
1180 lo_send (addr, retpath, "i", session->transport_sample());
1183 } else if (strcmp (argv[0]->s, X_("punch_out")) == 0) {
1186 lo_send (addr, retpath, "i", session->transport_sample());
1189 } else if (strcmp (argv[0]->s, X_("rec_enable")) == 0) {
1192 lo_send (addr, retpath, "i", session->transport_sample());
1204 OSC::routes_list (lo_message msg)
1209 OSCSurface *sur = get_surface(get_address (msg), true);
1211 for (int n = 0; n < (int) sur->nstrips; ++n) {
1213 boost::shared_ptr<Stripable> s = get_strip (n + 1, get_address (msg));
1216 // some things need the route
1217 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
1219 lo_message reply = lo_message_new ();
1221 if (boost::dynamic_pointer_cast<AudioTrack>(s)) {
1222 lo_message_add_string (reply, "AT");
1223 } else if (boost::dynamic_pointer_cast<MidiTrack>(s)) {
1224 lo_message_add_string (reply, "MT");
1225 } else if (boost::dynamic_pointer_cast<VCA>(s)) {
1226 lo_message_add_string (reply, "V");
1227 } else if (s->is_master()) {
1228 lo_message_add_string (reply, "MA");
1229 } else if (s->is_monitor()) {
1230 lo_message_add_string (reply, "MO");
1231 } else if (boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
1232 if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
1233 // r->feeds (session->master_out()) may make more sense
1234 if (session->master_out() && r->direct_feeds_according_to_reality (session->master_out())) {
1236 lo_message_add_string (reply, "B");
1238 // this is an Aux out
1239 lo_message_add_string (reply, "AX");
1242 lo_message_add_string (reply, "MB");
1246 lo_message_add_string (reply, s->name().c_str());
1248 // routes have inputs and outputs
1249 lo_message_add_int32 (reply, r->n_inputs().n_audio());
1250 lo_message_add_int32 (reply, r->n_outputs().n_audio());
1252 // non-routes like VCAs don't
1253 lo_message_add_int32 (reply, 0);
1254 lo_message_add_int32 (reply, 0);
1256 if (s->mute_control()) {
1257 lo_message_add_int32 (reply, s->mute_control()->get_value());
1259 lo_message_add_int32 (reply, 0);
1261 if (s->solo_control()) {
1262 lo_message_add_int32 (reply, s->solo_control()->get_value());
1264 lo_message_add_int32 (reply, 0);
1266 lo_message_add_int32 (reply, n + 1);
1267 if (s->rec_enable_control()) {
1268 lo_message_add_int32 (reply, s->rec_enable_control()->get_value());
1270 if (sur->feedback[14]) {
1271 lo_send_message (get_address (msg), X_("/reply"), reply);
1273 lo_send_message (get_address (msg), X_("#reply"), reply);
1275 lo_message_free (reply);
1279 // Send end of listing message
1280 lo_message reply = lo_message_new ();
1282 lo_message_add_string (reply, X_("end_route_list"));
1283 lo_message_add_int64 (reply, session->sample_rate());
1284 lo_message_add_int64 (reply, session->current_end_sample());
1285 if (session->monitor_out()) {
1286 // this session has a monitor section
1287 lo_message_add_int32 (reply, 1);
1289 lo_message_add_int32 (reply, 0);
1292 if (sur->feedback[14]) {
1293 lo_send_message (get_address (msg), X_("/reply"), reply);
1295 lo_send_message (get_address (msg), X_("#reply"), reply);
1298 lo_message_free (reply);
1299 // send feedback for newly created control surface
1300 strip_feedback (sur, true);
1301 global_feedback (sur);
1302 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
1307 OSC::surface_list (lo_message msg)
1313 OSC::get_surfaces ()
1316 /* this function is for debugging and prints lots of
1317 * information about what surfaces Ardour knows about and their
1318 * internal parameters. It is best accessed by sending:
1319 * /surface/list from oscsend. This command does not create
1323 PBD::info << string_compose ("\nList of known Surfaces (%1):\n", _surface.size());
1325 Glib::Threads::Mutex::Lock lm (surfaces_lock);
1326 for (uint32_t it = 0; it < _surface.size(); it++) {
1327 OSCSurface* sur = &_surface[it];
1328 char *chost = lo_url_get_hostname (sur->remote_url.c_str());
1329 string host = chost;
1331 string port = get_port (host);
1332 if (port != "auto") {
1333 port = "Manual port";
1337 PBD::info << string_compose ("\n Surface: %1 - URL: %2 %3\n", it, sur->remote_url, port);
1338 PBD::info << string_compose (" Number of strips: %1 Bank size: %2 Current Bank %3\n", sur->nstrips, sur->bank_size, sur->bank);
1339 PBD::info << string_compose (" Use Custom: %1 Custom Strips: %2\n", sur->custom_mode, sur->custom_strips.size ());
1340 PBD::info << string_compose (" Temp Mode: %1 Temp Strips: %2\n", sur->temp_mode, sur->temp_strips.size ());
1342 if (sur->usegroup == PBD::Controllable::UseGroup) {
1345 PBD::info << string_compose (" Strip Types: %1 Feedback: %2 No_clear flag: %3 Gain mode: %4 Use groups flag %5\n", \
1346 sur->strip_types.to_ulong(), sur->feedback.to_ulong(), sur->no_clear, sur->gainmode, ug);
1347 PBD::info << string_compose (" Using plugin: %1 of %2 plugins, with %3 params. Page size: %4 Page: %5\n", \
1348 sur->plugin_id, sur->plugins.size(), sur->plug_params.size(), sur->plug_page_size, sur->plug_page);
1349 PBD::info << string_compose (" Send page size: %1 Page: %2\n", sur->send_page_size, sur->send_page);
1350 PBD::info << string_compose (" Expanded flag %1 Track: %2 Jogmode: %3\n", sur->expand_enable, sur->expand, sur->jogmode);
1351 PBD::info << string_compose (" Personal monitor flag %1, Aux master: %2, Number of sends: %3\n", sur->cue, sur->aux, sur->sends.size());
1352 PBD::info << string_compose (" Linkset: %1 Device Id: %2\n", sur->linkset, sur->linkid);
1354 PBD::info << string_compose ("\nList of LinkSets (%1):\n", link_sets.size());
1355 std::map<uint32_t, LinkSet>::iterator it;
1356 for (it = link_sets.begin(); it != link_sets.end(); it++) {
1360 uint32_t devices = 0;
1361 LinkSet* set = &(*it).second;
1362 if (set->urls.size()) {
1363 devices = set->urls.size() - 1;
1365 PBD::info << string_compose ("\n Linkset %1 has %2 devices and sees %3 strips\n", (*it).first, devices, set->strips.size());
1366 PBD::info << string_compose (" Bank size: %1 Current bank: %2 Strip Types: %3\n", set->banksize, set->bank, set->strip_types.to_ulong());
1367 PBD::info << string_compose (" Auto bank sizing: %1 Linkset not ready flag: %2\n", set->autobank, set->not_ready);
1368 PBD::info << string_compose (" Use Custom: %1 Number of Custom Strips: %2\n", set->custom_mode, set->custom_strips.size ());
1369 PBD::info << string_compose (" Temp Mode: %1 Number of Temp Strips: %2\n", set->temp_mode, set->temp_strips.size ());
1371 PBD::info << endmsg;
1375 OSC::custom_clear (lo_message msg)
1380 OSCSurface *sur = get_surface(get_address (msg), true);
1381 sur->custom_mode = 0;
1382 sur->custom_strips.clear ();
1383 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, false, sur->custom_strips);
1384 sur->nstrips = sur->strips.size();
1386 uint32_t ls = sur->linkset;
1388 set = &(link_sets[ls]);
1389 set->custom_mode = 0;
1390 set->custom_strips.clear ();
1391 set->strips = sur->strips;
1393 return set_bank (1, msg);
1397 OSC::custom_mode (float state, lo_message msg)
1399 return _custom_mode ((uint32_t) state, get_address (msg));
1403 OSC::_custom_mode (uint32_t state, lo_address addr)
1408 OSCSurface *sur = get_surface(addr, true);
1410 uint32_t ls = sur->linkset;
1413 set = &(link_sets[ls]);
1414 sur->custom_mode = set->custom_mode;
1415 sur->custom_strips = set->custom_strips;
1417 sur->temp_mode = TempOff;
1419 if (sur->custom_strips.size () == 0) {
1420 PBD::warning << "No custom strips set to enable" << endmsg;
1421 sur->custom_mode = 0;
1423 set->custom_mode = 0;
1427 if (sur->bank_size) {
1428 sur->custom_mode = state | 0x4;
1430 sur->custom_mode = state;
1432 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips);
1433 sur->nstrips = sur->custom_strips.size();
1436 sur->custom_mode = 0;
1437 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 0, sur->custom_strips);
1438 sur->nstrips = sur->strips.size();
1441 set->custom_mode = sur->custom_mode;
1442 set->strips = sur->strips;
1443 set->temp_mode = sur->temp_mode;
1445 return _set_bank (1, addr);
1449 OSC::cancel_all_solos ()
1451 session->cancel_all_solo ();
1456 OSC::get_address (lo_message msg)
1458 lo_address addr = lo_message_get_source (msg);
1459 string host = lo_address_get_hostname (addr);
1460 string port = lo_address_get_port (addr);
1461 int protocol = lo_address_get_protocol (addr);
1462 string saved_port = get_port (host);
1463 if (saved_port != "") {
1464 if (saved_port != "auto") {
1466 return lo_address_new_with_proto (protocol, host.c_str(), port.c_str());
1468 return lo_message_get_source (msg);
1472 // if we get here we need to add a new entry for this surface
1474 new_port.host = host;
1476 new_port.port = remote_port;
1477 _ports.push_back (new_port);
1478 return lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str());
1480 new_port.port = "auto";
1481 _ports.push_back (new_port);
1482 return lo_message_get_source (msg);
1487 OSC::get_port (string host)
1489 for (uint32_t i = 0; i < _ports.size (); i++) {
1490 if (_ports[i].host == host) {
1491 return _ports[i].port;
1498 OSC::refresh_surface (lo_message msg)
1500 OSCSurface *s = get_surface(get_address (msg), true);
1501 uint32_t bs = s->bank_size;
1502 uint32_t st = (uint32_t) s->strip_types.to_ulong();
1503 uint32_t fb = (uint32_t) s->feedback.to_ulong();
1504 uint32_t gm = (uint32_t) s->gainmode;
1505 uint32_t sp = s->send_page_size;
1506 uint32_t pp = s->plug_page_size;
1508 surface_destroy (s);
1509 // restart all observers
1510 set_surface (bs, st, fb, gm, sp, pp, msg);
1515 OSC::clear_devices ()
1518 observer_busy = true;
1519 session_connections.drop_connections ();
1520 // clear out surfaces
1521 for (uint32_t it = 0; it < _surface.size(); ++it) {
1522 OSCSurface* sur = &_surface[it];
1523 surface_destroy (sur);
1529 PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
1531 observer_busy = false;
1536 OSC::parse_link (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
1538 int ret = 1; /* unhandled */
1541 PBD::warning << "OSC: /link/* needs at least one parameter" << endmsg;
1545 if (types[argc - 1] == 'f') {
1546 data = argv[argc - 1]->f;
1548 data = argv[argc - 1]->i;
1550 if (isdigit(strrchr (path, '/')[1])) {
1551 set = atoi (&(strrchr (path, '/')[1]));
1552 } else if (argc == 2) {
1553 if (types[0] == 'f') {
1554 set = (int) argv[0]->f;
1559 PBD::warning << "OSC: wrong number of parameters." << endmsg;
1562 LinkSet *ls = get_linkset (set, get_address (msg));
1567 if (!strncmp (path, X_("/link/bank_size"), 15)) {
1568 ls->banksize = (uint32_t) data;
1569 ls->autobank = false;
1570 ls->not_ready = link_check (set);
1571 if (ls->not_ready) {
1573 surface_link_state (ls);
1575 _set_bank (ls->bank, get_address (msg));
1579 } else if (!strncmp (path, X_("/link/set"), 9)) {
1580 ret = set_link (set, (uint32_t) data, get_address (msg));
1587 OSC::get_linkset (uint32_t set, lo_address addr)
1589 OSCSurface *sur = get_surface(addr);
1593 // need to check if set is wanted
1594 std::map<uint32_t, LinkSet>::iterator it;
1595 it = link_sets.find(set);
1596 if (it == link_sets.end()) {
1597 // no such linkset make it
1599 new_ls.banksize = 0;
1601 new_ls.autobank = true;
1602 new_ls.not_ready = true;
1603 new_ls.strip_types = sur->strip_types;
1604 new_ls.strips = sur->strips;
1605 new_ls.custom_strips = sur->custom_strips;
1606 new_ls.custom_mode = sur->custom_mode;
1607 new_ls.temp_mode = sur->temp_mode;
1608 new_ls.urls.resize (2);
1609 link_sets[set] = new_ls;
1611 ls = &link_sets[set];
1614 // User expects this surface to be removed from any sets
1615 uint32_t oldset = sur->linkset;
1617 uint32_t oldid = sur->linkid;
1620 LinkSet *ols = &link_sets[oldset];
1622 ols->not_ready = oldid;
1623 ols->urls[oldid] = "";
1624 surface_link_state (ols);
1632 OSC::set_link (uint32_t set, uint32_t id, lo_address addr)
1634 OSCSurface *sur = get_surface(addr, true);
1637 LinkSet *ls = get_linkset (set, addr);
1638 if (ls->urls.size() <= (uint32_t) id) {
1639 ls->urls.resize ((int) id + 1);
1641 ls->urls[(uint32_t) id] = sur->remote_url;
1642 ls->not_ready = link_check (set);
1643 if (ls->not_ready) {
1644 surface_link_state (ls);
1646 _set_bank (1, addr);
1652 OSC::link_strip_types (uint32_t linkset, uint32_t striptypes)
1659 std::map<uint32_t, LinkSet>::iterator it;
1660 it = link_sets.find(linkset);
1661 if (it == link_sets.end()) {
1662 // this should never happen... but
1665 ls = &link_sets[linkset];
1666 ls->strip_types = striptypes;
1667 ls->temp_mode = TempOff;
1668 for (uint32_t dv = 1; dv < ls->urls.size(); dv++) {
1671 if (ls->urls[dv] != "") {
1672 string url = ls->urls[dv];
1673 su = get_surface (lo_address_new_from_url (url.c_str()), true);
1674 if (su->linkset == linkset) {
1675 su->strip_types = striptypes;
1676 if (su->strip_types[10]) {
1677 su->usegroup = PBD::Controllable::UseGroup;
1679 su->usegroup = PBD::Controllable::NoGroup;
1689 OSC::surface_link_state (LinkSet * set)
1691 for (uint32_t dv = 1; dv < set->urls.size(); dv++) {
1693 if (set->urls[dv] != "") {
1694 string url = set->urls[dv];
1695 OSCSurface *sur = get_surface (lo_address_new_from_url (url.c_str()), true);
1696 for (uint32_t i = 0; i < sur->observers.size(); i++) {
1697 sur->observers[i]->set_link_ready (set->not_ready);
1704 OSC::link_check (uint32_t set)
1711 std::map<uint32_t, LinkSet>::iterator it;
1712 it = link_sets.find(set);
1713 if (it == link_sets.end()) {
1714 // this should never happen... but
1717 ls = &link_sets[set];
1718 uint32_t bank_total = 0;
1719 for (uint32_t dv = 1; dv < ls->urls.size(); dv++) {
1722 if (ls->urls[dv] != "") {
1723 string url = ls->urls[dv];
1724 su = get_surface (lo_address_new_from_url (url.c_str()), true);
1728 if (su->linkset == set) {
1729 bank_total = bank_total + su->bank_size;
1735 ls->banksize = bank_total;
1737 if (bank_total != ls->banksize) {
1738 return ls->urls.size();
1746 OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
1748 int ret = 1; /* unhandled */
1749 OSCSurface *sur = get_surface(get_address (msg), true);
1750 int pi_page = sur->plug_page_size;
1751 int se_page = sur->send_page_size;
1752 int fadermode = sur->gainmode;
1753 int feedback = sur->feedback.to_ulong();
1754 int strip_types = sur->strip_types.to_ulong();
1755 int bank_size = sur->bank_size;
1756 int linkset = sur->linkset;
1757 int linkid = sur->linkid;
1758 string host = lo_url_get_hostname(sur->remote_url.c_str());
1759 int port = atoi (get_port (host).c_str());
1761 if (argc == 1 && !strncmp (path, X_("/set_surface/feedback"), 21)) {
1762 if (types[0] == 'f') {
1763 ret = set_surface_feedback ((int)argv[0]->f, msg);
1765 ret = set_surface_feedback (argv[0]->i, msg);
1768 else if (argc == 1 && !strncmp (path, X_("/set_surface/bank_size"), 22)) {
1769 if (types[0] == 'f') {
1770 ret = set_surface_bank_size ((int)argv[0]->f, msg);
1772 ret = set_surface_bank_size (argv[0]->i, msg);
1775 else if (argc == 1 && !strncmp (path, X_("/set_surface/gainmode"), 21)) {
1776 if (types[0] == 'f') {
1777 ret = set_surface_gainmode ((int)argv[0]->f, msg);
1779 ret = set_surface_gainmode (argv[0]->i, msg);
1782 else if (argc == 1 && !strncmp (path, X_("/set_surface/strip_types"), 24)) {
1783 if (types[0] == 'f') {
1784 ret = set_surface_strip_types ((int)argv[0]->f, msg);
1786 ret = set_surface_strip_types (argv[0]->i, msg);
1789 else if (argc == 1 && !strncmp (path, X_("/set_surface/send_page_size"), 27)) {
1790 if (types[0] == 'f') {
1791 ret = sel_send_pagesize ((int)argv[0]->f, msg);
1793 ret = sel_send_pagesize (argv[0]->i, msg);
1796 else if (argc == 1 && !strncmp (path, X_("/set_surface/plugin_page_size"), 29)) {
1797 if (types[0] == 'f') {
1798 ret = sel_plug_pagesize ((int)argv[0]->f, msg);
1800 ret = sel_plug_pagesize (argv[0]->i, msg);
1803 else if (argc == 1 && !strncmp (path, X_("/set_surface/port"), 17)) {
1804 if (types[0] == 'f') {
1805 ret = set_surface_port ((int)argv[0]->f, msg);
1807 ret = set_surface_port (argv[0]->i, msg);
1809 } else if (strlen(path) == 12) {
1811 // command is in /set_surface iii form
1814 if (types[8] == 'f') {
1815 linkid = (int) argv[8]->f;
1817 linkid = argv[8]->i;
1821 if (types[7] == 'f') {
1822 linkset = (int) argv[7]->f;
1824 linkset = argv[7]->i;
1828 if (types[6] == 'f') {
1829 port = (int) argv[6]->f;
1835 if (types[5] == 'f') {
1836 pi_page = (int) argv[5]->f;
1838 pi_page = argv[5]->i;
1842 if (types[4] == 'f') {
1843 se_page = (int) argv[4]->f;
1845 se_page = argv[4]->i;
1849 if (types[3] == 'f') {
1850 fadermode = (int) argv[3]->f;
1852 fadermode = argv[3]->i;
1856 if (types[2] == 'f') {
1857 feedback = (int) argv[2]->f;
1859 feedback = argv[2]->i;
1863 if (types[1] == 'f') {
1864 strip_types = (int) argv[1]->f;
1866 strip_types = argv[1]->i;
1870 if (types[0] == 'f') {
1871 bank_size = (int) argv[0]->f;
1873 bank_size = argv[0]->i;
1875 set_surface_port (port, msg);
1876 ret = set_surface (bank_size, strip_types, feedback, fadermode, se_page, pi_page, msg);
1877 if ((uint32_t) linkset != sur->linkset) {
1878 set_link (linkset, linkid, get_address (msg));
1882 // send current setup
1884 lo_message reply = lo_message_new ();
1885 lo_message_add_int32 (reply, bank_size);
1886 lo_message_add_int32 (reply, strip_types);
1887 lo_message_add_int32 (reply, feedback);
1888 lo_message_add_int32 (reply, fadermode);
1889 lo_message_add_int32 (reply, se_page);
1890 lo_message_add_int32 (reply, pi_page);
1891 lo_message_add_int32 (reply, (int) linkset);
1892 lo_message_add_int32 (reply, (int) linkid);
1893 lo_message_add_int32 (reply, (int) port);
1894 lo_send_message (get_address (msg), X_("/set_surface"), reply);
1895 lo_message_free (reply);
1901 PBD::warning << "OSC: Too many parameters." << endmsg;
1905 } else if (isdigit(path[13])) {
1906 // some of our parameters must be "in-lined"
1907 bank_size = atoi (&path[13]);
1908 const char * par = strstr (&path[13], "/");
1910 strip_types = atoi (&par[1]);
1911 const char * fb = strstr (&par[1], "/");
1913 feedback = atoi (&fb[1]);
1914 const char * fm = strstr (&fb[1], "/");
1916 fadermode = atoi (&fm[1]);
1917 const char * sp = strstr (&fm[1], "/");
1919 se_page = atoi (&sp[1]);
1920 const char * pp = strstr (&sp[1], "/");
1922 pi_page = atoi (&pp[1]);
1923 const char * po = strstr (&pp[1], "/");
1925 port = atoi (&po[1]);
1926 const char * ls = strstr (&po[1], "/");
1928 linkset = atoi (&ls[1]);
1929 const char * li = strstr (&ls[1], "/");
1931 linkid = atoi (&li[1]);
1933 if (types[0] == 'f') {
1934 linkid = (int) argv[0]->f;
1935 } else if (types[0] == 'i') {
1936 linkid = argv[0]->i;
1940 if (types[0] == 'f') {
1941 linkset = (int) argv[0]->f;
1942 } else if (types[0] == 'i') {
1943 linkset = argv[0]->i;
1947 if (types[0] == 'f') {
1948 port = (int) argv[0]->f;
1949 } else if (types[0] == 'i') {
1954 if (types[0] == 'f') {
1955 pi_page = (int) argv[0]->f;
1956 } else if (types[0] == 'i') {
1957 pi_page = argv[0]->i;
1961 if (types[0] == 'f') {
1962 se_page = (int) argv[0]->f;
1963 } else if (types[0] == 'i') {
1964 se_page = argv[0]->i;
1968 if (types[0] == 'f') {
1969 fadermode = (int) argv[0]->f;
1970 } else if (types[0] == 'i') {
1971 fadermode = argv[0]->i;
1975 if (types[0] == 'f') {
1976 feedback = (int) argv[0]->f;
1977 } else if (types[0] == 'i') {
1978 feedback = argv[0]->i;
1982 if (types[0] == 'f') {
1983 strip_types = (int) argv[0]->f;
1984 } else if (types[0] == 'i') {
1985 strip_types = argv[0]->i;
1988 set_surface_port (port, msg);
1989 ret = set_surface (bank_size, strip_types, feedback, fadermode, se_page, pi_page, msg);
1990 if ((uint32_t) linkset != sur->linkset) {
1991 set_link (linkset, linkid, get_address (msg));
1998 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)
2000 if (observer_busy) {
2003 OSCSurface *s = get_surface(get_address (msg), true);
2004 s->bank_size = b_size;
2005 s->strip_types = strips;
2008 if (s->strip_types[10]) {
2009 s->usegroup = PBD::Controllable::UseGroup;
2011 s->usegroup = PBD::Controllable::NoGroup;
2013 s->send_page_size = se_size;
2014 s->plug_page_size = pi_size;
2016 s->temp_mode = TempOff;
2019 set_link (s->linkset, s->linkid, get_address (msg));
2020 link_strip_types (s->linkset, s->strip_types.to_ulong());
2022 // set bank and strip feedback
2023 strip_feedback(s, true);
2024 _set_bank (1, get_address (msg));
2025 _strip_select (boost::shared_ptr<Stripable> (), get_address (msg));
2028 global_feedback (s);
2029 sel_send_pagesize (se_size, msg);
2030 sel_plug_pagesize (pi_size, msg);
2035 OSC::set_surface_bank_size (uint32_t bs, lo_message msg)
2037 if (observer_busy) {
2040 OSCSurface *s = get_surface(get_address (msg), true);
2042 if (s->custom_mode && bs) {
2043 s->custom_mode = s->custom_mode | 0x4;
2046 set_link (s->linkset, s->linkid, get_address (msg));
2048 // set bank and strip feedback
2049 _set_bank (1, get_address (msg));
2055 OSC::set_surface_strip_types (uint32_t st, lo_message msg)
2057 if (observer_busy) {
2060 OSCSurface *s = get_surface(get_address (msg), true);
2061 s->strip_types = st;
2062 s->temp_mode = TempOff;
2063 if (s->strip_types[10]) {
2064 s->usegroup = PBD::Controllable::UseGroup;
2066 s->usegroup = PBD::Controllable::NoGroup;
2069 link_strip_types (s->linkset, st);
2071 // set bank and strip feedback
2072 strip_feedback(s, false);
2074 _strip_select (boost::shared_ptr<Stripable> (), get_address (msg));
2080 OSC::set_surface_feedback (uint32_t fb, lo_message msg)
2082 if (observer_busy) {
2085 OSCSurface *s = get_surface(get_address (msg), true);
2088 strip_feedback (s, true);
2089 global_feedback (s);
2090 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
2095 OSC::set_surface_gainmode (uint32_t gm, lo_message msg)
2097 if (observer_busy) {
2100 OSCSurface *s = get_surface(get_address (msg), true);
2103 strip_feedback (s, true);
2104 global_feedback (s);
2105 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), get_address (msg));
2110 OSC::set_surface_port (uint32_t po, lo_message msg)
2115 } else if (po > 1024) {
2116 new_port = string_compose ("%1", po);
2118 PBD::warning << "Port value must be greater than 1024" << endmsg;
2121 OSCSurface *sur = get_surface(get_address (msg), true);
2122 lo_address addr = lo_message_get_source (msg);
2123 string host = lo_address_get_hostname (addr);
2124 string port = lo_address_get_port (addr);
2125 int protocol = lo_address_get_protocol (addr);
2126 for (uint32_t i = 0; i < _ports.size (); i++) {
2127 if (_ports[i].host == host) {
2128 if (_ports[i].port == new_port) {
2129 // no change - do nothing
2132 lo_address new_addr;
2133 _ports[i].port = new_port;
2134 if (new_port == "auto") {
2137 new_addr = lo_address_new_with_proto (protocol, host.c_str(), new_port.c_str());
2140 rurl = lo_address_get_url (new_addr);
2141 sur->remote_url = rurl;
2143 for (uint32_t it = 0; it < _surface.size();) {
2144 if (&_surface[it] == sur) {
2148 char *sur_host = lo_url_get_hostname(_surface[it].remote_url.c_str());
2149 if (strstr (sur_host, host.c_str())) {
2150 surface_destroy (&_surface[it]);
2151 _surface.erase (_surface.begin() + it);
2156 if (sur->feedback.to_ulong()) {
2157 refresh_surface (msg);
2163 // should not get here
2168 OSC::check_surface (lo_message msg)
2173 get_surface(get_address (msg));
2178 OSC::get_surface (lo_address addr , bool quiet)
2182 rurl = lo_address_get_url (addr);
2185 for (uint32_t it = 0; it < _surface.size(); ++it) {
2186 //find setup for this surface
2187 if (!_surface[it].remote_url.find(r_url)){
2188 return &_surface[it];
2192 // No surface create one with default values
2194 s.remote_url = r_url;
2198 s.bank_size = default_banksize;
2199 s.observers.clear();
2202 s.strip_types = default_strip;
2203 s.feedback = default_feedback;
2204 s.gainmode = default_gainmode;
2205 s.usegroup = PBD::Controllable::NoGroup;
2206 s.custom_strips.clear ();
2208 s.temp_mode = TempOff;
2211 s.expand_enable = false;
2212 s.expand_strip = boost::shared_ptr<Stripable> ();
2216 s.strips = get_sorted_stripables(s.strip_types, s.cue, false, s.custom_strips);
2218 s.send_page_size = default_send_size;
2220 s.plug_page_size = default_plugin_size;
2225 s.nstrips = s.strips.size();
2227 _surface.push_back (s);
2231 strip_feedback (&s, true);
2232 global_feedback (&s);
2233 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
2236 return &_surface[_surface.size() - 1];
2239 // setup global feedback for a surface
2241 OSC::global_feedback (OSCSurface* sur)
2243 OSCGlobalObserver* o = sur->global_obs;
2247 if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) {
2249 // create a new Global Observer for this surface
2250 OSCGlobalObserver* o = new OSCGlobalObserver (*this, *session, sur);
2251 sur->global_obs = o;
2252 o->jog_mode (sur->jogmode);
2257 OSC::strip_feedback (OSCSurface* sur, bool new_bank_size)
2260 uint32_t ls = sur->linkset;
2263 set = &(link_sets[ls]);
2264 if (set->not_ready) {
2267 sur->custom_mode = set->custom_mode;
2268 sur->custom_strips = set->custom_strips;
2269 sur->temp_mode = set->temp_mode;
2270 sur->temp_strips = set->temp_strips;
2271 sur->temp_master = set->temp_master;
2273 if (!sur->temp_mode) {
2274 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, sur->custom_mode, sur->custom_strips);
2276 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
2278 sur->nstrips = sur->strips.size();
2280 set->strips = sur->strips;
2283 if (new_bank_size || (!sur->feedback[0] && !sur->feedback[1])) {
2284 // delete old observers
2285 for (uint32_t i = 0; i < sur->observers.size(); i++) {
2286 if (!sur->bank_size) {
2287 sur->observers[i]->clear_strip ();
2289 delete sur->observers[i];
2291 sur->observers.clear();
2293 uint32_t bank_size = sur->bank_size;
2295 bank_size = sur->nstrips;
2298 if (sur->feedback[0] || sur->feedback[1]) {
2299 for (uint32_t i = 0; i < bank_size; i++) {
2300 OSCRouteObserver* o = new OSCRouteObserver (*this, i + 1, sur);
2301 sur->observers.push_back (o);
2302 if (sur->temp_mode == BusOnly) {
2303 boost::shared_ptr<ARDOUR::Stripable> str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str()));
2304 boost::shared_ptr<ARDOUR::Send> send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str()));
2306 o->refresh_send (send, true);
2313 if (sur->feedback[0] || sur->feedback[1]) {
2314 for (uint32_t i = 0; i < sur->observers.size(); i++) {
2315 boost::shared_ptr<ARDOUR::Stripable> str = get_strip (i + 1, lo_address_new_from_url (sur->remote_url.c_str()));
2316 sur->observers[i]->refresh_strip(str, true);
2317 if (sur->temp_mode == BusOnly) {
2318 boost::shared_ptr<ARDOUR::Send> send = get_send (str, lo_address_new_from_url (sur->remote_url.c_str()));
2320 sur->observers[i]->refresh_send (send, true);
2330 OSC::notify_routes_added (ARDOUR::RouteList &)
2332 // not sure if we need this PI change seems to cover
2337 OSC::notify_vca_added (ARDOUR::VCAList &)
2339 // not sure if we need this PI change seems to cover
2351 OSC::_recalcbanks ()
2353 if (observer_busy) {
2357 * We have two different ways of working here:
2358 * 1) banked: The controller has a bank of strips and only can deal
2359 * with banksize strips. We start banksize observers which run until
2360 * either banksize is changed or Ardour exits.
2362 * 2) banksize is 0 or unlimited and so is the same size as the number
2363 * of strips. For a recalc, We want to tear down all strips but not send
2364 * a reset value for any of the controls and then rebuild all observers.
2365 * this is easier than detecting change in "bank" size and deleting or
2366 * adding just a few.
2369 // refresh each surface we know about.
2370 for (uint32_t it = 0; it < _surface.size(); ++it) {
2371 OSCSurface* sur = &_surface[it];
2373 lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
2375 _cue_set (sur->aux, addr);
2376 } else if (!sur->bank_size) {
2377 strip_feedback (sur, true);
2378 // This surface uses /strip/list tell it routes have changed
2380 reply = lo_message_new ();
2381 lo_send_message (addr, X_("/strip/list"), reply);
2382 lo_message_free (reply);
2384 strip_feedback (sur, false);
2386 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
2391 OSC::set_bank (uint32_t bank_start, lo_message msg)
2393 return _set_bank (bank_start, get_address (msg));
2396 // set bank is callable with either message or address
2398 OSC::_set_bank (uint32_t bank_start, lo_address addr)
2403 if (!session->nroutes()) {
2407 OSCSurface *s = get_surface (addr, true);
2409 Sorted striplist = s->strips;
2410 uint32_t nstrips = s->nstrips;
2413 uint32_t ls = s->linkset;
2416 //we have a linkset... deal with each surface
2417 set = &(link_sets[ls]);
2418 if (set->not_ready) {
2421 uint32_t d_count = set->urls.size();
2422 set->strips = striplist;
2423 bank_start = bank_limits_check (bank_start, set->banksize, nstrips);
2424 set->bank = bank_start;
2425 uint32_t not_ready = 0;
2426 for (uint32_t dv = 1; dv < d_count; dv++) {
2427 if (set->urls[dv] != "") {
2428 string url = set->urls[dv];
2429 OSCSurface *sur = get_surface (lo_address_new_from_url (url.c_str()));
2430 if (sur->linkset != ls) {
2434 lo_address sur_addr = lo_address_new_from_url (sur->remote_url.c_str());
2436 sur->bank = bank_start;
2437 bank_start = bank_start + sur->bank_size;
2438 strip_feedback (sur, false);
2439 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), sur_addr);
2441 lo_address_free (sur_addr);
2447 if (!set->not_ready) {
2448 set->not_ready = not_ready;
2455 surface_link_state (set);
2460 s->bank = bank_limits_check (bank_start, s->bank_size, nstrips);
2461 strip_feedback (s, true);
2462 _strip_select (boost::shared_ptr<ARDOUR::Stripable>(), addr);
2473 OSC::bank_limits_check (uint32_t bank, uint32_t size, uint32_t total)
2477 // no banking - bank includes all stripables
2482 // Do limits checking
2483 if (bank < 1) bank = 1;
2484 if (b_size >= total) {
2486 } else if (bank > ((total - b_size) + 1)) {
2487 // top bank is always filled if there are enough strips for at least one bank
2488 bank = (uint32_t)((total - b_size) + 1);
2494 OSC::bank_leds (OSCSurface* s)
2499 // light bankup or bankdown buttons if it is possible to bank in that direction
2500 lo_address addr = lo_address_new_from_url (s->remote_url.c_str());
2503 set = &(link_sets[s->linkset]);
2505 size = set->banksize;
2507 if (set->not_ready) {
2512 size = s->bank_size;
2515 if (size && (s->feedback[0] || s->feedback[1] || s->feedback[4])) {
2517 reply = lo_message_new ();
2518 if ((total <= size) || (bank > (total - size))) {
2519 lo_message_add_int32 (reply, 0);
2521 lo_message_add_int32 (reply, 1);
2523 lo_send_message (addr, X_("/bank_up"), reply);
2524 lo_message_free (reply);
2525 reply = lo_message_new ();
2527 lo_message_add_int32 (reply, 1);
2529 lo_message_add_int32 (reply, 0);
2531 lo_send_message (addr, X_("/bank_down"), reply);
2532 lo_message_free (reply);
2537 OSC::bank_up (lo_message msg)
2539 return bank_delta (1.0, msg);
2543 OSC::bank_delta (float delta, lo_message msg)
2548 // only do deltas of -1 0 or 1
2551 } else if (delta < 0) {
2554 // 0 key release ignore
2557 OSCSurface *s = get_surface(get_address (msg));
2558 if (!s->bank_size) {
2559 // bank size of 0 means use all strips no banking
2562 uint32_t old_bank = 0;
2563 uint32_t bank_size = 0;
2565 old_bank = link_sets[s->linkset].bank;
2566 bank_size = link_sets[s->linkset].banksize;
2569 bank_size = s->bank_size;
2571 uint32_t new_bank = old_bank + (bank_size * (int) delta);
2572 if ((int)new_bank < 1) {
2575 if (new_bank != old_bank) {
2576 set_bank (new_bank, msg);
2582 OSC::bank_down (lo_message msg)
2584 return bank_delta (-1.0, msg);
2588 OSC::use_group (float value, lo_message msg)
2593 OSCSurface *s = get_surface(get_address (msg));
2595 s->usegroup = PBD::Controllable::UseGroup;
2597 s->usegroup = PBD::Controllable::NoGroup;
2602 // this gets called for anything that starts with /select/group
2604 OSC::parse_sel_group (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
2606 OSCSurface *sur = get_surface(get_address (msg));
2607 boost::shared_ptr<Stripable> s = sur->select;
2608 int ret = 1; /* unhandled */
2610 if (!strncmp (path, X_("/select/group"), 13)) {
2612 if (types[0] == 's') {
2613 return strip_select_group (s, &argv[0]->s);
2617 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
2619 PBD::warning << "OSC: VCAs can not be part of a group." << endmsg;
2622 RouteGroup *rg = rt->route_group();
2624 PBD::warning << "OSC: This strip is not part of a group." << endmsg;
2628 if (types[0] == 'f') {
2629 value = (uint32_t) argv[0]->f;
2630 } else if (types[0] == 'i') {
2631 value = (uint32_t) argv[0]->i;
2634 if (!strncmp (path, X_("/select/group/enable"), 20)) {
2637 rg->set_active (value, this);
2641 int_message (X_("/select/group/enable"), 0, get_address (msg));
2644 else if (strcmp (path, X_("/select/group/gain")) == 0) {
2647 rg->set_gain ((bool) value);
2651 int_message (X_("/select/group/gain"), 0, get_address (msg));
2654 else if (strcmp (path, X_("/select/group/relative")) == 0) {
2657 rg->set_relative ((bool) value, this);
2661 int_message (X_("/select/group/relative"), 0, get_address (msg));
2664 else if (strcmp (path, X_("/select/group/mute")) == 0) {
2667 rg->set_mute ((bool) value);
2671 int_message (X_("/select/group/mute"), 0, get_address (msg));
2674 else if (strcmp (path, X_("/select/group/solo")) == 0) {
2677 rg->set_solo ((bool) value);
2681 int_message (X_("/select/group/solo"), 0, get_address (msg));
2684 else if (strcmp (path, X_("/select/group/recenable")) == 0) {
2687 rg->set_recenable ((bool) value);
2691 int_message (X_("/select/group/recenable"), 0, get_address (msg));
2694 else if (strcmp (path, X_("/select/group/select")) == 0) {
2697 rg->set_select ((bool) value);
2701 int_message (X_("/select/group/select"), 0, get_address (msg));
2704 else if (strcmp (path, X_("/select/group/active")) == 0) {
2707 rg->set_route_active ((bool) value);
2711 int_message (X_("/select/group/active"), 0, get_address (msg));
2714 else if (strcmp (path, X_("/select/group/color")) == 0) {
2717 rg->set_color ((bool) value);
2721 int_message (X_("/select/group/color"), 0, get_address (msg));
2724 else if (strcmp (path, X_("/select/group/monitoring")) == 0) {
2727 rg->set_monitoring ((bool) value);
2731 int_message (X_("/select/group/monitoring"), 0, get_address (msg));
2738 // this gets called for anything that starts with /select/vca
2740 OSC::parse_sel_vca (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
2742 OSCSurface *sur = get_surface(get_address (msg));
2743 boost::shared_ptr<Stripable> s;
2745 int ret = 1; /* unhandled */
2747 boost::shared_ptr<Slavable> slv = boost::dynamic_pointer_cast<Slavable> (s);
2749 uint32_t ivalue = 1024;
2750 if (strcmp (path, X_("/select/vca")) == 0) {
2752 if (types[0] == 's') {
2753 svalue = &argv[0]->s;
2754 if (types[1] == 'i') {
2755 ivalue = argv[1]->i;
2756 } else if (types[1] == 'f') {
2757 ivalue = (uint32_t) argv[1]->f;
2761 boost::shared_ptr<VCA> vca = get_vca_by_name (svalue);
2766 slv->unassign (vca);
2772 PBD::warning << "OSC: setting a vca needs both the vca name and it's state" << endmsg;
2775 else if (!strncmp (path, X_("/select/vca/toggle"), 18)) {
2777 if (types[0] == 's') {
2778 svalue = &argv[0]->s;
2779 string v_name = svalue.substr (0, svalue.rfind (" ["));
2780 boost::shared_ptr<VCA> vca = get_vca_by_name (v_name);
2781 if (s->slaved_to (vca)) {
2782 slv->unassign (vca);
2788 PBD::warning << "OSC: toggling needs the vca name as a string" << endmsg;
2791 PBD::warning << "OSC: toggling a vca needs the vca name" << endmsg;
2799 boost::shared_ptr<VCA>
2800 OSC::get_vca_by_name (std::string vname)
2802 StripableList stripables;
2803 session->get_stripables (stripables);
2804 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
2805 boost::shared_ptr<Stripable> s = *it;
2806 boost::shared_ptr<VCA> v = boost::dynamic_pointer_cast<VCA> (s);
2808 if (vname == v->name()) {
2813 return boost::shared_ptr<VCA>();
2817 OSC::set_temp_mode (lo_address addr)
2820 OSCSurface *sur = get_surface(addr);
2821 boost::shared_ptr<Stripable> s = sur->temp_master;
2823 if (sur->temp_mode == GroupOnly) {
2824 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
2826 RouteGroup *rg = rt->route_group();
2828 sur->temp_strips.clear();
2829 boost::shared_ptr<RouteList> rl = rg->route_list();
2830 for (RouteList::iterator it = rl->begin(); it != rl->end(); ++it) {
2831 boost::shared_ptr<Route> r = *it;
2832 boost::shared_ptr<Stripable> st = boost::dynamic_pointer_cast<Stripable> (r);
2833 sur->temp_strips.push_back(st);
2835 // check if this group feeds a bus or is slaved
2836 boost::shared_ptr<Stripable> mstr = boost::shared_ptr<Stripable> ();
2837 if (rg->has_control_master()) {
2838 boost::shared_ptr<VCA> vca = session->vca_manager().vca_by_number (rg->group_master_number());
2840 mstr = boost::dynamic_pointer_cast<Stripable> (vca);
2842 } else if (rg->has_subgroup()) {
2843 boost::shared_ptr<Route> sgr = rg->subgroup_bus().lock();
2845 mstr = boost::dynamic_pointer_cast<Stripable> (sgr);
2849 sur->temp_strips.push_back(mstr);
2851 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
2852 sur->nstrips = sur->temp_strips.size();
2856 } else if (sur->temp_mode == VCAOnly) {
2857 boost::shared_ptr<VCA> vca = boost::dynamic_pointer_cast<VCA> (s);
2859 sur->temp_strips.clear();
2860 StripableList stripables;
2861 session->get_stripables (stripables);
2862 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
2863 boost::shared_ptr<Stripable> st = *it;
2864 if (st->slaved_to (vca)) {
2865 sur->temp_strips.push_back(st);
2868 sur->temp_strips.push_back(s);
2869 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
2870 sur->nstrips = sur->temp_strips.size();
2873 } else if (sur->temp_mode == BusOnly) {
2874 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
2876 if (!rt->is_track () && rt->can_solo ()) {
2877 // this is a bus, but not master, monitor or audition
2878 sur->temp_strips.clear();
2879 StripableList stripables;
2880 session->get_stripables (stripables, PresentationInfo::AllStripables);
2881 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
2882 boost::shared_ptr<Stripable> st = *it;
2883 boost::shared_ptr<Route> ri = boost::dynamic_pointer_cast<Route> (st);
2885 if (ri && ri->direct_feeds_according_to_graph (rt, &sends)) {
2886 sur->temp_strips.push_back(st);
2889 sur->temp_strips.push_back(s);
2890 sur->strips = get_sorted_stripables(sur->strip_types, sur->cue, 1, sur->temp_strips);
2891 sur->nstrips = sur->temp_strips.size();
2895 } else if (sur->temp_mode == TempOff) {
2896 sur->temp_mode = TempOff;
2901 uint32_t ls = sur->linkset;
2903 set = &(link_sets[ls]);
2904 set->temp_mode = sur->temp_mode;
2905 set->temp_strips.clear ();
2906 set->temp_strips = sur->temp_strips;
2907 set->temp_master = sur->temp_master;
2908 set->strips = sur->strips;
2911 sur->temp_mode = TempOff;
2916 boost::shared_ptr<Send>
2917 OSC::get_send (boost::shared_ptr<Stripable> st, lo_address addr)
2919 OSCSurface *sur = get_surface(addr);
2920 boost::shared_ptr<Stripable> s = sur->temp_master;
2921 if (st && s && (st != s)) {
2922 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
2923 boost::shared_ptr<Route> rst = boost::dynamic_pointer_cast<Route> (st);
2924 //find what send number feeds s
2925 return rst->internal_send_for (rt);
2927 return boost::shared_ptr<Send> ();
2931 OSC::name_session (char *n, lo_message msg)
2936 string new_name = n;
2937 char illegal = Session::session_name_is_legal (new_name);
2940 PBD::warning << (string_compose (_("To ensure compatibility with various systems\n"
2941 "session names may not contain a '%1' character"), illegal)) << endmsg;
2944 switch (session->rename (new_name)) {
2946 PBD::warning << (_("That name is already in use by another directory/folder. Please try again.")) << endmsg;
2952 PBD::warning << (_("Renaming this session failed.\nThings could be seriously messed up at this point")) << endmsg;
2959 OSC::get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr)
2965 OSCSurface *s = get_surface(addr);
2968 if (!s->bank_size) {
2970 b_size = s->nstrips;
2972 b_size = s->bank_size;
2975 for (uint32_t n = s->bank; n < (min ((b_size + s->bank), s->nstrips + 1)); ++n) {
2976 if (n <= s->strips.size()) {
2977 if (strip == s->strips[n-1]) {
2978 return n - s->bank + 1;
2982 // strip not in current bank
2986 boost::shared_ptr<ARDOUR::Stripable>
2987 OSC::get_strip (uint32_t ssid, lo_address addr)
2989 OSCSurface *s = get_surface(addr);
2990 if (ssid && ((ssid + s->bank - 2) < s->nstrips)) {
2991 return s->strips[ssid + s->bank - 2];
2993 // guess it is out of range
2994 return boost::shared_ptr<ARDOUR::Stripable>();
2997 // send and plugin paging commands
2999 OSC::sel_send_pagesize (uint32_t size, lo_message msg)
3001 OSCSurface *s = get_surface(get_address (msg));
3002 if (size != s->send_page_size) {
3003 s->send_page_size = size;
3004 s->sel_obs->set_send_size(size);
3010 OSC::sel_send_page (int page, lo_message msg)
3012 OSCSurface *s = get_surface(get_address (msg));
3013 uint32_t send_size = s->send_page_size;
3015 send_size = s->nsends;
3017 uint32_t max_page = (uint32_t)(s->nsends / send_size) + 1;
3018 s->send_page = s->send_page + page;
3019 if (s->send_page < 1) {
3021 } else if ((uint32_t)s->send_page > max_page) {
3022 s->send_page = max_page;
3024 s->sel_obs->set_send_page (s->send_page);
3029 OSC::sel_plug_pagesize (uint32_t size, lo_message msg)
3031 OSCSurface *s = get_surface(get_address (msg));
3032 if (size != s->plug_page_size) {
3033 s->plug_page_size = size;
3034 s->sel_obs->set_plugin_size(size);
3040 OSC::sel_plug_page (int page, lo_message msg)
3046 OSCSurface *s = get_surface(get_address (msg));
3048 new_page = s->plug_page + s->plug_page_size;
3049 if ((uint32_t) new_page > s->plug_params.size ()) {
3050 new_page = s->plug_page;
3053 new_page = s->plug_page - s->plug_page_size;
3058 if (new_page != s->plug_page) {
3059 s->plug_page = new_page;
3060 s->sel_obs->set_plugin_page(s->plug_page);
3066 OSC::sel_plugin (int delta, lo_message msg)
3071 OSCSurface *sur = get_surface(get_address (msg));
3072 return _sel_plugin (sur->plugin_id + delta, get_address (msg));
3076 OSC::_sel_plugin (int id, lo_address addr)
3078 OSCSurface *sur = get_surface(addr);
3079 boost::shared_ptr<Stripable> s = sur->select;
3081 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
3086 // find out how many plugins we have
3089 sur->plugins.clear();
3092 if (r->nth_plugin (nplugs)) {
3093 if (r->nth_plugin(nplugs)->display_to_user()) {
3095 // need to check for mixbus channel strips (and exclude them)
3096 boost::shared_ptr<Processor> proc = r->nth_plugin (nplugs);
3097 boost::shared_ptr<PluginInsert> pi;
3098 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
3100 if (!pi->is_channelstrip()) {
3102 sur->plugins.push_back (nplugs);
3113 // limit plugin_id to actual plugins
3114 if (sur->plugins.size() < 1) {
3118 sur->sel_obs->set_plugin_id(-1, 1);
3121 } else if (id < 1) {
3123 } else if (sur->plugins.size() < (uint32_t) id) {
3124 sur->plugin_id = sur->plugins.size();
3126 sur->plugin_id = id;
3129 // we have a plugin number now get the processor
3130 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
3131 boost::shared_ptr<PluginInsert> pi;
3132 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
3133 PBD::warning << "OSC: Plugin: " << sur->plugin_id << " does not seem to be a plugin" << endmsg;
3136 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
3138 // put only input controls into a vector
3139 sur->plug_params.clear ();
3140 uint32_t nplug_params = pip->parameter_count();
3141 for ( uint32_t ppi = 0; ppi < nplug_params; ++ppi) {
3142 uint32_t controlid = pip->nth_parameter(ppi, ok);
3146 if (pip->parameter_is_input(controlid)) {
3147 sur->plug_params.push_back (ppi);
3154 sur->sel_obs->set_plugin_id(sur->plugins[sur->plugin_id - 1], sur->plug_page);
3162 OSC::transport_sample (lo_message msg)
3167 check_surface (msg);
3168 samplepos_t pos = session->transport_sample ();
3170 lo_message reply = lo_message_new ();
3171 lo_message_add_int64 (reply, pos);
3173 lo_send_message (get_address (msg), X_("/transport_frame"), reply);
3175 lo_message_free (reply);
3179 OSC::transport_speed (lo_message msg)
3184 check_surface (msg);
3185 double ts = session->transport_speed ();
3187 lo_message reply = lo_message_new ();
3188 lo_message_add_double (reply, ts);
3190 lo_send_message (get_address (msg), X_("/transport_speed"), reply);
3192 lo_message_free (reply);
3196 OSC::record_enabled (lo_message msg)
3201 check_surface (msg);
3202 int re = (int)session->get_record_enabled ();
3204 lo_message reply = lo_message_new ();
3205 lo_message_add_int32 (reply, re);
3207 lo_send_message (get_address (msg), X_("/record_enabled"), reply);
3209 lo_message_free (reply);
3213 OSC::scrub (float delta, lo_message msg)
3215 if (!session) return -1;
3216 check_surface (msg);
3218 scrub_place = session->transport_sample ();
3222 int64_t now = ARDOUR::get_microseconds ();
3223 int64_t diff = now - scrub_time;
3225 // speed 1 (or 0 if jog wheel supports touch)
3227 } else if ((diff > 20000) && (fabs(scrub_speed) == 1)) {
3228 // add some hysteresis to stop excess speed jumps
3231 speed = (int)(delta * 2);
3234 if (scrub_speed == speed) {
3235 // Already at that speed no change
3238 scrub_speed = speed;
3242 session->request_transport_speed (.5);
3244 session->request_transport_speed (9.9);
3246 } else if (speed < 0) {
3248 session->request_transport_speed (-.5);
3250 session->request_transport_speed (-1);
3253 session->request_transport_speed (0);
3260 OSC::jog (float delta, lo_message msg)
3262 if (!session) return -1;
3264 OSCSurface *s = get_surface(get_address (msg));
3270 jump_by_seconds (delta / 5);
3275 access_action ("Common/nudge-playhead-forward");
3276 } else if (delta < 0) {
3277 access_action ("Common/nudge-playhead-backward");
3285 double speed = get_transport_speed ();
3286 set_transport_speed (speed + (delta / 8.1));
3288 set_transport_speed (0);
3294 } else if (delta < 0) {
3300 access_action ("Editor/scroll-forward");
3301 } else if (delta < 0) {
3302 access_action ("Editor/scroll-backward");
3307 set_bank (s->bank + 1, msg);
3308 } else if (delta < 0) {
3309 set_bank (s->bank - 1, msg);
3315 } else if (delta < 0) {
3328 OSC::jog_mode (float mode, lo_message msg)
3330 if (!session) return -1;
3332 OSCSurface *s = get_surface(get_address (msg));
3333 if (get_transport_speed () != 1.0) {
3334 set_transport_speed (0);
3336 s->jogmode = (uint32_t) mode;
3337 s->global_obs->jog_mode (mode);
3341 // two structs to help with going to markers
3342 struct LocationMarker {
3343 LocationMarker (const std::string& l, samplepos_t w)
3344 : label (l), when (w) {}
3349 struct LocationMarkerSort {
3350 bool operator() (const LocationMarker& a, const LocationMarker& b) {
3351 return (a.when < b.when);
3356 OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg)
3359 PBD::warning << "Wrong number of parameters, one only." << endmsg;
3362 const Locations::LocationList& ll (session->locations ()->list ());
3363 uint32_t marker = 0;
3368 Location *cur_mark = 0;
3369 for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
3370 if ((*l)->is_mark ()) {
3371 if (strcmp (&argv[0]->s, (*l)->name().c_str()) == 0) {
3372 session->request_locate ((*l)->start (), false);
3374 } else if ((*l)->start () == session->transport_sample()) {
3380 cur_mark->set_name (&argv[0]->s);
3383 PBD::warning << string_compose ("Marker: \"%1\" - does not exist", &argv[0]->s) << endmsg;
3388 marker = (uint32_t) argv[0]->i - 1;
3391 marker = (uint32_t) argv[0]->f - 1;
3397 std::vector<LocationMarker> lm;
3398 // get Locations that are marks
3399 for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
3400 if ((*l)->is_mark ()) {
3401 lm.push_back (LocationMarker((*l)->name(), (*l)->start ()));
3404 // sort them by position
3405 LocationMarkerSort location_marker_sort;
3406 std::sort (lm.begin(), lm.end(), location_marker_sort);
3408 if (marker < lm.size()) {
3409 session->request_locate (lm[marker].when, false);
3412 // we were unable to deal with things
3417 OSC::group_list (lo_message msg)
3419 return send_group_list (get_address (msg));
3423 OSC::send_group_list (lo_address addr)
3426 reply = lo_message_new ();
3428 lo_message_add_string (reply, X_("none"));
3430 std::list<RouteGroup*> groups = session->route_groups ();
3431 for (std::list<RouteGroup *>::iterator i = groups.begin(); i != groups.end(); ++i) {
3432 RouteGroup *rg = *i;
3433 lo_message_add_string (reply, rg->name().c_str());
3435 lo_send_message (addr, X_("/group/list"), reply);
3436 lo_message_free (reply);
3441 OSC::click_level (float position)
3443 if (!session) return -1;
3444 if (session->click_gain()->gain_control()) {
3445 session->click_gain()->gain_control()->set_value (session->click_gain()->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
3450 // master and monitor calls
3452 OSC::master_set_gain (float dB)
3454 if (!session) return -1;
3455 boost::shared_ptr<Stripable> s = session->master_out();
3458 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
3460 float abs = dB_to_coefficient (dB);
3461 float top = s->gain_control()->upper();
3465 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3472 OSC::master_delta_gain (float delta)
3474 if (!session) return -1;
3475 boost::shared_ptr<Stripable> s = session->master_out();
3477 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
3479 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
3481 float abs = dB_to_coefficient (dB);
3482 float top = s->gain_control()->upper();
3486 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3493 OSC::master_set_fader (float position)
3495 if (!session) return -1;
3496 boost::shared_ptr<Stripable> s = session->master_out();
3498 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
3504 OSC::master_set_trim (float dB)
3506 if (!session) return -1;
3507 boost::shared_ptr<Stripable> s = session->master_out();
3510 s->trim_control()->set_value (dB_to_coefficient (dB), PBD::Controllable::NoGroup);
3517 OSC::master_set_pan_stereo_position (float position, lo_message msg)
3519 if (!session) return -1;
3520 OSCSurface *sur = get_surface(get_address (msg));
3522 float endposition = .5;
3523 boost::shared_ptr<Stripable> s = session->master_out();
3526 if (s->pan_azimuth_control()) {
3527 s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
3528 endposition = s->pan_azimuth_control()->internal_to_interface (s->pan_azimuth_control()->get_value ());
3532 if (sur->feedback[4]) {
3533 lo_message reply = lo_message_new ();
3534 lo_message_add_float (reply, endposition);
3536 lo_send_message (get_address (msg), X_("/master/pan_stereo_position"), reply);
3537 lo_message_free (reply);
3544 OSC::master_set_mute (uint32_t state)
3546 if (!session) return -1;
3548 boost::shared_ptr<Stripable> s = session->master_out();
3551 s->mute_control()->set_value (state, PBD::Controllable::NoGroup);
3558 OSC::master_select (lo_message msg)
3563 OSCSurface *sur = get_surface(get_address (msg));
3564 sur->expand_enable = false;
3565 boost::shared_ptr<Stripable> s = session->master_out();
3567 SetStripableSelection (s);
3574 OSC::monitor_set_gain (float dB)
3576 if (!session) return -1;
3577 boost::shared_ptr<Stripable> s = session->monitor_out();
3581 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
3583 float abs = dB_to_coefficient (dB);
3584 float top = s->gain_control()->upper();
3588 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3595 OSC::monitor_delta_gain (float delta)
3597 if (!session) return -1;
3598 boost::shared_ptr<Stripable> s = session->monitor_out();
3600 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
3602 s->gain_control()->set_value (0.0, PBD::Controllable::NoGroup);
3604 float abs = dB_to_coefficient (dB);
3605 float top = s->gain_control()->upper();
3609 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
3616 OSC::monitor_set_fader (float position)
3618 if (!session) return -1;
3619 boost::shared_ptr<Stripable> s = session->monitor_out();
3621 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
3627 OSC::monitor_set_mute (uint32_t state)
3629 if (!session) return -1;
3631 if (session->monitor_out()) {
3632 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
3633 mon->set_cut_all (state);
3639 OSC::monitor_set_dim (uint32_t state)
3641 if (!session) return -1;
3643 if (session->monitor_out()) {
3644 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
3645 mon->set_dim_all (state);
3651 OSC::monitor_set_mono (uint32_t state)
3653 if (!session) return -1;
3655 if (session->monitor_out()) {
3656 boost::shared_ptr<MonitorProcessor> mon = session->monitor_out()->monitor_control();
3657 mon->set_mono (state);
3663 OSC::route_get_sends(lo_message msg) {
3668 lo_arg **argv = lo_message_get_argv(msg);
3670 int rid = argv[0]->i;
3672 boost::shared_ptr<Stripable> strip = get_strip(rid, get_address(msg));
3677 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
3682 lo_message reply = lo_message_new();
3683 lo_message_add_int32(reply, rid);
3687 boost::shared_ptr<Processor> p = r->nth_send(i++);
3693 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (p);
3695 lo_message_add_int32(reply, get_sid(isend->target_route(), get_address(msg)));
3696 lo_message_add_string(reply, isend->name().c_str());
3697 lo_message_add_int32(reply, i);
3698 boost::shared_ptr<Amp> a = isend->amp();
3699 lo_message_add_float(reply, a->gain_control()->internal_to_interface (a->gain_control()->get_value()));
3700 lo_message_add_int32(reply, p->active() ? 1 : 0);
3703 // if used dedicated message path to identify this reply in async operation.
3704 // Naming it #reply wont help the client to identify the content.
3705 lo_send_message(get_address (msg), X_("/strip/sends"), reply);
3707 lo_message_free(reply);
3713 OSC::route_get_receives(lo_message msg) {
3718 lo_arg **argv = lo_message_get_argv(msg);
3720 uint32_t rid = argv[0]->i;
3723 boost::shared_ptr<Stripable> strip = get_strip(rid, get_address(msg));
3728 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (strip);
3733 boost::shared_ptr<RouteList> route_list = session->get_routes();
3735 lo_message reply = lo_message_new();
3736 lo_message_add_int32(reply, rid);
3738 for (RouteList::iterator i = route_list->begin(); i != route_list->end(); ++i) {
3739 boost::shared_ptr<Route> tr = boost::dynamic_pointer_cast<Route> (*i);
3746 boost::shared_ptr<Processor> p = tr->nth_send(j++);
3752 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (p);
3754 if( isend->target_route()->id() == r->id()){
3755 boost::shared_ptr<Amp> a = isend->amp();
3757 lo_message_add_int32(reply, get_sid(tr, get_address(msg)));
3758 lo_message_add_string(reply, tr->name().c_str());
3759 lo_message_add_int32(reply, j);
3760 lo_message_add_float(reply, a->gain_control()->internal_to_interface (a->gain_control()->get_value()));
3761 lo_message_add_int32(reply, p->active() ? 1 : 0);
3767 // I have used a dedicated message path to identify this reply in async operation.
3768 // Naming it #reply wont help the client to identify the content.
3769 lo_send_message(get_address (msg), X_("/strip/receives"), reply);
3770 lo_message_free(reply);
3777 OSC::set_automation (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
3779 if (!session) return -1;
3782 OSCSurface *sur = get_surface(get_address (msg));
3783 boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
3787 boost::shared_ptr<Send> send = boost::shared_ptr<Send> ();
3790 if (types[argc - 1] == 'f') {
3791 aut = (int)argv[argc - 1]->f;
3793 aut = argv[argc - 1]->i;
3797 //parse path first to find stripable
3798 if (!strncmp (path, X_("/strip/"), 7)) {
3799 // find ssid and stripable
3801 if (types[1] == 'f') {
3802 ssid = (uint32_t)argv[0]->f;
3806 strp = get_strip (ssid, get_address (msg));
3808 ssid = atoi (&(strrchr (path, '/' ))[1]);
3809 strp = get_strip (ssid, get_address (msg));
3811 send = get_send (strp, get_address (msg));
3813 } else if (!strncmp (path, X_("/select/"), 8)) {
3820 boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
3821 // other automatable controls can be added by repeating the next 6.5 lines
3822 if ((!strncmp (&path[ctr], X_("fader"), 5)) || (!strncmp (&path[ctr], X_("gain"), 4))) {
3823 if (strp->gain_control ()) {
3824 control = strp->gain_control ();
3826 PBD::warning << "No fader for this strip" << endmsg;
3829 control = send->gain_control ();
3832 PBD::warning << "Automation not available for " << path << endmsg;
3839 control->set_automation_state (ARDOUR::Off);
3843 control->set_automation_state (ARDOUR::Play);
3847 control->set_automation_state (ARDOUR::Write);
3851 control->set_automation_state (ARDOUR::Touch);
3855 control->set_automation_state (ARDOUR::Latch);
3868 OSC::touch_detect (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
3870 if (!session) return -1;
3873 OSCSurface *sur = get_surface(get_address (msg));
3874 boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
3875 boost::shared_ptr<Send> send = boost::shared_ptr<Send> ();
3881 if (types[argc - 1] == 'f') {
3882 touch = (int)argv[argc - 1]->f;
3884 touch = argv[argc - 1]->i;
3888 //parse path first to find stripable
3889 if (!strncmp (path, X_("/strip/"), 7)) {
3890 // find ssid and stripable
3892 if (types[0] == 'f') {
3893 ssid = (uint32_t)argv[0]->f;
3897 strp = get_strip (ssid, get_address (msg));
3899 ssid = atoi (&(strrchr (path, '/' ))[1]);
3900 strp = get_strip (ssid, get_address (msg));
3902 send = get_send (strp, get_address (msg));
3904 } else if (!strncmp (path, X_("/select/"), 8)) {
3911 boost::shared_ptr<AutomationControl> control = boost::shared_ptr<AutomationControl>();
3912 // other automatable controls can be added by repeating the next 6.5 lines
3913 if ((!strncmp (&path[ctr], X_("fader"), 5)) || (!strncmp (&path[ctr], X_("gain"), 4))) {
3914 if (strp->gain_control ()) {
3915 control = strp->gain_control ();
3917 PBD::warning << "No fader for this strip" << endmsg;
3920 control = send->gain_control ();
3923 PBD::warning << "Automation not available for " << path << endmsg;
3929 control->start_touch (control->session().transport_sample());
3933 control->stop_touch (control->session().transport_sample());
3936 // just in case some crazy surface starts sending control values before touch
3937 FakeTouchMap::iterator x = _touch_timeout.find(control);
3938 if (x != _touch_timeout.end()) {
3939 _touch_timeout.erase (x);
3948 OSC::fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl)
3952 if (ctrl->automation_state() == Touch && !ctrl->touching ()) {
3953 ctrl->start_touch (ctrl->session().transport_sample());
3954 _touch_timeout[ctrl] = 10;
3962 OSC::spill (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
3965 * spill should have the form of:
3966 * /select/spill (may have i or f keypress/release)
3967 * /strip/spill i (may have keypress and i may be inline)
3969 if (!session || argc > 1) return -1;
3972 OSCSurface *sur = get_surface(get_address (msg));
3973 boost::shared_ptr<Stripable> strp = boost::shared_ptr<Stripable>();
3975 OSCTempMode new_mode = TempOff;
3978 if (types[0] == 'f') {
3979 value = (int)argv[0]->f;
3984 // key release ignore
3989 //parse path first to find stripable
3990 if (!strncmp (path, X_("/strip/"), 7)) {
3992 * we don't know if value is press or ssid
3993 * so we have to check if the last / has an int after it first
3994 * if not then we use value
3997 ssid = atoi (&(strrchr (path, '/' ))[1]);
4001 strp = get_strip (ssid, get_address (msg));
4002 } else if (!strncmp (path, X_("/select/"), 8)) {
4008 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (strp);
4009 boost::shared_ptr<VCA> v = boost::dynamic_pointer_cast<VCA> (strp);
4010 if (strstr (path, X_("/vca")) || v) {
4011 //strp must be a VCA
4018 if (strstr (path, X_("/group"))) {
4019 //strp must be in a group
4021 RouteGroup *rg = rt->route_group();
4023 new_mode = GroupOnly;
4029 if (strstr (path, X_("/bus"))) {
4030 //strp must be a bus with either sends or no inputs
4032 if (!rt->is_track () && rt->can_solo ()) {
4038 // vca should never get here
4039 if (rt->is_track ()) {
4040 if (rt->route_group()) {
4041 new_mode = GroupOnly;
4043 } else if (!rt->is_track () && rt->can_solo ()) {
4048 sur->temp_mode = new_mode;
4049 sur->temp_master = strp;
4050 set_temp_mode (get_address (msg));
4060 OSC::route_mute (int ssid, int yn, lo_message msg)
4062 if (!session) return -1;
4063 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4064 OSCSurface *sur = get_surface(get_address (msg));
4067 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4068 return float_message_with_id (X_("/strip/mute"), ssid, 0, sur->feedback[2], get_address (msg));
4070 if (s->mute_control()) {
4071 s->mute_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
4076 return float_message_with_id (X_("/strip/mute"), ssid, 0, sur->feedback[2], get_address (msg));
4080 OSC::sel_mute (uint32_t yn, lo_message msg)
4082 OSCSurface *sur = get_surface(get_address (msg));
4083 boost::shared_ptr<Stripable> s;
4086 if (s->mute_control()) {
4087 s->mute_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4091 return float_message(X_("/select/mute"), 0, get_address (msg));
4095 OSC::route_solo (int ssid, int yn, lo_message msg)
4097 if (!session) return -1;
4098 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4099 OSCSurface *sur = get_surface(get_address (msg));
4102 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4103 return float_message_with_id (X_("/strip/solo"), ssid, 0, sur->feedback[2], get_address (msg));
4105 if (s->solo_control()) {
4106 s->solo_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
4110 return float_message_with_id (X_("/strip/solo"), ssid, 0, sur->feedback[2], get_address (msg));
4114 OSC::route_solo_iso (int ssid, int yn, lo_message msg)
4116 if (!session) return -1;
4117 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4118 OSCSurface *sur = get_surface(get_address (msg));
4121 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4122 return float_message_with_id (X_("/strip/solo_iso"), ssid, 0, sur->feedback[2], get_address (msg));
4124 if (s->solo_isolate_control()) {
4125 s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
4130 return float_message_with_id (X_("/strip/solo_iso"), ssid, 0, sur->feedback[2], get_address (msg));
4134 OSC::route_solo_safe (int ssid, int yn, lo_message msg)
4136 if (!session) return -1;
4137 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
4138 OSCSurface *sur = get_surface(get_address (msg));
4141 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4142 return float_message_with_id (X_("/strip/solo_safe"), ssid, 0, sur->feedback[2], get_address (msg));
4144 if (s->solo_safe_control()) {
4145 s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
4150 return float_message_with_id (X_("/strip/solo_safe"), ssid, 0, sur->feedback[2], get_address (msg));
4154 OSC::sel_solo (uint32_t yn, lo_message msg)
4156 OSCSurface *sur = get_surface(get_address (msg));
4157 boost::shared_ptr<Stripable> s;
4160 if (s->solo_control()) {
4161 session->set_control (s->solo_control(), yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4164 return float_message(X_("/select/solo"), 0, get_address (msg));
4168 OSC::sel_solo_iso (uint32_t yn, lo_message msg)
4170 OSCSurface *sur = get_surface(get_address (msg));
4171 boost::shared_ptr<Stripable> s;
4174 if (s->solo_isolate_control()) {
4175 s->solo_isolate_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4179 return float_message(X_("/select/solo_iso"), 0, get_address (msg));
4183 OSC::sel_solo_safe (uint32_t yn, lo_message msg)
4185 OSCSurface *sur = get_surface(get_address (msg));
4186 boost::shared_ptr<Stripable> s;
4189 if (s->solo_safe_control()) {
4190 s->solo_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4194 return float_message(X_("/select/solo_safe"), 0, get_address (msg));
4198 OSC::sel_recenable (uint32_t yn, lo_message msg)
4200 OSCSurface *sur = get_surface(get_address (msg));
4201 boost::shared_ptr<Stripable> s;
4204 if (s->rec_enable_control()) {
4205 s->rec_enable_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4206 if (s->rec_enable_control()->get_value()) {
4211 return float_message(X_("/select/recenable"), 0, get_address (msg));
4215 OSC::route_recenable (int ssid, int yn, lo_message msg)
4217 if (!session) return -1;
4218 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4219 OSCSurface *sur = get_surface(get_address (msg));
4222 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4223 return float_message_with_id (X_("/strip/recenable"), ssid, 0, sur->feedback[2], get_address (msg));
4225 if (s->rec_enable_control()) {
4226 s->rec_enable_control()->set_value (yn, sur->usegroup);
4227 if (s->rec_enable_control()->get_value()) {
4232 return float_message_with_id (X_("/strip/recenable"), ssid, 0, sur->feedback[2], get_address (msg));
4236 OSC::route_rename (int ssid, char *newname, lo_message msg) {
4240 OSCSurface *sur = get_surface(get_address (msg));
4241 boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
4244 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4245 text_message_with_id (X_("/strip/name"), ssid, string_compose ("%1-Send", s->name()), sur->feedback[2], get_address(msg));
4248 s->set_name(std::string(newname));
4255 OSC::sel_rename (char *newname, lo_message msg) {
4260 OSCSurface *sur = get_surface(get_address (msg));
4261 boost::shared_ptr<Stripable> s;
4264 s->set_name(std::string(newname));
4271 OSC::sel_comment (char *newcomment, lo_message msg) {
4276 OSCSurface *sur = get_surface(get_address (msg));
4277 boost::shared_ptr<Stripable> s;
4280 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
4282 PBD::warning << "OSC: can not set comment on VCAs." << endmsg;
4285 rt->set_comment (newcomment, this);
4292 OSC::sel_new_personal_send (char *foldback, lo_message msg)
4294 OSCSurface *sur = get_surface(get_address (msg));
4295 boost::shared_ptr<Stripable> s;
4297 boost::shared_ptr<Route> rt = boost::shared_ptr<Route> ();
4299 rt = boost::dynamic_pointer_cast<Route> (s);
4301 PBD::warning << "OSC: can not send from VCAs." << endmsg;
4305 /* if a foldbackbus called foldback exists use it
4306 * other wise create it. Then create a foldback send from
4307 * this route to that bus.
4309 string foldbackbus = foldback;
4310 string foldback_name = foldbackbus;
4311 if (foldbackbus.find ("- FB") == string::npos) {
4312 foldback_name = string_compose ("%1 - FB", foldbackbus);
4314 boost::shared_ptr<Route> lsn_rt = session->route_by_name (foldback_name);
4316 // doesn't exist but check if raw name does and is foldbackbus
4317 boost::shared_ptr<Route> raw_rt = session->route_by_name (foldbackbus);
4318 if (raw_rt && raw_rt->is_foldbackbus()) {
4321 // create the foldbackbus
4322 RouteList list = session->new_audio_route (1, 1, 0, 1, foldback_name, PresentationInfo::FoldbackBus, (uint32_t) -1);
4323 lsn_rt = *(list.begin());
4324 lsn_rt->presentation_info().set_hidden (true);
4325 session->set_dirty();
4329 //boost::shared_ptr<Route> rt_send = ;
4330 if (rt && (lsn_rt != rt)) {
4331 // make sure there isn't one already
4333 if (!rt->feeds (lsn_rt, &s_only)) {
4335 rt->add_foldback_send (lsn_rt);
4336 //boost::shared_ptr<Send> snd = rt->internal_send_for (aux);
4340 PBD::warning << "OSC: new_send - duplicate send, ignored." << endmsg;
4343 PBD::warning << "OSC: new_send - can't send to self." << endmsg;
4346 PBD::warning << "OSC: new_send - no FoldbackBus to send to." << endmsg;
4353 OSC::strip_group (int ssid, char *group, lo_message msg) {
4357 boost::shared_ptr<Stripable> s = get_strip(ssid, get_address(msg));
4358 return strip_select_group (s, group);
4362 OSC::sel_group (char *group, lo_message msg) {
4366 OSCSurface *sur = get_surface(get_address (msg));
4367 boost::shared_ptr<Stripable> s;
4369 return strip_select_group (s, group);
4373 OSC::strip_select_group (boost::shared_ptr<Stripable> s, char *group)
4376 if (grp == "" || grp == " ") {
4381 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s);
4383 PBD::warning << "OSC: VCAs can not be part of a group." << endmsg;
4386 RouteGroup *rg = rt->route_group();
4387 RouteGroup* new_rg = session->route_group_by_name (grp);
4389 string old_group = rg->name();
4390 if (grp == "none") {
4391 if (rg->size () == 1) {
4392 session->remove_route_group (*rg);
4396 } else if (grp != old_group) {
4398 // group exists switch to it
4399 if (rg->size () == 1) {
4400 session->remove_route_group (rg);
4412 if (grp == "none") {
4414 } else if (new_rg) {
4417 // create new group with this strip in it
4418 RouteGroup* new_rg = new RouteGroup (*session, grp);
4419 session->add_route_group (new_rg);
4428 OSC::sel_recsafe (uint32_t yn, lo_message msg)
4430 OSCSurface *sur = get_surface(get_address (msg));
4431 boost::shared_ptr<Stripable> s;
4434 if (s->rec_safe_control()) {
4435 s->rec_safe_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4436 if (s->rec_safe_control()->get_value()) {
4441 return float_message(X_("/select/record_safe"), 0, get_address (msg));
4445 OSC::route_recsafe (int ssid, int yn, lo_message msg)
4447 if (!session) return -1;
4448 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4449 OSCSurface *sur = get_surface(get_address (msg));
4451 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4452 return float_message_with_id (X_("/strip/record_safe"), ssid, 0, sur->feedback[2], get_address (msg));
4454 if (s->rec_safe_control()) {
4455 s->rec_safe_control()->set_value (yn, sur->usegroup);
4456 if (s->rec_safe_control()->get_value()) {
4461 return float_message_with_id (X_("/strip/record_safe"), ssid, 0, sur->feedback[2], get_address (msg));
4465 OSC::route_monitor_input (int ssid, int yn, lo_message msg)
4467 if (!session) return -1;
4468 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4469 OSCSurface *sur = get_surface(get_address (msg));
4472 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4473 return float_message_with_id (X_("/strip/monitor_input"), ssid, 0, sur->feedback[2], get_address (msg));
4475 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
4477 if (track->monitoring_control()) {
4478 std::bitset<32> value = track->monitoring_control()->get_value ();
4479 value[0] = yn ? 1 : 0;
4480 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
4486 return float_message_with_id (X_("/strip/monitor_input"), ssid, 0, sur->feedback[2], get_address (msg));
4490 OSC::sel_monitor_input (uint32_t yn, lo_message msg)
4492 OSCSurface *sur = get_surface(get_address (msg));
4493 boost::shared_ptr<Stripable> s;
4496 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
4498 if (track->monitoring_control()) {
4499 std::bitset<32> value = track->monitoring_control()->get_value ();
4500 value[0] = yn ? 1 : 0;
4501 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
4506 return float_message(X_("/select/monitor_input"), 0, get_address (msg));
4510 OSC::route_monitor_disk (int ssid, int yn, lo_message msg)
4512 if (!session) return -1;
4513 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4514 OSCSurface *sur = get_surface(get_address (msg));
4517 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4518 return float_message_with_id (X_("/strip/monitor_disk"), ssid, 0, sur->feedback[2], get_address (msg));
4520 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
4522 if (track->monitoring_control()) {
4523 std::bitset<32> value = track->monitoring_control()->get_value ();
4524 value[1] = yn ? 1 : 0;
4525 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
4531 return float_message_with_id (X_("/strip/monitor_disk"), ssid, 0, sur->feedback[2], get_address (msg));
4535 OSC::sel_monitor_disk (uint32_t yn, lo_message msg)
4537 OSCSurface *sur = get_surface(get_address (msg));
4538 boost::shared_ptr<Stripable> s;
4541 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (s);
4543 if (track->monitoring_control()) {
4544 std::bitset<32> value = track->monitoring_control()->get_value ();
4545 value[1] = yn ? 1 : 0;
4546 track->monitoring_control()->set_value (value.to_ulong(), sur->usegroup);
4551 return float_message(X_("/select/monitor_disk"), 0, get_address (msg));
4556 OSC::strip_phase (int ssid, int yn, lo_message msg)
4558 if (!session) return -1;
4559 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4560 OSCSurface *sur = get_surface(get_address (msg));
4563 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4564 return float_message_with_id (X_("/strip/polarity"), ssid, 0, sur->feedback[2], get_address (msg));
4566 if (s->phase_control()) {
4567 s->phase_control()->set_value (yn ? 1.0 : 0.0, sur->usegroup);
4572 return float_message_with_id (X_("/strip/polarity"), ssid, 0, sur->feedback[2], get_address (msg));
4576 OSC::sel_phase (uint32_t yn, lo_message msg)
4578 OSCSurface *sur = get_surface(get_address (msg));
4579 boost::shared_ptr<Stripable> s;
4582 if (s->phase_control()) {
4583 s->phase_control()->set_value (yn ? 1.0 : 0.0, PBD::Controllable::NoGroup);
4587 return float_message(X_("/select/polarity"), 0, get_address (msg));
4591 OSC::strip_expand (int ssid, int yn, lo_message msg)
4593 OSCSurface *sur = get_surface(get_address (msg));
4594 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4596 sur->expand_strip = s;
4598 sur->expand_enable = (bool) yn;
4600 boost::shared_ptr<Stripable> sel;
4602 sel = get_strip (ssid, get_address (msg));
4604 sel = boost::shared_ptr<Stripable> ();
4607 return _strip_select (sel, get_address (msg));
4611 OSC::strip_hide (int ssid, int state, lo_message msg)
4613 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4614 OSCSurface *sur = get_surface(get_address (msg));
4617 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
4618 return float_message_with_id (X_("/strip/hide"), ssid, 0, sur->feedback[2], get_address (msg));
4620 if (state != s->is_hidden ()) {
4621 s->presentation_info().set_hidden ((bool) state);
4628 OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
4633 OSCSurface *sur = get_surface(addr, true);
4634 boost::weak_ptr<Stripable> o_sel = sur->select;
4635 boost::shared_ptr<Stripable> old_sel= o_sel.lock ();
4636 boost::weak_ptr<Stripable> o_expand = sur->expand_strip;
4637 boost::shared_ptr<Stripable> old_expand= o_expand.lock ();
4639 // we got a null strip check that old strips are valid
4641 if (old_expand && sur->expand_enable) {
4642 sur->expand = get_sid (old_expand, addr);
4643 if (sur->strip_types[11] || sur->expand) {
4646 sur->expand_strip = boost::shared_ptr<Stripable> ();
4652 sur->expand_enable = false;
4653 if (ControlProtocol::first_selected_stripable()) {
4654 s = ControlProtocol::first_selected_stripable();
4656 s = session->master_out ();
4664 uint32_t nsends = 0;
4667 if (s->send_level_controllable (nsends)) {
4672 sur->nsends = nsends;
4674 s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
4676 OSCSelectObserver* so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs);
4677 if (sur->feedback[13]) {
4679 so->refresh_strip (s, nsends, sur->gainmode, true);
4681 OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, *session, sur);
4682 sur->sel_obs = sel_fb;
4684 sur->sel_obs->set_expand (sur->expand_enable);
4691 if (sur->feedback[0] || sur->feedback[1]) {
4692 uint32_t obs_expand = 0;
4693 if (sur->expand_enable) {
4694 sur->expand = get_sid (s, addr);
4695 obs_expand = sur->expand;
4699 for (uint32_t i = 0; i < sur->observers.size(); i++) {
4700 sur->observers[i]->set_expand (obs_expand);
4703 // need to set monitor for processor changed signal (for paging)
4704 string address = lo_address_get_url (addr);
4705 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
4707 r->processors_changed.connect (sur->proc_connection, MISSING_INVALIDATOR, boost::bind (&OSC::processor_changed, this, address), this);
4708 _sel_plugin (sur->plugin_id, addr);
4715 OSC::processor_changed (string address)
4717 lo_address addr = lo_address_new_from_url (address.c_str());
4718 OSCSurface *sur = get_surface (addr);
4719 _sel_plugin (sur->plugin_id, addr);
4721 sur->sel_obs->renew_sends ();
4722 sur->sel_obs->eq_restart (-1);
4727 OSC::strip_gui_select (int ssid, int yn, lo_message msg)
4729 //ignore button release
4735 OSCSurface *sur = get_surface(get_address (msg));
4736 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4738 sur->expand_enable = false;
4739 SetStripableSelection (s);
4741 if ((int) (sur->feedback.to_ulong())) {
4742 float_message_with_id (X_("/strip/select"), ssid, 0, sur->feedback[2], get_address (msg));
4750 OSC::sel_expand (uint32_t state, lo_message msg)
4752 OSCSurface *sur = get_surface(get_address (msg));
4753 boost::shared_ptr<Stripable> s;
4754 if (!sur->expand_strip) {
4756 float_message (X_("/select/expand"), 0.0, get_address (msg));
4759 sur->expand_enable = (bool) state;
4760 s = boost::shared_ptr<Stripable> ();
4762 sur->expand_enable = false;
4763 s = boost::shared_ptr<Stripable> ();
4766 return _strip_select (s, get_address (msg));
4770 OSC::sel_previous (lo_message msg)
4772 return sel_delta (-1, msg);
4776 OSC::sel_next (lo_message msg)
4778 return sel_delta (1, msg);
4782 OSC::sel_delta (int delta, lo_message msg)
4787 OSCSurface *sur = get_surface(get_address (msg));
4789 sel_strips = sur->strips;
4790 // the current selected strip _should_ be in sel_strips
4791 uint32_t nstps = sel_strips.size ();
4795 boost::shared_ptr<Stripable> new_sel = boost::shared_ptr<Stripable> ();
4796 boost::weak_ptr<Stripable> o_sel = sur->select;
4797 boost::shared_ptr<Stripable> old_sel= o_sel.lock ();
4798 for (uint32_t i = 0; i < nstps; i++) {
4799 if (old_sel == sel_strips[i]) {
4800 if (i && delta < 0) {
4801 // i is > 0 and delta is -1
4802 new_sel = sel_strips[i - 1];
4803 } else if ((i + 1) < nstps && delta > 0) {
4804 // i is at least 1 less than greatest and delta = 1
4805 new_sel = sel_strips[i + 1];
4806 } else if ((i + 1) >= nstps && delta > 0) {
4807 // i is greatest strip and delta 1
4808 new_sel = sel_strips[0];
4809 } else if (!i && delta < 0) {
4810 // i = 0 and delta -1
4811 new_sel = sel_strips[nstps - 1];
4813 // should not happen
4819 // our selected strip has vanished use the first one
4820 new_sel = sel_strips[0];
4823 if (!sur->expand_enable) {
4824 SetStripableSelection (new_sel);
4826 sur->expand_strip = new_sel;
4827 _strip_select (new_sel, get_address (msg));
4835 OSC::route_set_gain_dB (int ssid, float dB, lo_message msg)
4840 OSCSurface *sur = get_surface(get_address (msg));
4841 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4843 boost::shared_ptr<GainControl> gain_control;
4844 if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
4845 gain_control = get_send(s, get_address (msg))->gain_control();
4847 gain_control = s->gain_control();
4854 abs = dB_to_coefficient (dB);
4855 float top = gain_control->upper();
4860 fake_touch (gain_control);
4861 gain_control->set_value (abs, sur->usegroup);
4865 return float_message_with_id (X_("/strip/gain"), ssid, -193, sur->feedback[2], get_address (msg));
4869 OSC::sel_gain (float val, lo_message msg)
4871 OSCSurface *sur = get_surface(get_address (msg));
4872 boost::shared_ptr<Stripable> s;
4876 if (s->gain_control()) {
4880 abs = dB_to_coefficient (val);
4881 float top = s->gain_control()->upper();
4886 fake_touch (s->gain_control());
4887 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
4891 return float_message(X_("/select/gain"), -193, get_address (msg));
4895 OSC::sel_dB_delta (float delta, lo_message msg)
4897 OSCSurface *sur = get_surface(get_address (msg));
4898 boost::shared_ptr<Stripable> s;
4901 if (s->gain_control()) {
4902 float dB = accurate_coefficient_to_dB (s->gain_control()->get_value()) + delta;
4907 abs = dB_to_coefficient (dB);
4908 float top = s->gain_control()->upper();
4913 fake_touch (s->gain_control());
4914 s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
4918 return float_message(X_("/select/gain"), -193, get_address (msg));
4922 OSC::route_set_gain_fader (int ssid, float pos, lo_message msg)
4927 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4928 OSCSurface *sur = get_surface(get_address (msg));
4931 boost::shared_ptr<GainControl> gain_control;
4932 if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
4933 gain_control = get_send(s, get_address (msg))->gain_control();
4935 gain_control = s->gain_control();
4938 fake_touch (gain_control);
4939 gain_control->set_value (gain_control->interface_to_internal (pos), sur->usegroup);
4941 return float_message_with_id (X_("/strip/fader"), ssid, 0, sur->feedback[2], get_address (msg));
4944 return float_message_with_id (X_("/strip/fader"), ssid, 0, sur->feedback[2], get_address (msg));
4950 OSC::strip_db_delta (int ssid, float delta, lo_message msg)
4952 if (!session) return -1;
4953 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
4954 OSCSurface *sur = get_surface(get_address (msg));
4956 boost::shared_ptr<GainControl> gain_control;
4957 if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
4958 gain_control = get_send(s, get_address (msg))->gain_control();
4960 gain_control = s->gain_control();
4962 float db = accurate_coefficient_to_dB (gain_control->get_value()) + delta;
4967 abs = dB_to_coefficient (db);
4968 float top = gain_control->upper();
4973 gain_control->set_value (abs, sur->usegroup);
4980 OSC::sel_fader (float val, lo_message msg)
4982 OSCSurface *sur = get_surface(get_address (msg));
4983 boost::shared_ptr<Stripable> s;
4986 if (s->gain_control()) {
4987 fake_touch (s->gain_control());
4988 s->gain_control()->set_value (s->gain_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
4992 return float_message(X_("/select/fader"), 0, get_address (msg));
4996 OSC::route_set_trim_abs (int ssid, float level, lo_message msg)
4998 if (!session) return -1;
4999 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5000 OSCSurface *sur = get_surface(get_address (msg));
5003 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
5004 return float_message_with_id (X_("/strip/trimdB"), ssid, 0, sur->feedback[2], get_address (msg));
5006 if (s->trim_control()) {
5007 s->trim_control()->set_value (level, sur->usegroup);
5017 OSC::route_set_trim_dB (int ssid, float dB, lo_message msg)
5019 OSCSurface *sur = get_surface(get_address (msg));
5021 ret = route_set_trim_abs(ssid, dB_to_coefficient (dB), msg);
5023 return float_message_with_id (X_("/strip/trimdB"), ssid, 0, sur->feedback[2], get_address (msg));
5030 OSC::sel_trim (float val, lo_message msg)
5032 OSCSurface *sur = get_surface(get_address (msg));
5033 boost::shared_ptr<Stripable> s;
5036 if (s->trim_control()) {
5037 s->trim_control()->set_value (dB_to_coefficient (val), PBD::Controllable::NoGroup);
5041 return float_message(X_("/select/trimdB"), 0, get_address (msg));
5045 OSC::sel_hide (uint32_t state, lo_message msg)
5047 OSCSurface *sur = get_surface(get_address (msg));
5048 boost::shared_ptr<Stripable> s;
5051 if (state != s->is_hidden ()) {
5052 s->presentation_info().set_hidden ((bool) state);
5059 OSC::sel_pan_position (float val, lo_message msg)
5061 OSCSurface *sur = get_surface(get_address (msg));
5062 boost::shared_ptr<Stripable> s;
5065 if(s->pan_azimuth_control()) {
5066 s->pan_azimuth_control()->set_value (s->pan_azimuth_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
5070 return float_message(X_("/select/pan_stereo_position"), 0.5, get_address (msg));
5074 OSC::sel_pan_width (float val, lo_message msg)
5076 OSCSurface *sur = get_surface(get_address (msg));
5077 boost::shared_ptr<Stripable> s;
5080 if (s->pan_width_control()) {
5081 s->pan_width_control()->set_value (s->pan_width_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
5085 return float_message(X_("/select/pan_stereo_width"), 1, get_address (msg));
5089 OSC::route_set_pan_stereo_position (int ssid, float pos, lo_message msg)
5091 if (!session) return -1;
5092 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5093 OSCSurface *sur = get_surface(get_address (msg));
5096 boost::shared_ptr<PBD::Controllable> pan_control = boost::shared_ptr<PBD::Controllable>();
5097 if (sur->temp_mode == BusOnly && get_send (s, get_address (msg))) {
5098 boost::shared_ptr<ARDOUR::Send> send = get_send (s, get_address (msg));
5099 if (send->pan_outs() > 1) {
5100 pan_control = send->panner_shell()->panner()->pannable()->pan_azimuth_control;
5103 pan_control = s->pan_azimuth_control();
5106 pan_control->set_value (s->pan_azimuth_control()->interface_to_internal (pos), sur->usegroup);
5111 return float_message_with_id (X_("/strip/pan_stereo_position"), ssid, 0.5, sur->feedback[2], get_address (msg));
5115 OSC::route_set_pan_stereo_width (int ssid, float pos, lo_message msg)
5117 if (!session) return -1;
5118 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5119 OSCSurface *sur = get_surface(get_address (msg));
5122 if ((sur->temp_mode == BusOnly) && (s != sur->temp_master)) {
5123 return float_message_with_id (X_("/strip/pan_stereo_width"), ssid, 1, sur->feedback[2], get_address (msg));
5125 if (s->pan_width_control()) {
5126 s->pan_width_control()->set_value (pos, sur->usegroup);
5131 return float_message_with_id (X_("/strip/pan_stereo_width"), ssid, 1, sur->feedback[2], get_address (msg));
5135 OSC::route_set_send_gain_dB (int ssid, int id, float val, lo_message msg)
5140 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5141 OSCSurface *sur = get_surface(get_address (msg));
5153 abs = dB_to_coefficient (val);
5156 if (s->send_level_controllable (id)) {
5157 s->send_level_controllable (id)->set_value (abs, sur->usegroup);
5165 OSC::route_set_send_fader (int ssid, int id, float val, lo_message msg)
5170 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5171 OSCSurface *sur = get_surface(get_address (msg));
5179 if (s->send_level_controllable (id)) {
5180 abs = s->send_level_controllable(id)->interface_to_internal (val);
5181 s->send_level_controllable (id)->set_value (abs, sur->usegroup);
5189 OSC::sel_sendgain (int id, float val, lo_message msg)
5191 OSCSurface *sur = get_surface(get_address (msg));
5192 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
5193 return float_message_with_id (X_("/select/send_gain"), id, -193, sur->feedback[2], get_address (msg));
5195 boost::shared_ptr<Stripable> s;
5209 abs = dB_to_coefficient (val);
5212 if (sur->send_page_size) {
5213 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
5215 if (s->send_level_controllable (send_id)) {
5216 s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
5220 return float_message_with_id (X_("/select/send_gain"), id, -193, sur->feedback[2], get_address (msg));
5224 OSC::sel_sendfader (int id, float val, lo_message msg)
5226 OSCSurface *sur = get_surface(get_address (msg));
5227 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
5228 return float_message_with_id (X_("/select/send_fader"), id, 0, sur->feedback[2], get_address (msg));
5230 boost::shared_ptr<Stripable> s;
5239 if (sur->send_page_size) {
5240 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
5243 if (s->send_level_controllable (send_id)) {
5244 abs = s->send_level_controllable(send_id)->interface_to_internal (val);
5245 s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
5249 return float_message_with_id (X_("/select/send_fader"), id, 0, sur->feedback[2], get_address (msg));
5253 OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
5258 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5259 OSCSurface *sur = get_surface(get_address (msg));
5263 /* revert to zero-based counting */
5269 if (s->send_enable_controllable (sid)) {
5270 s->send_enable_controllable (sid)->set_value (val, sur->usegroup);
5274 if (s->send_level_controllable (sid)) {
5275 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5279 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(sid));
5296 OSC::sel_sendenable (int id, float val, lo_message msg)
5298 OSCSurface *sur = get_surface(get_address (msg));
5299 if (sur->send_page_size && (id > (int)sur->send_page_size)) {
5300 return float_message_with_id (X_("/select/send_enable"), id, 0, sur->feedback[2], get_address (msg));
5302 boost::shared_ptr<Stripable> s;
5309 if (sur->send_page_size) {
5310 send_id = send_id + ((sur->send_page - 1) * sur->send_page_size);
5312 if (s->send_enable_controllable (send_id)) {
5313 s->send_enable_controllable (send_id)->set_value (val, PBD::Controllable::NoGroup);
5316 if (s->send_level_controllable (send_id)) {
5317 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5319 // should never get here
5320 return float_message_with_id (X_("/select/send_enable"), id, 0, sur->feedback[2], get_address (msg));
5322 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(send_id));
5333 return float_message_with_id (X_("/select/send_enable"), id, 0, sur->feedback[2], get_address (msg));
5337 OSC::sel_master_send_enable (int state, lo_message msg)
5339 OSCSurface *sur = get_surface(get_address (msg));
5340 boost::shared_ptr<Stripable> s;
5343 if (s->master_send_enable_controllable ()) {
5344 s->master_send_enable_controllable()->set_value (state, PBD::Controllable::NoGroup);
5348 return float_message (X_("/select/master_send_enable"), 0, get_address(msg));
5352 OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg) {
5353 OSCSurface *sur = get_surface(get_address (msg));
5355 uint32_t piid = sur->plugin_id;
5360 // change parameter in already selected plugin
5361 if (types[0] == 'f') {
5362 paid = (int) argv[0]->f;
5367 } else if (argc == 3) {
5368 if (types[0] == 'f') {
5369 piid = (int) argv[0]->f;
5373 _sel_plugin (piid, get_address (msg));
5374 if (types[1] == 'f') {
5375 paid = (int) argv[1]->f;
5380 } else if (argc > 3) {
5381 PBD::warning << "OSC: Too many parameters: " << argc << endmsg;
5385 const char * par = strstr (&path[25], "/");
5387 piid = atoi (&path[25]);
5388 _sel_plugin (piid, msg);
5389 paid = atoi (&par[1]);
5391 // we have plugin id too
5394 paid = atoi (&path[25]);
5398 PBD::warning << "OSC: Must have parameters." << endmsg;
5401 if (!piid || piid > sur->plugins.size ()) {
5402 return float_message_with_id (X_("/select/plugin/parameter"), paid, 0, sur->feedback[2], get_address (msg));
5404 if (sur->plug_page_size && (paid > (int)sur->plug_page_size)) {
5405 return float_message_with_id (X_("/select/plugin/parameter"), paid, 0, sur->feedback[2], get_address (msg));
5407 boost::shared_ptr<Stripable> s = sur->select;
5408 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
5413 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
5414 boost::shared_ptr<PluginInsert> pi;
5415 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
5418 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5419 // paid is paged parameter convert to absolute
5420 int parid = paid + (int)sur->plug_page - 1;
5421 if (parid > (int) sur->plug_params.size ()) {
5422 if (sur->feedback[13]) {
5423 float_message_with_id (X_("/select/plugin/parameter"), paid, 0, sur->feedback[2], get_address (msg));
5429 uint32_t controlid = pip->nth_parameter(sur->plug_params[parid - 1], ok);
5433 ParameterDescriptor pd;
5434 pip->get_parameter_descriptor(controlid, pd);
5435 if ( pip->parameter_is_input(controlid) || pip->parameter_is_control(controlid) ) {
5436 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
5438 if (pd.integer_step && pd.upper == 1) {
5439 if (c->get_value () && value < 1.0) {
5440 c->set_value (0, PBD::Controllable::NoGroup);
5441 } else if (!c->get_value () && value) {
5442 c->set_value (1, PBD::Controllable::NoGroup);
5445 c->set_value (c->interface_to_internal (value), PBD::Controllable::NoGroup);
5454 OSC::sel_plugin_activate (float state, lo_message msg)
5459 OSCSurface *sur = get_surface(get_address (msg));
5460 if (sur->plugins.size() > 0) {
5461 boost::shared_ptr<Stripable> s = sur->select;
5463 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5466 boost::shared_ptr<Processor> redi=r->nth_plugin (sur->plugins[sur->plugin_id -1]);
5468 boost::shared_ptr<PluginInsert> pi;
5469 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5480 float_message (X_("/select/plugin/activate"), 0, get_address (msg));
5481 PBD::warning << "OSC: Select has no Plugin." << endmsg;
5486 OSC::route_plugin_list (int ssid, lo_message msg) {
5491 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
5494 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5499 lo_message reply = lo_message_new ();
5500 lo_message_add_int32 (reply, ssid);
5504 boost::shared_ptr<Processor> redi = r->nth_plugin(piid);
5509 boost::shared_ptr<PluginInsert> pi;
5511 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5512 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5515 lo_message_add_int32 (reply, piid + 1);
5517 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5518 lo_message_add_string (reply, pip->name());
5519 lo_message_add_int32(reply, redi->enabled() ? 1 : 0);
5524 lo_send_message (get_address (msg), X_("/strip/plugin/list"), reply);
5525 lo_message_free (reply);
5530 OSC::route_plugin_descriptor (int ssid, int piid, lo_message msg) {
5535 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
5538 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5542 boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
5545 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
5549 boost::shared_ptr<PluginInsert> pi;
5551 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5552 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5556 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5559 for ( uint32_t ppi = 0; ppi < pip->parameter_count(); ppi++) {
5561 uint32_t controlid = pip->nth_parameter(ppi, ok);
5565 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
5567 lo_message reply = lo_message_new();
5568 lo_message_add_int32 (reply, ssid);
5569 lo_message_add_int32 (reply, piid);
5571 lo_message_add_int32 (reply, ppi + 1);
5572 ParameterDescriptor pd;
5573 pi->plugin()->get_parameter_descriptor(controlid, pd);
5574 lo_message_add_string (reply, pd.label.c_str());
5576 // I've combined those binary descriptor parts in a bit-field to reduce lilo message elements
5578 flags |= pd.enumeration ? 1 : 0;
5579 flags |= pd.integer_step ? 2 : 0;
5580 flags |= pd.logarithmic ? 4 : 0;
5581 flags |= pd.sr_dependent ? 32 : 0;
5582 flags |= pd.toggled ? 64 : 0;
5583 flags |= pip->parameter_is_input(controlid) ? 0x80 : 0;
5585 std::string param_desc = pi->plugin()->describe_parameter(Evoral::Parameter(PluginAutomation, 0, controlid));
5586 flags |= (param_desc == X_("hidden")) ? 0x100 : 0;
5587 lo_message_add_int32 (reply, flags);
5589 switch(pd.datatype) {
5590 case ARDOUR::Variant::BEATS:
5591 lo_message_add_string(reply, _("BEATS"));
5593 case ARDOUR::Variant::BOOL:
5594 lo_message_add_string(reply, _("BOOL"));
5596 case ARDOUR::Variant::DOUBLE:
5597 lo_message_add_string(reply, _("DOUBLE"));
5599 case ARDOUR::Variant::FLOAT:
5600 lo_message_add_string(reply, _("FLOAT"));
5602 case ARDOUR::Variant::INT:
5603 lo_message_add_string(reply, _("INT"));
5605 case ARDOUR::Variant::LONG:
5606 lo_message_add_string(reply, _("LONG"));
5608 case ARDOUR::Variant::NOTHING:
5609 lo_message_add_string(reply, _("NOTHING"));
5611 case ARDOUR::Variant::PATH:
5612 lo_message_add_string(reply, _("PATH"));
5614 case ARDOUR::Variant::STRING:
5615 lo_message_add_string(reply, _("STRING"));
5617 case ARDOUR::Variant::URI:
5618 lo_message_add_string(reply, _("URI"));
5621 lo_message_add_string(reply, _("UNKNOWN"));
5624 lo_message_add_float (reply, pd.lower);
5625 lo_message_add_float (reply, pd.upper);
5626 lo_message_add_string (reply, pd.print_fmt.c_str());
5627 if ( pd.scale_points ) {
5628 lo_message_add_int32 (reply, pd.scale_points->size());
5629 for ( ARDOUR::ScalePoints::const_iterator i = pd.scale_points->begin(); i != pd.scale_points->end(); ++i) {
5630 lo_message_add_float (reply, i->second);
5631 lo_message_add_string (reply, ((std::string)i->first).c_str());
5635 lo_message_add_int32 (reply, 0);
5638 lo_message_add_double (reply, c->get_value());
5641 lo_message_add_double (reply, 0);
5644 lo_send_message (get_address (msg), X_("/strip/plugin/descriptor"), reply);
5645 lo_message_free (reply);
5648 lo_message reply = lo_message_new ();
5649 lo_message_add_int32 (reply, ssid);
5650 lo_message_add_int32 (reply, piid);
5651 lo_send_message (get_address (msg), X_("/strip/plugin/descriptor_end"), reply);
5652 lo_message_free (reply);
5658 OSC::route_plugin_reset (int ssid, int piid, lo_message msg) {
5663 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(get_strip (ssid, get_address (msg)));
5666 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5670 boost::shared_ptr<Processor> redi = r->nth_plugin(piid - 1);
5673 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
5677 boost::shared_ptr<PluginInsert> pi;
5679 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5680 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5684 pi->reset_parameters_to_default ();
5690 OSC::route_plugin_parameter (int ssid, int piid, int par, float val, lo_message msg)
5694 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5696 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5699 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5703 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
5706 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
5710 boost::shared_ptr<PluginInsert> pi;
5712 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5713 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5717 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5720 uint32_t controlid = pip->nth_parameter (par - 1,ok);
5723 PBD::error << "OSC: Cannot find parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "'" << endmsg;
5727 if (!pip->parameter_is_input(controlid)) {
5728 PBD::error << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is not a control input" << endmsg;
5732 ParameterDescriptor pd;
5733 pi->plugin()->get_parameter_descriptor (controlid,pd);
5735 if (val >= pd.lower && val <= pd.upper) {
5737 boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
5738 // cerr << "parameter:" << redi->describe_parameter(controlid) << " val:" << val << "\n";
5739 c->set_value (val, PBD::Controllable::NoGroup);
5741 PBD::warning << "OSC: Parameter # " << par << " for plugin # " << piid << " on RID '" << ssid << "' is out of range" << endmsg;
5742 PBD::info << "OSC: Valid range min=" << pd.lower << " max=" << pd.upper << endmsg;
5748 //prints to cerr only
5750 OSC::route_plugin_parameter_print (int ssid, int piid, int par, lo_message msg)
5755 boost::shared_ptr<Stripable> s = get_strip (ssid, get_address (msg));
5757 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5763 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
5769 boost::shared_ptr<PluginInsert> pi;
5771 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5775 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5778 uint32_t controlid = pip->nth_parameter (par - 1,ok);
5784 ParameterDescriptor pd;
5786 if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) {
5787 boost::shared_ptr<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
5789 cerr << "parameter: " << pd.label << "\n";
5791 cerr << "current value: " << c->get_value () << "\n";
5793 cerr << "current value not available, control does not exist\n";
5795 cerr << "lower value: " << pd.lower << "\n";
5796 cerr << "upper value: " << pd.upper << "\n";
5803 OSC::route_plugin_activate (int ssid, int piid, lo_message msg)
5807 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
5809 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5812 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5816 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
5819 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
5823 boost::shared_ptr<PluginInsert> pi;
5825 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5826 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5830 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5837 OSC::route_plugin_deactivate (int ssid, int piid, lo_message msg)
5841 boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
5843 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
5846 PBD::error << "OSC: Invalid Remote Control ID '" << ssid << "'" << endmsg;
5850 boost::shared_ptr<Processor> redi=r->nth_plugin (piid - 1);
5853 PBD::error << "OSC: cannot find plugin # " << piid << " for RID '" << ssid << "'" << endmsg;
5857 boost::shared_ptr<PluginInsert> pi;
5859 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
5860 PBD::error << "OSC: given processor # " << piid << " on RID '" << ssid << "' is not a Plugin." << endmsg;
5864 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
5873 OSC::sel_pan_elevation (float val, lo_message msg)
5875 OSCSurface *sur = get_surface(get_address (msg));
5876 boost::shared_ptr<Stripable> s;
5879 if (s->pan_elevation_control()) {
5880 s->pan_elevation_control()->set_value (s->pan_elevation_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
5884 return float_message(X_("/select/pan_elevation_position"), 0, get_address (msg));
5888 OSC::sel_pan_frontback (float val, lo_message msg)
5890 OSCSurface *sur = get_surface(get_address (msg));
5891 boost::shared_ptr<Stripable> s;
5894 if (s->pan_frontback_control()) {
5895 s->pan_frontback_control()->set_value (s->pan_frontback_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
5899 return float_message(X_("/select/pan_frontback_position"), 0.5, get_address (msg));
5903 OSC::sel_pan_lfe (float val, lo_message msg)
5905 OSCSurface *sur = get_surface(get_address (msg));
5906 boost::shared_ptr<Stripable> s;
5909 if (s->pan_lfe_control()) {
5910 s->pan_lfe_control()->set_value (s->pan_lfe_control()->interface_to_internal (val), PBD::Controllable::NoGroup);
5914 return float_message(X_("/select/pan_lfe_control"), 0, get_address (msg));
5917 // compressor control
5919 OSC::sel_comp_enable (float val, lo_message msg)
5921 OSCSurface *sur = get_surface(get_address (msg));
5922 boost::shared_ptr<Stripable> s;
5925 if (s->comp_enable_controllable()) {
5926 s->comp_enable_controllable()->set_value (s->comp_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
5930 return float_message(X_("/select/comp_enable"), 0, get_address (msg));
5934 OSC::sel_comp_threshold (float val, lo_message msg)
5936 OSCSurface *sur = get_surface(get_address (msg));
5937 boost::shared_ptr<Stripable> s;
5940 if (s->comp_threshold_controllable()) {
5941 s->comp_threshold_controllable()->set_value (s->comp_threshold_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
5945 return float_message(X_("/select/comp_threshold"), 0, get_address (msg));
5949 OSC::sel_comp_speed (float val, lo_message msg)
5951 OSCSurface *sur = get_surface(get_address (msg));
5952 boost::shared_ptr<Stripable> s;
5955 if (s->comp_speed_controllable()) {
5956 s->comp_speed_controllable()->set_value (s->comp_speed_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
5960 return float_message(X_("/select/comp_speed"), 0, get_address (msg));
5964 OSC::sel_comp_mode (float val, lo_message msg)
5966 OSCSurface *sur = get_surface(get_address (msg));
5967 boost::shared_ptr<Stripable> s;
5970 if (s->comp_mode_controllable()) {
5971 s->comp_mode_controllable()->set_value (s->comp_mode_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
5975 return float_message(X_("/select/comp_mode"), 0, get_address (msg));
5979 OSC::sel_comp_makeup (float val, lo_message msg)
5981 OSCSurface *sur = get_surface(get_address (msg));
5982 boost::shared_ptr<Stripable> s;
5985 if (s->comp_makeup_controllable()) {
5986 s->comp_makeup_controllable()->set_value (s->comp_makeup_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
5990 return float_message(X_("/select/comp_makeup"), 0, get_address (msg));
5996 OSC::sel_eq_enable (float val, lo_message msg)
5998 OSCSurface *sur = get_surface(get_address (msg));
5999 boost::shared_ptr<Stripable> s;
6002 if (s->eq_enable_controllable()) {
6003 s->eq_enable_controllable()->set_value (s->eq_enable_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup);
6007 return float_message(X_("/select/eq_enable"), 0, get_address (msg));
6011 OSC::sel_eq_hpf_freq (float val, lo_message msg)
6013 OSCSurface *sur = get_surface(get_address (msg));
6014 boost::shared_ptr<Stripable> s;
6017 if (s->filter_freq_controllable(true)) {
6018 s->filter_freq_controllable(true)->set_value (s->filter_freq_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
6022 return float_message(X_("/select/eq_hpf/freq"), 0, get_address (msg));
6026 OSC::sel_eq_lpf_freq (float val, lo_message msg)
6028 OSCSurface *sur = get_surface(get_address (msg));
6029 boost::shared_ptr<Stripable> s;
6032 if (s->filter_freq_controllable(false)) {
6033 s->filter_freq_controllable(false)->set_value (s->filter_freq_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
6037 return float_message(X_("/select/eq_lpf/freq"), 0, get_address (msg));
6041 OSC::sel_eq_hpf_enable (float val, lo_message msg)
6043 OSCSurface *sur = get_surface(get_address (msg));
6044 boost::shared_ptr<Stripable> s;
6047 if (s->filter_enable_controllable(true)) {
6048 s->filter_enable_controllable(true)->set_value (s->filter_enable_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
6052 return float_message(X_("/select/eq_hpf/enable"), 0, get_address (msg));
6056 OSC::sel_eq_lpf_enable (float val, lo_message msg)
6058 OSCSurface *sur = get_surface(get_address (msg));
6059 boost::shared_ptr<Stripable> s;
6062 if (s->filter_enable_controllable(false)) {
6063 s->filter_enable_controllable(false)->set_value (s->filter_enable_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
6067 return float_message(X_("/select/eq_lpf/enable"), 0, get_address (msg));
6071 OSC::sel_eq_hpf_slope (float val, lo_message msg)
6073 OSCSurface *sur = get_surface(get_address (msg));
6074 boost::shared_ptr<Stripable> s;
6077 if (s->filter_slope_controllable(true)) {
6078 s->filter_slope_controllable(true)->set_value (s->filter_slope_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup);
6082 return float_message(X_("/select/eq_hpf/slope"), 0, get_address (msg));
6086 OSC::sel_eq_lpf_slope (float val, lo_message msg)
6088 OSCSurface *sur = get_surface(get_address (msg));
6089 boost::shared_ptr<Stripable> s;
6092 if (s->filter_slope_controllable(false)) {
6093 s->filter_slope_controllable(false)->set_value (s->filter_slope_controllable(false)->interface_to_internal (val), PBD::Controllable::NoGroup);
6097 return float_message(X_("/select/eq_lpf/slope"), 0, get_address (msg));
6101 OSC::sel_eq_gain (int id, float val, lo_message msg)
6103 OSCSurface *sur = get_surface(get_address (msg));
6104 boost::shared_ptr<Stripable> s;
6110 if (s->eq_gain_controllable (id)) {
6111 s->eq_gain_controllable (id)->set_value (s->eq_gain_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
6115 return float_message_with_id (X_("/select/eq_gain"), id + 1, 0, sur->feedback[2], get_address (msg));
6119 OSC::sel_eq_freq (int id, float val, lo_message msg)
6121 OSCSurface *sur = get_surface(get_address (msg));
6122 boost::shared_ptr<Stripable> s;
6128 if (s->eq_freq_controllable (id)) {
6129 s->eq_freq_controllable (id)->set_value (s->eq_freq_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
6133 return float_message_with_id (X_("/select/eq_freq"), id + 1, 0, sur->feedback[2], get_address (msg));
6137 OSC::sel_eq_q (int id, float val, lo_message msg)
6139 OSCSurface *sur = get_surface(get_address (msg));
6140 boost::shared_ptr<Stripable> s;
6146 if (s->eq_q_controllable (id)) {
6147 s->eq_q_controllable (id)->set_value (s->eq_q_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
6151 return float_message_with_id (X_("/select/eq_q"), id + 1, 0, sur->feedback[2], get_address (msg));
6155 OSC::sel_eq_shape (int id, float val, lo_message msg)
6157 OSCSurface *sur = get_surface(get_address (msg));
6158 boost::shared_ptr<Stripable> s;
6164 if (s->eq_shape_controllable (id)) {
6165 s->eq_shape_controllable (id)->set_value (s->eq_shape_controllable(id)->interface_to_internal (val), PBD::Controllable::NoGroup);
6169 return float_message_with_id (X_("/select/eq_shape"), id + 1, 0, sur->feedback[2], get_address (msg));
6174 OSC::periodic (void)
6176 if (observer_busy) {
6180 Glib::usleep(100); // let flurry of signals subside
6182 for (uint32_t it = 0; it < _surface.size(); it++) {
6183 OSCSurface* sur = &_surface[it];
6184 global_feedback (sur);
6186 global_init = false;
6197 if (scrub_speed != 0) {
6198 // for those jog wheels that don't have 0 on release (touch), time out.
6199 int64_t now = ARDOUR::get_microseconds ();
6200 int64_t diff = now - scrub_time;
6201 if (diff > 120000) {
6203 session->request_transport_speed (0);
6204 // locate to the place PH was at last tick
6205 session->request_locate (scrub_place, false);
6208 for (uint32_t it = 0; it < _surface.size(); it++) {
6209 OSCSurface* sur = &_surface[it];
6210 OSCSelectObserver* so;
6211 if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
6215 if ((co = dynamic_cast<OSCCueObserver*>(sur->cue_obs)) != 0) {
6218 OSCGlobalObserver* go;
6219 if ((go = dynamic_cast<OSCGlobalObserver*>(sur->global_obs)) != 0) {
6222 for (uint32_t i = 0; i < sur->observers.size(); i++) {
6223 OSCRouteObserver* ro;
6224 if ((ro = dynamic_cast<OSCRouteObserver*>(sur->observers[i])) != 0) {
6230 for (FakeTouchMap::iterator x = _touch_timeout.begin(); x != _touch_timeout.end();) {
6231 _touch_timeout[(*x).first] = (*x).second - 1;
6233 boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
6235 ctrl->stop_touch (ctrl->session().transport_sample());
6236 _touch_timeout.erase (x++);
6247 XMLNode& node (ControlProtocol::get_state());
6248 node.set_property (X_("debugmode"), (int32_t) _debugmode); // TODO: enum2str
6249 node.set_property (X_("address-only"), address_only);
6250 node.set_property (X_("remote-port"), remote_port);
6251 node.set_property (X_("banksize"), default_banksize);
6252 node.set_property (X_("striptypes"), default_strip);
6253 node.set_property (X_("feedback"), default_feedback);
6254 node.set_property (X_("gainmode"), default_gainmode);
6255 node.set_property (X_("send-page-size"), default_send_size);
6256 node.set_property (X_("plug-page-size"), default_plugin_size);
6261 OSC::set_state (const XMLNode& node, int version)
6263 if (ControlProtocol::set_state (node, version)) {
6267 if (node.get_property (X_("debugmode"), debugmode)) {
6268 _debugmode = OSCDebugMode (debugmode);
6271 node.get_property (X_("address-only"), address_only);
6272 node.get_property (X_("remote-port"), remote_port);
6273 node.get_property (X_("banksize"), default_banksize);
6274 node.get_property (X_("striptypes"), default_strip);
6275 node.get_property (X_("feedback"), default_feedback);
6276 node.get_property (X_("gainmode"), default_gainmode);
6277 node.get_property (X_("send-page-size"), default_send_size);
6278 node.get_property (X_("plugin-page-size"), default_plugin_size);
6286 // predicate for sort call in get_sorted_stripables
6287 struct StripableByPresentationOrder
6289 bool operator () (const boost::shared_ptr<Stripable> & a, const boost::shared_ptr<Stripable> & b) const
6291 return a->presentation_info().order() < b->presentation_info().order();
6294 bool operator () (const Stripable & a, const Stripable & b) const
6296 return a.presentation_info().order() < b.presentation_info().order();
6299 bool operator () (const Stripable * a, const Stripable * b) const
6301 return a->presentation_info().order() < b->presentation_info().order();
6306 OSC::get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sorted my_list)
6309 StripableList stripables;
6310 StripableList custom_list;
6312 // fetch all stripables
6313 session->get_stripables (stripables, PresentationInfo::AllStripables);
6315 uint32_t nstps = my_list.size ();
6316 // check each custom strip to see if it still exists
6317 boost::shared_ptr<Stripable> s;
6318 for (uint32_t i = 0; i < nstps; i++) {
6319 bool exists = false;
6321 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
6322 boost::shared_ptr<Stripable> sl = *it;
6329 my_list[i] = boost::shared_ptr<Stripable>();
6331 custom_list.push_back (s);
6337 stripables = custom_list;
6340 // Look for stripables that match bit in sur->strip_types
6341 for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
6343 boost::shared_ptr<Stripable> s = *it;
6348 // banking off use all valid custom strips
6349 sorted.push_back (s);
6351 if ((!cue) && (!types[9]) && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
6352 // do nothing... skip it
6353 } else if (types[8] && (s->is_selected())) {
6354 sorted.push_back (s);
6355 } else if (types[9] && (s->presentation_info().flags() & PresentationInfo::Hidden)) {
6356 sorted.push_back (s);
6357 } else if (s->is_master() || s->is_monitor() || s->is_auditioner()) {
6358 // do nothing for these either (we add them later)
6360 if (types[0] && boost::dynamic_pointer_cast<AudioTrack>(s)) {
6361 sorted.push_back (s);
6362 } else if (types[1] && boost::dynamic_pointer_cast<MidiTrack>(s)) {
6363 sorted.push_back (s);
6364 } else if (types[4] && boost::dynamic_pointer_cast<VCA>(s)) {
6365 sorted.push_back (s);
6366 } else if (s->is_foldbackbus()) {
6368 sorted.push_back (s);
6372 if (types[2] && Profile->get_mixbus() && s->mixbus()) {
6373 sorted.push_back (s);
6376 if (boost::dynamic_pointer_cast<Route>(s) && !boost::dynamic_pointer_cast<Track>(s)) {
6377 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
6378 if (!(s->presentation_info().flags() & PresentationInfo::MidiBus)) {
6379 // note some older sessions will show midibuses as busses
6382 sorted.push_back (s);
6384 } else if (types[3]) {
6385 sorted.push_back (s);
6390 if (!custom || (custom & 0x2)) {
6391 sort (sorted.begin(), sorted.end(), StripableByPresentationOrder());
6394 // Master/Monitor might be anywhere... we put them at the end - Sorry ;)
6396 if (session->master_out()) {
6397 sorted.push_back (session->master_out());
6401 if (session->monitor_out()) {
6402 sorted.push_back (session->monitor_out());
6410 OSC::cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg)
6412 OSCSurface *s = get_surface(get_address (msg), true);
6416 if (types[0] == 'f') {
6418 } else if (types[0] == 'i') {
6419 value = (float) argv[0]->i;
6422 int ret = 1; /* unhandled */
6423 if (!strncmp (path, X_("/cue/aux"), 8)) {
6427 ret = cue_set ((uint32_t) value, msg);
6433 else if (!strncmp (path, X_("/cue/connect_aux"), 16)) {
6434 // Create new Aux bus
6436 if (argc == 1 && types[0] == 's') {
6438 ret = cue_connect_aux (dest, msg);
6440 PBD::warning << "OSC: connect_aux has wrong number or type of parameters." << endmsg;
6443 else if (!strncmp (path, X_("/cue/connect"), 12)) {
6444 // Connect to default Aux bus
6445 if ((!argc) || argv[0]->f || argv[0]->i) {
6446 ret = cue_set (1, msg);
6451 else if (!strncmp (path, X_("/cue/new_aux"), 12)) {
6452 // Create new Aux bus
6456 if (argc == 3 && types[0] == 's' && types[1] == 's' && types[2] == 's') {
6458 dest_1 = &argv[1]->s;
6459 dest_2 = &argv[2]->s;
6460 ret = cue_new_aux (name, dest_1, dest_2, 2, msg);
6461 } else if (argc == 2 && types[0] == 's' && types[1] == 's') {
6463 dest_1 = &argv[1]->s;
6465 ret = cue_new_aux (name, dest_1, dest_2, 1, msg);
6466 } else if (argc == 1 && types[0] == 's') {
6468 ret = cue_new_aux (name, dest_1, dest_2, 1, msg);
6470 PBD::warning << "OSC: new_aux has wrong number or type of parameters." << endmsg;
6473 else if (!strncmp (path, X_("/cue/new_send"), 13)) {
6474 // Create new send to aux
6475 string rt_name = "";
6476 if (argc == 1 && types[0] == 's') {
6477 rt_name = &argv[0]->s;
6478 ret = cue_new_send (rt_name, msg);
6480 PBD::warning << "OSC: new_send has wrong number or type of parameters." << endmsg;
6483 else if (!strncmp (path, X_("/cue/next_aux"), 13)) {
6484 // switch to next Aux bus
6485 if ((!argc) || argv[0]->f || argv[0]->i) {
6486 ret = cue_next (msg);
6491 else if (!strncmp (path, X_("/cue/previous_aux"), 17)) {
6492 // switch to previous Aux bus
6493 if ((!argc) || argv[0]->f || argv[0]->i) {
6494 ret = cue_previous (msg);
6499 else if (!strncmp (path, X_("/cue/send/fader/"), 16) && strlen (path) > 16) {
6501 int id = atoi (&path[16]);
6502 ret = cue_send_fader (id, value, msg);
6505 else if (!strncmp (path, X_("/cue/send/enable/"), 17) && strlen (path) > 17) {
6507 int id = atoi (&path[17]);
6508 ret = cue_send_enable (id, value, msg);
6511 else if (!strncmp (path, X_("/cue/fader"), 10)) {
6513 ret = cue_aux_fader (value, msg);
6516 else if (!strncmp (path, X_("/cue/mute"), 9)) {
6518 ret = cue_aux_mute (value, msg);
6526 OSC::cue_set (uint32_t aux, lo_message msg)
6529 return _cue_set (aux, get_address (msg));
6533 OSC::_cue_set (uint32_t aux, lo_address addr)
6536 OSCSurface *s = get_surface(addr, true);
6538 s->strip_types = 128;
6542 s->strips = get_sorted_stripables(s->strip_types, s->cue, false, s->custom_strips);
6544 s->nstrips = s->strips.size();
6546 surface_destroy (s);
6551 } else if (aux > s->nstrips) {
6555 // get a list of Auxes
6556 for (uint32_t n = 0; n < s->nstrips; ++n) {
6557 boost::shared_ptr<Stripable> stp = s->strips[n];
6559 text_message (string_compose (X_("/cue/name/%1"), n+1), stp->name(), addr);
6561 // aux must be at least one
6563 stp->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::_cue_set, this, aux, addr), this);
6564 // make a list of stripables with sends that go to this bus
6565 s->sends = cue_get_sorted_stripables(stp, aux, addr);
6567 s->cue_obs->refresh_strip (stp, s->sends, true);
6569 // start cue observer
6570 OSCCueObserver* co = new OSCCueObserver (*this, s);
6583 OSC::cue_new_aux (string name, string dest_1, string dest_2, uint32_t count, lo_message msg)
6585 // create a new bus named name - monitor
6587 boost::shared_ptr<Stripable> aux;
6588 name = string_compose ("%1 - FB", name);
6589 list = session->new_audio_route (count, count, 0, 1, name, PresentationInfo::FoldbackBus, (uint32_t) -1);
6590 aux = *(list.begin());
6592 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(aux);
6593 if (dest_1.size()) {
6594 PortSet& ports = r->output()->ports ();
6595 if (atoi( dest_1.c_str())) {
6596 dest_1 = string_compose ("system:playback_%1", dest_1);
6598 r->output ()->connect (*(ports.begin()), dest_1, this);
6600 if (atoi( dest_2.c_str())) {
6601 dest_2 = string_compose ("system:playback_%1", dest_2);
6603 PortSet::iterator i = ports.begin();
6605 r->output ()->connect (*(i), dest_2, this);
6608 cue_set ((uint32_t) -1, msg);
6609 session->set_dirty();
6616 OSC::cue_new_send (string rt_name, lo_message msg)
6618 OSCSurface *sur = get_surface(get_address (msg), true);
6620 boost::shared_ptr<Route> aux = boost::dynamic_pointer_cast<Route> (get_strip (sur->aux, get_address(msg)));
6622 boost::shared_ptr<Route> rt_send = session->route_by_name (rt_name);
6623 if (rt_send && (aux != rt_send)) {
6624 // make sure there isn't one already
6626 if (!rt_send->feeds (aux, &s_only)) {
6628 rt_send->add_foldback_send (aux);
6629 boost::shared_ptr<Send> snd = rt_send->internal_send_for (aux);
6633 PBD::warning << "OSC: new_send - duplicate send, ignored." << endmsg;
6636 PBD::warning << "OSC: new_send - route doesn't exist or is aux." << endmsg;
6639 PBD::warning << "OSC: new_send - No Aux to send to." << endmsg;
6642 PBD::warning << "OSC: new_send - monitoring not set, select aux first." << endmsg;
6648 OSC::cue_connect_aux (std::string dest, lo_message msg)
6650 OSCSurface *sur = get_surface(get_address (msg), true);
6653 boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (get_strip (sur->aux, get_address(msg)));
6656 rt->output()->disconnect (this);
6657 if (atoi( dest.c_str())) {
6658 dest = string_compose ("system:playback_%1", dest);
6660 PortSet& ports = rt->output()->ports ();
6661 rt->output ()->connect (*(ports.begin()), dest, this);
6662 session->set_dirty();
6668 PBD::warning << "OSC: cannot connect, no Aux bus chosen." << endmsg;
6674 OSC::cue_next (lo_message msg)
6676 OSCSurface *s = get_surface(get_address (msg), true);
6680 ret = cue_set (1, msg);
6682 if (s->aux < s->nstrips) {
6683 ret = cue_set (s->aux + 1, msg);
6685 ret = cue_set (s->nstrips, msg);
6691 OSC::cue_previous (lo_message msg)
6693 OSCSurface *s = get_surface(get_address (msg), true);
6696 ret = cue_set (1, msg);
6699 ret = cue_set (s->aux - 1, msg);
6701 ret = cue_set (1, msg);
6706 boost::shared_ptr<Send>
6707 OSC::cue_get_send (uint32_t id, lo_address addr)
6709 OSCSurface *s = get_surface(addr, true);
6710 if (id && s->aux > 0 && id <= s->sends.size()) {
6711 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s->sends[id - 1]);
6712 boost::shared_ptr<Stripable> aux = get_strip (s->aux, addr);
6714 return r->internal_send_for (boost::dynamic_pointer_cast<Route> (aux));
6717 return boost::shared_ptr<Send>();
6722 OSC::cue_aux_fader (float position, lo_message msg)
6724 if (!session) return -1;
6726 OSCSurface *sur = get_surface(get_address (msg), true);
6729 boost::shared_ptr<Stripable> s = get_strip (sur->aux, get_address (msg));
6732 if (s->gain_control()) {
6733 s->gain_control()->set_value (s->gain_control()->interface_to_internal (position), PBD::Controllable::NoGroup);
6739 float_message (X_("/cue/fader"), 0, get_address (msg));
6744 OSC::cue_aux_mute (float state, lo_message msg)
6746 if (!session) return -1;
6748 OSCSurface *sur = get_surface(get_address (msg), true);
6751 boost::shared_ptr<Stripable> s = get_strip (sur->aux, get_address (msg));
6753 if (s->mute_control()) {
6754 s->mute_control()->set_value (state ? 1.0 : 0.0, PBD::Controllable::NoGroup);
6760 float_message (X_("/cue/mute"), 0, get_address (msg));
6765 OSC::cue_send_fader (uint32_t id, float val, lo_message msg)
6770 boost::shared_ptr<Send> s = cue_get_send (id, get_address (msg));
6772 if (s->gain_control()) {
6773 s->gain_control()->set_value (s->gain_control()->interface_to_internal(val), PBD::Controllable::NoGroup);
6777 float_message (string_compose (X_("/cue/send/fader/%1"), id), 0, get_address (msg));
6782 OSC::cue_send_enable (uint32_t id, float state, lo_message msg)
6786 boost::shared_ptr<Send> s = cue_get_send (id, get_address (msg));
6795 float_message (string_compose (X_("/cue/send/enable/%1"), id), 0, get_address (msg));
6799 // generic send message
6801 OSC::float_message (string path, float val, lo_address addr)
6806 reply = lo_message_new ();
6807 lo_message_add_float (reply, (float) val);
6809 lo_send_message (addr, path.c_str(), reply);
6811 lo_message_free (reply);
6818 OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool in_line, lo_address addr)
6821 lo_message msg = lo_message_new ();
6823 path = string_compose ("%1/%2", path, ssid);
6825 lo_message_add_int32 (msg, ssid);
6827 lo_message_add_float (msg, value);
6829 lo_send_message (addr, path.c_str(), msg);
6831 lo_message_free (msg);
6837 OSC::int_message (string path, int val, lo_address addr)
6842 reply = lo_message_new ();
6843 lo_message_add_int32 (reply, (float) val);
6845 lo_send_message (addr, path.c_str(), reply);
6847 lo_message_free (reply);
6854 OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_line, lo_address addr)
6857 lo_message msg = lo_message_new ();
6859 path = string_compose ("%1/%2", path, ssid);
6861 lo_message_add_int32 (msg, ssid);
6863 lo_message_add_int32 (msg, value);
6865 lo_send_message (addr, path.c_str(), msg);
6867 lo_message_free (msg);
6873 OSC::text_message (string path, string val, lo_address addr)
6878 reply = lo_message_new ();
6879 lo_message_add_string (reply, val.c_str());
6881 lo_send_message (addr, path.c_str(), reply);
6883 lo_message_free (reply);
6890 OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr)
6893 lo_message msg = lo_message_new ();
6895 path = string_compose ("%1/%2", path, ssid);
6897 lo_message_add_int32 (msg, ssid);
6900 lo_message_add_string (msg, val.c_str());
6902 lo_send_message (addr, path.c_str(), msg);
6904 lo_message_free (msg);
6909 // we have to have a sorted list of stripables that have sends pointed at our aux
6910 // we can use the one in osc.cc to get an aux list
6912 OSC::cue_get_sorted_stripables(boost::shared_ptr<Stripable> aux, uint32_t id, lo_message msg)
6916 boost::shared_ptr<Route> aux_rt = boost::dynamic_pointer_cast<Route> (aux);
6917 Route::FedBy fed_by = aux_rt->fed_by();
6918 for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) {
6919 if (i->sends_only) {
6920 boost::shared_ptr<Stripable> s (i->r.lock());
6921 sorted.push_back (s);
6922 s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::cue_set, this, id, msg), this);
6925 sort (sorted.begin(), sorted.end(), StripableByPresentationOrder());