6
\$\begingroup\$

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?

\$\endgroup\$
  • 4
    \$\begingroup\$ For future reference note that dsp.stackexchange.com is now out of beta and is probably a better fit for this type of question. \$\endgroup\$ – Paul R Sep 22 '11 at 8:09
3
\$\begingroup\$

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.

\$\endgroup\$
5
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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