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