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;
65 if (feedback[0]) { // buttons are separate feedback
66 _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
67 name_changed (ARDOUR::Properties::name);
69 _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
70 change_message ("/select/mute", _strip->mute_control());
72 _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
73 change_message ("/select/solo", _strip->solo_control());
75 if (_strip->solo_isolate_control()) {
76 _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());
77 change_message ("/select/solo_iso", _strip->solo_isolate_control());
80 if (_strip->solo_safe_control()) {
81 _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());
82 change_message ("/select/solo_safe", _strip->solo_safe_control());
85 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
87 track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
88 monitor_status (track->monitoring_control());
91 boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
92 if (rec_controllable) {
93 rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
94 change_message ("/select/recenable", _strip->rec_enable_control());
97 boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
98 if (recsafe_controllable) {
99 recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
100 change_message ("/select/record_safe", _strip->rec_safe_control());
103 boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
104 if (phase_controllable) {
105 phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
106 change_message ("/select/polarity", _strip->phase_control());
111 if (feedback[1]) { // level controls
112 _strip->gain_control()->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_automation, this), OSC::instance());
113 _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
116 boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
117 if (trim_controllable) {
118 trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
119 trim_message ("/select/trimdB", _strip->trim_control());
122 boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
123 if (pan_controllable) {
124 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());
125 change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
128 boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
129 if (width_controllable) {
130 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());
131 change_message ("/select/pan_stereo_width", _strip->pan_width_control());
135 if (feedback[13]) { // Well known controls
136 // Rest of possible pan controls... Untested because I can't find a way to get them in the GUI :)
137 if (_strip->pan_elevation_control ()) {
138 _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());
139 change_message ("/select/pan_elevation_position", _strip->pan_elevation_control());
141 if (_strip->pan_frontback_control ()) {
142 _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());
143 change_message ("/select/pan_frontback_position", _strip->pan_frontback_control());
145 if (_strip->pan_lfe_control ()) {
146 _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());
147 change_message ("/select/pan_lfe_control", _strip->pan_lfe_control());
150 // sends, plugins and eq
151 // detecting processor changes is now in osc.cc
154 if (_strip->comp_enable_controllable ()) {
155 _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());
156 enable_message ("/select/comp_enable", _strip->comp_enable_controllable());
158 if (_strip->comp_threshold_controllable ()) {
159 _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());
160 change_message ("/select/comp_threshold", _strip->comp_threshold_controllable());
162 if (_strip->comp_speed_controllable ()) {
163 _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());
164 change_message ("/select/comp_speed", _strip->comp_speed_controllable());
166 if (_strip->comp_mode_controllable ()) {
167 _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
170 if (_strip->comp_makeup_controllable ()) {
171 _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());
172 change_message ("/select/comp_makeup", _strip->comp_makeup_controllable());
180 OSCSelectObserver::~OSCSelectObserver ()
182 strip_connections.drop_connections ();
183 // all strip buttons should be off and faders 0 and etc.
184 if (feedback[0]) { // buttons are separate feedback
185 send_float ("/select/expand", 0);
186 text_message ("/select/name", " ");
187 text_message ("/select/comment", " ");
188 send_float ("/select/mute", 0);
189 send_float ("/select/solo", 0);
190 send_float ("/select/recenable", 0);
191 send_float ("/select/record_safe", 0);
192 send_float ("/select/monitor_input", 0);
193 send_float ("/select/monitor_disk", 0);
194 send_float ("/select/polarity", 0);
195 send_float ("/select/n_inputs", 0);
196 send_float ("/select/n_outputs", 0);
198 if (feedback[1]) { // level controls
200 send_float ("/select/fader", 0);
202 send_float ("/select/gain", -193);
204 send_float ("/select/trimdB", 0);
205 send_float ("/select/pan_stereo_position", 0.5);
206 send_float ("/select/pan_stereo_width", 1);
209 send_float ("/select/signal", 0);
213 send_float ("/select/meter", 0);
215 send_float ("/select/meter", -193);
217 }else if (feedback[8]) {
218 send_float ("/select/meter", 0);
220 if (feedback[13]) { // Well known controls
221 send_float ("/select/pan_elevation_position", 0);
222 send_float ("/select/pan_frontback_position", .5);
223 send_float ("/select/pan_lfe_control", 0);
224 send_float ("/select/comp_enable", 0);
225 send_float ("/select/comp_threshold", 0);
226 send_float ("/select/comp_speed", 0);
227 send_float ("/select/comp_mode", 0);
228 text_message ("/select/comp_mode_name", " ");
229 text_message ("/select/comp_speed_name", " ");
230 send_float ("/select/comp_makeup", 0);
236 lo_address_free (addr);
240 OSCSelectObserver::renew_sends () {
246 OSCSelectObserver::renew_plugin () {
252 OSCSelectObserver::send_init()
254 // we don't know how many there are, so find out.
259 if (_strip->send_level_controllable (nsends)) {
268 // paging should be done in osc.cc in case there is no feedback
270 if (sur->send_page_size) {
271 send_size = sur->send_page_size;
274 uint32_t max_page = (uint32_t)(nsends / send_size) + 1;
275 if (sur->send_page < 1) {
277 } else if ((uint32_t)sur->send_page > max_page) {
278 sur->send_page = max_page;
280 uint32_t page_start = ((sur->send_page - 1) * send_size);
281 uint32_t last_send = sur->send_page * send_size;
284 for (uint32_t s = page_start; s < last_send; ++s, ++c) {
286 bool send_valid = false;
287 if (_strip->send_level_controllable (s)) {
288 _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());
289 send_timeout.push_back (0);
290 send_gain (c, _strip->send_level_controllable(s));
294 if (_strip->send_enable_controllable (s)) {
295 _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());
296 enable_message_with_id ("/select/send_enable", c, _strip->send_enable_controllable(s));
297 } else if (send_valid) {
298 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
300 // should never get here
301 send_float_with_id ("/select/send_enable", c, 0);
303 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(s));
305 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
306 proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), c, proc), OSC::instance());
307 send_float_with_id ("/select/send_enable", c, proc->enabled());
310 if (!gainmode && send_valid) {
311 text_with_id ("/select/send_name", c, _strip->send_name(s));
317 OSCSelectObserver::plugin_init()
319 if (!sur->plugin_id) {
323 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
328 // we have a plugin number now get the processor
329 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugin_id - 1);
330 boost::shared_ptr<PluginInsert> pi;
331 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
334 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
337 nplug_params = sur->plug_params.size ();
339 // default of 0 page size means show all
340 plug_size = nplug_params;
341 if (sur->plug_page_size) {
342 plug_size = sur->plug_page_size;
344 text_message ("/select/plugin/name", pip->name());
345 uint32_t page_end = nplug_params;
346 uint32_t max_page = 1;
347 if (plug_size && nplug_params) {
348 max_page = (uint32_t)((nplug_params - 1) / plug_size) + 1;
351 if (sur->plug_page < 1) {
354 if ((uint32_t)sur->plug_page > max_page) {
355 sur->plug_page = max_page;
357 uint32_t page_start = ((sur->plug_page - 1) * plug_size);
358 page_end = sur->plug_page * plug_size;
361 for ( uint32_t ppi = page_start; ppi < page_end; ++ppi, ++pid) {
362 if (ppi >= nplug_params) {
363 text_with_id ("/select/plugin/parameter/name", pid, " ");
364 send_float_with_id ("/select/plugin/parameter", pid, 0);
368 uint32_t controlid = pip->nth_parameter(sur->plug_params[ppi], ok);
372 ParameterDescriptor pd;
373 pip->get_parameter_descriptor(controlid, pd);
374 text_with_id ("/select/plugin/parameter/name", pid, pd.label);
375 if ( pip->parameter_is_input(controlid)) {
376 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
379 if (pd.integer_step && pd.upper == 1) {
382 c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
383 plugin_parameter_changed (pid, swtch, c);
390 OSCSelectObserver::send_end ()
392 send_connections.drop_connections ();
393 for (uint32_t i = 1; i <= send_size; i++) {
395 send_float_with_id ("/select/send_fader", i, 0);
397 send_float_with_id ("/select/send_gain", i, -193);
400 send_float_with_id ("/select/send_enable", i, 0);
402 text_with_id ("/select/send_name", i, " ");
404 // need to delete or clear send_timeout
405 send_timeout.clear();
410 OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
413 enable_message_with_id ("/select/plugin/parameter", pid, controllable);
415 change_message_with_id ("/select/plugin/parameter", pid, controllable);
420 OSCSelectObserver::plugin_end ()
422 plugin_connections.drop_connections ();
423 text_message ("/select/plugin/name", " ");
424 for (uint32_t i = 1; i <= plug_size; i++) {
425 send_float_with_id ("/select/plugin/parameter", i, 0);
427 text_with_id ("/select/plugin/parameter/name", i, " ");
433 OSCSelectObserver::tick ()
435 if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
437 if (_strip->peak_meter()) {
438 now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
442 if (now_meter < -144) now_meter = -193;
443 if (_last_meter != now_meter) {
444 if (feedback[7] || feedback[8]) {
445 string path = "/select/meter";
446 lo_message msg = lo_message_new ();
447 if (gainmode && feedback[7]) {
448 lo_message_add_float (msg, ((now_meter + 94) / 100));
449 lo_send_message (addr, path.c_str(), msg);
450 } else if ((!gainmode) && feedback[7]) {
451 lo_message_add_float (msg, now_meter);
452 lo_send_message (addr, path.c_str(), msg);
453 } else if (feedback[8]) {
454 uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
455 uint16_t ledbits = ~(0xfff<<ledlvl);
456 lo_message_add_int32 (msg, ledbits);
457 lo_send_message (addr, path.c_str(), msg);
459 lo_message_free (msg);
462 string path = "/select/signal";
463 lo_message msg = lo_message_new ();
465 if (now_meter < -40) {
470 lo_message_add_float (msg, signal);
471 lo_send_message (addr, path.c_str(), msg);
472 lo_message_free (msg);
475 _last_meter = now_meter;
480 if (gain_timeout == 1) {
481 text_message ("/select/name", _strip->name());
486 if (as == ARDOUR::Play || as == ARDOUR::Touch) {
487 if(_last_gain != _strip->gain_control()->get_value()) {
488 _last_gain = _strip->gain_control()->get_value();
494 if (_strip->comp_redux_controllable()) {
495 if (_strip->comp_redux_controllable()->get_parameter()) {
496 send_float ("/select/comp_redux", (float) _strip->comp_redux_controllable()->get_parameter ());
499 for (uint32_t i = 0; i < send_timeout.size(); i++) {
500 if (send_timeout[i]) {
501 if (send_timeout[i] == 1) {
502 text_with_id ("/select/send_name", i + 1, _strip->send_name(i));
512 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
514 if (!what_changed.contains (ARDOUR::Properties::name)) {
522 text_message ("/select/name", _strip->name());
523 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
525 //spit out the comment at the same time
526 text_message ("/select/comment", route->comment());
527 // lets tell the surface how many inputs this strip has
528 send_float ("/select/n_inputs", (float) route->n_inputs().n_total());
529 // lets tell the surface how many outputs this strip has
530 send_float ("/select/n_outputs", (float) route->n_outputs().n_total());
535 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
537 lo_message msg = lo_message_new ();
538 float val = controllable->get_value();
540 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
542 lo_send_message (addr, path.c_str(), msg);
543 lo_message_free (msg);
547 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
549 float val = controllable->get_value();
551 send_float (path, 1);
553 send_float (path, 0);
559 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
561 lo_message msg = lo_message_new ();
562 float val = controllable->get_value();
564 path = set_path (path, id);
566 lo_message_add_int32 (msg, id);
569 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
571 lo_send_message (addr, path.c_str(), msg);
572 lo_message_free (msg);
576 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
578 float val = controllable->get_value();
580 send_float_with_id (path, id, 1);
582 send_float_with_id (path, id, 0);
587 OSCSelectObserver::text_message (string path, std::string text)
589 lo_message msg = lo_message_new ();
591 lo_message_add_string (msg, text.c_str());
593 lo_send_message (addr, path.c_str(), msg);
594 lo_message_free (msg);
598 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
601 float val = controllable->get_value();
616 send_float ("/select/monitor_input", (float) input);
617 send_float ("/select/monitor_disk", (float) disk);
621 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
623 lo_message msg = lo_message_new ();
625 lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
627 lo_send_message (addr, path.c_str(), msg);
628 lo_message_free (msg);
632 OSCSelectObserver::gain_message ()
634 float value = _strip->gain_control()->get_value();
637 text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
639 send_float ("/select/fader", gain_to_position (value)); // XXX use internal_to_interface
642 send_float ("/select/gain", -200);
644 send_float ("/select/gain", accurate_coefficient_to_dB (value));
650 OSCSelectObserver::gain_automation ()
653 as = _strip->gain_control()->alist()->automation_state();
658 auto_name = "Manual";
677 send_float ("/select/fader/automation", output);
678 text_message ("/select/fader/automation_name", auto_name);
680 send_float ("/select/gain/automation", output);
681 text_message ("/select/gain/automation_name", auto_name);
688 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
690 lo_message msg = lo_message_new ();
695 db = controllable->get_value();
697 if (controllable->get_value() < 1e-15) {
700 db = accurate_coefficient_to_dB (controllable->get_value());
705 path = "/select/send_fader";
707 value = controllable->internal_to_interface (controllable->get_value());
709 value = gain_to_position (controllable->get_value()); // XXX use internal_to_interface
711 text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
712 if (send_timeout.size() > id) {
713 send_timeout[id] = 8;
716 path = "/select/send_gain";
721 path = set_path (path, id);
723 lo_message_add_int32 (msg, id);
726 lo_message_add_float (msg, value);
727 lo_send_message (addr, path.c_str(), msg);
728 lo_message_free (msg);
732 OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
734 // with no delay value is wrong
737 send_float_with_id ("/select/send_enable", id, proc->enabled());
741 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
743 lo_message msg = lo_message_new ();
745 path = set_path (path, id);
747 lo_message_add_int32 (msg, id);
750 lo_message_add_string (msg, name.c_str());
752 lo_send_message (addr, path.c_str(), msg);
753 lo_message_free (msg);
757 OSCSelectObserver::comp_mode ()
759 change_message ("/select/comp_mode", _strip->comp_mode_controllable());
760 text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
761 text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
765 OSCSelectObserver::eq_init()
767 // HPF and enable are special case, rest are in bands
768 if (_strip->filter_enable_controllable (true)) {
769 _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());
770 change_message ("/select/eq_hpf/enable", _strip->filter_enable_controllable(true));
773 if (_strip->filter_enable_controllable (false)) {
774 _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());
775 change_message ("/select/eq_lpf/enable", _strip->filter_enable_controllable(false));
778 if (_strip->filter_freq_controllable (true)) {
779 _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());
780 change_message ("/select/eq_hpf/freq", _strip->filter_freq_controllable(true));
783 if (_strip->filter_freq_controllable (false)) {
784 _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());
785 change_message ("/select/eq_lpf/freq", _strip->filter_freq_controllable(false));
788 if (_strip->filter_slope_controllable (true)) {
789 _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());
790 change_message ("/select/eq_hpf/slope", _strip->filter_slope_controllable(true));
793 if (_strip->filter_slope_controllable (false)) {
794 _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());
795 change_message ("/select/eq_lpf/slope", _strip->filter_slope_controllable(false));
798 if (_strip->eq_enable_controllable ()) {
799 _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());
800 enable_message ("/select/eq_enable", _strip->eq_enable_controllable());
803 uint32_t eq_bands = _strip->eq_band_cnt ();
808 for (uint32_t i = 0; i < eq_bands; i++) {
809 if (_strip->eq_band_name(i).size()) {
810 text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
812 if (_strip->eq_gain_controllable (i)) {
813 _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());
814 change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
816 if (_strip->eq_freq_controllable (i)) {
817 _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());
818 change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
820 if (_strip->eq_q_controllable (i)) {
821 _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());
822 change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
824 if (_strip->eq_shape_controllable (i)) {
825 _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());
826 change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
832 OSCSelectObserver::eq_end ()
834 //need to check feedback for [13]
835 eq_connections.drop_connections ();
836 if (_strip->filter_freq_controllable (true)) {
837 send_float ("/select/eq_hpf", 0);
839 if (_strip->eq_enable_controllable ()) {
840 send_float ("/select/eq_enable", 0);
843 for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
844 text_with_id ("/select/eq_band_name", i, " ");
845 send_float_with_id ("/select/eq_gain", i, 0);
846 send_float_with_id ("/select/eq_freq", i, 0);
847 send_float_with_id ("/select/eq_q", i, 0);
848 send_float_with_id ("/select/eq_shape", i, 0);
855 OSCSelectObserver::eq_restart(int x)
862 OSCSelectObserver::set_path (string path, uint32_t id)
865 path = string_compose ("%1/%2", path, id);
871 OSCSelectObserver::send_float (string path, float val)
873 lo_message msg = lo_message_new ();
874 lo_message_add_float (msg, val);
876 lo_send_message (addr, path.c_str(), msg);
877 lo_message_free (msg);
882 OSCSelectObserver::send_float_with_id (string path, uint32_t id, float val)
884 lo_message msg = lo_message_new ();
886 path = set_path (path, id);
888 lo_message_add_int32 (msg, id);
891 lo_message_add_float (msg, val);
893 lo_send_message (addr, path.c_str(), msg);
894 lo_message_free (msg);