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)
59 addr = lo_address_new_from_url (sur->remote_url.c_str());
60 gainmode = sur->gainmode;
61 feedback = sur->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());
110 _strip->gain_control()->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_automation, this), OSC::instance());
111 _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
114 boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
115 if (trim_controllable) {
116 trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
117 trim_message ("/select/trimdB", _strip->trim_control());
120 boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
121 if (pan_controllable) {
122 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());
123 change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
126 boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
127 if (width_controllable) {
128 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());
129 change_message ("/select/pan_stereo_width", _strip->pan_width_control());
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());
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());
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_control"), _strip->pan_lfe_control()), OSC::instance());
143 change_message ("/select/pan_lfe_control", _strip->pan_lfe_control());
146 // sends, plugins and eq
147 // detecting processor changes is now in osc.cc
149 // but... MB master send enable is different
150 if (_strip->master_send_enable_controllable ()) {
151 _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());
152 enable_message ("/select/master_send_enable", _strip->master_send_enable_controllable());
156 if (_strip->comp_enable_controllable ()) {
157 _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());
158 enable_message ("/select/comp_enable", _strip->comp_enable_controllable());
160 if (_strip->comp_threshold_controllable ()) {
161 _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());
162 change_message ("/select/comp_threshold", _strip->comp_threshold_controllable());
164 if (_strip->comp_speed_controllable ()) {
165 _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());
166 change_message ("/select/comp_speed", _strip->comp_speed_controllable());
168 if (_strip->comp_mode_controllable ()) {
169 _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
172 if (_strip->comp_makeup_controllable ()) {
173 _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());
174 change_message ("/select/comp_makeup", _strip->comp_makeup_controllable());
182 OSCSelectObserver::~OSCSelectObserver ()
185 strip_connections.drop_connections ();
186 // all strip buttons should be off and faders 0 and etc.
187 send_float ("/select/expand", 0);
188 text_message ("/select/name", " ");
189 text_message ("/select/comment", " ");
190 send_float ("/select/mute", 0);
191 send_float ("/select/solo", 0);
192 send_float ("/select/recenable", 0);
193 send_float ("/select/record_safe", 0);
194 send_float ("/select/monitor_input", 0);
195 send_float ("/select/monitor_disk", 0);
196 send_float ("/select/polarity", 0);
197 send_float ("/select/n_inputs", 0);
198 send_float ("/select/n_outputs", 0);
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);
208 send_float ("/select/signal", 0);
212 send_float ("/select/meter", 0);
214 send_float ("/select/meter", -193);
216 }else if (feedback[8]) {
217 send_float ("/select/meter", 0);
219 send_float ("/select/pan_elevation_position", 0);
220 send_float ("/select/pan_frontback_position", .5);
221 send_float ("/select/pan_lfe_control", 0);
222 send_float ("/select/comp_enable", 0);
223 send_float ("/select/comp_threshold", 0);
224 send_float ("/select/comp_speed", 0);
225 send_float ("/select/comp_mode", 0);
226 text_message ("/select/comp_mode_name", " ");
227 text_message ("/select/comp_speed_name", " ");
228 send_float ("/select/comp_makeup", 0);
233 lo_address_free (addr);
237 OSCSelectObserver::renew_sends () {
243 OSCSelectObserver::renew_plugin () {
249 OSCSelectObserver::send_init()
251 // we don't know how many there are, so find out.
256 if (_strip->send_level_controllable (nsends)) {
265 // paging should be done in osc.cc in case there is no feedback
267 if (sur->send_page_size) {
268 send_size = sur->send_page_size;
271 uint32_t max_page = (uint32_t)(nsends / send_size) + 1;
272 if (sur->send_page < 1) {
274 } else if ((uint32_t)sur->send_page > max_page) {
275 sur->send_page = max_page;
277 uint32_t page_start = ((sur->send_page - 1) * send_size);
278 uint32_t last_send = sur->send_page * send_size;
280 send_timeout.push_back (2);
282 for (uint32_t s = page_start; s < last_send; ++s, ++c) {
284 bool send_valid = false;
285 if (_strip->send_level_controllable (s)) {
286 _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());
287 send_timeout.push_back (2);
288 send_gain (c, _strip->send_level_controllable(s));
292 if (_strip->send_enable_controllable (s)) {
293 _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());
294 enable_message_with_id ("/select/send_enable", c, _strip->send_enable_controllable(s));
295 } else if (send_valid) {
296 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
298 // should never get here
299 send_float_with_id ("/select/send_enable", c, 0);
301 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(s));
303 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
304 proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), c, proc), OSC::instance());
305 send_float_with_id ("/select/send_enable", c, proc->enabled());
308 if (!gainmode && send_valid) {
309 text_with_id ("/select/send_name", c, _strip->send_name(s));
315 OSCSelectObserver::plugin_init()
317 if (!sur->plugin_id) {
321 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
326 // we have a plugin number now get the processor
327 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
328 boost::shared_ptr<PluginInsert> pi;
329 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
332 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
335 nplug_params = sur->plug_params.size ();
337 // default of 0 page size means show all
338 plug_size = nplug_params;
339 if (sur->plug_page_size) {
340 plug_size = sur->plug_page_size;
342 text_message ("/select/plugin/name", pip->name());
343 uint32_t page_end = nplug_params;
344 uint32_t max_page = 1;
345 if (plug_size && nplug_params) {
346 max_page = (uint32_t)((nplug_params - 1) / plug_size) + 1;
349 if (sur->plug_page < 1) {
352 if ((uint32_t)sur->plug_page > max_page) {
353 sur->plug_page = max_page;
355 uint32_t page_start = ((sur->plug_page - 1) * plug_size);
356 page_end = sur->plug_page * plug_size;
359 for ( uint32_t ppi = page_start; ppi < page_end; ++ppi, ++pid) {
360 if (ppi >= nplug_params) {
361 text_with_id ("/select/plugin/parameter/name", pid, " ");
362 send_float_with_id ("/select/plugin/parameter", pid, 0);
366 uint32_t controlid = pip->nth_parameter(sur->plug_params[ppi], ok);
370 ParameterDescriptor pd;
371 pip->get_parameter_descriptor(controlid, pd);
372 text_with_id ("/select/plugin/parameter/name", pid, pd.label);
373 if ( pip->parameter_is_input(controlid)) {
374 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
377 if (pd.integer_step && pd.upper == 1) {
380 c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
381 plugin_parameter_changed (pid, swtch, c);
388 OSCSelectObserver::send_end ()
390 send_connections.drop_connections ();
391 for (uint32_t i = 1; i <= send_size; i++) {
393 send_float_with_id ("/select/send_fader", i, 0);
395 send_float_with_id ("/select/send_gain", i, -193);
398 send_float_with_id ("/select/send_enable", i, 0);
400 text_with_id ("/select/send_name", i, " ");
402 // need to delete or clear send_timeout
403 send_timeout.clear();
408 OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
411 enable_message_with_id ("/select/plugin/parameter", pid, controllable);
413 change_message_with_id ("/select/plugin/parameter", pid, controllable);
418 OSCSelectObserver::plugin_end ()
420 plugin_connections.drop_connections ();
421 text_message ("/select/plugin/name", " ");
422 for (uint32_t i = 1; i <= plug_size; i++) {
423 send_float_with_id ("/select/plugin/parameter", i, 0);
425 text_with_id ("/select/plugin/parameter/name", i, " ");
431 OSCSelectObserver::tick ()
436 if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
438 if (_strip->peak_meter()) {
439 now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
443 if (now_meter < -144) now_meter = -193;
444 if (_last_meter != now_meter) {
445 if (feedback[7] || feedback[8]) {
446 string path = "/select/meter";
447 lo_message msg = lo_message_new ();
448 if (gainmode && feedback[7]) {
449 lo_message_add_float (msg, ((now_meter + 94) / 100));
450 lo_send_message (addr, path.c_str(), msg);
451 } else if ((!gainmode) && feedback[7]) {
452 lo_message_add_float (msg, now_meter);
453 lo_send_message (addr, path.c_str(), msg);
454 } else if (feedback[8]) {
455 uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
456 uint16_t ledbits = ~(0xfff<<ledlvl);
457 lo_message_add_int32 (msg, ledbits);
458 lo_send_message (addr, path.c_str(), msg);
460 lo_message_free (msg);
463 string path = "/select/signal";
464 lo_message msg = lo_message_new ();
466 if (now_meter < -40) {
471 lo_message_add_float (msg, signal);
472 lo_send_message (addr, path.c_str(), msg);
473 lo_message_free (msg);
476 _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();
492 if (_strip->comp_redux_controllable() && _strip->comp_enable_controllable() && _strip->comp_enable_controllable()->get_value()) {
493 float new_value = _strip->comp_redux_controllable()->get_parameter();
494 if (_comp_redux != new_value) {
495 send_float ("/select/comp_redux", new_value);
496 _comp_redux = new_value;
499 for (uint32_t i = 1; i <= send_timeout.size(); i++) {
500 if (send_timeout[i]) {
501 if (send_timeout[i] == 1) {
502 uint32_t pg_offset = (sur->send_page - 1) * sur->send_page_size;
503 text_with_id ("/select/send_name", i, _strip->send_name(pg_offset + i - 1));
511 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
513 if (!what_changed.contains (ARDOUR::Properties::name)) {
521 text_message ("/select/name", _strip->name());
522 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
524 //spit out the comment at the same time
525 text_message ("/select/comment", route->comment());
526 // lets tell the surface how many inputs this strip has
527 send_float ("/select/n_inputs", (float) route->n_inputs().n_total());
528 // lets tell the surface how many outputs this strip has
529 send_float ("/select/n_outputs", (float) route->n_outputs().n_total());
534 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
536 lo_message msg = lo_message_new ();
537 float val = controllable->get_value();
539 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
541 lo_send_message (addr, path.c_str(), msg);
542 lo_message_free (msg);
546 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
548 float val = controllable->get_value();
550 send_float (path, 1);
552 send_float (path, 0);
558 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
560 lo_message msg = lo_message_new ();
561 float val = controllable->get_value();
563 path = set_path (path, id);
565 lo_message_add_int32 (msg, id);
568 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
570 lo_send_message (addr, path.c_str(), msg);
571 lo_message_free (msg);
575 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
577 float val = controllable->get_value();
579 send_float_with_id (path, id, 1);
581 send_float_with_id (path, id, 0);
586 OSCSelectObserver::text_message (string path, std::string text)
588 lo_message msg = lo_message_new ();
590 lo_message_add_string (msg, text.c_str());
592 lo_send_message (addr, path.c_str(), msg);
593 lo_message_free (msg);
597 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
600 float val = controllable->get_value();
615 send_float ("/select/monitor_input", (float) input);
616 send_float ("/select/monitor_disk", (float) disk);
620 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
622 lo_message msg = lo_message_new ();
624 lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
626 lo_send_message (addr, path.c_str(), msg);
627 lo_message_free (msg);
631 OSCSelectObserver::gain_message ()
633 float value = _strip->gain_control()->get_value();
636 text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
638 send_float ("/select/fader", _strip->gain_control()->internal_to_interface (value));
641 send_float ("/select/gain", -200);
643 send_float ("/select/gain", accurate_coefficient_to_dB (value));
649 OSCSelectObserver::gain_automation ()
652 as = _strip->gain_control()->alist()->automation_state();
657 auto_name = "Manual";
676 send_float ("/select/fader/automation", output);
677 text_message ("/select/fader/automation_name", auto_name);
679 send_float ("/select/gain/automation", output);
680 text_message ("/select/gain/automation_name", auto_name);
687 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
689 lo_message msg = lo_message_new ();
694 db = controllable->get_value();
696 if (controllable->get_value() < 1e-15) {
699 db = accurate_coefficient_to_dB (controllable->get_value());
704 path = "/select/send_fader";
705 value = controllable->internal_to_interface (controllable->get_value());
706 text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
707 if (send_timeout.size() > id) {
708 send_timeout[id] = 8;
711 path = "/select/send_gain";
716 path = set_path (path, id);
718 lo_message_add_int32 (msg, id);
721 lo_message_add_float (msg, value);
722 lo_send_message (addr, path.c_str(), msg);
723 lo_message_free (msg);
727 OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
729 // with no delay value is wrong
732 send_float_with_id ("/select/send_enable", id, proc->enabled());
736 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
738 lo_message msg = lo_message_new ();
740 path = set_path (path, id);
742 lo_message_add_int32 (msg, id);
745 lo_message_add_string (msg, name.c_str());
747 lo_send_message (addr, path.c_str(), msg);
748 lo_message_free (msg);
752 OSCSelectObserver::comp_mode ()
754 change_message ("/select/comp_mode", _strip->comp_mode_controllable());
755 text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
756 text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
760 OSCSelectObserver::eq_init()
762 // HPF and enable are special case, rest are in bands
763 if (_strip->filter_enable_controllable (true)) {
764 _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());
765 change_message ("/select/eq_hpf/enable", _strip->filter_enable_controllable(true));
768 if (_strip->filter_enable_controllable (false)) {
769 _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());
770 change_message ("/select/eq_lpf/enable", _strip->filter_enable_controllable(false));
773 if (_strip->filter_freq_controllable (true)) {
774 _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());
775 change_message ("/select/eq_hpf/freq", _strip->filter_freq_controllable(true));
778 if (_strip->filter_freq_controllable (false)) {
779 _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());
780 change_message ("/select/eq_lpf/freq", _strip->filter_freq_controllable(false));
783 if (_strip->filter_slope_controllable (true)) {
784 _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());
785 change_message ("/select/eq_hpf/slope", _strip->filter_slope_controllable(true));
788 if (_strip->filter_slope_controllable (false)) {
789 _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());
790 change_message ("/select/eq_lpf/slope", _strip->filter_slope_controllable(false));
793 if (_strip->eq_enable_controllable ()) {
794 _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());
795 enable_message ("/select/eq_enable", _strip->eq_enable_controllable());
798 uint32_t eq_bands = _strip->eq_band_cnt ();
803 for (uint32_t i = 0; i < eq_bands; i++) {
804 if (_strip->eq_band_name(i).size()) {
805 text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
807 if (_strip->eq_gain_controllable (i)) {
808 _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());
809 change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
811 if (_strip->eq_freq_controllable (i)) {
812 _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());
813 change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
815 if (_strip->eq_q_controllable (i)) {
816 _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());
817 change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
819 if (_strip->eq_shape_controllable (i)) {
820 _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());
821 change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
827 OSCSelectObserver::eq_end ()
829 eq_connections.drop_connections ();
830 if (_strip->filter_freq_controllable (true)) {
831 send_float ("/select/eq_hpf", 0);
833 if (_strip->eq_enable_controllable ()) {
834 send_float ("/select/eq_enable", 0);
837 for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
838 text_with_id ("/select/eq_band_name", i, " ");
839 send_float_with_id ("/select/eq_gain", i, 0);
840 send_float_with_id ("/select/eq_freq", i, 0);
841 send_float_with_id ("/select/eq_q", i, 0);
842 send_float_with_id ("/select/eq_shape", i, 0);
849 OSCSelectObserver::eq_restart(int x)
856 OSCSelectObserver::set_path (string path, uint32_t id)
859 path = string_compose ("%1/%2", path, id);
865 OSCSelectObserver::send_float (string path, float val)
867 lo_message msg = lo_message_new ();
868 lo_message_add_float (msg, val);
870 lo_send_message (addr, path.c_str(), msg);
871 lo_message_free (msg);
876 OSCSelectObserver::send_float_with_id (string path, uint32_t id, float val)
878 lo_message msg = lo_message_new ();
880 path = set_path (path, id);
882 lo_message_add_int32 (msg, id);
885 lo_message_add_float (msg, val);
887 lo_send_message (addr, path.c_str(), msg);
888 lo_message_free (msg);