adamjakab / BeetsPluginBpmAnalyser

A beets plugin for obsessive-compulsive music geeks to add BPM information to their songs.
MIT License
26 stars 4 forks source link

BPM is different than running aubio separate from it #10

Closed 2V3EvG4LMJFdRe closed 7 months ago

2V3EvG4LMJFdRe commented 1 year ago

Problem

I have noticed that using aubio to tag my files with the script below generates a different value for BPM than this plugin. I wonder why? Which one do you think is more accurate?

#!/bin/bash

export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin/:/usr/bin/:/bin/

for file in "$@"
do
    # Get the filename without extension
    filename=$(basename "$file")
    extension="${filename##*.}"
    filename="${filename%.*}"

    # Use aubio to find the BPM of the audio file
    bpm=$(aubio tempo "$file" | awk '{printf("%.0f\n", $1)}')

    # Write the BPM to the ID3 tag using eyeD3
    eyeD3 "$file" --bpm="$bpm"
done
adamjakab commented 7 months ago

Interesting! This plugin also uses aubio but I just recently discovered that as of December 2023 (https://github.com/aubio/aubio/issues/116) it doesn't work anymore. Anyhow, how much difference do you see in the bpm values?

2V3EvG4LMJFdRe commented 7 months ago

To be honest, I was just looking casually on this at the time and ended up not following through with a workflow that includes bpm data since I figured I personally don't listen to electronic music that much. Suppose it's meant for DJs, but my playlists aren't that advanced.

adamjakab commented 7 months ago

Got it. Thanks for letting me know. I will close this issue as it is not an issue anymore ;).

@2V3EvG4LMJFdRe - Btw, BPM is not only for electronic music. I listen to a lot of different genres. It is a good way to classify music by "speed". I use BPM in conjunction with this BeetsPluginGoingRunning plugin to generate me playlists based on a series of attributes including BPM. But I do understand that it might not be the case for you.

Last thought (for future readers): In relation to your original question, this library determines overall song BPM by scanning though the song, taking samples, determining BPM of the sample and then calculating an average for the entire song (ref). If a song has a steady rhythm this method produces a valid result. If a song often changes speed the average will be... an average.

2V3EvG4LMJFdRe commented 7 months ago

It's always good to have more data available! That's encouraging that you can use it with more genres, I'll definitely look into it down the line. Thanks for updating the script.