TL;DR: My question is not about programming. Calculating BPM (beats per minute) using average is not working well. Any other ideas?
I'm studying a programming language and decided to develop a simple "Tap Tempo" app. It basically get user mouse clicks and calculate the BPM (beats per minute).
However, it's taking too long to get closer to the real BPM and even so it's an approximation. The more samples (clicks) I have, the more it gets near the real BPM, but more samples means the user has to click too many times to discover the BPM.
I'm basically starting a timer when the user clicks the first time, then divide the number of beats (samples/clicks) per the elapsed time since the last click/beat.
Something like: BPM = beats_count / elapsed_time.
The number of beats increases at every click and elapsed_time is not being reset periodically, so it grows "forever". I tried to reset the timer, but it doesn't have the expected effect.
Do you have any clues on other strategy other than using the average of beats per time?