1 /* 2 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net> 3 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com> 4 * Copyright (C) 2009 David Robillard <d@drobilla.net> 5 * Copyright (C) 2013-2016 Robin Gareus <robin@gareus.org> 6 * Copyright (C) 2015 Johannes Mueller <github@johannes-mueller.org> 7 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net> 8 * Copyright (C) 2016 Ben Loftis <ben@harrisonconsoles.com> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with this program; if not, write to the Free Software Foundation, Inc., 22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 */ 24 25 #ifndef ardour_osc_h 26 #define ardour_osc_h 27 28 #include <string> 29 #include <vector> 30 #include <bitset> 31 32 #include <sys/time.h> 33 #include <pthread.h> 34 35 #include <boost/shared_ptr.hpp> 36 37 #include <lo/lo.h> 38 39 #include <glibmm/main.h> 40 41 #define ABSTRACT_UI_EXPORTS 42 #include "pbd/abstract_ui.h" 43 44 #include "ardour/types.h" 45 #include "ardour/send.h" 46 #include "ardour/plugin.h" 47 #include "control_protocol/control_protocol.h" 48 49 #include "pbd/i18n.h" 50 51 class OSCControllable; 52 class OSCRouteObserver; 53 class OSCGlobalObserver; 54 class OSCSelectObserver; 55 class OSCCueObserver; 56 57 namespace ARDOUR { 58 class Session; 59 class Route; 60 } 61 62 /* this is mostly a placeholder because I suspect that at some 63 point we will want to add more members to accomodate 64 certain types of requests to the OSC UI 65 */ 66 67 namespace ArdourSurface { 68 69 struct OSCUIRequest : public BaseUI::BaseRequestObject { 70 public: OSCUIRequestOSCUIRequest71 OSCUIRequest () {} ~OSCUIRequestOSCUIRequest72 ~OSCUIRequest() {} 73 }; 74 75 class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> 76 { 77 public: 78 OSC (ARDOUR::Session&, uint32_t port); 79 virtual ~OSC(); 80 instance()81 static OSC* instance() { return _instance; } 82 83 XMLNode& get_state (); 84 int set_state (const XMLNode&, int version); 85 stripable_selection_changed()86 void stripable_selection_changed () {} 87 has_editor()88 bool has_editor () const { return true; } 89 void* get_gui () const; 90 void tear_down_gui (); 91 92 int set_active (bool yn); 93 bool get_active () const; 94 95 // generic osc send 96 Glib::Threads::Mutex _lo_lock; 97 int float_message (std::string, float value, lo_address addr); 98 int int_message (std::string, int value, lo_address addr); 99 int text_message (std::string path, std::string val, lo_address addr); 100 int float_message_with_id (std::string, uint32_t ssid, float value, bool in_line, lo_address addr); 101 int int_message_with_id (std::string, uint32_t ssid, int value, bool in_line, lo_address addr); 102 int text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr); 103 104 int send_group_list (lo_address addr); 105 106 int start (); 107 int stop (); 108 109 static void* request_factory (uint32_t); 110 111 enum OSCDebugMode { 112 Off, 113 Unhandled, 114 All 115 }; 116 117 enum OSCTempMode { 118 TempOff = 0, 119 GroupOnly = 1, 120 VCAOnly = 2, 121 BusOnly = 3 122 }; 123 124 typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > Sorted; 125 Sorted get_sorted_stripables(std::bitset<32> types, bool cue, uint32_t custom, Sorted my_list); 126 typedef std::map<boost::shared_ptr<ARDOUR::AutomationControl>, uint32_t> FakeTouchMap; 127 FakeTouchMap _touch_timeout; 128 129 // keep a surface's global setup by remote server url 130 struct OSCSurface { 131 public: 132 //global 133 std::string remote_url; // the url these setting belong to 134 bool no_clear; // don't send osc clear messages on strip change 135 uint32_t jogmode; // current jogmode 136 OSCGlobalObserver* global_obs; // pointer to this surface's global observer 137 uint32_t nstrips; // how many strips are there for strip_types 138 std::bitset<32> feedback; // What is fed back? strips/meters/timecode/bar_beat/global 139 int gainmode; // what kind of faders do we have Gain db or position 0 to 1? 140 PBD::Controllable::GroupControlDisposition usegroup; // current group disposition 141 Sorted custom_strips; // a sorted list of user selected strips 142 uint32_t custom_mode; // use custom strip list 143 OSCTempMode temp_mode; // use temp strip list 144 Sorted temp_strips; // temp strip list for grouponly, vcaonly, auxonly 145 boost::shared_ptr<ARDOUR::Stripable> temp_master; // stripable this surface uses as temp master 146 Sorted strips; // list of stripables for this surface 147 // strips 148 uint32_t bank; // current bank 149 uint32_t bank_size; // size of banks for this surface 150 std::vector<OSCRouteObserver*> observers; // route observers for this surface 151 std::bitset<32> strip_types;// what strip types are a part of this bank 152 //select 153 OSCSelectObserver* sel_obs; // So we can sync select feedback with selected channel 154 uint32_t expand; // Used by /select/select 155 bool expand_enable; // use expand instead of select 156 boost::shared_ptr<ARDOUR::Stripable> expand_strip; // stripable this surface uses for expand 157 boost::shared_ptr<ARDOUR::Stripable> select; // stripable this surface uses as selected 158 int plug_page; // current plugin page 159 uint32_t plug_page_size; // plugin page size (number of controls) 160 int plugin_id; // id of current plugin 161 std::vector<int> plug_params; // vector to store ports that are controls 162 std::vector<int> plugins; // stores allowable plugins with index (work around MB strip PIs) 163 int send_page; // current send page 164 uint32_t send_page_size; // send page size in channels 165 uint32_t nsends; // number of sends select has 166 PBD::ScopedConnection proc_connection; // for processor signal monitoring 167 // cue 168 bool cue; // is this a cue surface 169 uint32_t aux; // aux index for this cue surface 170 Sorted sends; // list of sends for cue aux 171 OSCCueObserver* cue_obs; // pointer to this surface's cue observer 172 uint32_t linkset; // ID of a set of surfaces used as one 173 uint32_t linkid; // ID of this surface within a linkset 174 }; 175 /* 176 * feedback bits: 177 * [0] - Strips - buttons 178 * [1] - Strips - variables (pots/faders) 179 * [2] - Strips - Send SSID as path extension 180 * [3] - Send heart beat to surface 181 * [4] - Send feedback for master/global buttons/variables 182 * [5] - Send Bar and Beat 183 * [6] - Send Time code 184 * [7] - Send metering as dB or positional depending on gainmode 185 * [8] - Send metering as 16 bits (led strip) 186 * [9] - Send signal present (signal greater than -20dB) 187 * [10] - Send Playhead position as samples 188 * [11] - Send Playhead position as minutes seconds 189 * [12] - Send Playhead position like primary/secondary GUI clocks 190 * [13] - Send well known feedback (for /select/command 191 * [14] - use OSC 1.0 only (#reply -> /reply) 192 * 193 * Strip_type bits: 194 * [0] - Audio Tracks 195 * [1] - Midi Tracks 196 * [2] - Audio Bus 197 * [3] - Midi Bus 198 * [4] - VCAs 199 * [5] - master 200 * [6] - Monitor 201 * [7] - Listen Bus 202 * [8] - Selected 203 * [9] - Hidden 204 * [10] - Use Groups 205 * [11] - Global Expand 206 */ 207 208 // storage for each surface's settings 209 mutable Glib::Threads::Mutex surfaces_lock; 210 typedef std::vector<OSCSurface> Surface; 211 Surface _surface; 212 213 // linked surfaces 214 struct LinkSet { 215 public: 216 std::vector<std::string> urls; //urls of linked surfaces 217 uint32_t banksize; // linkset banksize 218 uint32_t bank; // linkset current bank 219 bool autobank; // banksize is derived from total 220 uint32_t not_ready; // number of 1st device, 0 = ready 221 Sorted custom_strips; // a sorted list of user selected strips 222 uint32_t custom_mode; // use custom strip list 223 OSCTempMode temp_mode; // use custom strip list 224 Sorted temp_strips; // temp strip list for grouponly, vcaonly, auxonly 225 boost::shared_ptr<ARDOUR::Stripable> temp_master; // temp master stripable 226 std::bitset<32> strip_types; // strip_types for this linkset 227 Sorted strips; // list of valid strips in order for this set 228 }; 229 230 std::map<uint32_t, LinkSet> link_sets; 231 // list of linksets 232 233 struct PortAdd { 234 public: 235 std::string host; 236 std::string port; 237 }; 238 239 std::vector<PortAdd> _ports; 240 241 // GUI calls 242 std::string get_server_url (); set_debug_mode(OSCDebugMode m)243 void set_debug_mode (OSCDebugMode m) { _debugmode = m; } get_debug_mode()244 OSCDebugMode get_debug_mode () { return _debugmode; } get_portmode()245 int get_portmode() { return address_only; } set_portmode(int pm)246 void set_portmode (int pm) { address_only = pm; } get_banksize()247 int get_banksize () { return default_banksize; } set_banksize(int bs)248 void set_banksize (int bs) {default_banksize = bs; } get_gainmode()249 int get_gainmode() { return default_gainmode; } set_gainmode(int gm)250 void set_gainmode (int gm) { default_gainmode = gm; } get_defaultstrip()251 int get_defaultstrip() { return default_strip; } set_defaultstrip(int st)252 void set_defaultstrip (int st) { default_strip = st; } get_defaultfeedback()253 int get_defaultfeedback() { return default_feedback; } set_defaultfeedback(int fb)254 void set_defaultfeedback (int fb) { default_feedback = fb; } get_send_size()255 int get_send_size() { return default_send_size; } set_send_size(int ss)256 void set_send_size (int ss) { default_send_size = ss; } get_plugin_size()257 int get_plugin_size() { return default_plugin_size; } set_plugin_size(int ps)258 void set_plugin_size (int ps) { default_plugin_size = ps; } 259 void clear_devices (); 260 void gui_changed (); 261 void get_surfaces (); get_remote_port()262 std::string get_remote_port () { return remote_port; } set_remote_port(std::string pt)263 void set_remote_port (std::string pt) { remote_port = pt; } 264 265 protected: 266 void thread_init (); 267 void do_request (OSCUIRequest*); 268 269 GSource* local_server; 270 GSource* remote_server; 271 272 bool osc_input_handler (Glib::IOCondition, lo_server); 273 274 private: 275 uint32_t _port; 276 volatile bool _ok; 277 volatile bool _shutdown; 278 lo_server _osc_server; 279 lo_server _osc_unix_server; 280 std::string _osc_unix_socket_path; 281 std::string _osc_url_file; 282 OSCDebugMode _debugmode; 283 bool address_only; 284 std::string remote_port; 285 uint32_t default_banksize; 286 uint32_t default_strip; 287 uint32_t default_feedback; 288 uint32_t default_gainmode; 289 uint32_t default_send_size; 290 uint32_t default_plugin_size; 291 bool tick; 292 bool bank_dirty; 293 bool observer_busy; 294 float scrub_speed; // Current scrub speed 295 double scrub_place; // place of play head at latest jog/scrub wheel tick 296 int64_t scrub_time; // when did the wheel move last? 297 bool global_init; 298 boost::shared_ptr<ARDOUR::Stripable> _select; // which stripable out of /surface/stripables is gui selected 299 300 void register_callbacks (); 301 302 void route_added (ARDOUR::RouteList&); 303 304 // Handlers for "Application Hook" signals 305 void session_loaded (ARDOUR::Session&); 306 void session_exported (std::string, std::string); 307 308 // end "Application Hook" handles 309 310 std::string get_unix_server_url (); 311 lo_address get_address (lo_message msg); 312 std::string get_port (std::string host); 313 OSCSurface * get_surface (lo_address addr, bool quiet = false); 314 int check_surface (lo_message msg); 315 uint32_t get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr); 316 boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr); 317 void global_feedback (OSCSurface* sur); 318 void strip_feedback (OSCSurface* sur, bool new_bank_size); 319 void surface_destroy (OSCSurface* sur); 320 uint32_t bank_limits_check (uint32_t bank, uint32_t size, uint32_t total); 321 void bank_leds (OSCSurface* sur); 322 323 void send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg); 324 void current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg); 325 326 int current_value (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data); 327 328 int catchall (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg); 329 static int _catchall (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data); 330 331 int set_automation (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 332 int touch_detect (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 333 int fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl); 334 335 int spill (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 336 337 int route_get_sends (lo_message msg); 338 int route_get_receives(lo_message msg); 339 void routes_list (lo_message msg); 340 int group_list (lo_message msg); 341 void surface_list (lo_message msg); 342 void transport_sample (lo_message msg); 343 void transport_speed (lo_message msg); 344 void record_enabled (lo_message msg); 345 add_marker_name(const std::string & markername)346 void add_marker_name(const std::string &markername) { 347 add_marker(markername); 348 } 349 350 // cue 351 Sorted cue_get_sorted_stripables(boost::shared_ptr<ARDOUR::Stripable> aux, uint32_t id, lo_address); 352 int cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 353 int cue_set (uint32_t aux, lo_message msg); 354 int _cue_set (uint32_t aux, lo_address addr); 355 int cue_new_aux (std::string name, std::string dest_1, std::string dest_2, uint32_t count, lo_message msg); 356 int cue_new_send (std::string rt_name, lo_message msg); 357 int cue_connect_aux (std::string dest, lo_message msg); 358 int cue_next (lo_message msg); 359 int cue_previous (lo_message msg); 360 int cue_send_fader (uint32_t id, float position, lo_message msg); 361 int cue_send_enable (uint32_t id, float state, lo_message msg); 362 int cue_aux_fader (float position, lo_message msg); 363 int cue_aux_mute (float state, lo_message msg); 364 void cue_set_aux (uint32_t aux, lo_message msg); 365 boost::shared_ptr<ARDOUR::Send> cue_get_send (uint32_t id, lo_address addr); 366 // end cue 367 368 // link 369 LinkSet * get_linkset (uint32_t set, lo_address addr); 370 int parse_link (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 371 int link_check (uint32_t linkset); 372 int set_link (uint32_t set, uint32_t id, lo_address addr); 373 void surface_link_state (LinkSet * set); 374 void link_strip_types (uint32_t linkset, uint32_t striptypes); 375 376 #define OSC_DEBUG \ 377 if (_debugmode == All) { \ 378 debugmsg (dgettext(PACKAGE, "OSC"), path, types, argv, argc); \ 379 } 380 381 #define PATH_CALLBACK_MSG(name) \ 382 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 383 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 384 } \ 385 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 386 OSC_DEBUG; \ 387 if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \ 388 name (msg); \ 389 return 0; \ 390 } 391 392 PATH_CALLBACK_MSG(route_get_sends); 393 PATH_CALLBACK_MSG(route_get_receives); 394 PATH_CALLBACK_MSG(routes_list); 395 PATH_CALLBACK_MSG(group_list); 396 PATH_CALLBACK_MSG(sel_previous); 397 PATH_CALLBACK_MSG(sel_next); 398 PATH_CALLBACK_MSG(surface_list); 399 PATH_CALLBACK_MSG(transport_sample); 400 PATH_CALLBACK_MSG(transport_speed); 401 PATH_CALLBACK_MSG(record_enabled); 402 PATH_CALLBACK_MSG(refresh_surface); 403 PATH_CALLBACK_MSG(bank_up); 404 PATH_CALLBACK_MSG(bank_down); 405 PATH_CALLBACK_MSG(custom_clear); 406 407 #define PATH_CALLBACK(name) \ 408 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 409 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 410 } \ 411 int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, lo_message msg) { \ 412 OSC_DEBUG; \ 413 check_surface (msg); \ 414 if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \ 415 name (); \ 416 return 0; \ 417 } 418 419 PATH_CALLBACK(add_marker); 420 PATH_CALLBACK(loop_toggle); 421 PATH_CALLBACK(goto_start); 422 PATH_CALLBACK(goto_end); 423 PATH_CALLBACK(rewind); 424 PATH_CALLBACK(ffwd); 425 PATH_CALLBACK(transport_stop); 426 PATH_CALLBACK(transport_play); 427 PATH_CALLBACK(save_state); 428 PATH_CALLBACK(prev_marker); 429 PATH_CALLBACK(next_marker); 430 PATH_CALLBACK(undo); 431 PATH_CALLBACK(redo); 432 PATH_CALLBACK(toggle_punch_in); 433 PATH_CALLBACK(toggle_punch_out); 434 PATH_CALLBACK(rec_enable_toggle); 435 PATH_CALLBACK(toggle_all_rec_enables); 436 PATH_CALLBACK(all_tracks_rec_in); 437 PATH_CALLBACK(all_tracks_rec_out); 438 PATH_CALLBACK(cancel_all_solos); 439 PATH_CALLBACK(remove_marker_at_playhead); 440 PATH_CALLBACK(mark_in); 441 PATH_CALLBACK(mark_out); 442 PATH_CALLBACK(toggle_click); 443 PATH_CALLBACK(midi_panic); 444 PATH_CALLBACK(stop_forget); 445 PATH_CALLBACK(set_punch_range); 446 PATH_CALLBACK(set_loop_range); 447 PATH_CALLBACK(set_session_range); 448 PATH_CALLBACK(toggle_monitor_mute); 449 PATH_CALLBACK(toggle_monitor_dim); 450 PATH_CALLBACK(toggle_monitor_mono); 451 PATH_CALLBACK(quick_snapshot_stay); 452 PATH_CALLBACK(quick_snapshot_switch); 453 PATH_CALLBACK(fit_1_track); 454 PATH_CALLBACK(fit_2_tracks); 455 PATH_CALLBACK(fit_4_tracks); 456 PATH_CALLBACK(fit_8_tracks); 457 PATH_CALLBACK(fit_16_tracks); 458 PATH_CALLBACK(fit_32_tracks); 459 PATH_CALLBACK(fit_all_tracks); 460 PATH_CALLBACK(zoom_100_ms); 461 PATH_CALLBACK(zoom_1_sec); 462 PATH_CALLBACK(zoom_10_sec); 463 PATH_CALLBACK(zoom_1_min); 464 PATH_CALLBACK(zoom_5_min); 465 PATH_CALLBACK(zoom_10_min); 466 PATH_CALLBACK(zoom_to_session); 467 PATH_CALLBACK(temporal_zoom_in); 468 PATH_CALLBACK(temporal_zoom_out); 469 PATH_CALLBACK(scroll_up_1_track); 470 PATH_CALLBACK(scroll_dn_1_track); 471 PATH_CALLBACK(scroll_up_1_page); 472 PATH_CALLBACK(scroll_dn_1_page); 473 474 #define PATH_CALLBACK1(name,type,optional) \ 475 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 476 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 477 } \ 478 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 479 OSC_DEBUG; \ 480 check_surface (msg); \ 481 if (argc > 0) { \ 482 name (optional argv[0]->type); \ 483 } \ 484 return 0; \ 485 } 486 487 PATH_CALLBACK1(set_transport_speed,f,); 488 PATH_CALLBACK1(add_marker_name,s,&); 489 PATH_CALLBACK1(access_action,s,&); 490 491 PATH_CALLBACK1(jump_by_bars,f,); 492 PATH_CALLBACK1(jump_by_seconds,f,); 493 PATH_CALLBACK1(click_level,f,); 494 495 #define PATH_CALLBACK1_MSG(name,arg1type) \ 496 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 497 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 498 } \ 499 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 500 OSC_DEBUG; \ 501 if (argc > 0) { \ 502 name (argv[0]->arg1type, msg); \ 503 } \ 504 return 0; \ 505 } 506 507 #define PATH_CALLBACK1_MSG_s(name,arg1type) \ 508 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 509 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 510 } \ 511 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 512 OSC_DEBUG; \ 513 if (argc > 0) { \ 514 name (&argv[0]->arg1type, msg); \ 515 } \ 516 return 0; \ 517 } 518 519 PATH_CALLBACK1_MSG(scrub,f); 520 PATH_CALLBACK1_MSG(jog,f); 521 PATH_CALLBACK1_MSG(jog_mode,f); 522 PATH_CALLBACK1_MSG(bank_delta,f); 523 PATH_CALLBACK1_MSG(use_group,f); 524 PATH_CALLBACK1_MSG_s(name_session,s); 525 PATH_CALLBACK1_MSG_s(sel_new_personal_send,s); 526 PATH_CALLBACK1_MSG(sel_master_send_enable,i); 527 PATH_CALLBACK1_MSG(sel_pan_elevation,f); 528 PATH_CALLBACK1_MSG(sel_pan_frontback,f); 529 PATH_CALLBACK1_MSG(sel_pan_lfe,f); 530 PATH_CALLBACK1_MSG(sel_send_page,f); 531 PATH_CALLBACK1_MSG(sel_plug_page,f); 532 PATH_CALLBACK1_MSG(sel_plugin,f); 533 PATH_CALLBACK1_MSG(sel_plugin_activate,f); 534 PATH_CALLBACK1_MSG(sel_comp_enable,f); 535 PATH_CALLBACK1_MSG(sel_comp_threshold,f); 536 PATH_CALLBACK1_MSG(sel_comp_speed,f); 537 PATH_CALLBACK1_MSG(sel_comp_mode,f); 538 PATH_CALLBACK1_MSG(sel_comp_makeup,f); 539 PATH_CALLBACK1_MSG(sel_eq_enable,f); 540 PATH_CALLBACK1_MSG(sel_eq_hpf_freq,f); 541 PATH_CALLBACK1_MSG(sel_eq_hpf_enable,f); 542 PATH_CALLBACK1_MSG(sel_eq_hpf_slope,f); 543 PATH_CALLBACK1_MSG(sel_eq_lpf_freq,f); 544 PATH_CALLBACK1_MSG(sel_eq_lpf_enable,f); 545 PATH_CALLBACK1_MSG(sel_eq_lpf_slope,f); 546 PATH_CALLBACK1_MSG(sel_expand,i); 547 PATH_CALLBACK1_MSG(custom_mode,f); 548 549 #define PATH_CALLBACK2(name,arg1type,arg2type) \ 550 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 551 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 552 } \ 553 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 554 OSC_DEBUG; \ 555 check_surface (msg); \ 556 if (argc > 1) { \ 557 name (argv[0]->arg1type, argv[1]->arg2type); \ 558 } \ 559 return 0; \ 560 } 561 562 #define PATH_CALLBACK2_MSG(name,arg1type,arg2type) \ 563 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 564 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 565 } \ 566 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 567 OSC_DEBUG; \ 568 if (argc > 1) { \ 569 name (argv[0]->arg1type, argv[1]->arg2type, msg); \ 570 } \ 571 return 0; \ 572 } 573 574 #define PATH_CALLBACK2_MSG_s(name,arg1type,arg2type) \ 575 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 576 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 577 } \ 578 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 579 OSC_DEBUG; \ 580 if (argc > 1) { \ 581 name (argv[0]->arg1type, &argv[1]->arg2type, msg); \ 582 } \ 583 return 0; \ 584 } 585 586 #define PATH_CALLBACK3(name,arg1type,arg2type,arg3type) \ 587 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 588 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 589 } \ 590 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 591 OSC_DEBUG; \ 592 if (argc > 1) { \ 593 name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type, msg); \ 594 } \ 595 return 0; \ 596 } 597 598 #define PATH_CALLBACK4(name,arg1type,arg2type,arg3type,arg4type) \ 599 static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { \ 600 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, msg); \ 601 } \ 602 int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg) { \ 603 OSC_DEBUG; \ 604 if (argc > 1) { \ 605 name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type,argv[3]->arg4type, msg); \ 606 } \ 607 return 0; \ 608 } 609 610 PATH_CALLBACK2_MSG(sel_sendgain,i,f); 611 PATH_CALLBACK2_MSG(sel_sendfader,i,f); 612 PATH_CALLBACK2_MSG(sel_sendenable,i,f); 613 PATH_CALLBACK2_MSG(sel_eq_gain,i,f); 614 PATH_CALLBACK2_MSG(sel_eq_freq,i,f); 615 PATH_CALLBACK2_MSG(sel_eq_q,i,f); 616 PATH_CALLBACK2_MSG(sel_eq_shape,i,f); 617 618 PATH_CALLBACK2(locate,i,i); 619 PATH_CALLBACK2(loop_location,i,i); 620 PATH_CALLBACK3(route_set_send_gain_dB,i,i,f); 621 PATH_CALLBACK3(route_set_send_fader,i,i,f); 622 PATH_CALLBACK3(route_set_send_enable,i,i,f); 623 PATH_CALLBACK4(route_plugin_parameter,i,i,i,f); 624 PATH_CALLBACK3(route_plugin_parameter_print,i,i,i); 625 PATH_CALLBACK2_MSG(route_plugin_activate,i,i); 626 PATH_CALLBACK2_MSG(route_plugin_deactivate,i,i); 627 PATH_CALLBACK1_MSG(route_plugin_list,i); 628 PATH_CALLBACK2_MSG(route_plugin_descriptor,i,i); 629 PATH_CALLBACK2_MSG(route_plugin_reset,i,i); 630 631 int strip_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 632 int master_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 633 int monitor_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 634 int _strip_parse (const char *path, const char *sub_path, const char* types, lo_arg **argv, int argc, boost::shared_ptr<ARDOUR::Stripable> s, int param_1, bool strp, lo_message msg); 635 int strip_state (const char *path, boost::shared_ptr<ARDOUR::Stripable> s, int ssid, lo_message msg); 636 int strip_list (lo_message msg); 637 int _strip_select (boost::shared_ptr<ARDOUR::Stripable> s, lo_address addr); 638 int _strip_select2 (boost::shared_ptr<ARDOUR::Stripable> s, OSCSurface *sur, lo_address addr); 639 640 int route_set_send_gain_dB (int rid, int sid, float val, lo_message msg); 641 int route_set_send_fader (int rid, int sid, float val, lo_message msg); 642 int route_set_send_enable (int rid, int sid, float val, lo_message msg); 643 int route_plugin_parameter (int rid, int piid,int par, float val, lo_message msg); 644 int route_plugin_parameter_print (int rid, int piid,int par, lo_message msg); 645 int route_plugin_activate (int rid, int piid, lo_message msg); 646 int route_plugin_deactivate (int rid, int piid, lo_message msg); 647 int route_plugin_list(int ssid, lo_message msg); 648 int route_plugin_descriptor(int ssid, int piid, lo_message msg); 649 int route_plugin_reset(int ssid, int piid, lo_message msg); 650 651 //banking functions 652 int set_bank (uint32_t bank_start, lo_message msg); 653 int _set_bank (uint32_t bank_start, lo_address addr); 654 int bank_up (lo_message msg); 655 int bank_delta (float delta, lo_message msg); 656 int use_group (float value, lo_message msg); 657 int bank_down (lo_message msg); 658 // surface set up 659 int surface_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 660 int set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gmode, uint32_t se_size, uint32_t pi_size, lo_message msg); 661 int set_surface_bank_size (uint32_t bs, lo_message msg); 662 int set_surface_strip_types (uint32_t st, lo_message msg); 663 int set_surface_feedback (uint32_t fb, lo_message msg); 664 int set_surface_gainmode (uint32_t gm, lo_message msg); 665 int set_surface_port (uint32_t po, lo_message msg); 666 int refresh_surface (lo_message msg); 667 int custom_clear (lo_message msg); 668 int custom_mode (float state, lo_message msg); 669 int _custom_mode (uint32_t state, lo_address addr); 670 int name_session (char *n, lo_message msg); 671 // select 672 int select_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 673 int sel_send_pagesize (uint32_t size, lo_message msg); 674 int sel_send_page (int page, lo_message msg); 675 int sel_plug_pagesize (uint32_t size, lo_message msg); 676 int sel_plug_page (int page, lo_message msg); 677 int sel_plugin (int delta, lo_message msg); 678 int _sel_plugin (int id, lo_address addr); 679 int sel_plugin_activate (float state, lo_message msg); 680 int select_plugin_parameter (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 681 void processor_changed (std::string remote_url); 682 683 int scrub (float delta, lo_message msg); 684 int jog (float delta, lo_message msg); 685 int jog_mode (float mode, lo_message msg); 686 int set_marker (const char* types, lo_arg **argv, int argc, lo_message msg); 687 int click_level (float position); 688 int sel_previous (lo_message msg); 689 int sel_next (lo_message msg); 690 int sel_delta (int delta, lo_message msg); 691 boost::shared_ptr<ARDOUR::Send> get_send (boost::shared_ptr<ARDOUR::Stripable> st, lo_address addr); 692 int sel_sendgain (int id, float dB, lo_message msg); 693 int sel_sendfader (int id, float pos, lo_message msg); 694 int sel_sendenable (int id, float pos, lo_message msg); 695 int sel_master_send_enable (int state, lo_message msg); 696 int sel_expand (uint32_t state, lo_message msg); 697 int sel_pan_elevation (float val, lo_message msg); 698 int sel_pan_frontback (float val, lo_message msg); 699 int sel_pan_lfe (float val, lo_message msg); 700 int sel_comp_enable (float val, lo_message msg); 701 int sel_comp_threshold (float val, lo_message msg); 702 int sel_comp_speed (float val, lo_message msg); 703 int sel_comp_mode (float val, lo_message msg); 704 int sel_comp_makeup (float val, lo_message msg); 705 int sel_eq_enable (float val, lo_message msg); 706 int sel_eq_hpf_freq (float val, lo_message msg); 707 int sel_eq_hpf_enable (float val, lo_message msg); 708 int sel_eq_hpf_slope (float val, lo_message msg); 709 int sel_eq_lpf_freq (float val, lo_message msg); 710 int sel_eq_lpf_enable (float val, lo_message msg); 711 int sel_eq_lpf_slope (float val, lo_message msg); 712 int sel_eq_gain (int id, float val, lo_message msg); 713 int sel_eq_freq (int id, float val, lo_message msg); 714 int sel_eq_q (int id, float val, lo_message msg); 715 int sel_eq_shape (int id, float val, lo_message msg); 716 int sel_new_personal_send (char *n, lo_message msg); 717 int set_temp_mode (lo_address addr); 718 int parse_sel_group (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg); 719 boost::shared_ptr<ARDOUR::VCA> get_vca_by_name (std::string vname); 720 721 void listen_to_route (boost::shared_ptr<ARDOUR::Stripable>, lo_address); 722 723 void route_name_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Route> r, lo_address addr); 724 void recalcbanks (); 725 void _recalcbanks (); 726 void notify_routes_added (ARDOUR::RouteList &); 727 void notify_vca_added (ARDOUR::VCAList &); 728 729 int cancel_all_solos (); 730 int osc_toggle_roll (bool ret2strt); 731 bool periodic (void); 732 sigc::connection periodic_connection; 733 PBD::ScopedConnectionList session_connections; 734 735 void debugmsg (const char *prefix, const char *path, const char* types, lo_arg **argv, int argc); 736 737 static OSC* _instance; 738 739 mutable void *gui; 740 void build_gui (); 741 }; 742 743 } // namespace 744 745 #endif // ardour_osc_h 746