8000 Tempo algorithm is wrong. · Issue #14 · dodiku/AudioOwl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Tempo algorithm is wrong. #14
Open
@enn-nafnlaus

Description

@enn-nafnlaus

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0