BPM

README for bpm
Login

README for bpm

General

Get audio files as .mp3 from YouTube:

NOTE:

The youtube-dl tool has been blocked, but there is a fork: yt-dlp

yt-dlp -x --audio-format mp3 -o "feels.%(ext)s" https://www.youtube.com/watch?v=ozv4q2ov3Mk
yt-dlp -x --audio-format mp3 -o "pump-up-the-jam.%(ext)s" https://www.youtube.com/watch?v=9EcjWd-O4jI
yt-dlp -x --audio-format mp3 -o "blue-monday.%(ext)s" https://www.youtube.com/watch?v=c1GxjzHm5us
yt-dlp -x --audio-format mp3 -o "lady-bump.%(ext)s" https://www.youtube.com/watch?v=NelzIKT9ON4
yt-dlp -x --audio-format mp3 -o "girl-you-know-its-true.%(ext)s" https://www.youtube.com/watch?v=RdSmokR0Enk

Get the same files as .wav:

yt-dlp -x --audio-format wav -o "feels.%(ext)s" https://www.youtube.com/watch?v=ozv4q2ov3Mk
yt-dlp -x --audio-format wav -o "pump-up-the-jam.%(ext)s" https://www.youtube.com/watch?v=9EcjWd-O4jI
yt-dlp -x --audio-format wav -o "blue-monday.%(ext)s" https://www.youtube.com/watch?v=c1GxjzHm5us
yt-dlp -x --audio-format wav -o "lady-bump.%(ext)s" https://www.youtube.com/watch?v=NelzIKT9ON4
yt-dlp -x --audio-format wav -o "girl-you-know-its-true.%(ext)s" https://www.youtube.com/watch?v=RdSmokR0Enk

Get audio file with MSYS2:

pacman -S mingw-w64-x86_64-ffmpeg
wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe
./yt-dlp.exe --ffmpeg-location /mingw64/bin/ffmpeg.exe -x --audio-format wav -o "faulty-towers.%(ext)s" https://www.youtube.com/watch?v=PseBNmbIzGg

Play an audio file on Linux:

Play an audio file on MS Windows - external soundcard (0), internal speakers (1), monitor speakers (2):

Play with MSYS2 - internal speakers (0), monitor speakers (1):

pacman -S mingw-w64-x86_64-sox
/mingw64/bin/sox.exe faulty-towers.wav -t waveaudio 0

Expected results:

Goals

Conclusion

Use:

  1. Use aubio (complete library with various tools, among them a beat detector) for real-time detection, reading from files, pipes, etc, using an FFT algorithm from 2005.
  2. Use BTrack (small collection of C files) if you want to start from scratch. Good for real-time detection, using an FFT algorithm from 2011.
  3. Use beat-detector if you know Rust.
  4. Use bpm from the Linux package bpm-tools if nothing else is available, or if you are lazy. Applying a multiplying factor may improve results.

Results

read-from-aubiotrack

This program uses the output from aubiotrack and calculates both the median and the average values.

    make clean all

    aubiotrack -i feels.wav | ./bin/read-from-aubiotrack
    DEBUG: stored numbers = 381
    DEBUG: read errors = 0
    DEBUG: BPM median value: 102.222836
    DEBUG: BPM average value: 106.508915

    aubiotrack -i pump-up-the-jam.wav | ./bin/read-from-aubiotrack
    DEBUG: stored numbers = 451
    DEBUG: read errors = 0
    DEBUG: BPM median value: 126.532626
    DEBUG: BPM average value: 125.800103

    aubiotrack -i blue-monday.wav | ./bin/read-from-aubiotrack
    DEBUG: stored numbers = 977
    DEBUG: read errors = 0
    DEBUG: BPM median value: 131.987065
    DEBUG: BPM average value: 131.713718

    aubiotrack -i lady-bump.wav | ./bin/read-from-aubiotrack
    DEBUG: stored numbers = 359
    DEBUG: read errors = 0
    DEBUG: BPM median value: 123.599973
    DEBUG: BPM average value: 122.601263

    aubiotrack -i girl-you-know-its-true.wav | ./bin/read-from-aubiotrack
    DEBUG: stored numbers = 394
    DEBUG: read errors = 0
    DEBUG: BPM median value: 98.764457
    DEBUG: BPM average value: 102.734908

Conclusion:

aubio tempo uses the average of all values generated by aubiotrack to calculate the BPM.
Anyhow, the median value is closer to the expected value in most cases.

Details/README about each external project