Open
Description
Tempo appears to be calculated as "duration / (# of beats - 1)". That's not an accurate algorithm, as not all beats will be detected (or even present in the song), while half-beats will sometimes be detected.
A proper algorithm is:
tempo = sorted([beat_times[i+1] - beat_times[i] for i in range(len(beat_times) - 1)])[int((len(beat_times) - 1) / 2)]
or
tempo = statistics.median([beat_times[i+1] - beat_times[i] for i in range(len(beat_times) - 1)])
... depending on whether you want a hard median (no averaging in the case of there being an odd number of detected beats, aka an even number of gaps between them) or a soft median (with averaging between the two centre elements).
Metadata
Metadata
Assignees
Labels
No labels