Plotting SPL(dBA) from an audio WAV file?
Show older comments
Please forgive me for posting a separate post in accordance with rik's comments.
I reviewed the code you gave me last time and the graph I obtained is shown in Figure 1.
and my questions is:
The vertical axis is all negative,and there is still a difference with the graph I want (Figure 2).and i notice the "sensor_spectrum_dB" in this code .Do you know what this means? can I generate SPL(dBA) by this "sensor_spectrum_dB"?
Please forgive me for asking a lot of questions, I found myself really not very good at this,
thanks a lot.
Looking forward to your reply~
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display 2 : averaged FFT spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[freq, sensor_spectrum] = myfft_peak(signal,Fs,NFFT,OVERLAP);
% convert to dB scale (ref = 1)
sensor_spectrum_dB = 20*log10(sensor_spectrum);
% apply A weigthing if needed
if option_w == 1
pondA_dB = pondA_function(freq);
sensor_spectrum_dB = sensor_spectrum_dB+pondA_dB;
sensor_spectrum_dB=abs(sensor_spectrum_dB);
my_ylabel = ('Amplitude (dB (A))');
else
my_ylabel = ('Amplitude (dB (L))');
end
figure(2),semilogx(freq,sensor_spectrum_dB);grid on
df = freq(2)-freq(1); % frequency resolution
title(['Averaged FFT Spectrum / Fs = ' num2str(Fs) ' Hz / Delta f = ' num2str(df,3) ' Hz ']);
xlabel('Frequency (Hz)');ylabel(my_ylabel);
legend(leg_str);

figure 1

figure 2
Accepted Answer
More Answers (0)
Categories
Find more on Fourier Analysis and Filtering 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!