Method for making FFT
FFTW has functions to which you have to pass:
number of samples
(and some other flags for optimalization and stuff).
If you happen to retrieve pointer to XAudio2 buffer, you'll have to create your Output memory buffer. FFTW operation will populate the Output buffer with calculated Fourier Transformation.
There are some ways (AFAIR in FFTW it's called kinds) of getting output data buffer. I'll explain it on example later in this post.
Accessible frequencies depend on amount of probes you pass in Input Buffer. If you pass 8192-element Input Buffer, you'll get frequencies from -4095Hz to 4096 Hz. Then in order to get 20kHz spectrum you'd probably want to pass 40000 elements buffer. Since processing 2^N sized arrays is better, I recommend 65536 elements sized arrays to get -32767Hz to 32768Hz.
Don't worry about working with transfering data, retrieving and stuff, it'll be done within 10msec for sure.
And how to know which table indexes are the positive and negative frequencies? Well it depends on KIND of getting output data.
Sample of usage:
Let's say you want frequencies 1..8Hz. You have then to pass Input Buffer array of 16 float numbers. Then, you have to prepare memory for Output Buffer: it'll be array of 16 float numbers. FFTW works like this:
retrieve/malloc Input/Output buffers
select PLAN you want to do (as for us it'll be fftw_plan fftw_plan_r2r_1d(int n, double *in, double *out, fftw_r2r_kind kind, unsigned flags);
When you execute plan, your Output array will be probably populated with such points ( x(n) = amplitude at n Hz freq):
x(0), x(1), x(2), x(3), x(4), x(5), x(6), x(7), x(8), x(-7), x(-6), x(-5), x(-4), x(-3), x(-2), x(-1). So get rid if last 7 elements and you get what you're interested in.
If XAudio2 would have "get pointer to buffer" expression, then everything should be all right. And if you're going to make 0..20kHz in few bars like in Winamp, you'll have to sum/average parts of array.