Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

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

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 

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

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

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);
share|improve this answer
    
thanks that worked :-) –  Rick T Nov 27 '12 at 18:10
    
you can also just zero out the DC component :) –  shelleybutterfly Mar 3 at 10:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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