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)
60 addr = lo_address_new_from_url (sur->remote_url.c_str());
61 gainmode = sur->gainmode;
62 feedback = sur->feedback;
68 _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::name_changed, this, boost::lambda::_1), OSC::instance());
69 name_changed (ARDOUR::Properties::name);
71 _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/mute"), _strip->mute_control()), OSC::instance());
72 change_message ("/select/mute", _strip->mute_control());
74 _strip->solo_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/solo"), _strip->solo_control()), OSC::instance());
75 change_message ("/select/solo", _strip->solo_control());
77 if (_strip->solo_isolate_control()) {
78 _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());
79 change_message ("/select/solo_iso", _strip->solo_isolate_control());
82 if (_strip->solo_safe_control()) {
83 _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());
84 change_message ("/select/solo_safe", _strip->solo_safe_control());
87 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (_strip);
89 track->monitoring_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::monitor_status, this, track->monitoring_control()), OSC::instance());
90 monitor_status (track->monitoring_control());
93 boost::shared_ptr<AutomationControl> rec_controllable = _strip->rec_enable_control ();
94 if (rec_controllable) {
95 rec_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/recenable"), _strip->rec_enable_control()), OSC::instance());
96 change_message ("/select/recenable", _strip->rec_enable_control());
99 boost::shared_ptr<AutomationControl> recsafe_controllable = _strip->rec_safe_control ();
100 if (recsafe_controllable) {
101 recsafe_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/record_safe"), _strip->rec_safe_control()), OSC::instance());
102 change_message ("/select/record_safe", _strip->rec_safe_control());
105 boost::shared_ptr<AutomationControl> phase_controllable = _strip->phase_control ();
106 if (phase_controllable) {
107 phase_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/polarity"), _strip->phase_control()), OSC::instance());
108 change_message ("/select/polarity", _strip->phase_control());
111 _strip->gain_control()->alist()->automation_state_changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_automation, this), OSC::instance());
112 _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::gain_message, this), OSC::instance());
115 boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->trim_control());
116 if (trim_controllable) {
117 trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::trim_message, this, X_("/select/trimdB"), _strip->trim_control()), OSC::instance());
118 trim_message ("/select/trimdB", _strip->trim_control());
121 boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_azimuth_control());
122 if (pan_controllable) {
123 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());
124 change_message ("/select/pan_stereo_position", _strip->pan_azimuth_control());
127 boost::shared_ptr<Controllable> width_controllable = boost::dynamic_pointer_cast<Controllable>(_strip->pan_width_control());
128 if (width_controllable) {
129 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());
130 change_message ("/select/pan_stereo_width", _strip->pan_width_control());
133 // Rest of possible pan controls... Untested because I can't find a way to get them in the GUI :)
134 if (_strip->pan_elevation_control ()) {
135 _strip->pan_elevation_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_elevation_position"), _strip->pan_elevation_control()), OSC::instance());
136 change_message ("/select/pan_elevation_position", _strip->pan_elevation_control());
138 if (_strip->pan_frontback_control ()) {
139 _strip->pan_frontback_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_frontback_position"), _strip->pan_frontback_control()), OSC::instance());
140 change_message ("/select/pan_frontback_position", _strip->pan_frontback_control());
142 if (_strip->pan_lfe_control ()) {
143 _strip->pan_lfe_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/pan_lfe_control"), _strip->pan_lfe_control()), OSC::instance());
144 change_message ("/select/pan_lfe_control", _strip->pan_lfe_control());
147 // sends, plugins and eq
148 // detecting processor changes is now in osc.cc
150 // but... MB master send enable is different
151 if (_strip->master_send_enable_controllable ()) {
152 _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());
153 enable_message ("/select/master_send_enable", _strip->master_send_enable_controllable());
157 if (_strip->comp_enable_controllable ()) {
158 _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());
159 enable_message ("/select/comp_enable", _strip->comp_enable_controllable());
161 if (_strip->comp_threshold_controllable ()) {
162 _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());
163 change_message ("/select/comp_threshold", _strip->comp_threshold_controllable());
165 if (_strip->comp_speed_controllable ()) {
166 _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());
167 change_message ("/select/comp_speed", _strip->comp_speed_controllable());
169 if (_strip->comp_mode_controllable ()) {
170 _strip->comp_mode_controllable ()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::comp_mode, this), OSC::instance());
173 if (_strip->comp_makeup_controllable ()) {
174 _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());
175 change_message ("/select/comp_makeup", _strip->comp_makeup_controllable());
183 OSCSelectObserver::~OSCSelectObserver ()
186 strip_connections.drop_connections ();
187 // all strip buttons should be off and faders 0 and etc.
188 send_float ("/select/expand", 0);
189 text_message ("/select/name", " ");
190 text_message ("/select/comment", " ");
191 send_float ("/select/mute", 0);
192 send_float ("/select/solo", 0);
193 send_float ("/select/recenable", 0);
194 send_float ("/select/record_safe", 0);
195 send_float ("/select/monitor_input", 0);
196 send_float ("/select/monitor_disk", 0);
197 send_float ("/select/polarity", 0);
198 send_float ("/select/n_inputs", 0);
199 send_float ("/select/n_outputs", 0);
201 send_float ("/select/fader", 0);
203 send_float ("/select/gain", -193);
205 send_float ("/select/trimdB", 0);
206 send_float ("/select/pan_stereo_position", 0.5);
207 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 send_float ("/select/pan_elevation_position", 0);
221 send_float ("/select/pan_frontback_position", .5);
222 send_float ("/select/pan_lfe_control", 0);
223 send_float ("/select/comp_enable", 0);
224 send_float ("/select/comp_threshold", 0);
225 send_float ("/select/comp_speed", 0);
226 send_float ("/select/comp_mode", 0);
227 text_message ("/select/comp_mode_name", " ");
228 text_message ("/select/comp_speed_name", " ");
229 send_float ("/select/comp_makeup", 0);
234 lo_address_free (addr);
238 OSCSelectObserver::renew_sends () {
244 OSCSelectObserver::renew_plugin () {
250 OSCSelectObserver::send_init()
252 // we don't know how many there are, so find out.
257 if (_strip->send_level_controllable (nsends)) {
266 // paging should be done in osc.cc in case there is no feedback
268 if (sur->send_page_size) {
269 send_size = sur->send_page_size;
272 uint32_t max_page = (uint32_t)(nsends / send_size) + 1;
273 if (sur->send_page < 1) {
275 } else if ((uint32_t)sur->send_page > max_page) {
276 sur->send_page = max_page;
278 uint32_t page_start = ((sur->send_page - 1) * send_size);
279 uint32_t last_send = sur->send_page * send_size;
281 send_timeout.push_back (2);
283 _last_send.push_back (0.0);
285 for (uint32_t s = page_start; s < last_send; ++s, ++c) {
287 bool send_valid = false;
288 if (_strip->send_level_controllable (s)) {
289 _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());
290 send_timeout.push_back (2);
291 _last_send.push_back (0.0);
292 send_gain (c, _strip->send_level_controllable(s));
296 if (_strip->send_enable_controllable (s)) {
297 _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());
298 enable_message_with_id ("/select/send_enable", c, _strip->send_enable_controllable(s));
299 } else if (send_valid) {
300 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
302 // should never get here
303 send_float_with_id ("/select/send_enable", c, 0);
305 boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(s));
307 boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
308 proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), c, proc), OSC::instance());
309 send_float_with_id ("/select/send_enable", c, proc->enabled());
312 if (!gainmode && send_valid) {
313 text_with_id ("/select/send_name", c, _strip->send_name(s));
319 OSCSelectObserver::plugin_init()
321 if (!sur->plugin_id) {
325 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
330 // we have a plugin number now get the processor
331 boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
332 boost::shared_ptr<PluginInsert> pi;
333 if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
336 boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
339 nplug_params = sur->plug_params.size ();
341 // default of 0 page size means show all
342 plug_size = nplug_params;
343 if (sur->plug_page_size) {
344 plug_size = sur->plug_page_size;
346 text_message ("/select/plugin/name", pip->name());
347 uint32_t page_end = nplug_params;
348 uint32_t max_page = 1;
349 if (plug_size && nplug_params) {
350 max_page = (uint32_t)((nplug_params - 1) / plug_size) + 1;
353 if (sur->plug_page < 1) {
356 if ((uint32_t)sur->plug_page > max_page) {
357 sur->plug_page = max_page;
359 uint32_t page_start = ((sur->plug_page - 1) * plug_size);
360 page_end = sur->plug_page * plug_size;
363 for ( uint32_t ppi = page_start; ppi < page_end; ++ppi, ++pid) {
364 if (ppi >= nplug_params) {
365 text_with_id ("/select/plugin/parameter/name", pid, " ");
366 send_float_with_id ("/select/plugin/parameter", pid, 0);
370 uint32_t controlid = pip->nth_parameter(sur->plug_params[ppi], ok);
374 ParameterDescriptor pd;
375 pip->get_parameter_descriptor(controlid, pd);
376 text_with_id ("/select/plugin/parameter/name", pid, pd.label);
377 if ( pip->parameter_is_input(controlid)) {
378 boost::shared_ptr<AutomationControl> c = pi->automation_control(Evoral::Parameter(PluginAutomation, 0, controlid));
381 if (pd.integer_step && pd.upper == 1) {
384 c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
385 plugin_parameter_changed (pid, swtch, c);
392 OSCSelectObserver::send_end ()
394 send_connections.drop_connections ();
395 for (uint32_t i = 1; i <= send_size; i++) {
397 send_float_with_id ("/select/send_fader", i, 0);
399 send_float_with_id ("/select/send_gain", i, -193);
402 send_float_with_id ("/select/send_enable", i, 0);
404 text_with_id ("/select/send_name", i, " ");
406 // need to delete or clear send_timeout
407 send_timeout.clear();
412 OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
415 enable_message_with_id ("/select/plugin/parameter", pid, controllable);
417 change_message_with_id ("/select/plugin/parameter", pid, controllable);
422 OSCSelectObserver::plugin_end ()
424 plugin_connections.drop_connections ();
425 text_message ("/select/plugin/name", " ");
426 for (uint32_t i = 1; i <= plug_size; i++) {
427 send_float_with_id ("/select/plugin/parameter", i, 0);
429 text_with_id ("/select/plugin/parameter/name", i, " ");
435 OSCSelectObserver::tick ()
440 if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
442 if (_strip->peak_meter()) {
443 now_meter = _strip->peak_meter()->meter_level(0, MeterMCP);
447 if (now_meter < -144) now_meter = -193;
448 if (_last_meter != now_meter) {
449 if (feedback[7] || feedback[8]) {
450 string path = "/select/meter";
451 lo_message msg = lo_message_new ();
452 if (gainmode && feedback[7]) {
453 lo_message_add_float (msg, ((now_meter + 94) / 100));
454 lo_send_message (addr, path.c_str(), msg);
455 } else if ((!gainmode) && feedback[7]) {
456 lo_message_add_float (msg, now_meter);
457 lo_send_message (addr, path.c_str(), msg);
458 } else if (feedback[8]) {
459 uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
460 uint16_t ledbits = ~(0xfff<<ledlvl);
461 lo_message_add_int32 (msg, ledbits);
462 lo_send_message (addr, path.c_str(), msg);
464 lo_message_free (msg);
467 string path = "/select/signal";
468 lo_message msg = lo_message_new ();
470 if (now_meter < -40) {
475 lo_message_add_float (msg, signal);
476 lo_send_message (addr, path.c_str(), msg);
477 lo_message_free (msg);
480 _last_meter = now_meter;
484 if (gain_timeout == 1) {
485 text_message ("/select/name", _strip->name());
490 if (as == ARDOUR::Play || as == ARDOUR::Touch) {
491 if(_last_gain != _strip->gain_control()->get_value()) {
492 _last_gain = _strip->gain_control()->get_value();
496 if (_strip->comp_redux_controllable() && _strip->comp_enable_controllable() && _strip->comp_enable_controllable()->get_value()) {
497 float new_value = _strip->comp_redux_controllable()->get_parameter();
498 if (_comp_redux != new_value) {
499 send_float ("/select/comp_redux", new_value);
500 _comp_redux = new_value;
503 for (uint32_t i = 1; i <= send_timeout.size(); i++) {
504 if (send_timeout[i]) {
505 if (send_timeout[i] == 1) {
506 uint32_t pg_offset = (sur->send_page - 1) * sur->send_page_size;
507 text_with_id ("/select/send_name", i, _strip->send_name(pg_offset + i - 1));
515 OSCSelectObserver::name_changed (const PBD::PropertyChange& what_changed)
517 if (!what_changed.contains (ARDOUR::Properties::name)) {
525 text_message ("/select/name", _strip->name());
526 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
528 //spit out the comment at the same time
529 text_message ("/select/comment", route->comment());
530 // lets tell the surface how many inputs this strip has
531 send_float ("/select/n_inputs", (float) route->n_inputs().n_total());
532 // lets tell the surface how many outputs this strip has
533 send_float ("/select/n_outputs", (float) route->n_outputs().n_total());
538 OSCSelectObserver::change_message (string path, boost::shared_ptr<Controllable> controllable)
540 lo_message msg = lo_message_new ();
541 float val = controllable->get_value();
543 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
545 lo_send_message (addr, path.c_str(), msg);
546 lo_message_free (msg);
550 OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable> controllable)
552 float val = controllable->get_value();
554 send_float (path, 1);
556 send_float (path, 0);
562 OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
564 lo_message msg = lo_message_new ();
565 float val = controllable->get_value();
567 path = set_path (path, id);
569 lo_message_add_int32 (msg, id);
572 lo_message_add_float (msg, (float) controllable->internal_to_interface (val));
574 lo_send_message (addr, path.c_str(), msg);
575 lo_message_free (msg);
579 OSCSelectObserver::enable_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
581 float val = controllable->get_value();
583 send_float_with_id (path, id, 1);
585 send_float_with_id (path, id, 0);
590 OSCSelectObserver::text_message (string path, std::string text)
592 lo_message msg = lo_message_new ();
594 lo_message_add_string (msg, text.c_str());
596 lo_send_message (addr, path.c_str(), msg);
597 lo_message_free (msg);
601 OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
604 float val = controllable->get_value();
619 send_float ("/select/monitor_input", (float) input);
620 send_float ("/select/monitor_disk", (float) disk);
624 OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
626 if (_last_trim != controllable->get_value()) {
627 _last_trim = controllable->get_value();
631 lo_message msg = lo_message_new ();
633 lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
635 lo_send_message (addr, path.c_str(), msg);
636 lo_message_free (msg);
640 OSCSelectObserver::gain_message ()
642 float value = _strip->gain_control()->get_value();
643 if (_last_gain != value) {
650 text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
652 send_float ("/select/fader", _strip->gain_control()->internal_to_interface (value));
655 send_float ("/select/gain", -200);
657 send_float ("/select/gain", accurate_coefficient_to_dB (value));
663 OSCSelectObserver::gain_automation ()
666 as = _strip->gain_control()->alist()->automation_state();
671 auto_name = "Manual";
690 send_float ("/select/fader/automation", output);
691 text_message ("/select/fader/automation_name", auto_name);
693 send_float ("/select/gain/automation", output);
694 text_message ("/select/gain/automation_name", auto_name);
701 OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
703 if (_last_send[id] != controllable->get_value()) {
704 _last_send[id] = controllable->get_value();
708 lo_message msg = lo_message_new ();
713 db = controllable->get_value();
715 if (controllable->get_value() < 1e-15) {
718 db = accurate_coefficient_to_dB (controllable->get_value());
723 path = "/select/send_fader";
724 value = controllable->internal_to_interface (controllable->get_value());
725 text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
726 if (send_timeout.size() > id) {
727 send_timeout[id] = 8;
730 path = "/select/send_gain";
735 path = set_path (path, id);
737 lo_message_add_int32 (msg, id);
740 lo_message_add_float (msg, value);
741 lo_send_message (addr, path.c_str(), msg);
742 lo_message_free (msg);
746 OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
748 // with no delay value is wrong
751 send_float_with_id ("/select/send_enable", id, proc->enabled());
755 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
757 lo_message msg = lo_message_new ();
759 path = set_path (path, id);
761 lo_message_add_int32 (msg, id);
764 lo_message_add_string (msg, name.c_str());
766 lo_send_message (addr, path.c_str(), msg);
767 lo_message_free (msg);
771 OSCSelectObserver::comp_mode ()
773 change_message ("/select/comp_mode", _strip->comp_mode_controllable());
774 text_message ("/select/comp_mode_name", _strip->comp_mode_name(_strip->comp_mode_controllable()->get_value()));
775 text_message ("/select/comp_speed_name", _strip->comp_speed_name(_strip->comp_mode_controllable()->get_value()));
779 OSCSelectObserver::eq_init()
781 // HPF and enable are special case, rest are in bands
782 if (_strip->filter_enable_controllable (true)) {
783 _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());
784 change_message ("/select/eq_hpf/enable", _strip->filter_enable_controllable(true));
787 if (_strip->filter_enable_controllable (false)) {
788 _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());
789 change_message ("/select/eq_lpf/enable", _strip->filter_enable_controllable(false));
792 if (_strip->filter_freq_controllable (true)) {
793 _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());
794 change_message ("/select/eq_hpf/freq", _strip->filter_freq_controllable(true));
797 if (_strip->filter_freq_controllable (false)) {
798 _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());
799 change_message ("/select/eq_lpf/freq", _strip->filter_freq_controllable(false));
802 if (_strip->filter_slope_controllable (true)) {
803 _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());
804 change_message ("/select/eq_hpf/slope", _strip->filter_slope_controllable(true));
807 if (_strip->filter_slope_controllable (false)) {
808 _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());
809 change_message ("/select/eq_lpf/slope", _strip->filter_slope_controllable(false));
812 if (_strip->eq_enable_controllable ()) {
813 _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());
814 enable_message ("/select/eq_enable", _strip->eq_enable_controllable());
817 uint32_t eq_bands = _strip->eq_band_cnt ();
822 for (uint32_t i = 0; i < eq_bands; i++) {
823 if (_strip->eq_band_name(i).size()) {
824 text_with_id ("/select/eq_band_name", i + 1, _strip->eq_band_name (i));
826 if (_strip->eq_gain_controllable (i)) {
827 _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());
828 change_message_with_id ("/select/eq_gain", i + 1, _strip->eq_gain_controllable(i));
830 if (_strip->eq_freq_controllable (i)) {
831 _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());
832 change_message_with_id ("/select/eq_freq", i + 1, _strip->eq_freq_controllable(i));
834 if (_strip->eq_q_controllable (i)) {
835 _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());
836 change_message_with_id ("/select/eq_q", i + 1, _strip->eq_q_controllable(i));
838 if (_strip->eq_shape_controllable (i)) {
839 _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());
840 change_message_with_id ("/select/eq_shape", i + 1, _strip->eq_shape_controllable(i));
846 OSCSelectObserver::eq_end ()
848 eq_connections.drop_connections ();
849 if (_strip->filter_freq_controllable (true)) {
850 send_float ("/select/eq_hpf", 0);
852 if (_strip->eq_enable_controllable ()) {
853 send_float ("/select/eq_enable", 0);
856 for (uint32_t i = 1; i <= _strip->eq_band_cnt (); i++) {
857 text_with_id ("/select/eq_band_name", i, " ");
858 send_float_with_id ("/select/eq_gain", i, 0);
859 send_float_with_id ("/select/eq_freq", i, 0);
860 send_float_with_id ("/select/eq_q", i, 0);
861 send_float_with_id ("/select/eq_shape", i, 0);
868 OSCSelectObserver::eq_restart(int x)
875 OSCSelectObserver::set_path (string path, uint32_t id)
878 path = string_compose ("%1/%2", path, id);
884 OSCSelectObserver::send_float (string path, float val)
886 lo_message msg = lo_message_new ();
887 lo_message_add_float (msg, val);
889 lo_send_message (addr, path.c_str(), msg);
890 lo_message_free (msg);
895 OSCSelectObserver::send_float_with_id (string path, uint32_t id, float val)
897 lo_message msg = lo_message_new ();
899 path = set_path (path, id);
901 lo_message_add_int32 (msg, id);
904 lo_message_add_float (msg, val);
906 lo_send_message (addr, path.c_str(), msg);
907 lo_message_free (msg);