From 7473e8d2152547a12ea3dd4b2ab256b0c66b1ead Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sat, 18 May 2013 16:30:27 +0100 Subject: [PATCH] -Tap tempo now resets after 5 seconds un-tapped. Also uses 4th beat to calculate average --- src/timemanager.hxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/timemanager.hxx b/src/timemanager.hxx index 14d1675..b27aa24 100644 --- a/src/timemanager.hxx +++ b/src/timemanager.hxx @@ -12,7 +12,6 @@ using namespace std; - // inherits from ObserverSubject class TimeManager { @@ -57,6 +56,13 @@ class TimeManager void tap() { + // reset tap tempo to "first tap" if more than 5 secs elapsed since last tap + int sr = 44100; + if ( tapTempo[0] < frame - sr * 5 ) + { + tapTempoPos = 0; + } + if ( tapTempoPos < 3 ) { tapTempo[tapTempoPos] = frame; @@ -67,8 +73,9 @@ class TimeManager // calculate frames per tap int tapFpb1 = tapTempo[1] - tapTempo[0]; int tapFpb2 = tapTempo[2] - tapTempo[1]; + int tapFpb3 = frame - tapTempo[2]; // last tap, until now - int average = (tapFpb1 + tapFpb2) / 2; + int average = (tapFpb1 + tapFpb2 + tapFpb3) / 3; char buffer [50]; sprintf (buffer, "TM, tap() average = %i", average );