Old 12th March 2003, 18:24   #1
JSwing
Junior Member
 
Join Date: Mar 2003
Posts: 3
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
JSwing is offline   Reply With Quote
Old 12th March 2003, 20:31   #2
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
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 .

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.

UnConeD is offline   Reply With Quote
Old 12th March 2003, 21:21   #3
JSwing
Junior Member
 
Join Date: Mar 2003
Posts: 3
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
JSwing is offline   Reply With Quote
Old 12th March 2003, 22:09   #4
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
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.

UnConeD is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump