How to calculate the sound pressure (Pa) of an audio signal ?

Hi, I need your help. I have an audio signal y that I obtained using the function:
[y,fs] = audioread("audio.wav");
and I wanted to understand how it is possible to calculate the sound pressure (Pa) of this audio. I need Pa of the audio to calculate the sound pressure level (SPL). Thanks for your help.
Antonio.

16 Comments

hello
are you interested only in the overall (rms) value ?
then you can simply calculate the rms value of y and apply a calibration factor (engineering unit) that says if signal amplitude is 1 from the wav file than the "real" (physical) y is X times higher (or lower) (then y is expressed in Pa)
Hi, thanks for your reply, by calibration do you mean the calibration factor of the microphone ? If yes, is there a method to calculate this factor using matlab ? Thank you.
@Mathieu NOE Hi thanks for the help, my problem is that I need to calculate the SPL (sound pressure level) of a recorded audio. In matlab I saw that there is this function https://uk.mathworks.com/matlabcentral/fileexchange/35876-sound-pressure-level-calculator that allows to obtain SPL. In input this function takes as parameter p_Pa which would be the pressure of the signal. So using your suggestion I calculate rms of the signal, then apply the calibration factor on the result (rms_y * calibration_factor ?) , then I didn't understand the last step "which says that if the amplitude of the signal is 1 from the wav file that the "real" (physical) y is X times higher (or lower) (then y is expressed in Pa)". Thanks again for your help.
Antonio
the matlab function you found in the Fex is fine, but the data are supposed to be in Pascals
so you have to make sure that when you load your wav file , you have a calibration factor that relates the output from audioread (to load the wav file) and your signal in Pascals
wav data are scaled in +1 / -1 range, so if your are measuring loud sounds , you will have to reduce the Pa signals by a certain factor to match the +1 / -1 range of the wav format;
usually , the acoustic guy has a microphone calibtated sources and will record a knwon SPL sound with his recorder , so that he can multiply the "raw" wav data by the correct calibration factor to have his data in Pascals
hope this clarifies the concept of calibration - we say also engineering units
@Mathieu NOE thanks for the well detailed explanation, I will implement your suggestions. Thanks.
[x,Fs]=audioread('File.wav');
y=x(:,1);
n = length(x);
p=fft(y);
nUniquePts = ceil((n+1)/2);
p = p(1:nUniquePts); % select just the first half since the second half is a mirror image of the first
p = abs(p); % take the absolute value, or the magnitude
p = p/n; % scale by the numberof points so that the magnitude does not depend on the length of the signal or on its sampling frequency
p = p.^2; % square it to get the power
if rem(n, 2) % odd nfft excludes Nyquist point
p(2:end) = p(2:end)*2;
else
p(2:end -1) = p(2:end -1)*2;
end
F = (0:nUniquePts-1)*(Fs/n); % create the frequency array
dB= 10*log10(p/((2e-5)^2));
@Hasan Hassoun hi, does the variable "dB" represent the sound pressure of the audio ? I thank you for the answer and the code.
Yes it represents the Sound pressure level in dB
Note: using only a single calibration factor implies linear response for the microphone (or is it that the log is linear... not sure at the moment.) But that is not typically the case. Really you need calibration over a range of loudnesses.
@Walter Roberson thanks for the help and the suggestion for the calculation of the calibration factor.
@Hasan Hassoun code of can be analysis 1/3 octave of 'file.wav'?
use 'poctave'
https://in.mathworks.com/help/signal/ref/poctave.html
You are absolutely right. The calibration factor is non-linear. It needs a calibration over a range of dB level. I followed your suggestion. However, I have a calibrator only for 94 dB and 114 dB. For both cases, I found the measured sound level from the wav file as 73 dB and 92.3 dB which means I need to add a gain of 20 dB, i.e., calibration factor around 12.1. How can I be so sure about the measurement below 50dB or any other values except 94 and 114 dB?
hello
I don't find that there is a lot of non linearity in your calibration
94 dB / 114 dB at the calibrator gives you a reading of 73 / 92.3 dB so the 20 dB increase at the calibrator translates into a 19.3 dB delta at the "recorder" side which I personnaly find not too bad (0.7 dB non linearity is in many acoustic measurements a non event).
If you have the possibility to compare your microphone to a high quality "lab" certified mic then you should be fine.
otherwise you can use a good loudspeaker and simply start with a 94 dB tone, then go down in signal input amplitude to check the linearity at lower levels.
all the best

Sign in to comment.

Answers (1)

Here are relevant functions available with Audio Toolbox that are related to measuring loudness of an audio signal:

Categories

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

Asked:

on 14 Jan 2021

Answered:

on 22 Feb 2024

Community Treasure Hunt

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

Start Hunting!