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