How to calculate the sound pressure (Pa) of an audio signal ?
Show older comments
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
Mathieu NOE
on 14 Jan 2021
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)
Walter Roberson
on 14 Jan 2021
It is not possible to calculate sound pressure without calibration.
Antonio Spera
on 14 Jan 2021
Antonio Spera
on 14 Jan 2021
Edited: Walter Roberson
on 14 Jan 2021
Mathieu NOE
on 14 Jan 2021
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
Antonio Spera
on 14 Jan 2021
Hasan Hassoun
on 14 Jan 2021
[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));
Antonio Spera
on 14 Jan 2021
Hasan Hassoun
on 14 Jan 2021
Yes it represents the Sound pressure level in dB
Antonio Spera
on 14 Jan 2021
Walter Roberson
on 14 Jan 2021
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.
Antonio Spera
on 14 Jan 2021
ngoc quy hoang ngoc quy
on 28 Feb 2021
@Hasan Hassoun code of can be analysis 1/3 octave of 'file.wav'?
Md Saiful Islam
on 7 Apr 2022
Md Saiful Islam
on 7 Apr 2022
Edited: Md Saiful Islam
on 7 Apr 2022
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?
Mathieu NOE
on 8 Apr 2022
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
Answers (1)
jibrahim
on 22 Feb 2024
0 votes
Here are relevant functions available with Audio Toolbox that are related to measuring loudness of an audio signal:
- calibrateMicrophone: Calibration factor for microphone
- acousticLoudness: Perceived loudness of acoustic signal using the Zwicker Method (ISO 532-1:2017(E)) or the Moore-Glasberg Method (ISO 532-2:2017(E))
- loudnessMeter: Standard-compliant loudness measurements. Calculates the momentary loudness, short-term loudness, integrated loudness, loudness range (LRA), and true-peak value of an audio signal.
- integratedLoudness: Measure integrated loudness and loudness range
- splMeterhttps://www.mathworks.com/help/audio/ref/splmeter-system-object.html#d126e65252: Measure sound pressure level of audio signal
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!