From 3127587f9a9acb5bc19efea9a0aab8ad3214640b Mon Sep 17 00:00:00 2001 From: Colin Fletcher Date: Thu, 19 Mar 2015 20:14:06 +0000 Subject: [PATCH] Go back to using g_get_monotonic_time() for tap tempo Using ev->time doesn't work as well as I'd hoped, so revert to the previous method with g_get_monotonic_time(). --- gtk2_ardour/tempo_dialog.cc | 8 +++----- gtk2_ardour/tempo_dialog.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc index 2a353d4b7d..02686b62ff 100644 --- a/gtk2_ardour/tempo_dialog.cc +++ b/gtk2_ardour/tempo_dialog.cc @@ -261,18 +261,17 @@ TempoDialog::pulse_change () set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid()); } - bool TempoDialog::tap_tempo_button_press (GdkEventButton *ev) { - guint32 now; - now = ev->time; // milliseconds + gint64 now; + now = g_get_monotonic_time (); // microseconds if (tapped) { double interval, bpm; static const double decay = 0.5; - interval = (now - last_tap) * 1.0e-3; + interval = (now - last_tap) * 1.0e-6; if (interval <= 6.0) { // <= 6 seconds (say): >= 10 bpm if (average_interval > 0 && average_interval > interval / 1.2 && average_interval < interval * 1.2) { @@ -292,7 +291,6 @@ TempoDialog::tap_tempo_button_press (GdkEventButton *ev) tapped = true; } last_tap = now; - return false; } bool diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h index 97d89e2867..eda4e61f1a 100644 --- a/gtk2_ardour/tempo_dialog.h +++ b/gtk2_ardour/tempo_dialog.h @@ -60,8 +60,8 @@ private: NoteTypes note_types; bool tapped; // whether the tap-tempo button has been clicked - guint32 last_tap; // time of the last tap (in mS, from GdkEventButton::time). Only valid if tapped is true - double average_interval; // running average of tap tempo button press interval times + gint64 last_tap; + double average_interval; Gtk::ComboBoxText pulse_selector; Gtk::Adjustment bpm_adjustment;