c++ beat detection

Hi…! I would like to ask if anyone can recommend a C++ beat detection library. Preferably one that has been tested with OF.

I would like to be able to synchronize OF graphics with mic input.

thanks!

i translated the beat detection object for processing:
http://code.compartmental.net/beat/

that was not too hard for the fmod player but for using it on the mic input you’d also need some fft library like fftw. i haven’t done this yet so my code won’t be too useful for you i guess.
but if you’re interested i could post the files here.

best
joerg

I developed a beat detection algorithm using FMOD and FMOD’s fft tool - Let me know if you still want the code and I’ll forward it onto you…

Eoghan

i am also looking for a beat detection algorithm that works with OF. Am developing a project that detects beats from a music source to sync with particle movements.

Any help would be appreciated!

Thanks!

I, too, am starting a project that requires beat detection, and would like to use OF. joerg, Eoghan, have either of you folks posted your ported libraries? I would be a good place to start if so.

The aubio-library seems to be what you’re looking for. Maybe a good starting point for a generic audio labelling addon, eh? I’ll put it on my TODO list :slight_smile:

Cheers,
P.

i just reviewed my files. i think you might be better off if you translated the processing code to c++ again. it’s not that much work (probably less than to understand my code).

but anyway here’s the code:
http://joerg.piringer.net/OF/BeatDetect.zip

i removed all unnecessary code from the class but i didn’t do it very carefully so there’s probably something missing or some things that have no use for you still left. feel free to ask. the class name is also from this project i have been doing.

best
joerg

Hi Joerg.

I am looking in to beat detection with OF and saw your post.

Are you using the Ess library also with OF?
Do you think your beatDetect would work with ofxFft.

Do you have a working example by any chance?

Thanks,
Stephan.

no i don’t use the Ess lib.
i used the code in a huge program, so there’s no simple example to share…
sorry

best
joerg

thanks anyway.

but do you think it would work with ofxfft ? or how did you feed it the needed data?

thanks.
s.

I think you might have solved your problem since then,
but I just wanted to let you know that I just tried to mix the basic example of ofxFft and the beatdetect solution of jroge.

I changed a bit jroge code.
Also I may have lost some coefficient in road,
so it is not an optimal solution but still it may give you some ideas.

Project was made on OSX Lion with Xcode 4.2.1

ofxFft-example-beatD.zip

Hey man, I know this post was a while back. I’ve just started using open frameworks. I’m wondering how you went about doing this project.

Thanks

Hey Mukei.

I downloaded your sample file.
I am on OSx and noticed the ofxFft addon is liking to a lib OSx.
I only have win32. where did you get the osx lib from ?

I tried Kyle’s ofXFft sample and it works fine with out the OSx but i had to comment out #define USE_FFTW in ofxFft.h.
But you sample tells me to enable #define USE_FFTW

Thanks,
Stephan.

ok i think i figured this out myself.

in ofxFft.h i did
//#define USE_FFTW

in testApp.cpp i did
fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING);
// To use FFTW, try:
//fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING, OF_FFT_FFTW);

now it works.

now that i figured this part out I was able to compare it to the beat detection i have running with processing.cc .
the processing sketch seems to give me much better results.

http://lozano-hemmer.com/ss/beatD/

But I am not sure how to translate this code in to OF.

S.

Shouldn’t be super hard, I think you can replicate fEnergy() and sEnergy() and pass them the buffer in audioIn(). The way they’re doing beat detection is looking how quickly the “energy” of the sound is changing, i.e. how rapidly the volume is increasing; lots of increase and decrease = beat. I can give it a try in a little bit if you need some help.

that help would be greatly appreciated.

i am having a hard time with how the of audio buffer translate to the processing “AudioInput in”, “spect.averages” and the likes.

thanks,
s.

also you could try a higher level library like aubio: http://aubio.org- note that aubio is GPL but if it is for an installation you should be ok

i looked at some great examples that were posted on the forum, that use aubio. those came with aubioOSX.a and the include folder.

the newest version of aubio seems to have beat detection but if i saw this right http://aubio.org does not have a download that included this compiled library. or i just don’t know what i have to look for.

thanks,
stephan.

no, it seems for osx, the only options are macports, fink or compile it yourself. with macports you could install it and then move it and all it’s dependencies to you project folder. only thing, be careful to configure macports to work with 32bits so the libraries are compatible with OF. you can probably find the package in homebrew, which from what i’ve heard is easier than macports.