5bb55113c0597484b61a150586e1d0c6ba624303
[ardour.git] / libs / surfaces / osc / osc.h
1 /*
2  * Copyright (C) 2006-2009 Paul Davis
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19
20 #ifndef ardour_osc_h
21 #define ardour_osc_h
22
23 #include <string>
24 #include <vector>
25 #include <bitset>
26
27 #include <sys/time.h>
28 #include <pthread.h>
29
30 #include <boost/shared_ptr.hpp>
31
32 #include <lo/lo.h>
33
34 #include <glibmm/main.h>
35
36 #define ABSTRACT_UI_EXPORTS
37 #include "pbd/abstract_ui.h"
38
39 #include "ardour/types.h"
40 #include "ardour/send.h"
41 #include "control_protocol/control_protocol.h"
42
43 #include "pbd/i18n.h"
44
45 class OSCControllable;
46 class OSCRouteObserver;
47 class OSCGlobalObserver;
48 class OSCSelectObserver;
49 class OSCCueObserver;
50
51 namespace ARDOUR {
52 class Session;
53 class Route;
54 }
55
56 /* this is mostly a placeholder because I suspect that at some
57    point we will want to add more members to accomodate
58    certain types of requests to the OSC UI
59 */
60
61 namespace ArdourSurface {
62
63 struct OSCUIRequest : public BaseUI::BaseRequestObject {
64   public:
65         OSCUIRequest () {}
66         ~OSCUIRequest() {}
67 };
68
69 class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
70 {
71   public:
72         OSC (ARDOUR::Session&, uint32_t port);
73         virtual ~OSC();
74
75         static OSC* instance() { return _instance; }
76
77         XMLNode& get_state ();
78         int set_state (const XMLNode&, int version);
79
80         void stripable_selection_changed () {}
81
82         bool has_editor () const { return true; }
83         void* get_gui () const;
84         void  tear_down_gui ();
85
86         int set_active (bool yn);
87         bool get_active () const;
88
89         int start ();
90         int stop ();
91
92         static void* request_factory (uint32_t);
93
94         enum OSCDebugMode {
95                 Off,
96                 Unhandled,
97                 All
98         };
99
100         enum JogMode {
101                 JOG,
102                 NUDGE,
103                 SCRUB,
104                 SHUTTLE,
105                 MARKER,
106                 SCROLL,
107                 TRACK,
108                 BANK
109         };
110
111         typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > Sorted;
112         Sorted get_sorted_stripables(std::bitset<32> types, bool cue);
113         typedef std::map<boost::shared_ptr<ARDOUR::AutomationControl>, uint32_t> FakeTouchMap;
114         FakeTouchMap _touch_timeout;
115
116 // keep a surface's global setup by remote server url
117         struct OSCSurface {
118         public:
119                 std::string remote_url;         // the url these setting belong to
120                 bool no_clear;                          // don't send osc clear messages on strip change
121                 JogMode jogmode;                        // current jogmode
122                 uint32_t bank;                          // current bank
123                 uint32_t bank_size;                     // size of banks for this surface
124                 int plug_page;                          // current plugin page
125                 uint32_t plug_page_size;        // plugin page size (number of controls)
126                 uint32_t plugin;                        // id of current plugin
127                 int send_page;                          // current send page
128                 uint32_t send_page_size;        // send page size in channels
129                 std::bitset<32> strip_types;// what strip types are a part of this bank
130                 uint32_t nstrips;                       // how many strips are there for strip_types
131                 std::bitset<32> feedback;       // What is fed back? strips/meters/timecode/bar_beat/global
132                 int gainmode;                           // what kind of faders do we have Gain db or position 0 to 1?
133                 uint32_t expand;                        // Used by /select/select
134                 bool expand_enable;                     // use expand instead of select
135                 OSCSelectObserver* sel_obs;     // So we can sync select feedback with selected channel
136                 Sorted strips;                          // list of stripables for this surface
137                 bool cue;                                       // is this a cue surface
138                 uint32_t aux;                           // aux index for this cue surface
139                 Sorted sends;                           // list of sends for cue aux
140         };
141                 /*
142                  * feedback bits:
143                  * [0] - Strips - buttons
144                  * [1] - Strips - variables (pots/faders)
145                  * [2] - Strips - Send SSID as path extension
146                  * [3] - Send heart beat to surface
147                  * [4] - Send feedback for master/global buttons/variables
148                  * [5] - Send Bar and Beat
149                  * [6] - Send Time code
150                  * [7] - Send metering as dB or positional depending on gainmode
151                  * [8] - Send metering as 16 bits (led strip)
152                  * [9] - Send signal present (signal greater than -20dB)
153                  * [10] - Send Playhead position as samples
154                  * [11] - Send Playhead position as minutes seconds
155                  * [12] - Send Playhead position like primary/secondary GUI clocks
156                  * [13] - Send well known feedback (for /select/command
157                  */
158
159
160 // storage for  each surface's settings
161         typedef std::vector<OSCSurface> Surface;
162         Surface _surface;
163
164         std::string get_server_url ();
165         void set_debug_mode (OSCDebugMode m) { _debugmode = m; }
166         OSCDebugMode get_debug_mode () { return _debugmode; }
167         int get_portmode() { return address_only; }
168         void set_portmode (int pm) { address_only = pm; }
169         int get_banksize () { return default_banksize; }
170         void set_banksize (int bs) {default_banksize = bs; }
171         int get_gainmode() { return default_gainmode; }
172         void set_gainmode (int gm) { default_gainmode = gm; }
173         int get_defaultstrip() { return default_strip; }
174         void set_defaultstrip (int st) { default_strip = st; }
175         int get_defaultfeedback() { return default_feedback; }
176         void set_defaultfeedback (int fb) { default_feedback = fb; }
177         void clear_devices ();
178         void gui_changed ();
179         std::string get_remote_port () { return remote_port; }
180         void set_remote_port (std::string pt) { remote_port = pt; }
181
182   protected:
183         void thread_init ();
184         void do_request (OSCUIRequest*);
185
186         GSource* local_server;
187         GSource* remote_server;
188
189         bool osc_input_handler (Glib::IOCondition, lo_server);
190
191   private:
192         uint32_t _port;
193         volatile bool _ok;
194         volatile bool _shutdown;
195         lo_server _osc_server;
196         lo_server _osc_unix_server;
197         std::string _osc_unix_socket_path;
198         std::string _osc_url_file;
199         OSCDebugMode _debugmode;
200         bool address_only;
201         std::string remote_port;
202         uint32_t default_banksize;
203         uint32_t default_strip;
204         uint32_t default_feedback;
205         uint32_t default_gainmode;
206         bool tick;
207         bool bank_dirty;
208         float scrub_speed;              // Current scrub speed
209         double scrub_place;             // place of play head at latest jog/scrub wheel tick
210         int64_t scrub_time;             // when did the wheel move last?
211         bool global_init;
212         boost::shared_ptr<ARDOUR::Stripable> _select;   // which stripable out of /surface/stripables is gui selected
213
214         void register_callbacks ();
215
216         void route_added (ARDOUR::RouteList&);
217
218         // Handlers for "Application Hook" signals
219         void session_loaded (ARDOUR::Session&);
220         void session_exported (std::string, std::string);
221
222         // end "Application Hook" handles
223
224         std::string get_unix_server_url ();
225         lo_address get_address (lo_message msg);
226         OSCSurface * get_surface (lo_address addr);
227         int check_surface (lo_message msg);
228         uint32_t get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr);
229         boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr);
230         void global_feedback (std::bitset<32> feedback, lo_address addr, uint32_t gainmode);
231
232         void send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg);
233         void current_value_query (const char* path, size_t len, lo_arg **argv, int argc, lo_message msg);
234
235         int current_value (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
236
237         int catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data);
238         static int _catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
239
240         int set_automation (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg);
241         int touch_detect (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg);
242         int fake_touch (boost::shared_ptr<ARDOUR::AutomationControl> ctrl);
243
244         int route_get_sends (lo_message msg);
245         int route_get_receives(lo_message msg);
246         void routes_list (lo_message msg);
247         void transport_frame (lo_message msg);
248         void transport_speed (lo_message msg);
249         void record_enabled (lo_message msg);
250
251         // cue
252         Sorted cue_get_sorted_stripables(boost::shared_ptr<ARDOUR::Stripable> aux, uint32_t id, lo_message msg);
253         int cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg);
254         int cue_set (uint32_t aux, lo_message msg);
255         int _cue_set (uint32_t aux, lo_address addr);
256         int cue_next (lo_message msg);
257         int cue_previous (lo_message msg);
258         int cue_send_fader (uint32_t id, float position, lo_message msg);
259         int cue_send_enable (uint32_t id, float state, lo_message msg);
260         int cue_aux_fader (float position, lo_message msg);
261         int cue_aux_mute (float state, lo_message msg);
262         void cue_set_aux (uint32_t aux, lo_message msg);
263         int cue_float_message (std::string, float value, lo_address addr);
264         int text_message (std::string path, std::string val, lo_address addr);
265         boost::shared_ptr<ARDOUR::Send> cue_get_send (uint32_t id, lo_address addr);
266         // end cue
267
268 #define OSC_DEBUG \
269         if (_debugmode == All) { \
270                 debugmsg (dgettext(PACKAGE, "OSC"), path, types, argv, argc); \
271         }
272
273 #define PATH_CALLBACK_MSG(name) \
274         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
275                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
276         } \
277         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
278                 OSC_DEBUG; \
279                 if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \
280                 name (data); \
281                 return 0; \
282         }
283
284         PATH_CALLBACK_MSG(route_get_sends);
285         PATH_CALLBACK_MSG(route_get_receives);
286         PATH_CALLBACK_MSG(routes_list);
287         PATH_CALLBACK_MSG(transport_frame);
288         PATH_CALLBACK_MSG(transport_speed);
289         PATH_CALLBACK_MSG(record_enabled);
290         PATH_CALLBACK_MSG(refresh_surface);
291         PATH_CALLBACK_MSG(bank_up);
292         PATH_CALLBACK_MSG(bank_down);
293
294 #define PATH_CALLBACK(name) \
295         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
296                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
297         } \
298         int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *data) { \
299                 OSC_DEBUG; \
300                 check_surface (data); \
301                 if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \
302                 name (); \
303                 return 0; \
304         }
305
306         PATH_CALLBACK(add_marker);
307         PATH_CALLBACK(loop_toggle);
308         PATH_CALLBACK(goto_start);
309         PATH_CALLBACK(goto_end);
310         PATH_CALLBACK(rewind);
311         PATH_CALLBACK(ffwd);
312         PATH_CALLBACK(transport_stop);
313         PATH_CALLBACK(transport_play);
314         PATH_CALLBACK(save_state);
315         PATH_CALLBACK(prev_marker);
316         PATH_CALLBACK(next_marker);
317         PATH_CALLBACK(undo);
318         PATH_CALLBACK(redo);
319         PATH_CALLBACK(toggle_punch_in);
320         PATH_CALLBACK(toggle_punch_out);
321         PATH_CALLBACK(rec_enable_toggle);
322         PATH_CALLBACK(toggle_all_rec_enables);
323         PATH_CALLBACK(all_tracks_rec_in);
324         PATH_CALLBACK(all_tracks_rec_out);
325         PATH_CALLBACK(cancel_all_solos);
326         PATH_CALLBACK(remove_marker_at_playhead);
327         PATH_CALLBACK(mark_in);
328         PATH_CALLBACK(mark_out);
329         PATH_CALLBACK(toggle_click);
330         PATH_CALLBACK(midi_panic);
331         PATH_CALLBACK(toggle_roll);
332         PATH_CALLBACK(stop_forget);
333         PATH_CALLBACK(set_punch_range);
334         PATH_CALLBACK(set_loop_range);
335         PATH_CALLBACK(set_session_range);
336         PATH_CALLBACK(toggle_monitor_mute);
337         PATH_CALLBACK(toggle_monitor_dim);
338         PATH_CALLBACK(toggle_monitor_mono);
339         PATH_CALLBACK(quick_snapshot_stay);
340         PATH_CALLBACK(quick_snapshot_switch);
341         PATH_CALLBACK(fit_1_track);
342         PATH_CALLBACK(fit_2_tracks);
343         PATH_CALLBACK(fit_4_tracks);
344         PATH_CALLBACK(fit_8_tracks);
345         PATH_CALLBACK(fit_16_tracks);
346         PATH_CALLBACK(fit_32_tracks);
347         PATH_CALLBACK(fit_all_tracks);
348         PATH_CALLBACK(zoom_100_ms);
349         PATH_CALLBACK(zoom_1_sec);
350         PATH_CALLBACK(zoom_10_sec);
351         PATH_CALLBACK(zoom_1_min);
352         PATH_CALLBACK(zoom_5_min);
353         PATH_CALLBACK(zoom_10_min);
354         PATH_CALLBACK(zoom_to_session);
355         PATH_CALLBACK(temporal_zoom_in);
356         PATH_CALLBACK(temporal_zoom_out);
357         PATH_CALLBACK(scroll_up_1_track);
358         PATH_CALLBACK(scroll_dn_1_track);
359         PATH_CALLBACK(scroll_up_1_page);
360         PATH_CALLBACK(scroll_dn_1_page);
361
362 #define PATH_CALLBACK1(name,type,optional) \
363         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
364                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
365         } \
366         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
367                 OSC_DEBUG; \
368                 check_surface (data); \
369                 if (argc > 0) { \
370                         name (optional argv[0]->type); \
371                 } \
372                 return 0; \
373         }
374
375         PATH_CALLBACK1(set_transport_speed,f,);
376         PATH_CALLBACK1(access_action,s,&);
377
378         PATH_CALLBACK1(jump_by_bars,f,);
379         PATH_CALLBACK1(jump_by_seconds,f,);
380         PATH_CALLBACK1(master_set_gain,f,);
381         PATH_CALLBACK1(master_set_fader,f,);
382         PATH_CALLBACK1(master_set_trim,f,);
383         PATH_CALLBACK1(master_set_mute,i,);
384         PATH_CALLBACK1(monitor_set_gain,f,);
385         PATH_CALLBACK1(monitor_set_fader,f,);
386         PATH_CALLBACK1(monitor_set_mute,i,);
387         PATH_CALLBACK1(monitor_set_dim,i,);
388         PATH_CALLBACK1(monitor_set_mono,i,);
389
390 #define PATH_CALLBACK1_MSG(name,arg1type) \
391         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
392                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
393         } \
394         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
395                 OSC_DEBUG; \
396                 if (argc > 0) { \
397                         name (argv[0]->arg1type, data); \
398                 } \
399                 return 0; \
400         }
401
402         // pan position needs message info to send feedback
403         PATH_CALLBACK1_MSG(master_set_pan_stereo_position,f);
404
405         PATH_CALLBACK1_MSG(scrub,f);
406         PATH_CALLBACK1_MSG(jog,f);
407         PATH_CALLBACK1_MSG(jog_mode,f);
408         PATH_CALLBACK1_MSG(set_surface_bank_size,i);
409         PATH_CALLBACK1_MSG(set_surface_strip_types,i);
410         PATH_CALLBACK1_MSG(set_surface_feedback,i);
411         PATH_CALLBACK1_MSG(set_surface_gainmode,i);
412         PATH_CALLBACK1_MSG(sel_recenable,i);
413         PATH_CALLBACK1_MSG(sel_recsafe,i);
414         PATH_CALLBACK1_MSG(sel_mute,i);
415         PATH_CALLBACK1_MSG(sel_solo,i);
416         PATH_CALLBACK1_MSG(sel_solo_iso,i);
417         PATH_CALLBACK1_MSG(sel_solo_safe,i);
418         PATH_CALLBACK1_MSG(sel_monitor_input,i);
419         PATH_CALLBACK1_MSG(sel_monitor_disk,i);
420         PATH_CALLBACK1_MSG(sel_phase,i);
421         PATH_CALLBACK1_MSG(sel_gain,f);
422         PATH_CALLBACK1_MSG(sel_fader,f);
423         PATH_CALLBACK1_MSG(sel_trim,f);
424         PATH_CALLBACK1_MSG(sel_pan_position,f);
425         PATH_CALLBACK1_MSG(sel_pan_width,f);
426         PATH_CALLBACK1_MSG(sel_pan_elevation,f);
427         PATH_CALLBACK1_MSG(sel_pan_frontback,f);
428         PATH_CALLBACK1_MSG(sel_pan_lfe,f);
429         PATH_CALLBACK1_MSG(sel_send_page,f);
430         PATH_CALLBACK1_MSG(sel_send_pagesize,f);
431         PATH_CALLBACK1_MSG(sel_plug_page,f);
432         PATH_CALLBACK1_MSG(sel_plug_pagesize,f);
433         PATH_CALLBACK1_MSG(sel_plugin,f);
434         PATH_CALLBACK1_MSG(sel_comp_enable,f);
435         PATH_CALLBACK1_MSG(sel_comp_threshold,f);
436         PATH_CALLBACK1_MSG(sel_comp_speed,f);
437         PATH_CALLBACK1_MSG(sel_comp_mode,f);
438         PATH_CALLBACK1_MSG(sel_comp_makeup,f);
439         PATH_CALLBACK1_MSG(sel_eq_enable,f);
440         PATH_CALLBACK1_MSG(sel_eq_hpf_freq,f);
441         PATH_CALLBACK1_MSG(sel_eq_hpf_enable,f);
442         PATH_CALLBACK1_MSG(sel_eq_hpf_slope,f);
443         PATH_CALLBACK1_MSG(sel_eq_lpf_freq,f);
444         PATH_CALLBACK1_MSG(sel_eq_lpf_enable,f);
445         PATH_CALLBACK1_MSG(sel_eq_lpf_slope,f);
446         PATH_CALLBACK1_MSG(sel_expand,i);
447
448 #define PATH_CALLBACK2(name,arg1type,arg2type) \
449         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
450                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
451         } \
452         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
453                 OSC_DEBUG; \
454                 check_surface (data); \
455                 if (argc > 1) { \
456                         name (argv[0]->arg1type, argv[1]->arg2type); \
457                 } \
458                 return 0; \
459         }
460
461 #define PATH_CALLBACK2_MSG(name,arg1type,arg2type) \
462         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
463                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
464         } \
465         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
466                 OSC_DEBUG; \
467                 if (argc > 1) { \
468                         name (argv[0]->arg1type, argv[1]->arg2type, data); \
469                 } \
470                 return 0; \
471         }
472
473 #define PATH_CALLBACK2_MSG_s(name,arg1type,arg2type) \
474         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
475                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
476         } \
477         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
478                 OSC_DEBUG; \
479                 if (argc > 1) { \
480                         name (argv[0]->arg1type, &argv[1]->arg2type, data); \
481                 } \
482                 return 0; \
483         }
484
485 #define PATH_CALLBACK3(name,arg1type,arg2type,arg3type) \
486         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
487                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
488         } \
489         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
490                 OSC_DEBUG; \
491                 if (argc > 1) { \
492                         name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type, data); \
493                 } \
494                 return 0; \
495         }
496
497 #define PATH_CALLBACK4(name,arg1type,arg2type,arg3type,arg4type) \
498         static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
499                 return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
500         } \
501         int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
502                 OSC_DEBUG; \
503                 if (argc > 1) { \
504                         name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type,argv[3]->arg4type, data); \
505                 } \
506                 return 0; \
507         }
508
509         PATH_CALLBACK2_MSG(sel_sendgain,i,f);
510         PATH_CALLBACK2_MSG(sel_sendfader,i,f);
511         PATH_CALLBACK2_MSG(sel_sendenable,i,f);
512         PATH_CALLBACK2_MSG(sel_eq_gain,i,f);
513         PATH_CALLBACK2_MSG(sel_eq_freq,i,f);
514         PATH_CALLBACK2_MSG(sel_eq_q,i,f);
515         PATH_CALLBACK2_MSG(sel_eq_shape,i,f);
516
517         PATH_CALLBACK4(set_surface,i,i,i,i);
518         PATH_CALLBACK2(locate,i,i);
519         PATH_CALLBACK2(loop_location,i,i);
520         PATH_CALLBACK2_MSG_s(route_rename,i,s);
521         PATH_CALLBACK2_MSG(route_mute,i,i);
522         PATH_CALLBACK2_MSG(route_solo,i,i);
523         PATH_CALLBACK2_MSG(route_solo_iso,i,i);
524         PATH_CALLBACK2_MSG(route_solo_safe,i,i);
525         PATH_CALLBACK2_MSG(route_recenable,i,i);
526         PATH_CALLBACK2_MSG(route_recsafe,i,i);
527         PATH_CALLBACK2_MSG(route_monitor_input,i,i);
528         PATH_CALLBACK2_MSG(route_monitor_disk,i,i);
529         PATH_CALLBACK2_MSG(strip_phase,i,i);
530         PATH_CALLBACK2_MSG(strip_expand,i,i);
531         PATH_CALLBACK2_MSG(strip_gui_select,i,i);
532         PATH_CALLBACK2_MSG(route_set_gain_dB,i,f);
533         PATH_CALLBACK2_MSG(route_set_gain_fader,i,f);
534         PATH_CALLBACK2_MSG(route_set_trim_dB,i,f);
535         PATH_CALLBACK2_MSG(route_set_pan_stereo_position,i,f);
536         PATH_CALLBACK2_MSG(route_set_pan_stereo_width,i,f);
537         PATH_CALLBACK3(route_set_send_gain_dB,i,i,f);
538         PATH_CALLBACK3(route_set_send_fader,i,i,f);
539         PATH_CALLBACK3(route_set_send_enable,i,i,f);
540         PATH_CALLBACK4(route_plugin_parameter,i,i,i,f);
541         PATH_CALLBACK3(route_plugin_parameter_print,i,i,i);
542         PATH_CALLBACK2_MSG(route_plugin_activate,i,i);
543         PATH_CALLBACK2_MSG(route_plugin_deactivate,i,i);
544         PATH_CALLBACK1_MSG(route_plugin_list,i);
545         PATH_CALLBACK2_MSG(route_plugin_descriptor,i,i);
546         PATH_CALLBACK2_MSG(route_plugin_reset,i,i);
547
548         int route_rename (int rid, char *s, lo_message msg);
549         int route_mute (int rid, int yn, lo_message msg);
550         int route_solo (int rid, int yn, lo_message msg);
551         int route_solo_iso (int rid, int yn, lo_message msg);
552         int route_solo_safe (int rid, int yn, lo_message msg);
553         int route_recenable (int rid, int yn, lo_message msg);
554         int route_recsafe (int ssid, int yn, lo_message msg);
555         int route_monitor_input (int rid, int yn, lo_message msg);
556         int route_monitor_disk (int rid, int yn, lo_message msg);
557         int strip_phase (int rid, int yn, lo_message msg);
558         int strip_expand (int rid, int yn, lo_message msg);
559         int _strip_select (boost::shared_ptr<ARDOUR::Stripable> s, lo_address addr);
560         int strip_gui_select (int rid, int yn, lo_message msg);
561         int route_set_gain_abs (int rid, float level, lo_message msg);
562         int route_set_gain_dB (int rid, float dB, lo_message msg);
563         int route_set_gain_fader (int rid, float pos, lo_message msg);
564         int route_set_trim_abs (int rid, float level, lo_message msg);
565         int route_set_trim_dB (int rid, float dB, lo_message msg);
566         int route_set_pan_stereo_position (int rid, float left_right_fraction, lo_message msg);
567         int route_set_pan_stereo_width (int rid, float percent, lo_message msg);
568         int route_set_send_gain_dB (int rid, int sid, float val, lo_message msg);
569         int route_set_send_fader (int rid, int sid, float val, lo_message msg);
570         int route_set_send_enable (int rid, int sid, float val, lo_message msg);
571         int route_plugin_parameter (int rid, int piid,int par, float val, lo_message msg);
572         int route_plugin_parameter_print (int rid, int piid,int par, lo_message msg);
573         int route_plugin_activate (int rid, int piid, lo_message msg);
574         int route_plugin_deactivate (int rid, int piid, lo_message msg);
575         int route_plugin_list(int ssid, lo_message msg);
576         int route_plugin_descriptor(int ssid, int piid, lo_message msg);
577         int route_plugin_reset(int ssid, int piid, lo_message msg);
578
579         //banking functions
580         int set_bank (uint32_t bank_start, lo_message msg);
581         int _set_bank (uint32_t bank_start, lo_address addr);
582         int bank_up (lo_message msg);
583         int bank_down (lo_message msg);
584         int set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gmode, lo_message msg);
585         int set_surface_bank_size (uint32_t bs, lo_message msg);
586         int set_surface_strip_types (uint32_t st, lo_message msg);
587         int set_surface_feedback (uint32_t fb, lo_message msg);
588         int set_surface_gainmode (uint32_t gm, lo_message msg);
589         int refresh_surface (lo_message msg);
590         int sel_send_pagesize (uint32_t size, lo_message msg);
591         int sel_send_page (int page, lo_message msg);
592         int sel_plug_pagesize (uint32_t size, lo_message msg);
593         int sel_plug_page (int page, lo_message msg);
594         int sel_plugin (uint32_t id, lo_message msg);
595
596         int scrub (float delta, lo_message msg);
597         int jog (float delta, lo_message msg);
598         int jog_mode (float mode, lo_message msg);
599         int master_set_gain (float dB);
600         int master_set_fader (float position);
601         int master_set_trim (float dB);
602         int master_set_pan_stereo_position (float position, lo_message msg);
603         int master_set_mute (uint32_t state);
604         int monitor_set_gain (float dB);
605         int monitor_set_fader (float position);
606         int monitor_set_mute (uint32_t state);
607         int monitor_set_dim (uint32_t state);
608         int monitor_set_mono (uint32_t state);
609         int sel_recenable (uint32_t state, lo_message msg);
610         int sel_recsafe (uint32_t state, lo_message msg);
611         int sel_mute (uint32_t state, lo_message msg);
612         int sel_solo (uint32_t state, lo_message msg);
613         int sel_solo_iso (uint32_t state, lo_message msg);
614         int sel_solo_safe (uint32_t state, lo_message msg);
615         int sel_monitor_input (uint32_t state, lo_message msg);
616         int sel_monitor_disk (uint32_t state, lo_message msg);
617         int sel_phase (uint32_t state, lo_message msg);
618         int sel_gain (float state, lo_message msg);
619         int sel_fader (float state, lo_message msg);
620         int sel_trim (float val, lo_message msg);
621         int sel_pan_position (float val, lo_message msg);
622         int sel_pan_width (float val, lo_message msg);
623         int sel_sendgain (int id, float dB, lo_message msg);
624         int sel_sendfader (int id, float pos, lo_message msg);
625         int sel_sendenable (int id, float pos, lo_message msg);
626         int sel_expand (uint32_t state, lo_message msg);
627         int sel_pan_elevation (float val, lo_message msg);
628         int sel_pan_frontback (float val, lo_message msg);
629         int sel_pan_lfe (float val, lo_message msg);
630         int sel_comp_enable (float val, lo_message msg);
631         int sel_comp_threshold (float val, lo_message msg);
632         int sel_comp_speed (float val, lo_message msg);
633         int sel_comp_mode (float val, lo_message msg);
634         int sel_comp_makeup (float val, lo_message msg);
635         int sel_eq_enable (float val, lo_message msg);
636         int sel_eq_hpf_freq (float val, lo_message msg);
637         int sel_eq_hpf_enable (float val, lo_message msg);
638         int sel_eq_hpf_slope (float val, lo_message msg);
639         int sel_eq_lpf_freq (float val, lo_message msg);
640         int sel_eq_lpf_enable (float val, lo_message msg);
641         int sel_eq_lpf_slope (float val, lo_message msg);
642         int sel_eq_gain (int id, float val, lo_message msg);
643         int sel_eq_freq (int id, float val, lo_message msg);
644         int sel_eq_q (int id, float val, lo_message msg);
645         int sel_eq_shape (int id, float val, lo_message msg);
646
647         void listen_to_route (boost::shared_ptr<ARDOUR::Stripable>, lo_address);
648         void end_listen (boost::shared_ptr<ARDOUR::Stripable>, lo_address);
649         void drop_route (boost::weak_ptr<ARDOUR::Stripable>);
650         void route_lost (boost::weak_ptr<ARDOUR::Stripable>);
651         void gui_selection_changed (void);
652
653         void route_name_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Route> r, lo_address addr);
654         void recalcbanks ();
655         void _recalcbanks ();
656         void notify_routes_added (ARDOUR::RouteList &);
657         void notify_vca_added (ARDOUR::VCAList &);
658
659         int cancel_all_solos ();
660         bool periodic (void);
661         sigc::connection periodic_connection;
662         PBD::ScopedConnectionList session_connections;
663         PBD::ScopedConnectionList cueobserver_connections;
664
665         int route_send_fail (std::string path, uint32_t ssid, float val, lo_address addr);
666         int sel_send_fail (std::string path, uint32_t id, float val, lo_address addr);
667         int sel_fail (std::string path, float val, lo_address addr);
668
669         typedef std::list<OSCRouteObserver*> RouteObservers;
670
671         RouteObservers route_observers;
672
673         typedef std::list<OSCGlobalObserver*> GlobalObservers;
674         GlobalObservers global_observers;
675
676         typedef std::list<OSCCueObserver*> CueObservers;
677         CueObservers cue_observers;
678
679         void debugmsg (const char *prefix, const char *path, const char* types, lo_arg **argv, int argc);
680
681         static OSC* _instance;
682
683         mutable void *gui;
684         void build_gui ();
685 };
686
687 } // namespace
688
689 #endif // ardour_osc_h