OSC: make send enables work in MB
[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 "boost/lambda/lambda.hpp"
21
22 #include "ardour/session.h"
23 #include "ardour/track.h"
24 #include "ardour/monitor_control.h"
25 #include "ardour/dB.h"
26 #include "ardour/meter.h"
27 #include "ardour/phase_control.h"
28 #include "ardour/solo_isolate_control.h"
29 #include "ardour/solo_safe_control.h"
30 #include "ardour/route.h"
31
32 #include "osc.h"
33 #include "osc_select_observer.h"
34
35 #include "pbd/i18n.h"
36
37 using namespace std;
38 using namespace PBD;
39 using namespace ARDOUR;
40 using namespace ArdourSurface;
41
42 OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address a, uint32_t gm, std::bitset<32> fb)
43         : _strip (s)
44         ,gainmode (gm)
45         ,feedback (fb)
46         ,nsends (0)
47 {
48         addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
49
50         if (feedback[0]) { // buttons are separate feedback
51                 _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
52                 name_changed (ARDOUR::Properties::name);
53
54                 _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
55                 change_message ("/select/mute", _strip->mute_control());
56
57                 _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
58                 change_message ("/select/solo", _strip->solo_control());
59
60                 if (_strip->solo_isolate_control()) {
61                         _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());
62                         change_message ("/select/solo_iso", _strip->solo_isolate_control());
63                 }
64
65                 if (_strip->solo_safe_control()) {
66                         _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());
67                         change_message ("/select/solo_safe", _strip->solo_safe_control());
68                 }
69
70                 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
71                 if (track) {
72                         track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
73                         monitor_status (track->monitoring_control());
74                 }
75
76                 boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
77                 if (rec_controllable) {
78                         rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
79                         change_message ("/select/recenable", _strip->rec_enable_control());
80                 }
81
82                 boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
83                 if (recsafe_controllable) {
84                         recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
85                         change_message ("/select/record_safe", _strip->rec_safe_control());
86                 }
87
88                 boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
89                 if (phase_controllable) {
90                         phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
91                         change_message ("/select/polarity", _strip->phase_control());
92                 }
93
94         }
95
96         if (feedback[1]) { // level controls
97                 if (gainmode) {
98                         _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/fader"), _strip->gain_control()), OSC::instance());
99                         gain_message ("/select/fader", _strip->gain_control());
100                 } else {
101                         _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this, X_("/select/gain"), _strip->gain_control()), OSC::instance());
102                         gain_message ("/select/gain", _strip->gain_control());
103                 }
104
105                 boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
106                 if (trim_controllable) {
107                         trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
108                         trim_message ("/select/trimdB", _strip->trim_control());
109                 }
110
111                 boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
112                 if (pan_controllable) {
113                         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());
114                         change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
115                 }
116
117                 boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
118                 if (width_controllable) {
119                         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());
120                         change_message ("/select/pan_stereo_width", _strip->pan_width_control());
121                 }
122
123                 // detecting processor changes requires cast to route
124                 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
125                 if (r) {
126                         r->processors_changed.connect  (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_restart, this, -1), OSC::instance());
127                         send_init();
128                         eq_init();
129                 }
130
131         }
132         if (feedback[13]) { // Well known controls
133                 // Rest of possible pan controls... Untested because I can't find a way to get them in the GUI :)
134                 if (_strip->pan_elevation_control ()) {
135                         _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());
136                         change_message ("/select/pan_elevation_position", _strip->pan_elevation_control());
137                 }
138                 if (_strip->pan_frontback_control ()) {
139                         _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());
140                         change_message ("/select/pan_frontback_position", _strip->pan_frontback_control());
141                 }
142                 if (_strip->pan_lfe_control ()) {
143                         _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());
144                         change_message ("/select/pan_lfe_control", _strip->pan_lfe_control());
145                 }
146                 // Compressor
147                 if (_strip->comp_enable_controllable ()) {
148                         _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());
149                         enable_message ("/select/comp_enable", _strip->comp_enable_controllable());
150                 }
151                 if (_strip->comp_threshold_controllable ()) {
152                         _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());
153                         change_message ("/select/comp_threshold", _strip->comp_threshold_controllable());
154                 }
155                 if (_strip->comp_speed_controllable ()) {
156                         _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());
157                         change_message ("/select/comp_speed", _strip->comp_speed_controllable());
158                 }
159                 if (_strip->comp_mode_controllable ()) {
160                         _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
161                         comp_mode ();
162                 }
163                 if (_strip->comp_makeup_controllable ()) {
164                         _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());
165                         change_message ("/select/comp_makeup", _strip->comp_makeup_controllable());
166                 }
167
168         }
169
170         tick();
171 }
172
173 OSCSelectObserver::~OSCSelectObserver ()
174 {
175
176         strip_connections.drop_connections ();
177         // all strip buttons should be off and faders 0 and etc.
178         clear_strip ("/select/expand", 0);
179         if (feedback[0]) { // buttons are separate feedback
180                 text_message ("/select/name", " ");
181                 text_message ("/select/comment", " ");
182                 clear_strip ("/select/mute", 0);
183                 clear_strip ("/select/solo", 0);
184                 clear_strip ("/select/recenable", 0);
185                 clear_strip ("/select/record_safe", 0);
186                 clear_strip ("/select/monitor_input", 0);
187                 clear_strip ("/select/monitor_disk", 0);
188                 clear_strip ("/select/polarity", 0);
189                 clear_strip ("/select/n_inputs", 0);
190                 clear_strip ("/select/n_outputs", 0);
191         }
192         if (feedback[1]) { // level controls
193                 if (gainmode) {
194                         clear_strip ("/select/fader", 0);
195                 } else {
196                         clear_strip ("/select/gain", -193);
197                 }
198                 clear_strip ("/select/trimdB", 0);
199                 clear_strip ("/select/pan_stereo_position", 0.5);
200                 clear_strip ("/select/pan_stereo_width", 1);
201         }
202         if (feedback[9]) {
203                 clear_strip ("/select/signal", 0);
204         }
205         if (feedback[7]) {
206                 if (gainmode) {
207                         clear_strip ("/select/meter", 0);
208                 } else {
209                         clear_strip ("/select/meter", -193);
210                 }
211         }else if (feedback[8]) {
212                 clear_strip ("/select/meter", 0);
213         }
214         if (feedback[13]) { // Well known controls
215                 clear_strip ("/select/pan_elevation_position", 0);
216                 clear_strip ("/select/pan_frontback_position", .5);
217                 clear_strip ("/select/pan_lfe_control", 0);
218                 clear_strip ("/select/comp_enable", 0);
219                 clear_strip ("/select/comp_threshold", 0);
220                 clear_strip ("/select/comp_speed", 0);
221                 clear_strip ("/select/comp_mode", 0);
222                 text_message ("/select/comp_mode_name", " ");
223                 text_message ("/select/comp_speed_name", " ");
224                 clear_strip ("/select/comp_makeup", 0);
225         }
226         send_end();
227         eq_end();
228
229         lo_address_free (addr);
230 }
231
232 void
233 OSCSelectObserver::send_init()
234 {
235         // we don't know how many there are, so find out.
236         bool sends;
237         do {
238                 sends = false;
239                 if (_strip->send_level_controllable (nsends)) {
240                         _strip->send_level_controllable(nsends)->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain, this, nsends, _strip->send_level_controllable(nsends)), OSC::instance());
241                         send_gain (nsends, _strip->send_level_controllable(nsends));
242                         sends = true;
243                 }
244
245                 if (_strip->send_enable_controllable (nsends)) {
246                         _strip->send_enable_controllable(nsends)->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message_with_id, this, X_("/select/send_enable"), nsends + 1, _strip->send_enable_controllable(nsends)), OSC::instance());
247                         enable_message_with_id ("/select/send_enable", nsends + 1, _strip->send_enable_controllable(nsends));
248                         sends = true;
249                 } else if (sends) {
250                         // not used by Ardour, just mixbus so in Ardour always true
251                         clear_strip_with_id ("/select/send_enable", nsends + 1, 1);
252                 }
253                 // this should get signalled by the route the send goes to, (TODO)
254                 if (sends) { // if the gain control is there, this is too
255                         text_with_id ("/select/send_name", nsends + 1, _strip->send_name(nsends));
256                 }
257                 // Send numbers are 0 based, OSC is 1 based so this gets incremented at the end
258                 if (sends) {
259                         nsends++;
260                 }
261         } while (sends);
262 }
263
264 void
265 OSCSelectObserver::send_end ()
266 {
267         send_connections.drop_connections ();
268         for (uint32_t i = 1; i <= nsends; i++) {
269                 if (gainmode) {
270                         clear_strip_with_id ("/select/send_fader", i, 0);
271                 } else {
272                         clear_strip_with_id ("/select/send_gain", i, -193);
273                 }
274                 // next enable
275                 clear_strip_with_id ("/select/send_enable", i, 0);
276                 // next name
277                 text_with_id ("/select/send_name", i, " ");
278         }
279         nsends = 0;
280 }
281
282 void
283 OSCSelectObserver::send_restart(int x)
284 {
285         send_end();
286         send_init();
287 }
288
289 void
290 OSCSelectObserver::tick ()
291 {
292         if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
293                 float now_meter;
294                 if (_strip->peak_meter()) {
295                         now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
296                 } else {
297                         now_meter = -193;
298                 }
299                 if (now_meter < -144) now_meter = -193;
300                 if (_last_meter != now_meter) {
301                         if (feedback[7] || feedback[8]) {
302                                 string path = "/select/meter";
303                                 lo_message msg = lo_message_new ();
304                                 if (gainmode && feedback[7]) {
305                                         lo_message_add_float (msg, ((now_meter + 94) / 100));
306                                         lo_send_message (addr, path.c_str(), msg);
307                                 } else if ((!gainmode) && feedback[7]) {
308                                         lo_message_add_float (msg, now_meter);
309                                         lo_send_message (addr, path.c_str(), msg);
310                                 } else if (feedback[8]) {
311                                         uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
312                                         uint16_t ledbits = ~(0xfff<<ledlvl);
313                                         lo_message_add_int32 (msg, ledbits);
314                                         lo_send_message (addr, path.c_str(), msg);
315                                 }
316                                 lo_message_free (msg);
317                         }
318                         if (feedback[9]) {
319                                 string path = "/select/signal";
320                                 lo_message msg = lo_message_new ();
321                                 float signal;
322                                 if (now_meter < -40) {
323                                         signal = 0;
324                                 } else {
325                                         signal = 1;
326                                 }
327                                 lo_message_add_float (msg, signal);
328                                 lo_send_message (addr, path.c_str(), msg);
329                                 lo_message_free (msg);
330                         }
331                 }
332                 _last_meter = now_meter;
333
334         }
335
336 }
337
338 void
339 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
340 {
341         if (!what_changed.contains (ARDOUR::Properties::name)) {
342                 return;
343         }
344
345         if (!_strip) {
346                 return;
347         }
348
349         text_message ("/select/name", _strip->name());
350         boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
351         if (route) {
352                 //spit out the comment at the same time
353                 text_message ("/select/comment", route->comment());
354                 // lets tell the surface how many inputs this strip has
355                 clear_strip ("/select/n_inputs", (float) route->n_inputs().n_total());
356                 // lets tell the surface how many outputs this strip has
357                 clear_strip ("/select/n_outputs", (float) route->n_outputs().n_total());
358         }
359 }
360
361 void
362 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
363 {
364         lo_message msg = lo_message_new ();
365         float val = controllable->get_value();
366
367         lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
368
369         lo_send_message (addr, path.c_str(), msg);
370         lo_message_free (msg);
371 }
372
373 void
374 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
375 {
376         float val = controllable->get_value();
377         if (val) {
378                 clear_strip (path, 1);
379         } else {
380                 clear_strip (path, 0);
381         }
382
383 }
384
385 void
386 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
387 {
388         lo_message msg = lo_message_new ();
389         float val = controllable->get_value();
390         if (feedback[2]) {
391                 path = set_path (path, id);
392         } else {
393                 lo_message_add_int32 (msg, id);
394         }
395
396         lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
397
398         lo_send_message (addr, path.c_str(), msg);
399         lo_message_free (msg);
400 }
401
402 void
403 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
404 {
405         float val = controllable->get_value();
406         if (val) {
407                 clear_strip_with_id (path, id, 1);
408         } else {
409                 clear_strip_with_id (path, id, 0);
410         }
411 }
412
413 void
414 OSCSelectObserver::text_message (string path, std::string text)
415 {
416         lo_message msg = lo_message_new ();
417
418         lo_message_add_string (msg, text.c_str());
419
420         lo_send_message (addr, path.c_str(), msg);
421         lo_message_free (msg);
422 }
423
424 void
425 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
426 {
427         int disk, input;
428         float val = controllable->get_value();
429         switch ((int) val) {
430                 case 1:
431                         disk = 0;
432                         input = 1;
433                         break;
434                 case 2:
435                         disk = 1;
436                         input = 0;
437                         break;
438                 default:
439                         disk = 0;
440                         input = 0;
441         }
442
443         clear_strip ("/select/monitor_input", (float) input);
444         clear_strip ("/select/monitor_disk", (float) disk);
445 }
446
447 void
448 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
449 {
450         lo_message msg = lo_message_new ();
451
452         lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
453
454         lo_send_message (addr, path.c_str(), msg);
455         lo_message_free (msg);
456 }
457
458 void
459 OSCSelectObserver::gain_message (string path, boost::shared_ptr<Controllable> controllable)
460 {
461         lo_message msg = lo_message_new ();
462
463         if (gainmode) {
464                 lo_message_add_float (msg, gain_to_slider_position (controllable->get_value()));
465         } else {
466                 if (controllable->get_value() < 1e-15) {
467                         lo_message_add_float (msg, -200);
468                 } else {
469                         lo_message_add_float (msg, accurate_coefficient_to_dB (controllable->get_value()));
470                 }
471         }
472
473         lo_send_message (addr, path.c_str(), msg);
474         lo_message_free (msg);
475 }
476
477 void
478 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
479 {
480         lo_message msg = lo_message_new ();
481         string path;
482         float value;
483
484         if (gainmode) {
485                 path = "/select/send_fader";
486 #ifdef MIXBUS
487                 value = controllable->internal_to_interface (controllable->get_value());
488 #else
489                 value = gain_to_slider_position (controllable->get_value());
490 #endif
491         } else {
492                 path = "/select/send_gain";
493 #ifdef MIXBUS
494                 value = controllable->get_value();
495 #else
496                 if (controllable->get_value() < 1e-15) {
497                         value = -193;
498                 } else {
499                         value = accurate_coefficient_to_dB (controllable->get_value());
500                 }
501 #endif
502         }
503
504         if (feedback[2]) {
505                 path = set_path (path, id + 1);
506         } else {
507                 lo_message_add_int32 (msg, id + 1);
508         }
509
510         lo_message_add_float (msg, value);
511         lo_send_message (addr, path.c_str(), msg);
512         lo_message_free (msg);
513 }
514
515 void
516 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
517 {
518         lo_message msg = lo_message_new ();
519         if (feedback[2]) {
520                 path = set_path (path, id);
521         } else {
522                 lo_message_add_int32 (msg, id);
523         }
524
525         lo_message_add_string (msg, name.c_str());
526
527         lo_send_message (addr, path.c_str(), msg);
528         lo_message_free (msg);
529 }
530
531 void
532 OSCSelectObserver::comp_mode ()
533 {
534         change_message ("/select/comp_mode", _strip->comp_mode_controllable());
535         text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
536         text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
537 }
538
539 void
540 OSCSelectObserver::eq_init()
541 {
542         // HPF and enable are special case, rest are in bands
543         if (_strip->eq_hpf_controllable ()) {
544                 _strip->eq_hpf_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf"), _strip->eq_hpf_controllable()), OSC::instance());
545                 change_message ("/select/eq_hpf", _strip->eq_hpf_controllable());
546         }
547         if (_strip->eq_enable_controllable ()) {
548                 _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());
549                 enable_message ("/select/eq_enable", _strip->eq_enable_controllable());
550         }
551
552         uint32_t eq_bands = _strip->eq_band_cnt ();
553         if (!eq_bands) {
554                 return;
555         }
556
557         for (uint32_t i = 0; i < eq_bands; i++) {
558                 if (_strip->eq_band_name(i).size()) {
559                         text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
560                 }
561                 if (_strip->eq_gain_controllable (i)) {
562                         _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());
563                         change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
564                 }
565                 if (_strip->eq_freq_controllable (i)) {
566                         _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());
567                         change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
568                 }
569                 if (_strip->eq_q_controllable (i)) {
570                         _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());
571                         change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
572                 }
573                 if (_strip->eq_shape_controllable (i)) {
574                         _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());
575                         change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
576                 }
577         }
578 }
579
580 void
581 OSCSelectObserver::eq_end ()
582 {
583         //need to check feedback for [13]
584         eq_connections.drop_connections ();
585         clear_strip ("/select/eq_hpf", 0);
586         clear_strip ("/select/eq_enable", 0);
587
588         for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
589                 text_with_id ("/select/eq_band_name", i, " ");
590                 clear_strip_with_id ("/select/eq_gain", i, 0);
591                 clear_strip_with_id ("/select/eq_freq", i, 0);
592                 clear_strip_with_id ("/select/eq_q", i, 0);
593                 clear_strip_with_id ("/select/eq_shape", i, 0);
594
595
596         }
597 }
598
599 void
600 OSCSelectObserver::eq_restart(int x)
601 {
602         eq_end();
603         eq_init();
604 }
605
606 string
607 OSCSelectObserver::set_path (string path, uint32_t id)
608 {
609         if (feedback[2]) {
610   ostringstream os;
611   os << path << "/" << id;
612   path = os.str();
613         }
614         return path;
615 }
616
617 void
618 OSCSelectObserver::clear_strip (string path, float val)
619 {
620         lo_message msg = lo_message_new ();
621         lo_message_add_float (msg, val);
622
623         lo_send_message (addr, path.c_str(), msg);
624         lo_message_free (msg);
625
626 }
627
628 void
629 OSCSelectObserver::clear_strip_with_id (string path, uint32_t id, float val)
630 {
631         lo_message msg = lo_message_new ();
632         if (feedback[2]) {
633                 path = set_path (path, id);
634         } else {
635                 lo_message_add_int32 (msg, id);
636         }
637
638         lo_message_add_float (msg, val);
639
640         lo_send_message (addr, path.c_str(), msg);
641         lo_message_free (msg);
642
643 }
644