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
[vp_sig_orig, fs_rate, nbitsraw] = wavread(strcat(dirpathtmp,'/nov26/11262012_44100ahh.wav')); %must be mono

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); 
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;
  mx(2:end -1) = mx(2:end -1)*2;


% This is an evenly spaced frequency vector with NumUniquePts points. 
freq_vect = (0:NumUniquePts-1)*vp_sig_len/nfft; 

%get phase of new signal
phase = unwrap(angle(fftx)); %get phase of orginal signal
array_sort=sortrows(array,-2); %sort by largest amplitude first 

I'm using Octave 3.2.4 on Linux Ubuntu 64bit.


A strong amplitude response at 0 Hz simply means that you have a very strong DC offset. In other words, it just means that the mean of your signal is not 0.

If this is the only problem you have, then all you really need to do, is remove the mean of your signal. In other words:

vp_sig_orig = vp_sig_orig - mean(vp_sig_orig);
  • $\begingroup$ you can also just zero out the DC component :) $\endgroup$ Mar 3 '14 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.