Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to do the examples within the GameDev.net Beat Detection article ( http://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html ) I have no issue with performing a FFT and getting the frequency data and doing most of the article. I'm running into trouble though in the section 2.B, Enhancements and beat decision factors.

in this section the author gives 3 equations numbered R10-R12 to be used to determine how many bins go into each subband:

R10
R10 - Linear increase of the width of the subband with its index

R11
R11 - We can choose for example the width of the first subband

R12
R12 - The sum of all the widths must not exceed 1024

He says the following in the article: "Once you have equations (R11) and (R12) it is fairly easy to extract 'a' and 'b', and thus to find the law of the 'wi'. This calculus of 'a' and 'b' must be made manually and 'a' and 'b' defined as constants in the source; indeed they do not vary during the song."

However, I cannot seem to understand how these values are calculated...I'm probably missing something simple, but learning fourier analysis in a couple of weeks has left me Decimated-in-Mind and I cannot seem to see it.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

All he's saying is humans are more sensitive to low frequency sound. That is, it's easier for humans to detect that there is even a difference between 65Hz and 69Hz than 2093Hz and 2097Hz.

2093Hz and 2097Hz would pretty much sound the same to a human. But 65Hz is C2 on the piano and 69Hz is C#2 -- so two completely distinct notes on a piano.

So he says "just make SMALLER bins for low frequency and BIGGER bins for high frequency"

In

w_i = a*i + b

i presumably indexes from 1 to #subbands you're using. For the first subband, the WIDTH is small:

w_1 = a + b

For the 7th subband, the width is nearly 7 times the width of the 1st subband

w_7 = 7a + b

He goes on to say that a and b are basically arbitrary choice depending on the size of your buffers etc. b is sort of a "bin size minimum" and a is the size that linearly scales.

If we choose a=10 and b=10 for example, then we get

w_1 = 20
w_2 = 30
w_3 = 40
...

w_32 = 330

R12 states the SUM of all the bins can't exceed 1024 (buffer size), so actually that particular choice of a and b wouldn't work (a is too large). You'd have to choose a and b so that the sum of w_1..w_32 is less than 1024 (unless you increase the buffer size)

share|improve this answer
    
Thank you for your answer. I'm thinking that this particular part of this article isn't correct. Since it isn't a logarithmic scaling at all :/ or even smaller bins for the lower frequencies. –  Mykel Stone Nov 18 '12 at 21:04
    
Checking Minims Javadocs, they do their logarithmic scaling by dividing the nyquist frequency in half again and again like so: 0-1, 1-2, 2-4, 4-8, 8-16, 16-32, 32-64, 64-128, 128-256, etc This makes much more sense than what the article is saying. –  Mykel Stone Nov 18 '12 at 21:11
add comment

R12 defines a constraint between a and b, once you've picked n (the number of subbands). For instance, with n = 32 the equation is 32*b + 528*a = 1024. It sounds like a and b are supposed to be integers, so ideally one would find a solution to this equation such that both a and b are integers.

However, in general such a solution won't exist (or there will only be a "trivial" solution with a = 0, which probably isn't what you want). So I suppose that a and b have to be allowed to take fractional values and you would round off the size of each subband to the nearest integer. Or maybe you could do something trickier like distributing the power of a bin into two adjacent subbands, when it falls on the edge between them.

In that case you would just have to pick a value for b and solve for the resulting a (or vice versa).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.