You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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).
The text was updated successfully, but these errors were encountered: