Jump to content
  • Advertisement
Sign in to follow this  
StasB

Interpreting FFT Output?

This topic is 2990 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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."

Share this post


Link to post
Share on other sites
Hm I am not quite sure but most
FFT algorithms should have Fs/2 as their
highest detectable frequency.
As described in Nyquist-Shannon's sampling theorem
your sampling rate needs to be at least 2 times bigger
than the highest frequency you want to be able to detect.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!