OSC group sharing should be cleared for VCAs
[ardour.git] / libs / surfaces / osc / osc_select_observer.cc
1 /*
2     Copyright (C) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <vector>
21 #include "boost/lambda/lambda.hpp"
22
23 #include "pbd/control_math.h"
24
25 #include "ardour/session.h"
26 #include "ardour/track.h"
27 #include "ardour/monitor_control.h"
28 #include "ardour/dB.h"
29 #include "ardour/meter.h"
30 #include "ardour/phase_control.h"
31 #include "ardour/solo_isolate_control.h"
32 #include "ardour/solo_safe_control.h"
33 #include "ardour/route.h"
34 #include "ardour/route_group.h"
35 #include "ardour/route_group_member.h"
36 #include "ardour/send.h"
37 #include "ardour/plugin.h"
38 #include "ardour/plugin_insert.h"
39 #include "ardour/processor.h"
40 #include "ardour/readonly_control.h"
41 #include "ardour/vca.h"
42
43 #include "osc.h"
44 #include "osc_select_observer.h"
45
46 #include <glibmm.h>
47
48 #include "pbd/i18n.h"
49
50 using namespace std;
51 using namespace PBD;
52 using namespace ARDOUR;
53 using namespace ArdourSurface;
54
55 OSCSelectObserver::OSCSelectObserver (OSC& o, ARDOUR::Session& s, ArdourSurface::OSC::OSCSurface* su)
56         : _osc (o)
57         ,sur (su)
58         ,nsends (0)
59         ,_last_gain (-1.0)
60         ,_last_trim (-1.0)
61         ,_init (true)
62         ,eq_bands (0)
63         ,_expand (2048)
64 {
65         session = &s;
66         addr = lo_address_new_from_url  (sur->remote_url.c_str());
67         gainmode = sur->gainmode;
68         feedback = sur->feedback;
69         in_line = feedback[2];
70         send_page_size = sur->send_page_size;
71         send_size = send_page_size;
72         send_page = sur->send_page;
73         plug_page_size = sur->plug_page_size;
74         plug_size = plug_page_size;
75         plug_page = sur->plug_page;
76         if (sur->plugins.size () > 0) {
77                 plug_id = sur->plugins[sur->plugin_id - 1];
78         } else {
79                 plug_id = -1;
80         }
81         _group_name = "\n";
82         _group_sharing[15] = 1;
83         refresh_strip (sur->select, sur->nsends, gainmode, true);
84         set_expand (sur->expand_enable);
85 }
86
87 OSCSelectObserver::~OSCSelectObserver ()
88 {
89         _init = true;
90         no_strip ();
91         lo_address_free (addr);
92 }
93
94 void
95 OSCSelectObserver::no_strip ()
96 {
97         // This gets called on drop references
98         _init = true;
99
100         strip_connections.drop_connections ();
101         send_connections.drop_connections ();
102         plugin_connections.drop_connections ();
103         eq_connections.drop_connections ();
104         _strip = boost::shared_ptr<Stripable> ();
105         /*
106          * The strip will sit idle at this point doing nothing until
107          * the surface has recalculated it's strip list and then calls
108          * refresh_strip. Otherwise refresh strip will get a strip address
109          * that does not exist... Crash
110          */
111  }
112
113 void
114 OSCSelectObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, uint32_t s_nsends, uint32_t gm, bool force)
115 {
116         _init = true;
117         if (_tick_busy) {
118                 Glib::usleep(100); // let tick finish
119         }
120         gainmode = gm;
121
122         if (_strip && (new_strip == _strip) && !force) {
123                 _init = false;
124                 return;
125         }
126
127         _strip = new_strip;
128         if (!_strip) {
129                 clear_observer ();
130                 return;
131         }
132
133         _strip->DropReferences.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::no_strip, this), OSC::instance());
134         as = ARDOUR::Off;
135         _comp_redux = 1;
136         nsends = s_nsends;
137         _last_gain = -1.0;
138         _last_trim = -1.0;
139
140         _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
141         name_changed (ARDOUR::Properties::name);
142
143         boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (_strip);
144         if (rt) {
145                 rt->route_group_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::group_name, this), OSC::instance());
146                 group_name ();
147
148                 rt->comment_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comment_changed, this), OSC::instance());
149                 comment_changed ();
150
151                 session->RouteGroupPropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::group_sharing, this, _1), OSC::instance());
152                 group_sharing (rt->route_group ());
153         } else {
154                 group_sharing (0);
155         }
156
157         _strip->presentation_info().PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::pi_changed, this, _1), OSC::instance());
158         _osc.float_message (X_("/select/hide"), _strip->is_hidden (), addr);
159
160         _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
161         change_message (X_("/select/mute"), _strip->mute_control());
162
163         _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
164         change_message (X_("/select/solo"), _strip->solo_control());
165
166         if (_strip->solo_isolate_control()) {
167                 _strip->solo_isolate_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo_iso"), _strip->solo_isolate_control()), OSC::instance());
168                 change_message (X_("/select/solo_iso"), _strip->solo_isolate_control());
169         }
170
171         if (_strip->solo_safe_control()) {
172                 _strip->solo_safe_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo_safe"), _strip->solo_safe_control()), OSC::instance());
173                 change_message (X_("/select/solo_safe"), _strip->solo_safe_control());
174         }
175
176         boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
177         if (track) {
178                 track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
179                 monitor_status (track->monitoring_control());
180         }
181
182         boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
183         if (rec_controllable) {
184                 rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
185                 change_message (X_("/select/recenable"), _strip->rec_enable_control());
186         }
187
188         boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
189         if (recsafe_controllable) {
190                 recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
191                 change_message (X_("/select/record_safe"), _strip->rec_safe_control());
192         }
193
194         boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
195         if (phase_controllable) {
196                 phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
197                 change_message (X_("/select/polarity"), _strip->phase_control());
198         }
199
200         _strip->gain_control()->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_automation, this), OSC::instance());
201         _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
202         gain_automation ();
203
204         boost::shared_ptr<Slavable> slv = boost::dynamic_pointer_cast<Slavable> (_strip);
205         slv->AssignmentChange.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::slaved_changed, this, _1, _2), OSC::instance());
206         slaved_changed (boost::shared_ptr<VCA>(), false);
207
208         boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
209         if (trim_controllable) {
210                 trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
211                 trim_message (X_("/select/trimdB"), _strip->trim_control());
212         }
213
214         boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
215         if (pan_controllable) {
216                 pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_stereo_position"), _strip->pan_azimuth_control()), OSC::instance());
217                 change_message (X_("/select/pan_stereo_position"), _strip->pan_azimuth_control());
218         }
219
220         boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
221         if (width_controllable) {
222                 width_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_stereo_width"), _strip->pan_width_control()), OSC::instance());
223                 change_message (X_("/select/pan_stereo_width"), _strip->pan_width_control());
224         }
225
226         // Rest of possible pan controls... Untested because I can't find a way to get them in the GUI :)
227         if (_strip->pan_elevation_control ()) {
228                 _strip->pan_elevation_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_elevation_position"), _strip->pan_elevation_control()), OSC::instance());
229                 change_message (X_("/select/pan_elevation_position"), _strip->pan_elevation_control());
230         }
231         if (_strip->pan_frontback_control ()) {
232                 _strip->pan_frontback_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_frontback_position"), _strip->pan_frontback_control()), OSC::instance());
233                 change_message (X_("/select/pan_frontback_position"), _strip->pan_frontback_control());
234         }
235         if (_strip->pan_lfe_control ()) {
236                 _strip->pan_lfe_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_lfe_control"), _strip->pan_lfe_control()), OSC::instance());
237                 change_message (X_("/select/pan_lfe_control"), _strip->pan_lfe_control());
238         }
239
240         // sends, plugins and eq
241         // detecting processor changes is now in osc.cc
242
243         // but... MB master send enable is different
244         if (_strip->master_send_enable_controllable ()) {
245                 _strip->master_send_enable_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/master_send_enable"), _strip->master_send_enable_controllable()), OSC::instance());
246                 enable_message (X_("/select/master_send_enable"), _strip->master_send_enable_controllable());
247         }
248
249         // Compressor
250         if (_strip->comp_enable_controllable ()) {
251                 _strip->comp_enable_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/comp_enable"), _strip->comp_enable_controllable()), OSC::instance());
252                 enable_message (X_("/select/comp_enable"), _strip->comp_enable_controllable());
253         }
254         if (_strip->comp_threshold_controllable ()) {
255                 _strip->comp_threshold_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/comp_threshold"), _strip->comp_threshold_controllable()), OSC::instance());
256                 change_message (X_("/select/comp_threshold"), _strip->comp_threshold_controllable());
257         }
258         if (_strip->comp_speed_controllable ()) {
259                 _strip->comp_speed_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/comp_speed"), _strip->comp_speed_controllable()), OSC::instance());
260                 change_message (X_("/select/comp_speed"), _strip->comp_speed_controllable());
261         }
262         if (_strip->comp_mode_controllable ()) {
263                 _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
264                 comp_mode ();
265         }
266         if (_strip->comp_makeup_controllable ()) {
267                 _strip->comp_makeup_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/comp_makeup"), _strip->comp_makeup_controllable()), OSC::instance());
268                 change_message (X_("/select/comp_makeup"), _strip->comp_makeup_controllable());
269         }
270         renew_sends ();
271         renew_plugin ();
272         eq_restart(0);
273         _init = false;
274
275         tick();
276 }
277
278 void
279 OSCSelectObserver::set_expand (uint32_t expand)
280 {
281         if (expand != _expand) {
282                 _expand = expand;
283                 if (expand) {
284                         _osc.float_message (X_("/select/expand"), 1.0, addr);
285                 } else {
286                         _osc.float_message (X_("/select/expand"), 0.0, addr);
287                 }
288         }
289 }
290
291 void
292 OSCSelectObserver::clear_observer ()
293 {
294         _init = true;
295         strip_connections.drop_connections ();
296         // all strip buttons should be off and faders 0 and etc.
297         _osc.float_message (X_("/select/expand"), 0, addr);
298         _osc.text_message (X_("/select/name"), " ", addr);
299         _osc.text_message (X_("/select/group"), " ", addr);
300         _osc.text_message (X_("/select/comment"), " ", addr);
301         _osc.float_message (X_("/select/mute"), 0, addr);
302         _osc.float_message (X_("/select/solo"), 0, addr);
303         _osc.float_message (X_("/select/recenable"), 0, addr);
304         _osc.float_message (X_("/select/record_safe"), 0, addr);
305         _osc.float_message (X_("/select/monitor_input"), 0, addr);
306         _osc.float_message (X_("/select/monitor_disk"), 0, addr);
307         _osc.float_message (X_("/select/polarity"), 0, addr);
308         _osc.float_message (X_("/select/n_inputs"), 0, addr);
309         _osc.float_message (X_("/select/n_outputs"), 0, addr);
310         _osc.int_message (X_("/select/group/gain"), 0, addr);
311         _osc.int_message (X_("/select/group/relative"), 0, addr);
312         _osc.int_message (X_("/select/group/mute"), 0, addr);
313         _osc.int_message (X_("/select/group/solo"), 0, addr);
314         _osc.int_message (X_("/select/group/recenable"), 0, addr);
315         _osc.int_message (X_("/select/group/select"), 0, addr);
316         _osc.int_message (X_("/select/group/active"), 0, addr);
317         _osc.int_message (X_("/select/group/color"), 0, addr);
318         _osc.int_message (X_("/select/group/monitoring"), 0, addr);
319         _osc.int_message (X_("/select/group/enable"), 0, addr);
320         if (gainmode) {
321                 _osc.float_message (X_("/select/fader"), 0, addr);
322         } else {
323                 _osc.float_message (X_("/select/gain"), -193, addr);
324         }
325         _osc.float_message (X_("/select/trimdB"), 0, addr);
326         _osc.float_message (X_("/select/pan_stereo_position"), 0.5, addr);
327         _osc.float_message (X_("/select/pan_stereo_width"), 1, addr);
328         if (feedback[9]) {
329                 _osc.float_message (X_("/select/signal"), 0, addr);
330         }
331         if (feedback[7]) {
332                 if (gainmode) {
333                         _osc.float_message (X_("/select/meter"), 0, addr);
334                 } else {
335                         _osc.float_message (X_("/select/meter"), -193, addr);
336                 }
337         }else if (feedback[8]) {
338                 _osc.float_message (X_("/select/meter"), 0, addr);
339         }
340         _osc.float_message (X_("/select/pan_elevation_position"), 0, addr);
341         _osc.float_message (X_("/select/pan_frontback_position"), .5, addr);
342         _osc.float_message (X_("/select/pan_lfe_control"), 0, addr);
343         _osc.float_message (X_("/select/comp_enable"), 0, addr);
344         _osc.float_message (X_("/select/comp_threshold"), 0, addr);
345         _osc.float_message (X_("/select/comp_speed"), 0, addr);
346         _osc.float_message (X_("/select/comp_mode"), 0, addr);
347         _osc.text_message (X_("/select/comp_mode_name"), " ", addr);
348         _osc.text_message (X_("/select/comp_speed_name"), " ", addr);
349         _osc.float_message (X_("/select/comp_makeup"), 0, addr);
350         _osc.float_message (X_("/select/expand"), 0.0, addr);
351         send_end();
352         plugin_end();
353         eq_end();
354 }
355
356 void
357 OSCSelectObserver::set_send_page (uint32_t page)
358 {
359         if (send_page != page) {
360                 send_page = page;
361                 renew_sends ();
362         }
363 }
364
365 void
366 OSCSelectObserver::set_send_size (uint32_t size)
367 {
368         send_page_size = size;
369         renew_sends ();
370 }
371
372 void
373 OSCSelectObserver::renew_sends () {
374         send_connections.drop_connections ();
375         send_timeout.clear();
376         send_init();
377 }
378
379 void
380 OSCSelectObserver::send_init()
381 {
382         send_size = nsends;
383         if (send_page_size) {
384                 send_size = send_page_size;
385         }
386         if (!send_size) {
387                 return;
388         }
389         uint32_t page_start = ((send_page - 1) * send_size);
390         uint32_t last_send = send_page * send_size;
391         uint32_t c = 1;
392         send_timeout.push_back (2);
393         _last_send.clear();
394         _last_send.push_back (0.0);
395
396         for (uint32_t s = page_start; s < last_send; ++s, ++c) {
397
398                 bool send_valid = false;
399                 if (_strip->send_level_controllable (s)) {
400                         _strip->send_level_controllable(s)->Changed.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain, this, c, _strip->send_level_controllable(s)), OSC::instance());
401                         send_timeout.push_back (2);
402                         _last_send.push_back (20.0);
403                         send_gain (c, _strip->send_level_controllable(s));
404                         send_valid = true;
405                 } else {
406                         send_gain (c, _strip->send_level_controllable(s));
407                         _osc.float_message_with_id (X_("/select/send_enable"), c, 0, in_line, addr);
408                         _osc.text_message_with_id (X_("/select/send_name"), c, " ", in_line, addr);
409                 }
410
411                 if (_strip->send_enable_controllable (s)) {
412                         _strip->send_enable_controllable(s)->Changed.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message_with_id, this, X_("/select/send_enable"), c, _strip->send_enable_controllable(s)), OSC::instance());
413                         enable_message_with_id (X_("/select/send_enable"), c, _strip->send_enable_controllable(s));
414                 } else if (send_valid) {
415                         boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
416                         if (!r) {
417                                 // should never get here
418                                 _osc.float_message_with_id (X_("/select/send_enable"), c, 0, in_line, addr);
419                         }
420                         boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(s));
421                         if (snd) {
422                                 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
423                                 proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), c, proc), OSC::instance());
424                                 _osc.float_message_with_id (X_("/select/send_enable"), c, proc->enabled(), in_line, addr);
425                         }
426                 }
427                 if ((gainmode != 1) && send_valid) {
428                         _osc.text_message_with_id (X_("/select/send_name"), c, _strip->send_name(s), in_line, addr);
429                 }
430         }
431 }
432
433 void
434 OSCSelectObserver::send_end ()
435 {
436         send_connections.drop_connections ();
437         for (uint32_t i = 1; i <= send_size; i++) {
438                 if (gainmode) {
439                         _osc.float_message_with_id (X_("/select/send_fader"), i, 0, in_line, addr);
440                 } else {
441                         _osc.float_message_with_id (X_("/select/send_gain"), i, -193, in_line, addr);
442                 }
443                 // next enable
444                 _osc.float_message_with_id (X_("/select/send_enable"), i, 0, in_line, addr);
445                 // next name
446                 _osc.text_message_with_id (X_("/select/send_name"), i, " ", in_line, addr);
447         }
448         // need to delete or clear send_timeout
449         send_size = 0;
450         send_timeout.clear();
451 }
452
453 void
454 OSCSelectObserver::set_plugin_id (int id, uint32_t page)
455 {
456         plug_id = id;
457         plug_page = page;
458         renew_plugin ();
459 }
460
461 void
462 OSCSelectObserver::set_plugin_page (uint32_t page)
463 {
464         plug_page = page;
465         renew_plugin ();
466 }
467
468 void
469 OSCSelectObserver::set_plugin_size (uint32_t size)
470 {
471         plug_page_size = size;
472         renew_plugin ();
473 }
474
475 void
476 OSCSelectObserver::renew_plugin () {
477         plugin_connections.drop_connections ();
478         plugin_init();
479 }
480
481 void
482 OSCSelectObserver::plugin_init()
483 {
484         if (plug_id < 0) {
485                 plugin_end ();
486                 return;
487         }
488         boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
489         if (!r) {
490                 plugin_end ();
491                 return;
492         }
493
494         // we have a plugin number now get the processor
495         boost::shared_ptr<Processor> proc = r->nth_plugin (plug_id);
496         boost::shared_ptr<PluginInsert> pi;
497         if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
498                 plugin_end ();
499                 return;
500         }
501         boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
502         // we have a plugin we can ask if it is activated
503         proc->ActiveChanged.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plug_enable, this, X_("/select/plugin/activate"), proc), OSC::instance());
504         _osc.float_message (X_("/select/plugin/activate"), proc->enabled(), addr);
505
506         bool ok = false;
507         // put only input controls into a vector
508         plug_params.clear ();
509         uint32_t nplug_params  = pip->parameter_count();
510         for ( uint32_t ppi = 0;  ppi < nplug_params; ++ppi) {
511                 uint32_t controlid = pip->nth_parameter(ppi, ok);
512                 if (!ok) {
513                         continue;
514                 }
515                 if (pip->parameter_is_input(controlid)) {
516                         plug_params.push_back (ppi);
517                 }
518         }
519         nplug_params = plug_params.size ();
520
521         // default of 0 page size means show all
522         plug_size = nplug_params;
523         if (plug_page_size) {
524                 plug_size = plug_page_size;
525         }
526         _osc.text_message (X_("/select/plugin/name"), pip->name(), addr);
527         uint32_t page_start = plug_page - 1;
528         uint32_t page_end = page_start + plug_size;
529
530         int pid = 1;
531         for ( uint32_t ppi = page_start;  ppi < page_end; ++ppi, ++pid) {
532                 if (ppi >= nplug_params) {
533                         _osc.text_message_with_id (X_("/select/plugin/parameter/name"), pid, " ", in_line, addr);
534                         _osc.float_message_with_id (X_("/select/plugin/parameter"), pid, 0, in_line, addr);
535                         continue;
536                 }
537
538                 uint32_t controlid = pip->nth_parameter(plug_params[ppi], ok);
539                 if (!ok) {
540                         continue;
541                 }
542                 ParameterDescriptor pd;
543                 pip->get_parameter_descriptor(controlid, pd);
544                 _osc.text_message_with_id (X_("/select/plugin/parameter/name"), pid, pd.label, in_line, addr);
545                 if ( pip->parameter_is_input(controlid)) {
546                         boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
547                         if (c) {
548                                 bool swtch = false;
549                                 if (pd.integer_step && pd.upper == 1) {
550                                         swtch = true;
551                                 }
552                                 c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
553                                 plugin_parameter_changed (pid, swtch, c);
554                         }
555                 }
556         }
557 }
558
559 void
560 OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
561 {
562         if (swtch) {
563                 enable_message_with_id (X_("/select/plugin/parameter"), pid, controllable);
564         } else {
565                 change_message_with_id (X_("/select/plugin/parameter"), pid, controllable);
566         }
567 }
568
569 void
570 OSCSelectObserver::plugin_end ()
571 {
572         plugin_connections.drop_connections ();
573         _osc.float_message (X_("/select/plugin/activate"), 0, addr);
574         _osc.text_message (X_("/select/plugin/name"), " ", addr);
575         for (uint32_t i = 1; i <= plug_size; i++) {
576                 _osc.float_message_with_id (X_("/select/plugin/parameter"), i, 0, in_line, addr);
577                 // next name
578                 _osc.text_message_with_id (X_("/select/plugin/parameter/name"), i, " ", in_line, addr);
579         }
580         plug_size = 0;
581         nplug_params = 0;
582 }
583
584 void
585 OSCSelectObserver::tick ()
586 {
587         if (_init) {
588                 return;
589         }
590         _tick_busy = true;
591         if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
592                 float now_meter;
593                 if (_strip->peak_meter()) {
594                         now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
595                 } else {
596                         now_meter = -193;
597                 }
598                 if (now_meter < -144) now_meter = -193;
599                 if (_last_meter != now_meter) {
600                         if (feedback[7] || feedback[8]) {
601                                 string path = X_("/select/meter");
602                                 if (gainmode && feedback[7]) {
603                                         _osc.float_message (path, ((now_meter + 94) / 100), addr);
604                                 } else if ((!gainmode) && feedback[7]) {
605                                         _osc.float_message (path, now_meter, addr);
606                                 } else if (feedback[8]) {
607                                         uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
608                                         uint16_t ledbits = ~(0xfff<<ledlvl);
609                                         _osc.float_message (path, ledbits, addr);
610                                 }
611                         }
612                         if (feedback[9]) {
613                                 string path = X_("/select/signal");
614                                 float signal;
615                                 if (now_meter < -40) {
616                                         signal = 0;
617                                 } else {
618                                         signal = 1;
619                                 }
620                                 _osc.float_message (path, signal, addr);
621                         }
622                 }
623                 _last_meter = now_meter;
624
625         }
626         if (gain_timeout) {
627                 if (gain_timeout == 1) {
628                         _osc.text_message (X_("/select/name"), _strip->name(), addr);
629                 }
630                 gain_timeout--;
631         }
632
633         if (as == ARDOUR::Play ||  as == ARDOUR::Touch) {
634                 if(_last_gain != _strip->gain_control()->get_value()) {
635                         _last_gain = _strip->gain_control()->get_value();
636                                 gain_message ();
637                 }
638         }
639         if (_strip->comp_redux_controllable() && _strip->comp_enable_controllable() && _strip->comp_enable_controllable()->get_value()) {
640                 float new_value = _strip->comp_redux_controllable()->get_parameter();
641                 if (_comp_redux != new_value) {
642                         _osc.float_message (X_("/select/comp_redux"), new_value, addr);
643                         _comp_redux = new_value;
644                 }
645         }
646         for (uint32_t i = 1; i <= send_timeout.size(); i++) {
647                 if (send_timeout[i]) {
648                         if (send_timeout[i] == 1) {
649                                 uint32_t pg_offset = (send_page - 1) * send_page_size;
650                                 _osc.text_message_with_id (X_("/select/send_name"), i, _strip->send_name(pg_offset + i - 1), in_line, addr);
651                         }
652                         send_timeout[i]--;
653                 }
654         }
655         _tick_busy = false;
656 }
657
658 void
659 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
660 {
661         if (!what_changed.contains (ARDOUR::Properties::name)) {
662                 return;
663         }
664
665         if (!_strip) {
666                 return;
667         }
668
669         _osc.text_message (X_("/select/name"), _strip->name(), addr);
670         boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
671         if (route) {
672                 // lets tell the surface how many inputs this strip has
673                 _osc.float_message (X_("/select/n_inputs"), (float) route->n_inputs().n_total(), addr);
674                 // lets tell the surface how many outputs this strip has
675                 _osc.float_message (X_("/select/n_outputs"), (float) route->n_outputs().n_total(), addr);
676         }
677 }
678
679 void
680 OSCSelectObserver::group_name ()
681 {
682         boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (_strip);
683         string new_name = " ";
684         RouteGroup *rg = rt->route_group();
685         if (rg) {
686                 new_name = rg->name();
687         }
688         if (new_name != _group_name) {
689                 _osc.text_message (X_("/select/group"), new_name, addr);
690                 _group_name = new_name;
691                 _group_sharing[15] = 1;
692         }
693         _osc.send_group_list (addr);
694         group_sharing (rg);
695 }
696
697 void
698 OSCSelectObserver::group_sharing (RouteGroup *rgc)
699 {
700         boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (_strip);
701         RouteGroup *rg;
702         if (rt) {
703                 rg = rt->route_group();
704         }
705         if (rg && rt) {
706                 if (rg->is_gain () != _group_sharing[0] || _group_sharing[15]) {
707                         _group_sharing[0] = rg->is_gain ();
708                         _osc.int_message (X_("/select/group/gain"), _group_sharing[0], addr);
709                 }
710                 if (rg->is_relative () != _group_sharing[1] || _group_sharing[15]) {
711                         _group_sharing[1] = rg->is_relative ();
712                         _osc.int_message (X_("/select/group/relative"), _group_sharing[1], addr);
713                 }
714                 if (rg->is_mute () != _group_sharing[2] || _group_sharing[15]) {
715                         _group_sharing[2] = rg->is_mute ();
716                         _osc.int_message (X_("/select/group/mute"), _group_sharing[2], addr);
717                 }
718                 if (rg->is_solo () != _group_sharing[3] || _group_sharing[15]) {
719                         _group_sharing[3] = rg->is_solo ();
720                         _osc.int_message (X_("/select/group/solo"), _group_sharing[3], addr);
721                 }
722                 if (rg->is_recenable () != _group_sharing[4] || _group_sharing[15]) {
723                         _group_sharing[4] = rg->is_recenable ();
724                         _osc.int_message (X_("/select/group/recenable"), _group_sharing[4], addr);
725                 }
726                 if (rg->is_select () != _group_sharing[5] || _group_sharing[15]) {
727                         _group_sharing[5] = rg->is_select ();
728                         _osc.int_message (X_("/select/group/select"), _group_sharing[5], addr);
729                 }
730                 if (rg->is_route_active () != _group_sharing[6] || _group_sharing[15]) {
731                         _group_sharing[6] = rg->is_route_active ();
732                         _osc.int_message (X_("/select/group/active"), _group_sharing[6], addr);
733                 }
734                 if (rg->is_color () != _group_sharing[7] || _group_sharing[15]) {
735                         _group_sharing[7] = rg->is_color ();
736                         _osc.int_message (X_("/select/group/color"), _group_sharing[7], addr);
737                 }
738                 if (rg->is_monitoring () != _group_sharing[8] || _group_sharing[15]) {
739                         _group_sharing[8] = rg->is_monitoring ();
740                         _osc.int_message (X_("/select/group/monitoring"), _group_sharing[8], addr);
741                 }
742                 if (rg->is_active () != _group_sharing[9] || _group_sharing[15]) {
743                         _group_sharing[9] = rg->is_active ();
744                         _osc.int_message (X_("/select/group/enable"), _group_sharing[9], addr);
745                 }
746         } else {
747                 _osc.int_message (X_("/select/group/gain"), 0, addr);
748                 _osc.int_message (X_("/select/group/relative"), 0, addr);
749                 _osc.int_message (X_("/select/group/mute"), 0, addr);
750                 _osc.int_message (X_("/select/group/solo"), 0, addr);
751                 _osc.int_message (X_("/select/group/recenable"), 0, addr);
752                 _osc.int_message (X_("/select/group/select"), 0, addr);
753                 _osc.int_message (X_("/select/group/active"), 0, addr);
754                 _osc.int_message (X_("/select/group/color"), 0, addr);
755                 _osc.int_message (X_("/select/group/monitoring"), 0, addr);
756                 _osc.int_message (X_("/select/group/enable"), 0, addr);
757         }
758         _group_sharing[15] = 0;
759 }
760
761 void
762 OSCSelectObserver::comment_changed ()
763 {
764         boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (_strip);
765         if (rt) {
766                 _osc.text_message (X_("/select/comment"), rt->comment(), addr);
767         }
768 }
769
770 void
771 OSCSelectObserver::pi_changed (PBD::PropertyChange const& what_changed)
772 {
773         if (!what_changed.contains (ARDOUR::Properties::hidden)) {
774                 return;
775         }
776         _osc.float_message (X_("/select/hide"), _strip->is_hidden (), addr);
777 }
778
779 void
780 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
781 {
782         float val = controllable->get_value();
783
784         _osc.float_message (path, (float) controllable->internal_to_interface (val), addr);
785 }
786
787 void
788 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
789 {
790         float val = controllable->get_value();
791         if (val) {
792                 _osc.float_message (path, 1, addr);
793         } else {
794                 _osc.float_message (path, 0, addr);
795         }
796
797 }
798
799 void
800 OSCSelectObserver::plug_enable (string path, boost::shared_ptr<Processor> proc)
801 {
802         // with no delay value is wrong
803         Glib::usleep(10);
804
805         _osc.float_message (path, proc->enabled(), addr);
806 }
807
808 void
809 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
810 {
811         float val = controllable->get_value();
812
813         _osc.float_message_with_id (path, id, (float) controllable->internal_to_interface (val), in_line, addr);
814 }
815
816 void
817 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
818 {
819         float val = controllable->get_value();
820         if (val) {
821                 _osc.float_message_with_id (path, id, 1, in_line, addr);
822         } else {
823                 _osc.float_message_with_id (path, id, 0, in_line, addr);
824         }
825 }
826
827 void
828 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
829 {
830         int disk, input;
831         float val = controllable->get_value();
832         switch ((int) val) {
833                 case 1:
834                         disk = 0;
835                         input = 1;
836                         break;
837                 case 2:
838                         disk = 1;
839                         input = 0;
840                         break;
841                 default:
842                         disk = 0;
843                         input = 0;
844         }
845
846         _osc.float_message (X_("/select/monitor_input"), (float) input, addr);
847         _osc.float_message (X_("/select/monitor_disk"), (float) disk, addr);
848 }
849
850 void
851 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
852 {
853         if (_last_trim != controllable->get_value()) {
854                 _last_trim = controllable->get_value();
855         } else {
856                 return;
857         }
858
859         _osc.float_message (path, (float) accurate_coefficient_to_dB (controllable->get_value()), addr);
860 }
861
862 void
863 OSCSelectObserver::gain_message ()
864 {
865         float value = _strip->gain_control()->get_value();
866         if (_last_gain != value) {
867                 _last_gain = value;
868         } else {
869                 return;
870         }
871
872         if (gainmode) {
873                 _osc.float_message (X_("/select/fader"), _strip->gain_control()->internal_to_interface (value), addr);
874                 if (gainmode == 1) {
875                         _osc.text_message (X_("/select/name"), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)), addr);
876                         gain_timeout = 8;
877                 }
878         }
879         if (!gainmode || gainmode == 2) {
880                 if (value < 1e-15) {
881                         _osc.float_message (X_("/select/gain"), -200, addr);
882                 } else {
883                         _osc.float_message (X_("/select/gain"), accurate_coefficient_to_dB (value), addr);
884                 }
885         }
886 }
887
888 void
889 OSCSelectObserver::gain_automation ()
890 {
891         float output = 0;
892         as = _strip->gain_control()->alist()->automation_state();
893         string auto_name;
894         switch (as) {
895                 case ARDOUR::Off:
896                         output = 0;
897                         auto_name = "Manual";
898                         break;
899                 case ARDOUR::Play:
900                         output = 1;
901                         auto_name = "Play";
902                         break;
903                 case ARDOUR::Write:
904                         output = 2;
905                         auto_name = "Write";
906                         break;
907                 case ARDOUR::Touch:
908                         output = 3;
909                         auto_name = "Touch";
910                         break;
911                 case ARDOUR::Latch:
912                         output = 4;
913                         auto_name = "Latch";
914                         break;
915                 default:
916                         break;
917         }
918
919         if (gainmode) {
920                 _osc.float_message (X_("/select/fader/automation"), output, addr);
921                 _osc.text_message (X_("/select/fader/automation_name"), auto_name, addr);
922         } else {
923                 _osc.float_message (X_("/select/gain/automation"), output, addr);
924                 _osc.text_message (X_("/select/gain/automation_name"), auto_name, addr);
925         }
926
927         gain_message ();
928 }
929
930 void
931 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
932 {
933         float raw_value = 0.0;
934         if (controllable) {
935                 raw_value = controllable->get_value();
936         }
937         if (_last_send[id] != raw_value) {
938                 _last_send[id] = raw_value;
939         } else {
940                 return;
941         }
942         string path;
943         float value = 0.0;
944         float db;
945 #ifdef MIXBUS
946         if (controllable) {
947                 db = raw_value;
948         } else {
949                 db = -193;
950         }
951 #else
952         if (raw_value < 1e-15) {
953                 db = -193;
954         } else {
955                 db = accurate_coefficient_to_dB (raw_value);
956         }
957 #endif
958
959         if (gainmode) {
960                 if (controllable) {
961                         value = controllable->internal_to_interface (raw_value);
962                 }
963                 _osc.float_message_with_id (X_("/select/send_fader"), id, value, in_line, addr);
964                 if (gainmode == 1) {
965                         _osc.text_message_with_id (X_("/select/send_name") , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db), in_line, addr);
966                         if (send_timeout.size() > id) {
967                                 send_timeout[id] = 8;
968                         }
969                 }
970         }
971         if (!gainmode || gainmode == 2) {
972                 _osc.float_message_with_id (X_("/select/send_gain"), id, db, in_line, addr);
973         }
974
975 }
976
977 void
978 OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
979 {
980         // with no delay value is wrong
981         Glib::usleep(10);
982
983         _osc.float_message_with_id (X_("/select/send_enable"), id, proc->enabled(), in_line, addr);
984 }
985
986 void
987 OSCSelectObserver::comp_mode ()
988 {
989         change_message (X_("/select/comp_mode"), _strip->comp_mode_controllable());
990         _osc.text_message (X_("/select/comp_mode_name"), _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()), addr);
991         _osc.text_message (X_("/select/comp_speed_name"), _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()), addr);
992 }
993
994 void
995 OSCSelectObserver::eq_init()
996 {
997         // HPF and enable are special case, rest are in bands
998         if (_strip->filter_enable_controllable (true)) {
999                 _strip->filter_enable_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/enable"), _strip->filter_enable_controllable (true)), OSC::instance());
1000                 change_message (X_("/select/eq_hpf/enable"), _strip->filter_enable_controllable(true));
1001         }
1002
1003         if (_strip->filter_enable_controllable (false)) {
1004                 _strip->filter_enable_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/enable"), _strip->filter_enable_controllable (false)), OSC::instance());
1005                 change_message (X_("/select/eq_lpf/enable"), _strip->filter_enable_controllable(false));
1006         }
1007
1008         if (_strip->filter_freq_controllable (true)) {
1009                 _strip->filter_freq_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/freq"), _strip->filter_freq_controllable (true)), OSC::instance());
1010                 change_message (X_("/select/eq_hpf/freq"), _strip->filter_freq_controllable(true));
1011         }
1012
1013         if (_strip->filter_freq_controllable (false)) {
1014                 _strip->filter_freq_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/freq"), _strip->filter_freq_controllable (false)), OSC::instance());
1015                 change_message (X_("/select/eq_lpf/freq"), _strip->filter_freq_controllable(false));
1016         }
1017
1018         if (_strip->filter_slope_controllable (true)) {
1019                 _strip->filter_slope_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/slope"), _strip->filter_slope_controllable (true)), OSC::instance());
1020                 change_message (X_("/select/eq_hpf/slope"), _strip->filter_slope_controllable(true));
1021         }
1022
1023         if (_strip->filter_slope_controllable (false)) {
1024                 _strip->filter_slope_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/slope"), _strip->filter_slope_controllable (false)), OSC::instance());
1025                 change_message (X_("/select/eq_lpf/slope"), _strip->filter_slope_controllable(false));
1026         }
1027
1028         if (_strip->eq_enable_controllable ()) {
1029                 _strip->eq_enable_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/eq_enable"), _strip->eq_enable_controllable()), OSC::instance());
1030                 enable_message (X_("/select/eq_enable"), _strip->eq_enable_controllable());
1031         }
1032
1033         eq_bands = _strip->eq_band_cnt ();
1034         if (eq_bands < 0) {
1035                 eq_bands = 0;
1036         }
1037         if (!eq_bands) {
1038                 return;
1039         }
1040
1041         for (int i = 0; i < eq_bands; i++) {
1042                 if (_strip->eq_band_name(i).size()) {
1043                         _osc.text_message_with_id (X_("/select/eq_band_name"), i + 1, _strip->eq_band_name (i), in_line, addr);
1044                 }
1045                 if (_strip->eq_gain_controllable (i)) {
1046                         _strip->eq_gain_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_gain"), i + 1, _strip->eq_gain_controllable(i)), OSC::instance());
1047                         change_message_with_id (X_("/select/eq_gain"), i + 1, _strip->eq_gain_controllable(i));
1048                 }
1049                 if (_strip->eq_freq_controllable (i)) {
1050                         _strip->eq_freq_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_freq"), i + 1, _strip->eq_freq_controllable(i)), OSC::instance());
1051                         change_message_with_id (X_("/select/eq_freq"), i + 1, _strip->eq_freq_controllable(i));
1052                 }
1053                 if (_strip->eq_q_controllable (i)) {
1054                         _strip->eq_q_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_q"), i + 1, _strip->eq_q_controllable(i)), OSC::instance());
1055                         change_message_with_id (X_("/select/eq_q"), i + 1, _strip->eq_q_controllable(i));
1056                 }
1057                 if (_strip->eq_shape_controllable (i)) {
1058                         _strip->eq_shape_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_shape"), i + 1, _strip->eq_shape_controllable(i)), OSC::instance());
1059                         change_message_with_id (X_("/select/eq_shape"), i + 1, _strip->eq_shape_controllable(i));
1060                 }
1061         }
1062 }
1063
1064 void
1065 OSCSelectObserver::eq_end ()
1066 {
1067         eq_connections.drop_connections ();
1068                 _osc.float_message (X_("/select/eq_hpf"), 0, addr);
1069                 _osc.float_message (X_("/select/eq_enable"), 0, addr);
1070
1071         for (int i = 1; i <= eq_bands; i++) {
1072                 _osc.text_message_with_id (X_("/select/eq_band_name"), i, " ", in_line, addr);
1073                 _osc.float_message_with_id (X_("/select/eq_gain"), i, 0, in_line, addr);
1074                 _osc.float_message_with_id (X_("/select/eq_freq"), i, 0, in_line, addr);
1075                 _osc.float_message_with_id (X_("/select/eq_q"), i, 0, in_line, addr);
1076                 _osc.float_message_with_id (X_("/select/eq_shape"), i, 0, in_line, addr);
1077
1078
1079         }
1080 }
1081
1082 void
1083 OSCSelectObserver::eq_restart(int x)
1084 {
1085         eq_connections.drop_connections ();
1086         //eq_end();
1087         eq_init();
1088 }
1089
1090 void
1091 OSCSelectObserver::slaved_changed (boost::shared_ptr<VCA> vca, bool state)
1092 {
1093         lo_message reply;
1094         reply = lo_message_new ();
1095         StripableList stripables;
1096         session->get_stripables (stripables);
1097         for (StripableList::iterator it = stripables.begin(); it != stripables.end(); ++it) {
1098                 boost::shared_ptr<Stripable> s = *it;
1099
1100                 // we only want VCAs
1101                 boost::shared_ptr<VCA> v = boost::dynamic_pointer_cast<VCA> (s);
1102                 if (v) {
1103                         lo_message_add_string (reply, v->name().c_str());
1104                         if (_strip->slaved_to (v)) {
1105                                 lo_message_add_int32 (reply, 1);
1106                         } else {
1107                                 lo_message_add_int32 (reply, 0);
1108                         }
1109                 }
1110         }
1111         lo_send_message (addr, X_("/select/vcas"), reply);
1112         lo_message_free (reply);
1113 }