Re: Spectrum Analysis: Understanding the results of Amplitude Spectrum/Power Spectrum calculation
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
|