summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLen Ovens <len@ovenwerks.net>2017-07-24 10:14:21 -0700
committerLen Ovens <len@ovenwerks.net>2017-07-24 10:21:31 -0700
commitb694ee9e534441724977157e5bc226d9a2d8fb44 (patch)
tree701a6a7338653bc6003ca1f6402d33c9dc6dfa15
parent3ab4a1d1475db9fb8a65fdb8e885b530b742dfc1 (diff)
OSC: only use gain change signals if value changes
-rw-r--r--libs/surfaces/osc/osc_cue_observer.cc7
-rw-r--r--libs/surfaces/osc/osc_cue_observer.h1
-rw-r--r--libs/surfaces/osc/osc_global_observer.cc25
-rw-r--r--libs/surfaces/osc/osc_global_observer.h3
-rw-r--r--libs/surfaces/osc/osc_route_observer.cc11
-rw-r--r--libs/surfaces/osc/osc_route_observer.h1
-rw-r--r--libs/surfaces/osc/osc_select_observer.cc19
-rw-r--r--libs/surfaces/osc/osc_select_observer.h2
8 files changed, 68 insertions, 1 deletions
diff --git a/libs/surfaces/osc/osc_cue_observer.cc b/libs/surfaces/osc/osc_cue_observer.cc
index 11d62073cf..7d027b4f18 100644
--- a/libs/surfaces/osc/osc_cue_observer.cc
+++ b/libs/surfaces/osc/osc_cue_observer.cc
@@ -49,6 +49,7 @@ OSCCueObserver::OSCCueObserver (boost::shared_ptr<Stripable> s, std::vector<boos
send_change_message ("/cue/mute", 0, _strip->mute_control());
gain_timeout.push_back (0);
+ _last_gain.push_back (0.0);
_strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCCueObserver::send_gain_message, this, 0, _strip->gain_control()), OSC::instance());
send_gain_message (0, _strip->gain_control());
@@ -132,6 +133,7 @@ OSCCueObserver::send_init()
if (send->gain_control()) {
gain_timeout.push_back (0);
+ _last_gain.push_back (0.0);
send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, boost::bind (&OSCCueObserver::send_gain_message, this, i + 1, send->gain_control()), OSC::instance());
send_gain_message (i + 1, send->gain_control());
}
@@ -213,6 +215,11 @@ OSCCueObserver::text_with_id (string path, uint32_t id, string val)
void
OSCCueObserver::send_gain_message (uint32_t id, boost::shared_ptr<Controllable> controllable)
{
+ if (_last_gain[id] != controllable->get_value()) {
+ _last_gain[id] = controllable->get_value();
+ } else {
+ return;
+ }
string path = "/cue";
if (id) {
path = "/cue/send";
diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h
index 37c61a622b..fe318c9d91 100644
--- a/libs/surfaces/osc/osc_cue_observer.h
+++ b/libs/surfaces/osc/osc_cue_observer.h
@@ -54,6 +54,7 @@ class OSCCueObserver
float _last_meter;
std::vector<uint32_t> gain_timeout;
bool tick_enable;
+ std::vector<float> _last_gain;
void name_changed (const PBD::PropertyChange& what_changed, uint32_t id);
void send_change_message (std::string path, uint32_t id, boost::shared_ptr<PBD::Controllable> controllable);
diff --git a/libs/surfaces/osc/osc_global_observer.cc b/libs/surfaces/osc/osc_global_observer.cc
index a76463d467..0649626271 100644
--- a/libs/surfaces/osc/osc_global_observer.cc
+++ b/libs/surfaces/osc/osc_global_observer.cc
@@ -39,6 +39,9 @@ using namespace ArdourSurface;
OSCGlobalObserver::OSCGlobalObserver (Session& s, ArdourSurface::OSC::OSCSurface* su)
: sur (su)
,_init (true)
+ ,_last_master_gain (0.0)
+ ,_last_master_trim (0.0)
+ ,_last_monitor_gain (0.0)
{
addr = lo_address_new_from_url (sur->remote_url.c_str());
//addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
@@ -268,10 +271,25 @@ OSCGlobalObserver::send_change_message (string path, boost::shared_ptr<Controlla
void
OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
{
+ bool ismaster = false;
+ if (path.find("master") != std::string::npos) {
+ ismaster = true;
+ if (_last_master_gain != controllable->get_value()) {
+ _last_master_gain = controllable->get_value();
+ } else {
+ return;
+ }
+ } else {
+ if (_last_monitor_gain != controllable->get_value()) {
+ _last_monitor_gain = controllable->get_value();
+ } else {
+ return;
+ }
+ }
if (gainmode) {
float_message (string_compose ("%1fader", path), controllable->internal_to_interface (controllable->get_value()));
text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
- if (path.find("master") != std::string::npos) {
+ if (ismaster) {
master_timeout = 8;
} else {
monitor_timeout = 8;
@@ -289,6 +307,11 @@ OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllabl
void
OSCGlobalObserver::send_trim_message (string path, boost::shared_ptr<Controllable> controllable)
{
+ if (_last_master_trim != controllable->get_value()) {
+ _last_master_trim = controllable->get_value();
+ } else {
+ return;
+ }
float_message (X_("/master/trimdB"), (float) accurate_coefficient_to_dB (controllable->get_value()));
}
diff --git a/libs/surfaces/osc/osc_global_observer.h b/libs/surfaces/osc/osc_global_observer.h
index 9c4e0d6ddc..ea5a0702a5 100644
--- a/libs/surfaces/osc/osc_global_observer.h
+++ b/libs/surfaces/osc/osc_global_observer.h
@@ -51,6 +51,9 @@ class OSCGlobalObserver
ArdourSurface::OSC::OSCSurface* sur;
bool _init;
+ float _last_master_gain;
+ float _last_master_trim;
+ float _last_monitor_gain;
lo_address addr;
std::string path;
uint32_t gainmode;
diff --git a/libs/surfaces/osc/osc_route_observer.cc b/libs/surfaces/osc/osc_route_observer.cc
index 506ad8aea6..550fd396a0 100644
--- a/libs/surfaces/osc/osc_route_observer.cc
+++ b/libs/surfaces/osc/osc_route_observer.cc
@@ -43,6 +43,7 @@ OSCRouteObserver::OSCRouteObserver (boost::shared_ptr<Stripable> s, uint32_t ss,
,ssid (ss)
,sur (su)
,_last_gain (0.0)
+ ,_last_trim (0.0)
,_init (true)
{
addr = lo_address_new_from_url (sur->remote_url.c_str());
@@ -342,6 +343,11 @@ OSCRouteObserver::send_monitor_status (boost::shared_ptr<Controllable> controlla
void
OSCRouteObserver::send_trim_message (string path, boost::shared_ptr<Controllable> controllable)
{
+ if (_last_trim != controllable->get_value()) {
+ _last_trim = controllable->get_value();
+ } else {
+ return;
+ }
if (gainmode) {
text_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
trim_timeout = 8;
@@ -364,6 +370,11 @@ OSCRouteObserver::send_trim_message (string path, boost::shared_ptr<Controllable
void
OSCRouteObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
{
+ if (_last_gain != controllable->get_value()) {
+ _last_gain = controllable->get_value();
+ } else {
+ return;
+ }
lo_message msg = lo_message_new ();
if (feedback[2]) {
diff --git a/libs/surfaces/osc/osc_route_observer.h b/libs/surfaces/osc/osc_route_observer.h
index acf4a8744b..7c80dae936 100644
--- a/libs/surfaces/osc/osc_route_observer.h
+++ b/libs/surfaces/osc/osc_route_observer.h
@@ -59,6 +59,7 @@ class OSCRouteObserver
uint32_t gain_timeout;
uint32_t trim_timeout;
float _last_gain;
+ float _last_trim;
bool _init;
ARDOUR::AutoState as;
diff --git a/libs/surfaces/osc/osc_select_observer.cc b/libs/surfaces/osc/osc_select_observer.cc
index 092da95a5a..9abe578390 100644
--- a/libs/surfaces/osc/osc_select_observer.cc
+++ b/libs/surfaces/osc/osc_select_observer.cc
@@ -54,6 +54,7 @@ OSCSelectObserver::OSCSelectObserver (boost::shared_ptr<Stripable> s, lo_address
,sur (su)
,nsends (0)
,_last_gain (0.0)
+ ,_last_trim (0.0)
,_init (true)
{
addr = lo_address_new_from_url (sur->remote_url.c_str());
@@ -278,6 +279,8 @@ OSCSelectObserver::send_init()
uint32_t last_send = sur->send_page * send_size;
uint32_t c = 1;
send_timeout.push_back (2);
+ _last_send.clear();
+ _last_send.push_back (0.0);
for (uint32_t s = page_start; s < last_send; ++s, ++c) {
@@ -285,6 +288,7 @@ OSCSelectObserver::send_init()
if (_strip->send_level_controllable (s)) {
_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());
send_timeout.push_back (2);
+ _last_send.push_back (0.0);
send_gain (c, _strip->send_level_controllable(s));
send_valid = true;
}
@@ -619,6 +623,11 @@ OSCSelectObserver::monitor_status (boost::shared_ptr<Controllable> controllable)
void
OSCSelectObserver::trim_message (string path, boost::shared_ptr<Controllable> controllable)
{
+ if (_last_trim != controllable->get_value()) {
+ _last_trim = controllable->get_value();
+ } else {
+ return;
+ }
lo_message msg = lo_message_new ();
lo_message_add_float (msg, (float) accurate_coefficient_to_dB (controllable->get_value()));
@@ -631,6 +640,11 @@ void
OSCSelectObserver::gain_message ()
{
float value = _strip->gain_control()->get_value();
+ if (_last_gain != value) {
+ _last_gain = value;
+ } else {
+ return;
+ }
if (gainmode) {
text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
@@ -686,6 +700,11 @@ OSCSelectObserver::gain_automation ()
void
OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable)
{
+ if (_last_send[id] != controllable->get_value()) {
+ _last_send[id] = controllable->get_value();
+ } else {
+ return;
+ }
lo_message msg = lo_message_new ();
string path;
float value;
diff --git a/libs/surfaces/osc/osc_select_observer.h b/libs/surfaces/osc/osc_select_observer.h
index 71640fd106..393a19dc70 100644
--- a/libs/surfaces/osc/osc_select_observer.h
+++ b/libs/surfaces/osc/osc_select_observer.h
@@ -66,6 +66,8 @@ class OSCSelectObserver
float _last_meter;
uint32_t nsends;
float _last_gain;
+ float _last_trim;
+ std::vector<float> _last_send;
bool _init;
float _comp_redux;
ARDOUR::AutoState as;