6

I'm looking at the Fourier Transform (really, at a sliding DFT) to analyze (visually and intuitively) the frequency components of a sound over time. But the DFT produces complex numbers, and I'm not sure how or whether to visualize them.

Should I just graph the magnitude of the result?

I've tried letting the argument/phase of the resulting number affect the hue of the graph, but it just looks more or less like a rainbow oil spill. It doesn't seem to help me understand anything about the sound.

Or would just dropping the imaginary part convey just as much?

Grumdrig
  • 505
  • 4
  • 12
  • 4
    For future reference note that http://dsp.stackexchange.com is now out of beta and is probably a better fit for this type of question. – Paul R Sep 22 '11 at 08:09

2 Answers2

5

Yes, just use the magnitude of the FFT output (\$\sqrt{re^2 + im^2}\$) - this gives you an estimate of the power spectrum. Phase information is generally of little interest in this context.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
Paul R
  • 752
  • 5
  • 16
3

The two numbers you get per frequency are the real and imaginary part of that frequency component in the original signal. These two together are sometimes called a phaser.

You can visualize this by plotting them on a graph where the real component is the X axis and the imaginary component the Y axis. You can add the two components and draw the result as a vector starting at the origin. Now imagine that vector spinning counter clockwise pivoting at the origin at the particular frequency of the sample. The projection onto the real axis would be a sine function over time, which is the contribution of that frequency in your original sample. The particular position your algorithm gave for the spinning vector was just where the signal was at time = 0.

From this you can hopefully see that what you want is the magnitude of that spinning vector. To get that, you square the two components, add them, then take the square root of the result, just like PaulR said. His answer is right, but I was trying to give you some feel for where it came from.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915