diff options
author | Len Ovens <len@ovenwerks.net> | 2018-04-17 13:10:59 -0700 |
---|---|---|
committer | Len Ovens <len@ovenwerks.net> | 2018-06-19 09:46:29 -0700 |
commit | 2fa49c51b27a128e1e545bced6f9c520c49a71cf (patch) | |
tree | 1a44d81ee10634dc9a4de0d369c11002684bbf2c /libs/surfaces | |
parent | 5ce341c12730c68ea6fd3cb09a2afff80a4d5b6e (diff) |
OSC: Feedback was not making it to surface
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/osc/osc.cc | 35 | ||||
-rw-r--r-- | libs/surfaces/osc/osc.h | 2 | ||||
-rw-r--r-- | libs/surfaces/osc/osc_global_observer.cc | 72 | ||||
-rw-r--r-- | libs/surfaces/osc/osc_global_observer.h | 1 | ||||
-rw-r--r-- | libs/surfaces/osc/osc_route_observer.cc | 2 |
5 files changed, 66 insertions, 46 deletions
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 2cb1857487..b82c442957 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1737,6 +1737,7 @@ OSC::surface_parse (const char *path, const char* types, lo_arg **argv, int argc int se_page = sur->send_page_size; int fadermode = sur->gainmode; int feedback = sur->feedback.to_ulong(); + sur->feedback = 0; int strip_types = sur->strip_types.to_ulong(); int bank_size = sur->bank_size; int linkset = sur->linkset; @@ -2129,7 +2130,9 @@ OSC::set_surface_port (uint32_t po, lo_message msg) it++; } } - refresh_surface (msg); + if (sur->feedback.to_ulong()) { + refresh_surface (msg); + } return 0; } } @@ -2215,7 +2218,9 @@ void OSC::global_feedback (OSCSurface* sur) { OSCGlobalObserver* o = sur->global_obs; - delete o; + if (o) { + delete o; + } if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) { // create a new Global Observer for this surface @@ -2850,7 +2855,6 @@ OSC::_sel_bus_only (lo_address addr) { OSCSurface *sur = get_surface(addr); boost::shared_ptr<Stripable> s = sur->select; - std::cout << string_compose ("bus_only for: %1\n", s->name()); if (s) { boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s); if (rt) { @@ -4482,7 +4486,6 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr) _select = s; } if (s != old_sel) { - std::cout << string_compose ("new Select: %1\n", s->name()); sur->select = s; /* @@ -4507,7 +4510,6 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr) OSCSelectObserver* so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs); if (sur->feedback[13]) { if (so != 0) { - std::cout << string_compose ("refreshing select: %1\n", s->name()); so->refresh_strip (s, nsends, sur->gainmode, true); } else { OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, *session, sur); @@ -4531,7 +4533,6 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr) } } if (s != old_sel) { - std::cout << string_compose ("new Select2: %1\n", s->name()); sur->select = s; if (sur->temp_mode == GroupOnly) { boost::shared_ptr<Route> ort = boost::dynamic_pointer_cast<Route> (old_sel); @@ -4577,7 +4578,6 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr) _set_bank (1, addr); } } else if (sur->temp_mode == BusOnly) { - std::cout << string_compose ("bus only select: %1\n", s->name()); boost::shared_ptr<Route> rt = boost::dynamic_pointer_cast<Route> (s); if (rt) { if (!rt->is_track () && rt->can_solo ()) { @@ -4705,9 +4705,7 @@ OSC::sel_delta (int delta, lo_message msg) boost::weak_ptr<Stripable> o_sel = sur->select; boost::shared_ptr<Stripable> old_sel= o_sel.lock (); for (uint32_t i = 0; i < nstps; i++) { - std::cout << string_compose ("try strip %1 - %2\n", i, sel_strips[i]->name()); if (old_sel == sel_strips[i]) { - std::cout << string_compose ("got strip %1 - %2\n", i, sel_strips[i]->name()); if (i && delta < 0) { new_sel = sel_strips[i - 1]; } else if ((i + 1) < nstps && delta > 0) { @@ -4720,7 +4718,6 @@ OSC::sel_delta (int delta, lo_message msg) // should not happen return -1; } - std::cout << string_compose ("New strip %1\n",new_sel->name()); } } if (!new_sel) { @@ -6577,13 +6574,16 @@ OSC::cue_send_enable (uint32_t id, float state, lo_message msg) int OSC::float_message (string path, float val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_float (reply, (float) val); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6591,6 +6591,7 @@ OSC::float_message (string path, float val, lo_address addr) int OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6600,20 +6601,25 @@ OSC::float_message_with_id (std::string path, uint32_t ssid, float value, bool i lo_message_add_float (msg, value); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } int OSC::int_message (string path, int val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_int32 (reply, (float) val); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6621,6 +6627,7 @@ OSC::int_message (string path, int val, lo_address addr) int OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6630,20 +6637,25 @@ OSC::int_message_with_id (std::string path, uint32_t ssid, int value, bool in_li lo_message_add_int32 (msg, value); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } int OSC::text_message (string path, string val, lo_address addr) { + _lo_lock.lock (); lo_message reply; reply = lo_message_new (); lo_message_add_string (reply, val.c_str()); lo_send_message (addr, path.c_str(), reply); + Glib::usleep(1); lo_message_free (reply); + _lo_lock.unlock (); return 0; } @@ -6651,6 +6663,7 @@ OSC::text_message (string path, string val, lo_address addr) int OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, bool in_line, lo_address addr) { + _lo_lock.lock (); lo_message msg = lo_message_new (); if (in_line) { path = string_compose ("%1/%2", path, ssid); @@ -6661,7 +6674,9 @@ OSC::text_message_with_id (std::string path, uint32_t ssid, std::string val, boo lo_message_add_string (msg, val.c_str()); lo_send_message (addr, path.c_str(), msg); + Glib::usleep(1); lo_message_free (msg); + _lo_lock.unlock (); return 0; } diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index 41e1fb6a2e..fb721f2b1c 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -88,7 +88,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> bool get_active () const; // generic osc send - + Glib::Threads::Mutex _lo_lock; int float_message (std::string, float value, lo_address addr); int int_message (std::string, int value, lo_address addr); int text_message (std::string path, std::string val, lo_address addr); diff --git a/libs/surfaces/osc/osc_global_observer.cc b/libs/surfaces/osc/osc_global_observer.cc index 0917ce3761..01d16c2e6a 100644 --- a/libs/surfaces/osc/osc_global_observer.cc +++ b/libs/surfaces/osc/osc_global_observer.cc @@ -41,9 +41,9 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS : _osc (o) ,sur (su) ,_init (true) - ,_last_master_gain (0.0) - ,_last_master_trim (0.0) - ,_last_monitor_gain (0.0) + ,_last_master_gain (-1.0) + ,_last_master_trim (-1.0) + ,_last_monitor_gain (-1.0) ,_jog_mode (1024) ,last_punchin (4) ,last_punchout (4) @@ -55,6 +55,7 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS feedback = sur->feedback; uint32_t jogmode = sur->jogmode; _last_sample = -1; + mark_text = ""; if (feedback[4]) { // connect to all the things we want to send feed back from @@ -70,21 +71,21 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(strip->mute_control()); mute_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/mute"), strip->mute_control()), OSC::instance()); - send_change_message (X_("/master/mute"), strip->mute_control()); + send_change_message (X_("/master/mute"), mute_controllable); boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(strip->trim_control()); trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_trim_message, this, X_("/master/trimdB"), strip->trim_control()), OSC::instance()); - send_trim_message (X_("/master/trimdB"), strip->trim_control()); + send_trim_message (X_("/master/trimdB"), trim_controllable); boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(strip->pan_azimuth_control()); if (pan_controllable) { pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/pan_stereo_position"), strip->pan_azimuth_control()), OSC::instance()); - send_change_message (X_("/master/pan_stereo_position"), strip->pan_azimuth_control()); + send_change_message (X_("/master/pan_stereo_position"), pan_controllable); } boost::shared_ptr<Controllable> gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control()); gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/master/"), strip->gain_control()), OSC::instance()); - send_gain_message (X_("/master/"), strip->gain_control()); + send_gain_message (X_("/master/"), gain_controllable); // monitor stuff next strip = session->monitor_out(); @@ -104,8 +105,8 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS send_change_message (X_("/monitor/mono"), mon_mono_cont); gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control()); - gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/monitor/"), strip->gain_control()), OSC::instance()); - send_gain_message (X_("/monitor/"), strip->gain_control()); + gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/monitor/"), strip->gain_control()), OSC::instance()); + send_gain_message (X_("/monitor/"), gain_controllable); } //Transport feedback @@ -361,6 +362,7 @@ void OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable) { bool ismaster = false; + if (path.find(X_("master")) != std::string::npos) { ismaster = true; if (_last_master_gain != controllable->get_value()) { @@ -443,34 +445,36 @@ OSCGlobalObserver::marks_changed () void OSCGlobalObserver::mark_update () { - if (!lm.size()) { - _osc.text_message (X_("/marker"), "No Marks", addr); - return; - } - uint32_t prev = 0; - uint32_t next = lm.size() - 1; - for (uint32_t i = 0; i < lm.size (); i++) { - if ((lm[i].when <= _last_sample) && (i > prev)) { - prev = i; + string send_str = "No Marks"; + if (lm.size()) { + uint32_t prev = 0; + uint32_t next = lm.size() - 1; + for (uint32_t i = 0; i < lm.size (); i++) { + if ((lm[i].when <= _last_sample) && (i > prev)) { + prev = i; + } + if ((lm[i].when >= _last_sample) && (i < next)) { + next = i; + break; + } } - if ((lm[i].when >= _last_sample) && (i < next)) { - next = i; - break; + if ((prev_mark != lm[prev].when) || (next_mark != lm[next].when)) { + string send_str = lm[prev].label; + prev_mark = lm[prev].when; + next_mark = lm[next].when; + if (prev != next) { + send_str = string_compose ("%1 <-> %2", lm[prev].label, lm[next].label); + } + if (_last_sample > lm[lm.size() - 1].when) { + send_str = string_compose ("%1 <-", lm[lm.size() - 1].label); + } + if (_last_sample < lm[0].when) { + send_str = string_compose ("-> %1", lm[0].label); + } } } - if ((prev_mark != lm[prev].when) || (next_mark != lm[next].when)) { - string send_str = lm[prev].label; - prev_mark = lm[prev].when; - next_mark = lm[next].when; - if (prev != next) { - send_str = string_compose ("%1 <-> %2", lm[prev].label, lm[next].label); - } - if (_last_sample > lm[lm.size() - 1].when) { - send_str = string_compose ("%1 <-", lm[lm.size() - 1].label); - } - if (_last_sample < lm[0].when) { - send_str = string_compose ("-> %1", lm[0].label); - } + if (send_str != mark_text) { + mark_text = send_str; _osc.text_message (X_("/marker"), send_str, addr); } diff --git a/libs/surfaces/osc/osc_global_observer.h b/libs/surfaces/osc/osc_global_observer.h index 04403d0328..2f6972fce0 100644 --- a/libs/surfaces/osc/osc_global_observer.h +++ b/libs/surfaces/osc/osc_global_observer.h @@ -59,6 +59,7 @@ class OSCGlobalObserver float _last_monitor_gain; lo_address addr; std::string path; + std::string mark_text; uint32_t gainmode; std::bitset<32> feedback; ARDOUR::Session* session; diff --git a/libs/surfaces/osc/osc_route_observer.cc b/libs/surfaces/osc/osc_route_observer.cc index 840142f4a6..a519635586 100644 --- a/libs/surfaces/osc/osc_route_observer.cc +++ b/libs/surfaces/osc/osc_route_observer.cc @@ -107,7 +107,7 @@ OSCRouteObserver::no_strip () * that does not exist... Crash */ } - + void OSCRouteObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, bool force) { |