[linux-audio-dev] Audio sampling and fft accuracy.

Fons Adriaensen fons at kokkinizita.net
Sun Dec 10 10:11:18 EST 2006


On Sun, Dec 10, 2006 at 12:35:13PM +0000, James Courtier-Dutton wrote:

> If I have a sample 2kHz sine wave signal at 50% peak.
> I then add a white noise signal at 20%.

This is rather ambiguous. What do you mean by 'at 20%' ? Most noise
signals do not have a clearly defined peak amplitude. Gaussian noise,
even with finite power, has an infinite peak amplitude ! So you should
always use the RMS value to indicate a noise level.

> I then do a FFT transform.
> If I design the FFT so that 2kHz is at the center of one of the FFT 
> buckets, how close will the FFT figure be to the 50% sine wave input.
> Obviously, there will be a variation due to the amount of noise. So the 
> output of the FFT buckets will be 50+-error.

Not exactly. The error will not be symmetric around the sine amplitude
as the average power of the noise is not zero. When you convert the 
complex FFT output to a real value by x*x+y*y, you effectively measure
power. Even if you take the square root of this afterwards, it's still
power, expressed in amplitude units. The value in the signal bin is the
signal power plus the noise power in that bin, which will fluctuate 
around its mean value, and that mean value is not zero.

> Will this variation as a result of noise decrease as I use more and more 
> samples per fft block? I.e.Will the +-error value decrease?

Yes. Assuming the noise is white, its power will on average be divided
evenly over all the FFT bins. So the more bins, the less noise there will
be in each of them. But you never reach zero, as that would require an
infinite length FFT.

> I would think it should decrease, as a result of the general averaging 
> the fft routine will make to the noise signal. I would think that as the 
> noise was random, it should average out to zero over time.

No. It's average power is not zero. It decreases because there are more
bins, and the sum of the powers in all bins must be the power of the signal.

If you average the powers measured by a number of shorter FFTs (each one
using 'new' noise of course), then the noise power in each bin will 
converge to P / (N / 2), where P is the total noise power and N the FFT
length. Subtract this from the power in the bin where your signal is,
and you get the exact signal power.

-- 
FA

Lascia la spina, cogli la rosa.



More information about the linux-audio-dev mailing list