2 Copyright (C) 2009 Paul Davis
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.
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.
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.
21 #include "boost/lambda/lambda.hpp"
23 #include "pbd/control_math.h"
25 #include "ardour/session.h"
26 #include "ardour/track.h"
27 #include "ardour/monitor_control.h"
28 #include "ardour/dB.h"
29 #include "ardour/meter.h"
30 #include "ardour/phase_control.h"
31 #include "ardour/solo_isolate_control.h"
32 #include "ardour/solo_safe_control.h"
33 #include "ardour/route.h"
34 #include "ardour/send.h"
35 #include "ardour/plugin.h"
36 #include "ardour/plugin_insert.h"
37 #include "ardour/processor.h"
38 #include "ardour/readonly_control.h"
41 #include "osc_select_observer.h"
49 using namespace ARDOUR;
50 using namespace ArdourSurface;
52 OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address a, ArdourSurface::OSC::OSCSurface* su)
58 addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
59 gainmode = sur->gainmode;
60 feedback = sur->feedback;
66 if (feedback[0]) { // buttons are separate feedback
67 _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
68 name_changed (ARDOUR::Properties::name);
70 _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
71 change_message ("/select/mute", _strip->mute_control());
73 _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
74 change_message ("/select/solo", _strip->solo_control());
76 if (_strip->solo_isolate_control()) {
77 _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());
78 change_message ("/select/solo_iso", _strip->solo_isolate_control());
81 if (_strip->solo_safe_control()) {
82 _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());
83 change_message ("/select/solo_safe", _strip->solo_safe_control());
86 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
88 track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
89 monitor_status (track->monitoring_control());
92 boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
93 if (rec_controllable) {
94 rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
95 change_message ("/select/recenable", _strip->rec_enable_control());
98 boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
99 if (recsafe_controllable) {
100 recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
101 change_message ("/select/record_safe", _strip->rec_safe_control());
104 boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
105 if (phase_controllable) {
106 phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
107 change_message ("/select/polarity", _strip->phase_control());
112 if (feedback[1]) { // level controls
113 _strip->gain_control()->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_automation, this), OSC::instance());
114 _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
117 boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
118 if (trim_controllable) {
119 trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
120 trim_message ("/select/trimdB", _strip->trim_control());
123 boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
124 if (pan_controllable) {
125 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());
126 change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
129 boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
130 if (width_controllable) {
131 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());
132 change_message ("/select/pan_stereo_width", _strip->pan_width_control());
136 if (feedback[13]) { // Well known controls
137 // Rest of possible pan controls... Untested because I can't find a way to get them in the GUI :)
138 if (_strip->pan_elevation_control ()) {
139 _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());
140 change_message ("/select/pan_elevation_position", _strip->pan_elevation_control());
142 if (_strip->pan_frontback_control ()) {
143 _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());
144 change_message ("/select/pan_frontback_position", _strip->pan_frontback_control());
146 if (_strip->pan_lfe_control ()) {
147 _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());
148 change_message ("/select/pan_lfe_control", _strip->pan_lfe_control());
151 // sends, plugins and eq
152 // detecting processor changes is now in osc.cc
154 // but... MB master send enable is different
155 if (_strip->master_send_enable_controllable ()) {
156 _strip->master_send_enable_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/master_send_enable"), _strip->master_send_enable_controllable()), OSC::instance());
157 enable_message ("/select/master_send_enable", _strip->master_send_enable_controllable());
161 if (_strip->comp_enable_controllable ()) {
162 _strip->comp_enable_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/comp_enable"), _strip->comp_enable_controllable()), OSC::instance());
163 enable_message ("/select/comp_enable", _strip->comp_enable_controllable());
165 if (_strip->comp_threshold_controllable ()) {
166 _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());
167 change_message ("/select/comp_threshold", _strip->comp_threshold_controllable());
169 if (_strip->comp_speed_controllable ()) {
170 _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());
171 change_message ("/select/comp_speed", _strip->comp_speed_controllable());
173 if (_strip->comp_mode_controllable ()) {
174 _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
177 if (_strip->comp_makeup_controllable ()) {
178 _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());
179 change_message ("/select/comp_makeup", _strip->comp_makeup_controllable());
187 OSCSelectObserver::~OSCSelectObserver ()
189 strip_connections.drop_connections ();
190 // all strip buttons should be off and faders 0 and etc.
191 if (feedback[0]) { // buttons are separate feedback
192 send_float ("/select/expand", 0);
193 text_message ("/select/name", " ");
194 text_message ("/select/comment", " ");
195 send_float ("/select/mute", 0);
196 send_float ("/select/solo", 0);
197 send_float ("/select/recenable", 0);
198 send_float ("/select/record_safe", 0);
199 send_float ("/select/monitor_input", 0);
200 send_float ("/select/monitor_disk", 0);
201 send_float ("/select/polarity", 0);
202 send_float ("/select/n_inputs", 0);
203 send_float ("/select/n_outputs", 0);
205 if (feedback[1]) { // level controls
207 send_float ("/select/fader", 0);
209 send_float ("/select/gain", -193);
211 send_float ("/select/trimdB", 0);
212 send_float ("/select/pan_stereo_position", 0.5);
213 send_float ("/select/pan_stereo_width", 1);
216 send_float ("/select/signal", 0);
220 send_float ("/select/meter", 0);
222 send_float ("/select/meter", -193);
224 }else if (feedback[8]) {
225 send_float ("/select/meter", 0);
227 if (feedback[13]) { // Well known controls
228 send_float ("/select/pan_elevation_position", 0);
229 send_float ("/select/pan_frontback_position", .5);
230 send_float ("/select/pan_lfe_control", 0);
231 send_float ("/select/comp_enable", 0);
232 send_float ("/select/comp_threshold", 0);
233 send_float ("/select/comp_speed", 0);
234 send_float ("/select/comp_mode", 0);
235 text_message ("/select/comp_mode_name", " ");
236 text_message ("/select/comp_speed_name", " ");
237 send_float ("/select/comp_makeup", 0);
243 lo_address_free (addr);
247 OSCSelectObserver::renew_sends () {
253 OSCSelectObserver::renew_plugin () {
259 OSCSelectObserver::send_init()
261 // we don't know how many there are, so find out.
266 if (_strip->send_level_controllable (nsends)) {
275 // paging should be done in osc.cc in case there is no feedback
277 if (sur->send_page_size) {
278 send_size = sur->send_page_size;
281 uint32_t max_page = (uint32_t)(nsends / send_size) + 1;
282 if (sur->send_page < 1) {
284 } else if ((uint32_t)sur->send_page > max_page) {
285 sur->send_page = max_page;
287 uint32_t page_start = ((sur->send_page - 1) * send_size);
288 uint32_t last_send = sur->send_page * send_size;
290 send_timeout.push_back (2);
292 for (uint32_t s = page_start; s < last_send; ++s, ++c) {
294 bool send_valid = false;
295 if (_strip->send_level_controllable (s)) {
296 _strip->send_level_controllable(s)->Changed.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_gain, this, c, _strip->send_level_controllable(s)), OSC::instance());
297 send_timeout.push_back (2);
298 send_gain (c, _strip->send_level_controllable(s));
302 if (_strip->send_enable_controllable (s)) {
303 _strip->send_enable_controllable(s)->Changed.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message_with_id, this, X_("/select/send_enable"), c, _strip->send_enable_controllable(s)), OSC::instance());
304 enable_message_with_id ("/select/send_enable", c, _strip->send_enable_controllable(s));
305 } else if (send_valid) {
306 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
308 // should never get here
309 send_float_with_id ("/select/send_enable", c, 0);
311 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(s));
313 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
314 proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), c, proc), OSC::instance());
315 send_float_with_id ("/select/send_enable", c, proc->enabled());
318 if (!gainmode && send_valid) {
319 text_with_id ("/select/send_name", c, _strip->send_name(s));
325 OSCSelectObserver::plugin_init()
327 if (!sur->plugin_id) {
331 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
336 // we have a plugin number now get the processor
337 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
338 boost::shared_ptr<PluginInsert> pi;
339 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
342 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
345 nplug_params = sur->plug_params.size ();
347 // default of 0 page size means show all
348 plug_size = nplug_params;
349 if (sur->plug_page_size) {
350 plug_size = sur->plug_page_size;
352 text_message ("/select/plugin/name", pip->name());
353 uint32_t page_end = nplug_params;
354 uint32_t max_page = 1;
355 if (plug_size && nplug_params) {
356 max_page = (uint32_t)((nplug_params - 1) / plug_size) + 1;
359 if (sur->plug_page < 1) {
362 if ((uint32_t)sur->plug_page > max_page) {
363 sur->plug_page = max_page;
365 uint32_t page_start = ((sur->plug_page - 1) * plug_size);
366 page_end = sur->plug_page * plug_size;
369 for ( uint32_t ppi = page_start; ppi < page_end; ++ppi, ++pid) {
370 if (ppi >= nplug_params) {
371 text_with_id ("/select/plugin/parameter/name", pid, " ");
372 send_float_with_id ("/select/plugin/parameter", pid, 0);
376 uint32_t controlid = pip->nth_parameter(sur->plug_params[ppi], ok);
380 ParameterDescriptor pd;
381 pip->get_parameter_descriptor(controlid, pd);
382 text_with_id ("/select/plugin/parameter/name", pid, pd.label);
383 if ( pip->parameter_is_input(controlid)) {
384 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
387 if (pd.integer_step && pd.upper == 1) {
390 c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
391 plugin_parameter_changed (pid, swtch, c);
398 OSCSelectObserver::send_end ()
400 send_connections.drop_connections ();
401 for (uint32_t i = 1; i <= send_size; i++) {
403 send_float_with_id ("/select/send_fader", i, 0);
405 send_float_with_id ("/select/send_gain", i, -193);
408 send_float_with_id ("/select/send_enable", i, 0);
410 text_with_id ("/select/send_name", i, " ");
412 // need to delete or clear send_timeout
413 send_timeout.clear();
418 OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
421 enable_message_with_id ("/select/plugin/parameter", pid, controllable);
423 change_message_with_id ("/select/plugin/parameter", pid, controllable);
428 OSCSelectObserver::plugin_end ()
430 plugin_connections.drop_connections ();
431 text_message ("/select/plugin/name", " ");
432 for (uint32_t i = 1; i <= plug_size; i++) {
433 send_float_with_id ("/select/plugin/parameter", i, 0);
435 text_with_id ("/select/plugin/parameter/name", i, " ");
441 OSCSelectObserver::tick ()
443 if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
445 if (_strip->peak_meter()) {
446 now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
450 if (now_meter < -144) now_meter = -193;
451 if (_last_meter != now_meter) {
452 if (feedback[7] || feedback[8]) {
453 string path = "/select/meter";
454 lo_message msg = lo_message_new ();
455 if (gainmode && feedback[7]) {
456 lo_message_add_float (msg, ((now_meter + 94) / 100));
457 lo_send_message (addr, path.c_str(), msg);
458 } else if ((!gainmode) && feedback[7]) {
459 lo_message_add_float (msg, now_meter);
460 lo_send_message (addr, path.c_str(), msg);
461 } else if (feedback[8]) {
462 uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
463 uint16_t ledbits = ~(0xfff<<ledlvl);
464 lo_message_add_int32 (msg, ledbits);
465 lo_send_message (addr, path.c_str(), msg);
467 lo_message_free (msg);
470 string path = "/select/signal";
471 lo_message msg = lo_message_new ();
473 if (now_meter < -40) {
478 lo_message_add_float (msg, signal);
479 lo_send_message (addr, path.c_str(), msg);
480 lo_message_free (msg);
483 _last_meter = now_meter;
488 if (gain_timeout == 1) {
489 text_message ("/select/name", _strip->name());
494 if (as == ARDOUR::Play || as == ARDOUR::Touch) {
495 if(_last_gain != _strip->gain_control()->get_value()) {
496 _last_gain = _strip->gain_control()->get_value();
502 if (_strip->comp_redux_controllable() && _strip->comp_enable_controllable() && _strip->comp_enable_controllable()->get_value()) {
503 float new_value = _strip->comp_redux_controllable()->get_parameter();
504 if (_comp_redux != new_value) {
505 send_float ("/select/comp_redux", new_value);
506 _comp_redux = new_value;
509 for (uint32_t i = 1; i <= send_timeout.size(); i++) {
510 if (send_timeout[i]) {
511 if (send_timeout[i] == 1) {
512 uint32_t pg_offset = (sur->send_page - 1) * sur->send_page_size;
513 text_with_id ("/select/send_name", i, _strip->send_name(pg_offset + i - 1));
523 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
525 if (!what_changed.contains (ARDOUR::Properties::name)) {
533 text_message ("/select/name", _strip->name());
534 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
536 //spit out the comment at the same time
537 text_message ("/select/comment", route->comment());
538 // lets tell the surface how many inputs this strip has
539 send_float ("/select/n_inputs", (float) route->n_inputs().n_total());
540 // lets tell the surface how many outputs this strip has
541 send_float ("/select/n_outputs", (float) route->n_outputs().n_total());
546 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
548 lo_message msg = lo_message_new ();
549 float val = controllable->get_value();
551 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
553 lo_send_message (addr, path.c_str(), msg);
554 lo_message_free (msg);
558 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
560 float val = controllable->get_value();
562 send_float (path, 1);
564 send_float (path, 0);
570 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
572 lo_message msg = lo_message_new ();
573 float val = controllable->get_value();
575 path = set_path (path, id);
577 lo_message_add_int32 (msg, id);
580 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
582 lo_send_message (addr, path.c_str(), msg);
583 lo_message_free (msg);
587 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
589 float val = controllable->get_value();
591 send_float_with_id (path, id, 1);
593 send_float_with_id (path, id, 0);
598 OSCSelectObserver::text_message (string path, std::string text)
600 lo_message msg = lo_message_new ();
602 lo_message_add_string (msg, text.c_str());
604 lo_send_message (addr, path.c_str(), msg);
605 lo_message_free (msg);
609 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
612 float val = controllable->get_value();
627 send_float ("/select/monitor_input", (float) input);
628 send_float ("/select/monitor_disk", (float) disk);
632 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
634 lo_message msg = lo_message_new ();
636 lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
638 lo_send_message (addr, path.c_str(), msg);
639 lo_message_free (msg);
643 OSCSelectObserver::gain_message ()
645 float value = _strip->gain_control()->get_value();
648 text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
650 send_float ("/select/fader", _strip->gain_control()->internal_to_interface (value));
653 send_float ("/select/gain", -200);
655 send_float ("/select/gain", accurate_coefficient_to_dB (value));
661 OSCSelectObserver::gain_automation ()
664 as = _strip->gain_control()->alist()->automation_state();
669 auto_name = "Manual";
688 send_float ("/select/fader/automation", output);
689 text_message ("/select/fader/automation_name", auto_name);
691 send_float ("/select/gain/automation", output);
692 text_message ("/select/gain/automation_name", auto_name);
699 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
701 lo_message msg = lo_message_new ();
706 db = controllable->get_value();
708 if (controllable->get_value() < 1e-15) {
711 db = accurate_coefficient_to_dB (controllable->get_value());
716 path = "/select/send_fader";
717 value = controllable->internal_to_interface (controllable->get_value());
718 text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
719 if (send_timeout.size() > id) {
720 send_timeout[id] = 8;
723 path = "/select/send_gain";
728 path = set_path (path, id);
730 lo_message_add_int32 (msg, id);
733 lo_message_add_float (msg, value);
734 lo_send_message (addr, path.c_str(), msg);
735 lo_message_free (msg);
739 OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
741 // with no delay value is wrong
744 send_float_with_id ("/select/send_enable", id, proc->enabled());
748 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
750 lo_message msg = lo_message_new ();
752 path = set_path (path, id);
754 lo_message_add_int32 (msg, id);
757 lo_message_add_string (msg, name.c_str());
759 lo_send_message (addr, path.c_str(), msg);
760 lo_message_free (msg);
764 OSCSelectObserver::comp_mode ()
766 change_message ("/select/comp_mode", _strip->comp_mode_controllable());
767 text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
768 text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
772 OSCSelectObserver::eq_init()
774 // HPF and enable are special case, rest are in bands
775 if (_strip->filter_enable_controllable (true)) {
776 _strip->filter_enable_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/enable"), _strip->filter_enable_controllable (true)), OSC::instance());
777 change_message ("/select/eq_hpf/enable", _strip->filter_enable_controllable(true));
780 if (_strip->filter_enable_controllable (false)) {
781 _strip->filter_enable_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/enable"), _strip->filter_enable_controllable (false)), OSC::instance());
782 change_message ("/select/eq_lpf/enable", _strip->filter_enable_controllable(false));
785 if (_strip->filter_freq_controllable (true)) {
786 _strip->filter_freq_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/freq"), _strip->filter_freq_controllable (true)), OSC::instance());
787 change_message ("/select/eq_hpf/freq", _strip->filter_freq_controllable(true));
790 if (_strip->filter_freq_controllable (false)) {
791 _strip->filter_freq_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/freq"), _strip->filter_freq_controllable (false)), OSC::instance());
792 change_message ("/select/eq_lpf/freq", _strip->filter_freq_controllable(false));
795 if (_strip->filter_slope_controllable (true)) {
796 _strip->filter_slope_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf/slope"), _strip->filter_slope_controllable (true)), OSC::instance());
797 change_message ("/select/eq_hpf/slope", _strip->filter_slope_controllable(true));
800 if (_strip->filter_slope_controllable (false)) {
801 _strip->filter_slope_controllable (false)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_lpf/slope"), _strip->filter_slope_controllable (false)), OSC::instance());
802 change_message ("/select/eq_lpf/slope", _strip->filter_slope_controllable(false));
805 if (_strip->eq_enable_controllable ()) {
806 _strip->eq_enable_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/eq_enable"), _strip->eq_enable_controllable()), OSC::instance());
807 enable_message ("/select/eq_enable", _strip->eq_enable_controllable());
810 uint32_t eq_bands = _strip->eq_band_cnt ();
815 for (uint32_t i = 0; i < eq_bands; i++) {
816 if (_strip->eq_band_name(i).size()) {
817 text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
819 if (_strip->eq_gain_controllable (i)) {
820 _strip->eq_gain_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_gain"), i + 1, _strip->eq_gain_controllable(i)), OSC::instance());
821 change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
823 if (_strip->eq_freq_controllable (i)) {
824 _strip->eq_freq_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_freq"), i + 1, _strip->eq_freq_controllable(i)), OSC::instance());
825 change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
827 if (_strip->eq_q_controllable (i)) {
828 _strip->eq_q_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_q"), i + 1, _strip->eq_q_controllable(i)), OSC::instance());
829 change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
831 if (_strip->eq_shape_controllable (i)) {
832 _strip->eq_shape_controllable(i)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message_with_id, this, X_("/select/eq_shape"), i + 1, _strip->eq_shape_controllable(i)), OSC::instance());
833 change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
839 OSCSelectObserver::eq_end ()
841 //need to check feedback for [13]
842 eq_connections.drop_connections ();
843 if (_strip->filter_freq_controllable (true)) {
844 send_float ("/select/eq_hpf", 0);
846 if (_strip->eq_enable_controllable ()) {
847 send_float ("/select/eq_enable", 0);
850 for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
851 text_with_id ("/select/eq_band_name", i, " ");
852 send_float_with_id ("/select/eq_gain", i, 0);
853 send_float_with_id ("/select/eq_freq", i, 0);
854 send_float_with_id ("/select/eq_q", i, 0);
855 send_float_with_id ("/select/eq_shape", i, 0);
862 OSCSelectObserver::eq_restart(int x)
869 OSCSelectObserver::set_path (string path, uint32_t id)
872 path = string_compose ("%1/%2", path, id);
878 OSCSelectObserver::send_float (string path, float val)
880 lo_message msg = lo_message_new ();
881 lo_message_add_float (msg, val);
883 lo_send_message (addr, path.c_str(), msg);
884 lo_message_free (msg);
889 OSCSelectObserver::send_float_with_id (string path, uint32_t id, float val)
891 lo_message msg = lo_message_new ();
893 path = set_path (path, id);
895 lo_message_add_int32 (msg, id);
898 lo_message_add_float (msg, val);
900 lo_send_message (addr, path.c_str(), msg);
901 lo_message_free (msg);