Archive: How to find beat per minute of a wave file?


12th March 2003 18:24 UTC

How to find beat per minute of a wave file?
Hi, does anyone know how to write a java program to find the beat per minute of a wave file? any suggestion on how to find the algorithm of beat detection. I couldn't find any algorithm to find the beat per minute of a music.


Thanks,

JSwing


12th March 2003 20:31 UTC

This is not related to AVS in any way, but I'm in a good mood and I happen to be programming exactly the same as you're asking (but in C++ and with MP3s). So I'll be nice and help you out :rolleyes: .

The easiest way is to split up the wave file into small pieces, do an FFT (fourier transform) on each of them and try to find a periodicity in it. In memory, you'll get what you see when you use a timescope in AVS.
By comparing the timescope data with itself shifted back in time and finding the offset at which the sum of the differences (or squared differences) is minimalised, you can get a good idea of the song's tempo. Then you can find the beat by searching for peaks if needed.

I've had similar trouble locating something like this one the web so you'll need to do most things yourself.


12th March 2003 21:21 UTC

Uncone, what do you mean by comparing the timescope? How do I find the timescope? Is your program in C++ working? Can you tell me what kind of algorithm to figure it out?

Thanks,

JSwing


12th March 2003 22:09 UTC

If FFT (fast fourier transform, it IS the algorithm) doesn't ring a bell, I'm sorry but you're going to need to read some more about signal analysis.

Finding the BPM of a song is not a simple problem.

To summarize:
- Use an FFT to find the spectrum for each part of the wave file
- Compare the FFT results of all the pieces with itself shifted back an increasing amount of time and find the shift offset for which the difference between the values is minimal

To visualise the problem, start a new AVS preset and add a 'render / timescope' component. Make sure 'clear every frame' is off in the main section of the preset.
You should now see the FFT data being plotted along the time axis. For songs with a clear beat, you should see a pattern horizontally. This is what you need to determine through code.