   Interpreting FFT Output?
  Hi!I'm trying to do some basic audio processing, an area that I'm not yet very familiar with. I want to calculate the amplitude of a wave with some arbitrary frequency 'f', if such a wave is indeed a part of the series of waves that compose my signal. If my (very limited) understanding of the Fourier Transform is correct, the output from a FFT should give me the information I need. I've found several C implementations of FFT online, but I don't quite understand how to extract the information I need from their output. They all seem to accept some N^2 complex samples and return N^2 complex samples. Perhaps someone could explain how the amplitudes are calculated from the complex number samples? Also, how do I know which output samples correspond to which frequencies?Thanks in advance for any help.Stas B.   
  1. The amplitude is the absolute value of the complex number  |a + b i| = sqrt(a^2 + b^2)and the phase is its 'argument' or 'angle,'  arg(a + b i) = atan2(b, a)2. Usually the highest index corresponds to the sampling frequency (call it 'Fs'), so your output is over the range [0, Fs].  The top half of the array, over the interval (-Fs/2,Fs] is just a repeat of the lower half though (in terms of magnitude, that is; phase has the opposite sign.)  (Also, since the DFT's (Discrete Fourier Transform's) output is periodic, it helps to think of it rewrapped to the range [-Fs/2, Fs/2].  Then it has Hermetian symmetry (which is basically all I was saying about the array)).3. If you're trying to learn this stuff, I recommend Oppenheim & Schafer; it's what electrical engineering students the world 'round use.4. In your post, I think you meant "2^N," not "N^2."   ;  Thank you very much for the clarification!It makes sense now.   ;  Hm I am not quite sure but mostFFT algorithms should have Fs/2 as theirhighest detectable frequency.As described in Nyquist-Shannon's sampling theoremyour sampling rate needs to be at least 2 times biggerthan the highest frequency you want to be able to detect.   ;  It's not that the FFT algorithm can't detect higher frequencies. The fundamental properties of discrete-time sampling means frequencies above half the sampling frequency doesn't even exist in the first place.   ;  To elaborate on Brother Bob's point... In principle, you can certainly detect energy that occurs at higher frequencies than Fs/2, but it will be aliased down; e.g., energy from (1 + 1/4)Fs ends up in the same bin as energy from (1/4)Fs.That said, all this is moot, because we're talking about programming computers, not designing hardware, and the sampling has already taken place.  And whoever designed the sound card put an analog filter (called an antialiasing filter) in front of the sampler to eliminate frequencies above Fs/2 before sampling... so aliasing is not an issue.   