简体   繁体   中英

Having issue with units for wav file spectral density analysis (db artificially low)

I have the below code which is adapted from other code I found here. It runs fine and the plot looks as expected except the db levels are ~80db too low. Note, intended unit is db re 1uPa. Would appreciate any input on fixing this, I am thinking it has something to do with needing re 1uPa but I can't track back the issue and I'm just a poor biologist trying to learn to code!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FFT parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NFFT = 96000;    % 
NOVERLAP = round(0.75*NFFT);
w = hanning(NFFT);
% spectrogram dB scale
spectrogram_dB_scale = 100;  % dB range scale (means , the lowest displayed level is XX dB below the max level)
gain = 20
sensitivity = - 165
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[data,Fs]=audioread('sample.wav'); %(newer matlab)
samples = length(data);
dt = 1/Fs;
t = (0:dt:(samples-1)*dt);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display 1 : averaged FFT spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[sensor_spectrum, freq] = pwelch(data,w,NOVERLAP,NFFT,Fs);
% convert to dB scale (ref = 1)
sensor_spectrum_dB = 20*log10(sensor_spectrum) - sensitivity - gain ;


figure(1),semilogx(freq,sensor_spectrum_dB);grid
title(['Averaged FFT Spectrum  / Fs = ' num2str(Fs) ' Hz / Delta f = ' num2str(freq(2)-freq(1)) ' Hz ']);
xlabel('Frequency (Hz)');ylabel('Amplitude (dB (L))');
  1. Regardless, you want to plot the output of pwelch using 10*log10 since you're dealing with a power spectrum.

  2. Without knowing a little more about your data it's going to be hard to help... is it sound data? physiological? what is the sensitivity unit? What is gain ??

  3. Scaling the PSD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM