DSPRelated.com
Forums

Spectrum of audio data

Started by Unknown May 10, 2006
Dear All,

   i want  to do a spectrum plot of audio data, for this i am doing
like this
   1. Taking the FFT of the data;
   2. Finding the absolute(magnitude) of the fft output abs =
(sqrt(Re^2 + Im^2)).
   3. Then i am normalizing Norm = (2 * abs )/N) where N is FFT Length.
   4. I am taking  20 * log10(Norm).

  when i check the values i am getting spectrum values more -120 dB
like -132dB.

My query is
1. Can the spectrum of audio can be more than -120dB
2. Is the normalization what i am doing is right.

Please help me out,
Thanks a lot in advance,
With warm regards,
-Prasad B C

mailprassi@gmail.com wrote:
> Dear All, > > i want to do a spectrum plot of audio data, for this i am doing > like this > 1. Taking the FFT of the data; > 2. Finding the absolute(magnitude) of the fft output abs = > (sqrt(Re^2 + Im^2)). > 3. Then i am normalizing Norm = (2 * abs )/N) where N is FFT Length. > 4. I am taking 20 * log10(Norm).
Seems OK.
> when i check the values i am getting spectrum values more -120 dB > like -132dB. > > My query is > 1. Can the spectrum of audio can be more than -120dB > 2. Is the normalization what i am doing is right.
I don't know exactly what you expected, but I assume you wanted some measurement like 60-70 dB for speech, 110 dB for a jet engine, or stuff like that. To get to those seorts of numbers, you need a calibrated system. You need a calibration source, with known source level, and you need to feed it to the microphone. Then, you have to insert whatever numerical scaling constant is necessary to get the "known" numerical answer. Rune
mailprassi@gmail.com wrote:
> Dear All, > > i want to do a spectrum plot of audio data, for this i am doing > like this > 1. Taking the FFT of the data; > 2. Finding the absolute(magnitude) of the fft output abs = > (sqrt(Re^2 + Im^2)). > 3. Then i am normalizing Norm = (2 * abs )/N) where N is FFT Length. > 4. I am taking 20 * log10(Norm). > > when i check the values i am getting spectrum values more -120 dB > like -132dB. > > My query is > 1. Can the spectrum of audio can be more than -120dB > 2. Is the normalization what i am doing is right. > > Please help me out, > Thanks a lot in advance, > With warm regards, > -Prasad B C
Input a full scale single tone and normalize the output so that it comes out as 0 dB... Mark
Hi Prasad,

I assume you mix up some concepts related to dB-values of a spectrum.

Assuming your measurements (data) are voltage, the way you are
calculating your values you get results in dB respective 1V. What is
confusing you, is that values that are usually given with audio spectra
are decibel related to sound pressure level (dB SPL), which is related
to a sound pressure level of 20micropascal. So, these are two
completely different y-axes!

That means your -120dB is assumably some voltage level, which belongs
directly to your measurement result but says nothing at all about the
sound pressure. -120dB is 1 microvolt, which is a really small value.
Are this values real measurements, and are you sure it was measured
correctly? Because, if I assume that you measure your input data with a
quite good frontend (say, 20 Bit-precision ADC), you may be able to
measure levels down to -110dBV, and there should be some ground noise
around this level across the whole spectrum. Real measurements below
this level, e.g. -130dB, sounds not realistic to me, and if you are
able to really measure voltage levels below -132dBV, please tell me how
since I really need this audio frontend :-)

On the other hand, to get the y-axis-value you probably want, namely
the usually applied dB-values for sound pressure (dB SPL), you need to
convert your measurements from voltage to sound pressure. To do so, you
need to know the sensitivity of your sensor, e.g. microphone, and
calculate the SPL from your voltage. Once you know how much pressure
you have measured you convert the values to dB SPL. (By the way, pay
attention to the fact that microphones' sensitivity values are given
again in dB, this time in dB respective 1V/Pa. I know, the third
different dB-scale, it is quite confusing,...)
Looking on the dbSPL vs. frequency diagram, there might be values
between something like 20dB and 140dB. If you have values below or
above that, I again would doubt your calculations a little bit.

Hope that helps to avoid some confusions.

Regards

stereo

One thing I notice (at least you did not mention it):

You should divide the DC component by 2 because it is unique.

mailprassi@gmail.com wrote:
> Dear All, > > i want to do a spectrum plot of audio data, for this i am doing > like this > 1. Taking the FFT of the data; > 2. Finding the absolute(magnitude) of the fft output abs = > (sqrt(Re^2 + Im^2)). > 3. Then i am normalizing Norm = (2 * abs )/N) where N is FFT Length. > 4. I am taking 20 * log10(Norm).
You can speed this up by skipping the sqrt function and instead using 10log(abs) + 10log(2/N) Note that 10log(2/N) is a constant, so you don't need to calculate it at run time. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 Anything is possible if you don't know what you are talking about.
dB is a relative measure - it has to compare to something - say 1Volt
or whatever. On it's own dB has no meaning. You can say a signal is 3dB
smaller than another for example.


Tam

Hi Stereo,

>Real measurements below >this level, e.g. -130dB, sounds not realistic to me, and if you are >able to really measure voltage levels below -132dBV, please tell me how >since I really need this audio frontend :-)
I have tested my FFT code with the audio file with full of transients, my FFT Length is 512 and when i calculate the spectrum exactly at the fole over frequency(i.e, FFT-Len/2) and previous 10 magnitudes i am getting the more values that is >-115dB to -135dB, can i know where i could have gone wrong. As at the DC value and at fold over frequency the value will be real so i have done like this 1. abs = sqrt(Re^2) 2. Norm = 2*(abs)/N N= FFTLength 3. Spec in dB = 20 * log10(Norm); your suggestion would be of great help, Regards, -Prasad B C
Jim Thomas wrote:
> mailprassi@gmail.com wrote:
..
> > i want to do a spectrum plot of audio data, for this i am doing > > like this > > 1. Taking the FFT of the data; > > 2. Finding the absolute(magnitude) of the fft output abs = > > (sqrt(Re^2 + Im^2)). > > 3. Then i am normalizing Norm = (2 * abs )/N) where N is FFT Length. > > 4. I am taking 20 * log10(Norm). > > You can speed this up by skipping the sqrt function and instead using > > 10log(abs) + 10log(2/N)
i think that should be " 10*log10(abs^2) " where abs^2 = Re^2 + Im^2 . also, i think the OP needs to decently window his data before the FFT. r b-j
Hi Prasad,

so your input is an audio file, and the dB-values seem to refer to full
scale values (0dB is Full Scale, whatever voltage this is). If your
values are going down to -135dB or so, you might have a nice, clean 24
Bit recording - whether this is a real recording or artificially
generated data (e.g. from MATLAB) defines wheather these results are
reasonable or not. It is quite hard (or today even impossible) to get a
recording with real 24 Bit resolution, this is what I was writing in my
first posting. But it is very easy to generate such an artificial
recording, e.g. with signal generators in MATLAB.

Therefore you might not have to care about the conversion to dB SPL,
what I was writing first. The falloff of the spectrum you have just
before fs/2 seems to me like your anti-aliasing filter.

However, if you are not analysing your complete data at once (to get
just one spectrum), but cut it into pieces to get a number of
subsequent spectra, you should take care about windowing issues, as rbj
wrote above.

Regards

stereo