OSC: Make pan controls work properly with MB 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 "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                 if (_strip->comp_redux_controllable ()) {
168                         _strip->comp_redux_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/comp_redux"), _strip->comp_redux_controllable()), OSC::instance());
169                         change_message ("/select/comp_redux", _strip->comp_redux_controllable());
170                 }
171
172         }
173
174         tick();
175 }
176
177 OSCSelectObserver::~OSCSelectObserver ()
178 {
179
180         strip_connections.drop_connections ();
181         // all strip buttons should be off and faders 0 and etc.
182         clear_strip ("/select/expand", 0);
183         if (feedback[0]) { // buttons are separate feedback
184                 text_message ("/select/name", " ");
185                 text_message ("/select/comment", " ");
186                 clear_strip ("/select/mute", 0);
187                 clear_strip ("/select/solo", 0);
188                 clear_strip ("/select/recenable", 0);
189                 clear_strip ("/select/record_safe", 0);
190                 clear_strip ("/select/monitor_input", 0);
191                 clear_strip ("/select/monitor_disk", 0);
192                 clear_strip ("/select/polarity", 0);
193                 clear_strip ("/select/n_inputs", 0);
194                 clear_strip ("/select/n_outputs", 0);
195         }
196         if (feedback[1]) { // level controls
197                 if (gainmode) {
198                         clear_strip ("/select/fader", 0);
199                 } else {
200                         clear_strip ("/select/gain", -193);
201                 }
202                 clear_strip ("/select/trimdB", 0);
203                 clear_strip ("/select/pan_stereo_position", 0.5);
204                 clear_strip ("/select/pan_stereo_width", 1);
205         }
206         if (feedback[9]) {
207                 clear_strip ("/select/signal", 0);
208         }
209         if (feedback[7]) {
210                 if (gainmode) {
211                         clear_strip ("/select/meter", 0);
212                 } else {
213                         clear_strip ("/select/meter", -193);
214                 }
215         }else if (feedback[8]) {
216                 clear_strip ("/select/meter", 0);
217         }
218         if (feedback[13]) { // Well known controls
219                 clear_strip ("/select/pan_elevation_position", 0);
220                 clear_strip ("/select/pan_frontback_position", .5);
221                 clear_strip ("/select/pan_lfe_control", 0);
222                 clear_strip ("/select/comp_enable", 0);
223                 clear_strip ("/select/comp_threshold", 0);
224                 clear_strip ("/select/comp_speed", 0);
225                 clear_strip ("/select/comp_mode", 0);
226                 text_message ("/select/comp_mode_name", " ");
227                 text_message ("/select/comp_speed_name", " ");
228                 clear_strip ("/select/comp_makeup", 0);
229                 clear_strip ("/select/comp_redux", 0);
230         }
231         send_end();
232         eq_end();
233
234         lo_address_free (addr);
235 }
236
237 void
238 OSCSelectObserver::send_init()
239 {
240         // we don't know how many there are, so find out.
241         bool sends;
242         do {
243                 sends = false;
244                 if (_strip->send_level_controllable (nsends)) {
245                         _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());
246                         send_gain (nsends, _strip->send_level_controllable(nsends));
247                         sends = true;
248                 }
249
250                 if (_strip->send_enable_controllable (nsends)) {
251                         _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());
252                         change_message_with_id ("/select/send_enable", nsends + 1, _strip->send_enable_controllable(nsends));
253                         sends = true;
254                 } else if (sends) {
255                         // not used by Ardour, just mixbus so in Ardour always true
256                         clear_strip_with_id ("/select/send_enable", nsends + 1, 1);
257                 }
258                 // this should get signalled by the route the send goes to, (TODO)
259                 if (sends) { // if the gain control is there, this is too
260                         text_with_id ("/select/send_name", nsends + 1, _strip->send_name(nsends));
261                 }
262                 // Send numbers are 0 based, OSC is 1 based so this gets incremented at the end
263                 if (sends) {
264                         nsends++;
265                 }
266         } while (sends);
267 }
268
269 void
270 OSCSelectObserver::send_end ()
271 {
272         send_connections.drop_connections ();
273         for (uint32_t i = 1; i <= nsends; i++) {
274                 if (gainmode) {
275                         clear_strip_with_id ("/select/send_fader", i, 0);
276                 } else {
277                         clear_strip_with_id ("/select/send_gain", i, -193);
278                 }
279                 // next enable
280                 clear_strip_with_id ("/select/send_enable", i, 0);
281                 // next name
282                 text_with_id ("/select/send_name", i, " ");
283         }
284         nsends = 0;
285 }
286
287 void
288 OSCSelectObserver::send_restart(int x)
289 {
290         send_end();
291         send_init();
292 }
293
294 void
295 OSCSelectObserver::tick ()
296 {
297         if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
298                 float now_meter;
299                 if (_strip->peak_meter()) {
300                         now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
301                 } else {
302                         now_meter = -193;
303                 }
304                 if (now_meter < -144) now_meter = -193;
305                 if (_last_meter != now_meter) {
306                         if (feedback[7] || feedback[8]) {
307                                 string path = "/select/meter";
308                                 lo_message msg = lo_message_new ();
309                                 if (gainmode && feedback[7]) {
310                                         uint32_t lev1023 = (uint32_t)((now_meter + 54) * 17.05);
311                                         lo_message_add_int32 (msg, lev1023);
312                                         lo_send_message (addr, path.c_str(), msg);
313                                 } else if ((!gainmode) && feedback[7]) {
314                                         lo_message_add_float (msg, now_meter);
315                                         lo_send_message (addr, path.c_str(), msg);
316                                 } else if (feedback[8]) {
317                                         uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
318                                         uint16_t ledbits = ~(0xfff<<ledlvl);
319                                         lo_message_add_int32 (msg, ledbits);
320                                         lo_send_message (addr, path.c_str(), msg);
321                                 }
322                                 lo_message_free (msg);
323                         }
324                         if (feedback[9]) {
325                                 string path = "/select/signal";
326                                 lo_message msg = lo_message_new ();
327                                 float signal;
328                                 if (now_meter < -40) {
329                                         signal = 0;
330                                 } else {
331                                         signal = 1;
332                                 }
333                                 lo_message_add_float (msg, signal);
334                                 lo_send_message (addr, path.c_str(), msg);
335                                 lo_message_free (msg);
336                         }
337                 }
338                 _last_meter = now_meter;
339
340         }
341
342 }
343
344 void
345 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
346 {
347         if (!what_changed.contains (ARDOUR::Properties::name)) {
348                 return;
349         }
350
351         if (!_strip) {
352                 return;
353         }
354
355         text_message ("/select/name", _strip->name());
356         boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
357         if (route) {
358                 //spit out the comment at the same time
359                 text_message ("/select/comment", route->comment());
360                 // lets tell the surface how many inputs this strip has
361                 clear_strip ("/select/n_inputs", (float) route->n_inputs().n_total());
362                 // lets tell the surface how many outputs this strip has
363                 clear_strip ("/select/n_outputs", (float) route->n_outputs().n_total());
364         }
365 }
366
367 void
368 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
369 {
370         lo_message msg = lo_message_new ();
371         float val = controllable->get_value();
372
373         lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
374
375         lo_send_message (addr, path.c_str(), msg);
376         lo_message_free (msg);
377 }
378
379 void
380 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
381 {
382         lo_message msg = lo_message_new ();
383         float val = controllable->get_value();
384         if (feedback[2]) {
385                 path = set_path (path, id);
386         } else {
387                 lo_message_add_int32 (msg, id);
388         }
389
390         lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
391
392         lo_send_message (addr, path.c_str(), msg);
393         lo_message_free (msg);
394 }
395
396 void
397 OSCSelectObserver::text_message (string path, std::string text)
398 {
399         lo_message msg = lo_message_new ();
400
401         lo_message_add_string (msg, text.c_str());
402
403         lo_send_message (addr, path.c_str(), msg);
404         lo_message_free (msg);
405 }
406
407 void
408 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
409 {
410         int disk, input;
411         float val = controllable->get_value();
412         switch ((int) val) {
413                 case 1:
414                         disk = 0;
415                         input = 1;
416                         break;
417                 case 2:
418                         disk = 1;
419                         input = 0;
420                         break;
421                 default:
422                         disk = 0;
423                         input = 0;
424         }
425
426         clear_strip ("/select/monitor_input", (float) input);
427         clear_strip ("/select/monitor_disk", (float) disk);
428 }
429
430 void
431 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
432 {
433         lo_message msg = lo_message_new ();
434
435         lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
436
437         lo_send_message (addr, path.c_str(), msg);
438         lo_message_free (msg);
439 }
440
441 void
442 OSCSelectObserver::gain_message (string path, boost::shared_ptr<Controllable> controllable)
443 {
444         lo_message msg = lo_message_new ();
445
446         if (gainmode) {
447                 if (controllable->get_value() == 1) {
448                         lo_message_add_int32 (msg, 800);
449                 } else {
450                         lo_message_add_int32 (msg, gain_to_slider_position (controllable->get_value()) * 1023);
451                 }
452         } else {
453                 if (controllable->get_value() < 1e-15) {
454                         lo_message_add_float (msg, -200);
455                 } else {
456                         lo_message_add_float (msg, accurate_coefficient_to_dB (controllable->get_value()));
457                 }
458         }
459
460         lo_send_message (addr, path.c_str(), msg);
461         lo_message_free (msg);
462 }
463
464 void
465 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
466 {
467         lo_message msg = lo_message_new ();
468         string path;
469         float value;
470
471         if (gainmode) {
472                 path = "/select/send_fader";
473                 if (controllable->get_value() == 1) {
474                         value = 800;
475                 } else {
476                         value = gain_to_slider_position (controllable->get_value());
477                 }
478         } else {
479                 path = "/select/send_gain";
480                 if (controllable->get_value() < 1e-15) {
481                         value = -193;
482                 } else {
483                         value = accurate_coefficient_to_dB (controllable->get_value());
484                 }
485         }
486
487         if (feedback[2]) {
488                 path = set_path (path, id + 1);
489         } else {
490                 lo_message_add_int32 (msg, id + 1);
491         }
492
493         lo_message_add_float (msg, value);
494         lo_send_message (addr, path.c_str(), msg);
495         lo_message_free (msg);
496 }
497
498 void
499 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
500 {
501         lo_message msg = lo_message_new ();
502         if (feedback[2]) {
503                 path = set_path (path, id);
504         } else {
505                 lo_message_add_int32 (msg, id);
506         }
507
508         lo_message_add_string (msg, name.c_str());
509
510         lo_send_message (addr, path.c_str(), msg);
511         lo_message_free (msg);
512 }
513
514 void
515 OSCSelectObserver::comp_mode ()
516 {
517         change_message ("/select/comp_mode", _strip->comp_mode_controllable());
518         text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
519         text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
520 }
521
522 void
523 OSCSelectObserver::eq_init()
524 {
525         // HPF and enable are special case, rest are in bands
526         if (_strip->eq_hpf_controllable ()) {
527                 _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());
528                 change_message ("/select/eq_hpf", _strip->eq_hpf_controllable());
529         }
530         if (_strip->eq_enable_controllable ()) {
531                 _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());
532                 change_message ("/select/eq_enable", _strip->eq_enable_controllable());
533         }
534
535         uint32_t eq_bands = _strip->eq_band_cnt ();
536         if (!eq_bands) {
537                 return;
538         }
539
540         for (uint32_t i = 0; i < eq_bands; i++) {
541                 if (_strip->eq_band_name(i).size()) {
542                         text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
543                 }
544                 if (_strip->eq_gain_controllable (i)) {
545                         _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());
546                         change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
547                 }
548                 if (_strip->eq_freq_controllable (i)) {
549                         _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());
550                         change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
551                 }
552                 if (_strip->eq_q_controllable (i)) {
553                         _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());
554                         change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
555                 }
556                 if (_strip->eq_shape_controllable (i)) {
557                         _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());
558                         change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
559                 }
560         }
561 }
562
563 void
564 OSCSelectObserver::eq_end ()
565 {
566         //need to check feedback for [13]
567         eq_connections.drop_connections ();
568         clear_strip ("/select/eq_hpf", 0);
569         clear_strip ("/select/eq_enable", 0);
570
571         for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
572                 text_with_id ("/select/eq_band_name", i, " ");
573                 clear_strip_with_id ("/select/eq_gain", i, 0);
574                 clear_strip_with_id ("/select/eq_freq", i, 0);
575                 clear_strip_with_id ("/select/eq_q", i, 0);
576                 clear_strip_with_id ("/select/eq_shape", i, 0);
577
578
579         }
580 }
581
582 void
583 OSCSelectObserver::eq_restart(int x)
584 {
585         eq_end();
586         eq_init();
587 }
588
589 string
590 OSCSelectObserver::set_path (string path, uint32_t id)
591 {
592         if (feedback[2]) {
593   ostringstream os;
594   os << path << "/" << id;
595   path = os.str();
596         }
597         return path;
598 }
599
600 void
601 OSCSelectObserver::clear_strip (string path, float val)
602 {
603         lo_message msg = lo_message_new ();
604         lo_message_add_float (msg, val);
605
606         lo_send_message (addr, path.c_str(), msg);
607         lo_message_free (msg);
608
609 }
610
611 void
612 OSCSelectObserver::clear_strip_with_id (string path, uint32_t id, float val)
613 {
614         lo_message msg = lo_message_new ();
615         if (feedback[2]) {
616                 path = set_path (path, id);
617         } else {
618                 lo_message_add_int32 (msg, id);
619         }
620
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