# Calculating sound pressure level using microphone measurements

98 views (last 30 days)
Fatih on 18 Feb 2014
Commented: Arnav Mendiratta on 25 Oct 2017
I used a microphone to take measurements. I converted the measurements to pressure values (in units of Pascal) using sensitivity value of the microphone. The sampling rate was 8000 samples/sec. I want to calculate Sound Pressure Level (SPL) in terms of decibel, which is with respect to a reference pressure value (Pref = 20 microPascal).
So, I have to calculate
20*log10(SOMETHING/Pref)
for each octave band.
My question is: How should I calculate SOMETHING in the above expression for each octave band, from the pressure measurements?
Attached is the m-file that I used to calculate SPL value of a cosine function with amplitude 1 and frequency 500 Hz. I implemented 5 different methods to calculate SOMETHING in the above expression which resulted in different SPL values. You can find explanations for each method below. (The file also included A-weighting calculations.) Which one is the correct one or is there another way of properly performing the calculation?
%%METHOD 1
% 1) take fft -> Y = fft(y)
% 2) calculate db = 20*log10((abs(Y)/Pref))
% 3) For each octave band with fmin=f1 and fmax = f2:
% SOMETHING = mean of db in between f1 and f2
%------------------------------------------
%%METHOD 2
% 1) take fft -> Y = fft(y)
% 2) For each octave band with fmin=f1 and fmax = f2:
% 2a) zero out Y for other octave bands
% 2b) calculate RMS using this cutted version of Y.
% SOMETHING = RMS using this cutted version of Y
%------------------------------------------
%%METHOD 3
% 1) Construct a filter bank
% 2) For each octave band with fmin=f1 and fmax = f2:
% 2a) apply related filter to the original signal to obtain a signal.
% 2b) calculate rms from the obtained signal.
% SOMETHING = rms value obtained from the output of filtering
% operation
%------------------------------------------
%%METHOD 4:
% 1) take PSD.
% 2) Calculate decibel function using 20*log10(sqrt(PSD)/Pref)
% 3) For each octave band with fmin=f1 and fmax = f2:
% SOMETHING = mean of decibel function between f1 and f2
%------------------------------------------
%%METHOD 5:
% 1) take PSD.
% 2) For each octave band with fmin=f1 and fmax = f2:
% 2a) zero out other PSD values related to other frequencies
% 2b) calculate the area under PSD
% SOMETHING = sqrt(area under PSD between f1 and f2)

Chad Greene on 22 May 2014
This is a little bit clunky, but you could bandpass filter your signal for each octave band, then calculate the spl of the bandpass-filtered signal.

Arnav Mendiratta on 19 Jun 2017

Karsten on 25 Sep 2017
Is there a special reason you want to calculate octave bands first? If you just need an A-weighted decibel value for your files...
There is a script to create an A-weighting filter on FileExchange You will need the script adsgn(fs). Insert your sample rate for 'fs'. Now, you can use a simple filter method to perform a-weighting on your files.
Your next step is simply to calculate the rms of the signal and here is your SOMETHING.
Arnav Mendiratta on 25 Oct 2017
Standard compliant A/C/K weighting filters are also available with Audio System Toolbox:

### Categories

Find more on Measurements and Spatial Audio in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by