We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Minim BeatDetect frequency-related questions
Page Index Toggle Pages: 1
Minim BeatDetect frequency-related questions (Read 1201 times)
Minim BeatDetect frequency-related questions
Jan 28th, 2009, 2:12am
Hi all,

I'm new to this forum so first of all hello to everyone and thanks in advance for all the helpful advice :)

I have been looking at the BeatDetect implementation in Minim and have a couple of questions related to how it defines and uses the frequency ranges.

I wrote a simple, helloworld-like programme that creates a BeatDetect object in frequency energy mode from a default AudioBuffer (1024 and 44100, the usual). I noticed that there are only 27 frequency bands available, i.e. isOnset(i) can be called only with 0 < i < 27 otherwise it throws an ArrayIndexOutOfBoundsException.

Why 27? Is it fixed or configurable? Or maybe it depends on some parameter of the AudioBuffer itself?

In other words, I was wondering whether it is possible to explicitly configure the frequency bands used by the algorithm (how many bands and which frequency range each band spans), so that real-time reactive animations can be tuned and tweaked for the specific tracks they are going to be used on.

Thanks a lot,
Re: Minim BeatDetect frequency-related questions
Reply #1 - Jan 28th, 2009, 11:52pm
Ok I looked at the documentation about the FFT and at the code of BeatDetect and worked out the "magic" 27 number.

Maybe this is really basic, but in case someone is wondering the same thing here it is.

The FFT used in the BeatDetect class is initialised with the timeSize and sampleRate passed, say 1024 and 44100Hz in the default case. The accessible frequency range is up to the Nyquist frequency, which is 22050Hz.

In BeatDetect the FFT is set to work with logarithmic averages, starting from the octave at 60Hz up to 22050Hz, and splitting each octave in 3 averages. Each average will vary in size, as the size of each octave double every time (60-120, 120-240, 240-480 etc up to 22050 in this case). If you multiply the number of octaves in the range by 3 you will find 27, which is the number of averages on which beats are detected.

60Hz and 3 avgs/octave are hardcoded in the method that initialises the frequency energy parameters. To make BeatDetect more configurable, these values should be exposed by BeatDetect through some kind of setAvgs(initialOctave, numAvgsPerOctave) method.

However, maybe this is the configuration that makes more sense and exposing it would just make things more complicated without providing an actual benefit?

I would be curious to know how these parameters were determined in the first place...

Re: Minim BeatDetect frequency-related questions
Reply #2 - May 3rd, 2009, 3:46pm

I actually had the same question.
You seem to have answered it. thanks! Though to be accurate, I think the width of the first octave should be 22 Hz, not 60. It then goes on to 44, 88, 176, 352, 704... up to 22050, in 9 octaves.

Now, the beat detection algorithm in frequency mode seems to return a LOT of false positives... It is actually very very sensitive. Would there be a way of adjusting this, other than by using the input levels as a 'threshold'?

Page Index Toggle Pages: 1