DSPRelated.com
Forums

For FFT sample for 1 second completely required ?

Started by rajeshhegde8 September 30, 2006
Hi,

I am trying to process audio came from microphone using FFT.
But audio driver gives only 512 bytes in a buffer. Sampling rate is
44Khz.

Whether to do FFT complete sample for 1 sec is required ? Or I can process
these 512 Bytes buffer one by one ? If yes any examples on net ?

I already have a Function which takes buffer and sampling rate and does
FFT. (i.e from Numerical Recipies using C) Can any body suggest me how to
modify the same ?


rajeshhegde8 skrev:
> Hi, > > I am trying to process audio came from microphone using FFT. > But audio driver gives only 512 bytes in a buffer. Sampling rate is > 44Khz. > > Whether to do FFT complete sample for 1 sec is required ?
The requirements to the FFT depends on what you attempt to do. Unless you have a very specific requirement to the frequency resolution, you can use shorter buffer lengths.
> Or I can process these 512 Bytes buffer one by one ?
Sure you can. Or you can concatenate two buffers to a=A8 1024 pt FFT, four buffers to a 2048 pt FFT etc. It may be a bit fiddely to actually implement, thiugh.=20 Rune
Thanks Rune,

Actually I want to process Audio signal at 44KHz and I need to get power
level of all the individual frequencies of 22KHz sound signal !

If I process 2KHz buffer at a time FFT will give only 2KHz frequency only
right ? How I will know actual frequency of each point ? 


rajeshhegde8 skrev:
> Thanks Rune, > > Actually I want to process Audio signal at 44KHz and I need to get power > level of all the individual frequencies of 22KHz sound signal ! > > If I process 2KHz buffer at a time FFT will give only 2KHz frequency only > right ?
No. The FFT analysis will give coefficients over the full bandwidth 0 - Fs.
> How I will know actual frequency of each point ?
First you have to decide how many frequency coefficients you need. With a 2k buffer, you will get a frequency resolution of Df = fs/N ~ 44000/2000 Hz = 22 Hz. If this is too large, you have to use a larger buffer. Rune
Rune Allnor skrev:
> rajeshhegde8 skrev: > > Thanks Rune, > > > > Actually I want to process Audio signal at 44KHz and I need to get power > > level of all the individual frequencies of 22KHz sound signal ! > > > > If I process 2KHz buffer at a time FFT will give only 2KHz frequency only > > right ? > > No. The FFT analysis will give coefficients over the full bandwidth 0 - > Fs. > > > How I will know actual frequency of each point ? > > First you have to decide how many frequency coefficients you need. > With a 2k buffer, you will get a frequency resolution of > > Df = fs/N ~ 44000/2000 Hz = 22 Hz. > > If this is too large, you have to use a larger buffer.
Sorry. I stopped short of actually answering your question. So you have N = 44000 samples, each are 22 Hz apart. The n'th sample in the spectrum is at frequency f_n = n*Df, n = 0,...,N-1. Rune
Thanks Rune,
Great explaination. I think it made many concepts more clear.

It means if I want frequency resolution of 22Khz I need a buffer of size
44Khz. Otherwise it is not possible to get exact frequency for which the
power and phase belongs to. 

If I choose 2K Bytes buffer then frequency resolution would be 22Hz. e.g:
If we assume FFT returns 2048 complex numbers for 2K Bytes buffer. Then
first complex number specifies power and phase of any frequency between 1
to 22 Hz Right ? But we can't figure out which frequency within 1Hz to
22Hz resolution the power belongs to. i.e This is exactly like placing
filters of bandwidth of 22 Hz side by side for all the frequencies from 0
to 44KHz.

Please clarify

-- Rajesh Hegde
rajeshhegde8 skrev:
> Thanks Rune, > Great explaination. I think it made many concepts more clear. > > It means if I want frequency resolution of 22Khz I need a buffer of size > 44Khz. Otherwise it is not possible to get exact frequency for which the > power and phase belongs to.
I think there is a confusion of terminology here. "Frequency resolution" means the distance between adjacent spectrum coefficients. With the above parameters, you need 2 samples to reach 22kHz resolution...
> If I choose 2K Bytes buffer then frequency resolution would be 22Hz. e.g: > If we assume FFT returns 2048 complex numbers for 2K Bytes buffer. Then > first complex number specifies power and phase
Implicitly, yes. You get the real and imaginary parts, which you have to convert to pwer and phase (although it may be more common to use either magnitude and phase, or just power alone).
> of any frequency between 1 > to 22 Hz Right ?
No. The coefficients represent an interval on in the frequency axis. On can not determine, from the coefficients, the magnitude and phase of the continuous spectrum. One can interpolate to find something that (hopefully) is good enough for the present purpose, but these are intricate issues that usually spawn heated debate when they come up on comp.dsp.
> But we can't figure out which frequency within 1Hz to > 22Hz resolution the power belongs to.
That's right. The coefficient does not belog to "a frequency", it represents the frequency interval.
> i.e This is exactly like placing > filters of bandwidth of 22 Hz side by side for all the frequencies from 0 > to 44KHz.
That view has been maintained by a number of regulars here. Rune