Converting Real and Imaginary FFT output to Frequency and Amplitude

Dave Moore picture Dave Moore · Feb 26, 2012 · Viewed 11.9k times · Source

I'm designing a real time Audio Analyser to be embedded on a FPGA chip. The finished system will read in a live audio stream and output frequency and amplitude pairs for the X most prevalent frequencies.

I've managed to implement the FFT so far, but it's current output is just the real and imaginary parts for each window, and what I want to know is, how do I convert this into the frequency and amplitude pairs?

I've been doing some reading on the FFT, and I see how they can be turned into a magnitude and phase relationship but I need a format that someone without a knowledge of complex mathematics could read!

Thanks


Thanks for these quick responses!

The output from the FFT I'm getting at the moment is a continuous stream of real and imaginary pairs. I'm not sure whether to break these up into packets of the same size as my input packets (64 values), and treat them as an array, or deal with them individually.

The sample rate, I have no problem with. As I configured the FFT myself, I know that it's running off the global clock of 50MHz. As for the Array Index (if the output is an array of course...), I have no idea.

If we say that the output is a series of One-Dimensional arrays of 64 complex values:

1) How do I find the array index [i]?

2) Will each array return a single frequency part, or a number of them?

Thankyou so much for all your help! I'd be lost without it.

Answer

Novak picture Novak · Feb 26, 2012

Well, the bad news is, there's no way around needing to understand complex numbers. The good news is, just because they're called complex numbers doesn't mean they're, y'know, complicated. So first, check out the wikipedia page, and for an audio application I'd say, read down to about section 3.2, maybe skipping the section on square roots: http://en.wikipedia.org/wiki/Complex_number

What that's telling you is that if you have a complex number, a + bi, you can picture it as living in the x,y plane at location (a,b). To get the magnitude and phase, all you have to do is find two quantities:

  • The distance from the origin of the plane, which is the magnitude, and
  • The angle from the x-axis, which is the phase.

The magnitude is simple enough: sqrt(a^2 + b^2).

The phase is equally simple: atan2(b,a).