I have executed an FFT on a .wav file of a person saying "ahhh" which shows the frequency and amplitude of the audio file. When I run it on a .wav file it shows the frequency 0 Hz as having the highest amplitude. I'm not sure where the problem is within my code and how I can fix it.
How does 0 Hz have the max amplitude? The reason I'm trying to fix this is that I want to find the frequency with the highest amplitude in the wave file then run some calculation against it but running calculations against 0hz doesn't make any sense to me especially when I have to do multiplication with it.
When I look at the
array_sort variable it says the frequency is 0hz and 0.117341 as it's amplitude.
Here's the wave file and .m file I'm using http://dl.dropbox.com/u/6576402/questions/fft/11262012_44100ahh.wav
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
I'm using Octave 3.2.4 on Linux Ubuntu 64bit.