SPL of wav file

11 visualizaciones (últimos 30 días)
Ryan Moore
Ryan Moore el 14 de Mzo. de 2016
Respondida: Binaya el 20 de Ag. de 2024
Hello I have several different recordings of a piano and I wish to calculate the mean SPL over all frequency bins to get a single number for each wav recording level. I am totally new to Matlab and could do with some advice.

Respuestas (1)

Binaya
Binaya el 20 de Ag. de 2024
Hi Ryan
I understand that you want to calculate mean SPL i.e. Sound Pressure Level for all frequency bins in a recorded file.
To calculate the SPL we need the amplitude of the audio signal at each frequency level which can be obtained from the frequency representation of the signal like Fourier transform, Laplace transform.
You can use the "fft" function to calculate the Fourier Transform of the given audio signal. Once the Fourier Transform is calculated you can use the following code snippet to calculate the mean SPL:
N = length(audioData)
Y = fft(audioData); % Compute the FFT
P2 = abs(Y/N); % Two-sided spectrum
P1 = P2(1:N/2+1); % Single-sided spectrum
P1(2:end-1) = 2*P1(2:end-1); % Correct the amplitude
p_ref = 20e-6;
% Calculate SPL
SPL = 20 * log10(P1 / p_ref);
% Compute the mean SPL
meanSPL = mean(SPL);
Similarly, you can find the sound pressure level for all audio files.
Hope this helps.

Categorías

Más información sobre Signal Processing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by