I have a set of pressure data at a sampling rate of 262144 Hz for 3 seconds making it 786432 samples of pressure data. I want to plot a curve of the SPL (sound pressure level) vs frequency. I first converted pressure data to SPL using <span class="MathJax" id="MathJax-Element-1-Frame" tabindex="0" data-mathml="20log10⁡(P/Pref)" role="presentation" style="border: 0px; font-variant: inherit; font-stretch: inherit; line-height: normal; font-family: inherit; vertical-align: baseline; box-sizing: inherit; display: inline; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; position: relative;">20log10(P/Pref)20log10(P/Pref) and performed a 4096 point FFT for the 192 segments of data and averaged them.
However, I couldn't get the required SPL values in decibels. Was the approach correct? If not, could you please point out the mistake in my approach?
The steps will be, in this order:
- apply window function (e.g. Hann or Hamming)
- calculate FFT
- calculate magnitude of FFT (sqrt(re*re+im*im))
- convert magnitude to dB (20*log10(magnitude))
- apply combined correction/calibration factors (window function compensation, FFT factor of N scaling if needed, factor of 2 for symmetric FFT, Pref calibration, etc) - this can just be a single dB correction value that you add to the dB magnitude values
If your Pref calibration data varies with frequency (e.g. microphone with non-flat frequency response) then it's a little more complicated than the above, but the same basic principles apply.
Note also that if you want weighted dB SPL (e.g. A weighting) then you'll also need to apply the relevant frequency dependent weighting corrections.