summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/tempo_dialog.cc14
-rw-r--r--gtk2_ardour/tempo_dialog.h2
2 files changed, 7 insertions, 9 deletions
diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc
index 56e375dc91..a969581369 100644
--- a/gtk2_ardour/tempo_dialog.cc
+++ b/gtk2_ardour/tempo_dialog.cc
@@ -257,18 +257,16 @@ TempoDialog::pulse_change ()
void
TempoDialog::tap_tempo ()
{
- struct timeval now;
- gettimeofday (&now, NULL);
+ gint64 now;
+ now = g_get_monotonic_time (); // microseconds
- if (last_tap.tv_sec >= 0 || last_tap.tv_usec > 0) {
- struct timeval diff;
+ if (last_tap > 0) {
double interval, bpm;
static const double decay = 0.5;
- timersub (&now, &last_tap, &diff);
- interval = diff.tv_sec + diff.tv_usec * 1.0e-6;
- if (interval <= 0.25) {
- // >= 15 bpm, say
+ interval = (now - last_tap) * 1.0e-6;
+ if (interval <= 6.0) {
+ // >= 10 bpm, say
if (average_interval > 0) {
average_interval = interval * decay
+ average_interval * (1.0-decay);
diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h
index 9e97afa98d..616be2433e 100644
--- a/gtk2_ardour/tempo_dialog.h
+++ b/gtk2_ardour/tempo_dialog.h
@@ -57,7 +57,7 @@ private:
typedef std::map<std::string,float> NoteTypes;
NoteTypes note_types;
- struct timeval last_tap;
+ gint64 last_tap;
double average_interval;
Gtk::ComboBoxText pulse_selector;