13
0

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().
This commit is contained in:
Colin Fletcher 2015-03-19 20:14:06 +00:00
parent ee959e73fd
commit 3127587f9a
2 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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;