summaryrefslogtreecommitdiff
path: root/gtk2_ardour/tempo_dialog.cc
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2015-03-09 19:19:16 +0000
committerColin Fletcher <colin.m.fletcher@googlemail.com>2015-03-09 19:19:16 +0000
commit37b0e8ac90aae8d5359f67a7a32bfe78ad6422af (patch)
tree83703827b06406f0e045f584a18a36b1a8ed95dc /gtk2_ardour/tempo_dialog.cc
parentf7a2df1c9a8c540f7e5778561c8527c525874b84 (diff)
Use ev->time rather than g_get_monotonic_time() for tap tempo
Connect signal_button_press_event of 'Tap Tempo' button rather than signal_clicked so we can use the time member of GdkEventButton to calculate the tapped tempo. It seems to me that this is the right thing to do.
Diffstat (limited to 'gtk2_ardour/tempo_dialog.cc')
-rw-r--r--gtk2_ardour/tempo_dialog.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc
index 18b5e144cb..e11644131b 100644
--- a/gtk2_ardour/tempo_dialog.cc
+++ b/gtk2_ardour/tempo_dialog.cc
@@ -178,7 +178,7 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type,
when_beat_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
when_beat_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false);
pulse_selector.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::pulse_change));
- tap_tempo_button.signal_clicked().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo));
+ tap_tempo_button.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_button_press), false);
}
bool
@@ -258,17 +258,18 @@ TempoDialog::pulse_change ()
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
}
-void
-TempoDialog::tap_tempo ()
+
+bool
+TempoDialog::tap_tempo_button_press (GdkEventButton *ev)
{
gint64 now;
- now = g_get_monotonic_time (); // microseconds
+ now = ev->time; // milliseconds
if (last_tap > 0) {
double interval, bpm;
static const double decay = 0.5;
- interval = (now - last_tap) * 1.0e-6;
+ interval = (now - last_tap) * 1.0e-3;
if (interval <= 6.0) {
// >= 10 bpm, say
if (average_interval > 0) {
@@ -287,6 +288,7 @@ TempoDialog::tap_tempo ()
average_interval = 0;
}
last_tap = now;
+ return false;
}
MeterDialog::MeterDialog (TempoMap& map, framepos_t frame, const string&)