summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-03-10 10:46:24 +0100
committerRobin Gareus <robin@gareus.org>2015-03-10 10:49:52 +0100
commit3547540f98658ed5839832aa68e6fe23098cd236 (patch)
tree6ae8527556915524c3e219f3e78d41e864fc046d
parent2e82aa2743623cf4734e54f7cd37933439bfbbe6 (diff)
throttle TransportStateChange signal emissions
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/session_transport.cc23
2 files changed, 23 insertions, 1 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 7d2908a18c..b50d502e16 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -992,6 +992,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
double _transport_speed;
double _default_transport_speed;
double _last_transport_speed;
+ double _signalled_varispeed;
double _target_transport_speed;
CubicInterpolation interpolation;
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 5e01f14bdd..b392dabcbf 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -1321,7 +1321,28 @@ Session::set_transport_speed (double speed, framepos_t destination_frame, bool a
}
DEBUG_TRACE (DEBUG::Transport, string_compose ("send TSC3 with speed = %1\n", _transport_speed));
- TransportStateChange (); /* EMIT SIGNAL */
+
+ /* throttle signal emissions.
+ * when slaved [_last]_transport_speed
+ * usually changes every cycle (tiny amounts due to DLL).
+ * Emitting a signal every cycle is overkill and unwarranted.
+ *
+ * Using _last_transport_speed is not acceptable,
+ * since it allows for large changes over a long period
+ * of time. Hence we introduce a dedicated variable to keep track
+ *
+ * The 0.2% dead-zone is somewhat arbitrary. Main use-case
+ * for TransportStateChange() here is the ShuttleControl display.
+ */
+ if (fabsf(_signalled_varispeed - speed) > .002f
+ // still, signal hard changes to 1.0 and 0.0:
+ || ( speed == 1.f && _signalled_varispeed != 1.f)
+ || ( speed == 0.f && _signalled_varispeed != 0.f)
+ )
+ {
+ TransportStateChange (); /* EMIT SIGNAL */
+ _signalled_varispeed = speed;
+ }
}
}