4
$\begingroup$

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 $20\log_{10}(P/P_{ref})$ 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?

$\endgroup$
  • 2
    $\begingroup$ You will almost certainly want to do the FFT before you convert to decibels, not after. $\endgroup$ – Oliver Charlesworth Jan 2 '12 at 12:31
  • $\begingroup$ However, this is not a programming question. Once you know what maths you want to do, then programming it should be easy (if it's not, then ask a specific question). $\endgroup$ – Oliver Charlesworth Jan 2 '12 at 12:31
  • $\begingroup$ programming is not an issue at all..so you want me to do a fft of the pressure data and then do the SPL calculations? $\endgroup$ – Fayaaz Hussain Jan 2 '12 at 12:57
6
$\begingroup$

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.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ @Dilip Sarwate: yes, you can get rid of the sqrt and compensate for this in the dB calculation - note that I had a typo there previously - it's normally 20*log10(magnitude) but of course you can just make this 10*log10(magnitude_squared). I deliberately didn't include this optimisation in the interest of clarity. $\endgroup$ – Paul R Jan 3 '12 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy