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