[英]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.它运行良好,plot 看起来和预期的一样,除了 db 级别太低了 ~80db。 Note, intended unit is db re 1uPa.请注意,预期单位为 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!非常感谢有关解决此问题的任何意见,我认为这与需要 re 1uPa 有关,但我无法追溯问题,我只是一个试图学习编码的可怜的生物学家!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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))');
Regardless, you want to plot the output of pwelch
using 10*log10
since you're dealing with a power spectrum.无论如何,您想要使用10*log10
的 plot 和 pwelch 的pwelch
,因为您正在处理功率谱。
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
??什么是gain
??
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.