7

I have a project with a requirement to get the BPM of a wave or MP3 file programmatically using .Net (VB.Net or C#).

Does anyone know of a binary or library for this or have a code snippet to steer me in the right direction?

asheeshr
  • 4,088
  • 6
  • 31
  • 50
Robert
  • 81
  • 1
  • 5
  • It's not .net specific, but there's lots of helpful information and suggested algorithms on this question: [how-to-detect-bpm-of-the-song-by-programming](http://stackoverflow.com/questions/657073/how-to-detect-bpm-of-the-song-by-programming) – Simon P Stevens May 06 '10 at 15:37
  • @BS: It is very simple: you simply do an FFT (Fast Fourier Transform) and analyze your transformed data (a trivial search in an array, looking for a max value). I've written my own FFT in Java in about 40 lines of code or so (don't remember exactly for it was a long time ago, but it was short). This is similar to finding at which RPM an engine is turning by analyzing a car's noise (like, say, a formula one car [but in the car engine case, you need to know how many cylinders the car has]). Been there, done that, both to determine .wav BPMs and car engine RPMs, in Java, last century ;) – SyntaxT3rr0r May 07 '10 at 14:01

3 Answers3

2

For the part where you get the samples from WAV or MP3 in .NET code, I use NAudio (at CodePlex), free, usable in commercial apps, no real documentation, just sample code.

Conrad Albrecht
  • 1,976
  • 2
  • 15
  • 19
2

First, if you want to do sound with .Net, I would recommend fmod which is awesome and has a .Net wrapper (http://www.fmod.org).
Next, to get the BPM there are several methods but the one I find the most effective is the "beat spectrum" (described here: http://www.rotorbrain.com/foote/papers/icme2001/icmehtml.htm).
This algorithm computes a similarity matrix by comparing each short sample of the music with every others. Once the similarity matrix is computed it is possible to get average similarity between every samples pairs {S(T);S(T+1)} for each time interval T: this is the beat spectrum. The first high peak in the beat spectrum is most of the time the beat duration. The best part is you can also do things like music structure or rythm analyses.
If you are interested in this field, I would suggest to read other Jonathan Foote papers.

jeremy-george
  • 1,171
  • 1
  • 9
  • 20
1

Here's a commercial product that has a C# library. A trial is also available: http://adionsoft.net/bpm/

Dinah
  • 52,922
  • 30
  • 133
  • 149