FFT to dBa to overall dBa

31 views (last 30 days)
zachary gilvey
zachary gilvey on 17 Jul 2019
Edited: zachary gilvey on 18 Jul 2019
So I have a .wav file and I am trying to determine the overall sound energy from the file. The code I have is pretty basic so far and provides an accurate FFT of the sound being produced from the file.
clc
clear all
close all
[data, fs] = audioread('TEST.wav');
data_fft = fft(data);
dB = 10.*log10((10*abs(data_fft)).^2);
frequency(:,1) = ((1:480000)/10); %480,000 48 kHz (divide 10 second audio file)
Weighting = 2+20.*log10((12200^2.*frequency.^4./((frequency.^2+20.6.^2).*(frequency.^2+12200.^2).*((frequency.^2+107.2.^2).*(frequency.^2+737.9.^2)).^0.5))); %Apply A weighting
dBa = dB + Weighting;
Now that I have the dBa values vs frequency, I want to determine the overal sound value from this. The angle I am working towards is determining the 1/3 octave "averaged" values potentially from a filter and then taking the "rms" of those values but I am not sure how to apply this filter or take into account all of the values.

Accepted Answer

zachary gilvey
zachary gilvey on 18 Jul 2019
Edited: zachary gilvey on 18 Jul 2019
Hello,
Simply what you would do is add all of the ratio of pressures. To do this I wrote a while loop. Here 48 is the 48 kHz sample rate. They are summed and then log'd again.
i = 0;
while i < length(frequency)/2
i = i+1;
Lp = dBa(i,1)./10; %Lp/10=log10(Prms^2/Pref^2)
Prms_Pref = 10^Lp; %10^(Lp/10)=Prms^2/Pref^2
P_ratio(i,1) = Prms_Pref;
end
Leq = 10*log10(sum(P_ratio)/48);
Leq = round(Leq,3,'significant')

More Answers (0)

Categories

Find more on Audio I/O and Waveform Generation 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!