DSPRelated.com
Forums

Spectrum Analysis: Understanding the results of Amplitude Spectrum/Power Spectrum calculation

Started by Michael February 9, 2006
Hello,

I have no idea how to interpret my results of Amplitude Spectrum calculation 
correctly:

Here is what I have done:

I read in AudioSamples from Mono 16Bit 22050Hz File and normalize it to 
[-1,1]

Then I use fftw to make a forward realFFT and calculate the Amplitude 
Spectrum with

sqrt(re * re + im * im);

Or should it be "sqrt(re * re + im * im) / number FFT points;" ?

What is more, I do not know what is the possible minimum and maximum value 
which could be expected when calculating the amplitude spectrum (I want to 
plot the spectrogram and therefore I need to find the proper min/max values 
for the axis).
Due to the function written above I achieve values like 0.182323 and I do 
not know how to interpret that result.

The power spectrum shows power at each frequency line. Which value stands 
for minimal power and which for maximum power?

Converting to Logarithmic Units:
You use the formula 20* log10( Amp/AmpReference ) to convert Amplitude 
Spectrum to decibel ratio. Which value does AmpReference have?

Thanks in advance, Michael 


Michael wrote:
> Hello, > > I have no idea how to interpret my results of Amplitude Spectrum calculation > correctly: > > Here is what I have done: > > I read in AudioSamples from Mono 16Bit 22050Hz File and normalize it to > [-1,1]
How?
> Then I use fftw to make a forward realFFT and calculate the Amplitude > Spectrum with > > sqrt(re * re + im * im);
No need to take the square root if you later take the log. Instead of 20*log(), simply use 10*log().
> Or should it be "sqrt(re * re + im * im) / number FFT points;" ? > > What is more, I do not know what is the possible minimum and maximum value > which could be expected when calculating the amplitude spectrum (I want to > plot the spectrogram and therefore I need to find the proper min/max values > for the axis).
The minimum is the smallest value; the maximum is the largest. If you already normalized to +/-1, the maximum is unlikely to exceed 1 by much.
> Due to the function written above I achieve values like 0.182323 and I do > not know how to interpret that result.
It's a relative number that will vary with the setting of the volume control and the choice of reference.
> The power spectrum shows power at each frequency line. Which value stands > for minimal power and which for maximum power?
The smaller the number, the smaller the power.
> Converting to Logarithmic Units: > You use the formula 20* log10( Amp/AmpReference ) to convert Amplitude > Spectrum to decibel ratio. Which value does AmpReference have?
Whatever is appropriate to your problem. Recall that log(a/b) = log(a) - log(b) So that the choice of reference just shifts the graph up or down without changing its shape. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Hi again,

>> I read in AudioSamples from Mono 16Bit 22050Hz File and normalize it to >> [-1,1] > > How?
I divide all the sample values by 32768 (16Bit)
>> Then I use fftw to make a forward realFFT and calculate the Amplitude >> Spectrum with >> >> sqrt(re * re + im * im); > > No need to take the square root if you later take the log. Instead of > 20*log(), simply use 10*log().
>> Converting to Logarithmic Units: >> You use the formula 20* log10( Amp/AmpReference ) to convert Amplitude >> Spectrum to decibel ratio. Which value does AmpReference have? > > Whatever is appropriate to your problem. Recall that > log(a/b) = log(a) - log(b) > So that the choice of reference just shifts the graph up or down without > changing its shape. >
Okay, my goal is to visualize a graph of time against frequency (darker points mean higher density). Later, it should be possible to find parts with high energy or to do spectral smoothing or to sum up adjacent frequency bands. Lets say I have 22050Hz input , 1024 FFT coefficients. Thus, I could separate frequency bands of about 21 Hz (22050/1024) So, i do not need any information about phase? Therefore, just calculate the Power Spectrum instead of Amplitude Spectrum? And visualize the result in decibel ratio with 10*log(re*re + im*im). And leave the AmpReference to zero, thus log( Amp/AmpReference ) = log(Amp) - log(1) And what about windowing? A frame shift of 50% means to shift a 1024-point-fft through the audio file by a step factor of 512? Thank you very much, Michael