Ignore initial taps as they are generally inaccurate

This commit is contained in:
Dean Herbert 2022-06-01 20:57:24 +09:00
parent b88bce9b8b
commit f3f7e28353

View File

@ -275,20 +275,23 @@ namespace osu.Game.Screens.Edit.Timing
IsHandlingTapping.Value = false; IsHandlingTapping.Value = false;
} }
private const int initial_taps_to_ignore = 4;
private const int max_taps_to_consider = 8;
private void handleTap() private void handleTap()
{ {
tapTimings.Add(Clock.CurrentTime); tapTimings.Add(Clock.CurrentTime);
if (tapTimings.Count > 8) if (tapTimings.Count > initial_taps_to_ignore + max_taps_to_consider)
tapTimings.RemoveAt(0); tapTimings.RemoveAt(0);
if (tapTimings.Count < 5) if (tapTimings.Count < initial_taps_to_ignore * 2)
{ {
bpmText.Text = new string('.', tapTimings.Count); bpmText.Text = new string('.', tapTimings.Count);
return; return;
} }
double bpm = Math.Round(60000 / ((tapTimings.Last() - tapTimings.First()) / (tapTimings.Count - 1))); double bpm = Math.Round(60000 / ((tapTimings.Last() - tapTimings.Skip(initial_taps_to_ignore).First()) / (tapTimings.Count - initial_taps_to_ignore - 1)));
bpmText.Text = $"{bpm} BPM"; bpmText.Text = $"{bpm} BPM";