The FFT: Real, Imaginary, Magnitude, PhaseWeve mentioned that most FFTs return their information in the form of a complex pair: a real part and an imaginary part. Theres obviously a lot more to say about that, but it gets pretty mathematical, and well let you explore that on your own. But weve been talking about the data that an FFT returns more in terms of the amplitude (or magnitude) and phase of a given frequency bin. What is important in this discussion is that you understand more or less how to get from the complex number pair to the magnitude/phase pair, which is generally, for computer music, more useful. Youll probably want to manipulate amplitudes and phases, not complex numbers. It turns out not to be so hard. Remember that an imaginary number, written in the form: a + bi, can be represented in a two-dimensional space as follows: The length of the line from the origin to the point (a, b) is the magnitude specific to the spectral bin; that is, its the amount of energy at that frequency. Its just the hypotenuse of the right triangle drawn to the x-axis. The equation for it is very simple: You might recognize that as the equation for the length of the hypotenuse of a right triangle (called the Pythagorean theorem). That was pretty easy, right? Deriving the phase from the complex pair is a little trickier. What we want to find is the angle made by that point to the x-axis. Remember that phases are expressed in radians, 0 to It turns out that were looking for an angle that is the ratio of the opposite side to the adjacent side (remember: SOH CAH TOA: sin, opposite over hypotenuse; cosine, adjacent over hypotenuse; tangent, opposite over adjacent). We want the angle whose tangent is the y-value (opposite) over the x-value (adjacent), or b/a. Thats called the arctangent, and is written as tan-1. So the equation for calculating phase is: = tan- 1 (a/b) There, that wasnt so painful, was it? |
©Burk/Polansky/Repetto/Roberts/Rockmore. All rights reserved.