我已经对一个说“ahhh”的人的 .wav 文件执行了 FFT,它显示了音频文件的频率和幅度。当我在 .wav 文件上运行它时,它显示频率 0 Hz 具有最高幅度。我不确定问题出在我的代码中以及如何解决它。
0 Hz 如何具有最大幅度?我试图解决这个问题的原因是我想在波形文件中找到振幅最高的频率,然后对其进行一些计算,但是对 0hz 进行计算对我来说没有任何意义,尤其是当我必须这样做的时候与它相乘。
当我查看array_sort变量时,它显示频率为0hz,幅度为 0.117341。
这是我正在使用的波形文件和 .m 文件 http://dl.dropbox.com/u/6576402/questions/fft/11262012_44100ahh.wav
http://dl.dropbox.com/u/6576402/questions/fft/test_rtfftphase_question.m
clear all, clc,clf,tic
dirpathtmp=strcat('/tmp/');
[vp_sig_orig, fs_rate, nbitsraw] = wavread(strcat(dirpathtmp,'/nov26/11262012_44100ahh.wav')); %must be mono
fs=fs_rate;
t_rebuilt=linspace(0,2*pi,fs); %creates same size time for new signal as orginal signal good for error checking
vp_sig_len=length(vp_sig_orig); %get sample rate from vp fs_rate needs to be an even number?
% Use next highest power of 2 greater than or equal to length(x) to calculate FFT.
nfft= 2^(nextpow2(length(vp_sig_orig)));
% Take fft, padding with zeros so that length(fftx) is equal to nfft
fftx = fft(vp_sig_orig,nfft);
sigfft= fft(vp_sig_orig);
sigifft=ifft(sigfft);
sigphase = unwrap(angle(sigfft')); %get phase of orginal signal
% Calculate the number of unique points
NumUniquePts = ceil((nfft+1)/2);
% FFT is symmetric, throw away second half
fftx = fftx(1:NumUniquePts);
% Take the magnitude of fft of x and scale the fft so that it is not a function of the length of x
mx = abs(fftx)/length(vp_sig_orig); %replaced for testing from stackexchage
if rem(nfft, 2) % odd nfft excludes Nyquist point
mx(2:end) = mx(2:end)*2;
else
mx(2:end -1) = mx(2:end -1)*2;
end
amp=mx;
ampinv=abs(amp-max(amp));
% This is an evenly spaced frequency vector with NumUniquePts points.
freq_vect = (0:NumUniquePts-1)*vp_sig_len/nfft;
freq=freq_vect';
%get phase of new signal
phase = unwrap(angle(fftx)); %get phase of orginal signal
array=[freq,amp];
array_sort=sortrows(array,-2); %sort by largest amplitude first
我在 Linux Ubuntu 64 位上使用 Octave 3.2.4。