Electronics > Beginners
how to interpret the magnitude of FFT
engineheat:
Hi,
In one of my project, I record an audio using a mic connected to a PC, and calculate the FFT using Python. I used PyAudio for the recording. Upon calculating the magnitude, I noticed that its range can vary depending on the format (16 bit vs 32 bit) of the recording. I don't know if I did something wrong or is there an explanation for this. So how do you magnitude of, say, 150 at 2000Hz or magnitude of 1200 at 4000Hz? Are there any physical meanings to the numbers or are they meaningful only in a relative sense?
Furthermore, I want to take the audio data and convert it to a A-weighted decibel reading much like those given in handheld decibel meters. Is this something I can do from the FFT? A simple example would be nice.
Thanks
radiolistener:
--- Quote from: engineheat on June 19, 2019, 06:26:38 pm ---I noticed that its range can vary depending on the format (16 bit vs 32 bit) of the recording.
--- End quote ---
yes, it depends on FFT length and sample resolution (bits). You're need to normalize FFT result by divide magnitudes with FFT length multiplied by half of the sample max value power(2, N)/2, where N is sample resolution in bits. Also, you can do it by translate your magnitude to decibels:
magnitude = sqrt(re*re + im*im);
db = 20 * log10(magnitude);
and then you can substract constant to normalize it and get power relative to maximum (full scale):
dbNormalized = db - 20 * log10(fftLength * pow(2,N)/2)
after that you will get normalized value in decibels.
For example, if you get FFT for the recording length 10000 samples, and 16 bits per sample, then calculations will be the following:
dbNormalized = 20 * log10(magnitude) - 20 * log10(10000 * pow(2, 16)/2) = 20 * (log10(magnitude) - log10(10000 * 32768))
0 dB means maximum allowed (full scale) amplitude for ADC.
-20 dB means 10 times smaller amplitude than maximum.
-40 dB means 100 times smaller amplitude than maximum.
-60 dB means 1000 times smaller amplitude than maximum.
etc
If you know the power of maximum allowed amplitude in dBm, you can add it and get absolute value of the power.
For example, if your 16 bit ADC has 10 dBm power for maximum allowed amplitude (full scale), then:
absolute power in dBm = dbNormalized + 10 dBm
--- Quote from: engineheat on June 19, 2019, 06:26:38 pm ---I want to take the audio data and convert it to a A-weighted decibel reading much like those given in handheld decibel meters. Is this something I can do from the FFT? A simple example would be nice.
--- End quote ---
I'm not familiar with A-weighting scale, but as I understand, you're need to correct normalized decibels with some correction table. Just substract some value taken from the table. I don't know how to calculate this correction table.
engineheat:
--- Quote from: radiolistener on June 19, 2019, 08:53:35 pm ---
--- Quote from: engineheat on June 19, 2019, 06:26:38 pm ---I noticed that its range can vary depending on the format (16 bit vs 32 bit) of the recording.
--- End quote ---
yes, it depends on FFT length and sample resolution (bits). You're need to normalize FFT result by divide magnitudes with FFT length multiplied by half of the sample max value power(2, N)/2, where N is sample resolution in bits.
--- End quote ---
Thanks. So the normalized FFT will always range from 0 to 1?
For a given sound, can the normalized FFT change drastically if one uses a different PC (or sound card) to do the recording? I guess it can since you mentioned dbm at max amplitude, which is ADC dependent.
dmills:
Yep, ADC, Preamp gain and Mic dependent, there is a reason sound pressure meters come with calibrators...
Incidentally you can save on a square root by taking advantage of the way logs work with powers:
\[dB=20\log((Re^2 + Im^2)^{0.5}) = 10\log(Re^2 + Im^2)\]
engineheat:
--- Quote from: dmills on June 27, 2019, 01:55:56 pm ---Yep, ADC, Preamp gain and Mic dependent, there is a reason sound pressure meters come with calibrators...
Incidentally you can save on a square root by taking advantage of the way logs work with powers:
\[dB=20\log((Re^2 + Im^2)^{0.5}) = 10\log(Re^2 + Im^2)\]
--- End quote ---
Thanks, but calibration is probably not necessary if I just want to compare the relative difference of two signals right? So if I record using the same equipment and signal A has double the amplitude at 1000hz compared to signal B, I can conclude that signal A has double the amplitude at 1000 hz right?
Granted there might be some minor details that makes the above statement not exactly true in real life, but you get my gist.
Navigation
[0] Message Index
[#] Next page
Go to full version