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