[PD] fft beginner question
Frank Barknecht
fbar at footils.org
Tue Nov 20 16:39:46 CET 2007
Hallo,
hard off hat gesagt: // hard off wrote:
> i'm really not sure about this next bit...but i think the reason why
> you get a real part and an imaginary part is because the analysis
> finds the angle between one sample and the next one. ..if it's a
> steep angle, then that's a high frequency...if it's a flatter angle,
> then that's a lower frequency.
That's not quite correct. The data, that the FFT gives you, not only
has the frequency content of a block encoded, but also the phase. In
my little tutorial I compare it to a bank of [osc~] objects that are
tuned in fixed integer multiples of SR/blocksize from 0 to SR/2, where
FFT gives you the amplitude of each osc~ plus its phase (second inlet
of [osc~]).
So we're dealing not with single numbers here, but with pairs of
numbers that specify how loud and at which phase the osc~ sounds.
Pairs of numbers are like coordinates into a 2-dimensional space. They
could be cartesian (x and y) or polar (angle and radius). Complex
numbers are just pairs of numbers as well. FFT gives out cartesian
coordinates (re = x, im = y) that are connected to phase and
magnitude, if you view the latter as the respective polar coordinates
for that fft-bin.
To convert from cartesian to polar you can use:
magn = sqrt(re^2 + im^2) <-- cf. pythagoras here
phs = arctan(im/re)
You can convert back as well using similar formula.
Why does FFT give cartesian coordinates? Well, as you can convert
between both representations it could give polar directly as well.
(You could make a little abstractions to get a polar [fft~] object.)
For some calculations polar, for others cartesian coordinates are
easier to use. To quote Miller:
The main reason we use complex numbers in electronic music is
because they magically automate trigonometric calculations. We
frequently have to add angles together in order to talk about the
changing phase of an audio signal as time progresses (or as it is
shifted in time, as in this chapter). It turns out that, if you
multiply two complex numbers, the argument of the product is the sum
of the arguments of the two factors.
http://crca.ucsd.edu/~msp/techniques/latest/book-html/node105.html
"Argument" is the angle here.
Ciao
--
Frank Barknecht _ ______footils.org__
More information about the Pd-list
mailing list