OSC: MB spelling mistakes stopped compile fix
[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::change_message, this, X_("/select/comp_enable"), _strip->comp_enable_controllable()), OSC::instance());
149                         change_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::change_message_with_id, this, X_("/select/send_enable"), nsends + 1, _strip->send_enable_controllable(nsends)), OSC::instance());
247                         change_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::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
375 {
376         lo_message msg = lo_message_new ();
377         float val = controllable->get_value();
378         if (feedback[2]) {
379                 path = set_path (path, id);
380         } else {
381                 lo_message_add_int32 (msg, id);
382         }
383
384         lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
385
386         lo_send_message (addr, path.c_str(), msg);
387         lo_message_free (msg);
388 }
389
390 void
391 OSCSelectObserver::text_message (string path, std::string text)
392 {
393         lo_message msg = lo_message_new ();
394
395         lo_message_add_string (msg, text.c_str());
396
397         lo_send_message (addr, path.c_str(), msg);
398         lo_message_free (msg);
399 }
400
401 void
402 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
403 {
404         int disk, input;
405         float val = controllable->get_value();
406         switch ((int) val) {
407                 case 1:
408                         disk = 0;
409                         input = 1;
410                         break;
411                 case 2:
412                         disk = 1;
413                         input = 0;
414                         break;
415                 default:
416                         disk = 0;
417                         input = 0;
418         }
419
420         clear_strip ("/select/monitor_input", (float) input);
421         clear_strip ("/select/monitor_disk", (float) disk);
422 }
423
424 void
425 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
426 {
427         lo_message msg = lo_message_new ();
428
429         lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
430
431         lo_send_message (addr, path.c_str(), msg);
432         lo_message_free (msg);
433 }
434
435 void
436 OSCSelectObserver::gain_message (string path, boost::shared_ptr<Controllable> controllable)
437 {
438         lo_message msg = lo_message_new ();
439
440         if (gainmode) {
441                 lo_message_add_float (msg, gain_to_slider_position (controllable->get_value()));
442         } else {
443                 if (controllable->get_value() < 1e-15) {
444                         lo_message_add_float (msg, -200);
445                 } else {
446                         lo_message_add_float (msg, accurate_coefficient_to_dB (controllable->get_value()));
447                 }
448         }
449
450         lo_send_message (addr, path.c_str(), msg);
451         lo_message_free (msg);
452 }
453
454 void
455 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
456 {
457         lo_message msg = lo_message_new ();
458         string path;
459         float value;
460
461         if (gainmode) {
462                 path = "/select/send_fader";
463 #ifdef MIXBUS
464                 value = controllable->internal_to_interface (controllable->get_value());
465 #else
466                 value = gain_to_slider_position (controllable->get_value());
467 #endif
468         } else {
469                 path = "/select/send_gain";
470 #ifdef MIXBUS
471                 value = controllable->get_value();
472 #else
473                 if (controllable->get_value() < 1e-15) {
474                         value = -193;
475                 } else {
476                         value = accurate_coefficient_to_dB (controllable->get_value());
477                 }
478 #endif
479         }
480
481         if (feedback[2]) {
482                 path = set_path (path, id + 1);
483         } else {
484                 lo_message_add_int32 (msg, id + 1);
485         }
486
487         lo_message_add_float (msg, value);
488         lo_send_message (addr, path.c_str(), msg);
489         lo_message_free (msg);
490 }
491
492 void
493 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
494 {
495         lo_message msg = lo_message_new ();
496         if (feedback[2]) {
497                 path = set_path (path, id);
498         } else {
499                 lo_message_add_int32 (msg, id);
500         }
501
502         lo_message_add_string (msg, name.c_str());
503
504         lo_send_message (addr, path.c_str(), msg);
505         lo_message_free (msg);
506 }
507
508 void
509 OSCSelectObserver::comp_mode ()
510 {
511         change_message ("/select/comp_mode", _strip->comp_mode_controllable());
512         text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
513         text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
514 }
515
516 void
517 OSCSelectObserver::eq_init()
518 {
519         // HPF and enable are special case, rest are in bands
520         if (_strip->eq_hpf_controllable ()) {
521                 _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());
522                 change_message ("/select/eq_hpf", _strip->eq_hpf_controllable());
523         }
524         if (_strip->eq_enable_controllable ()) {
525                 _strip->eq_enable_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_enable"), _strip->eq_enable_controllable()), OSC::instance());
526                 change_message ("/select/eq_enable", _strip->eq_enable_controllable());
527         }
528
529         uint32_t eq_bands = _strip->eq_band_cnt ();
530         if (!eq_bands) {
531                 return;
532         }
533
534         for (uint32_t i = 0; i < eq_bands; i++) {
535                 if (_strip->eq_band_name(i).size()) {
536                         text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
537                 }
538                 if (_strip->eq_gain_controllable (i)) {
539                         _strip->eq_gain_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_gain"), i, _strip->eq_gain_controllable(i)), OSC::instance());
540                         change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
541                 }
542                 if (_strip->eq_freq_controllable (i)) {
543                         _strip->eq_freq_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_freq"), i, _strip->eq_freq_controllable(i)), OSC::instance());
544                         change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
545                 }
546                 if (_strip->eq_q_controllable (i)) {
547                         _strip->eq_q_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_q"), i, _strip->eq_q_controllable(i)), OSC::instance());
548                         change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
549                 }
550                 if (_strip->eq_shape_controllable (i)) {
551                         _strip->eq_shape_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_shape"), i, _strip->eq_shape_controllable(i)), OSC::instance());
552                         change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
553                 }
554         }
555 }
556
557 void
558 OSCSelectObserver::eq_end ()
559 {
560         //need to check feedback for [13]
561         eq_connections.drop_connections ();
562         clear_strip ("/select/eq_hpf", 0);
563         clear_strip ("/select/eq_enable", 0);
564
565         for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
566                 text_with_id ("/select/eq_band_name", i, " ");
567                 clear_strip_with_id ("/select/eq_gain", i, 0);
568                 clear_strip_with_id ("/select/eq_freq", i, 0);
569                 clear_strip_with_id ("/select/eq_q", i, 0);
570                 clear_strip_with_id ("/select/eq_shape", i, 0);
571
572
573         }
574 }
575
576 void
577 OSCSelectObserver::eq_restart(int x)
578 {
579         eq_end();
580         eq_init();
581 }
582
583 string
584 OSCSelectObserver::set_path (string path, uint32_t id)
585 {
586         if (feedback[2]) {
587   ostringstream os;
588   os << path << "/" << id;
589   path = os.str();
590         }
591         return path;
592 }
593
594 void
595 OSCSelectObserver::clear_strip (string path, float val)
596 {
597         lo_message msg = lo_message_new ();
598         lo_message_add_float (msg, val);
599
600         lo_send_message (addr, path.c_str(), msg);
601         lo_message_free (msg);
602
603 }
604
605 void
606 OSCSelectObserver::clear_strip_with_id (string path, uint32_t id, float val)
607 {
608         lo_message msg = lo_message_new ();
609         if (feedback[2]) {
610                 path = set_path (path, id);
611         } else {
612                 lo_message_add_int32 (msg, id);
613         }
614
615         lo_message_add_float (msg, val);
616
617         lo_send_message (addr, path.c_str(), msg);
618         lo_message_free (msg);
619
620 }
621