Understanding FFT as A Coder and Synth Nut

  • From: Veli-Pekka Tätilä <vtatila@xxxxxxxxxxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 13 Oct 2007 00:11:42 +0300

Hi list,
Ok first DSp question here. I'd like to do a simple guitar tuner for
SymbianOs and the difficult thing is the DSP side. If this was Native
Instruments' Reaktor I would simply use a frequency tracker module but
I'd need equivalent functionality in code.

I've read on the Web that FFT, Fast Fourier Transform, let's me look at
a discrete signal in time domain, e.g. a series of amplituide values
(samples) at a given sampling rate, as a series of sine waves at
different frequencies and amplitudes in stead kinda like building up
patches with an additive synth. Tracking the fundamental, say from a
guitar, then becomes porting some existing FFT lib into SymbianOs and
then recording the sample in some chunks, analysing it an then scanning
the frequency table to find the partial with the strongest amplitude out
there. Sounds simple enough.

I've found some free FFT code, even:


That is:


However, not being at all mathematically minded, I don't seem to
understand the docs. Heck, I don't even know what a complex number is
and to me a Vector is first and formost a Java data type, <grin>.

I've been able to conclude that the function takes some input array of
probably float-like data of a length that is a power of two. But what
does it put in the output array, i.e. how do I know what the frequencies
are it breaks the signal into and what's the range of amplitude values
they use? The frequency depends on the sampling rate, of course, so I
suppose I already know the maximum frequency knowing how many samples
are taken each second, and the size of my window i.e. input array, and
recalling the Nyquist limit of the hihest frequency being half the
sampling rate.

The only audio coding I've done before was VST and all I know is that in
it amplitudes are -1.0 to 1.0 inclusive, 32-bit floats measured in Db
where the formula is:

dB = 20 * log10(a / b)

(from the Sound Forge manual I read, actually).

where b is some reference amplituide, typically what they put 0 dB at in
digital audio, that is say 1.0. I do know what a logarithm is but any
higher math is generally beyond me, unless I see the practical value as
in audio coding, in which case I just might be motivated enough to try
to learn, <grin>. As a learner, antropomorphic natural language from
concrete to abstract works best, followed by code with clear variable
names or comments, and abstract math definitions are about the hardest
to understand out there. personally, they simply are not a natural mode
of thinking to me, and once I get them, I think the solution in natural
language, not in the language of mathematics. FOrtunately, one doesn't
have to be a good mathematician to be a decent coder, to me coding, even
architectural design, is infinitely more concrete and more like common
sensical. But hey, that's just me.

Back on track, though, for your information, here are the docs for the
FFT function:

/*      Name:
do_fft                                                        */
/*      Description: Compute the FFT of the
array.                          */
/*      Input
parameters:                                                   */
/*        - x: pointer on the source array
(time).                          */
/*      Output
parameters:                                                  */
/*        - f: pointer on the destination array
(frequencies).              */
/*             f [0...length(x)/2] = real
values,                           */
/*             f [length(x)/2+1...length(x)-1] = imaginary values
of        */
/*               coefficents
1...length(x)/2-1.                             */
/*      Throws:
Nothing                                                     */

void    FFTReal::do_fft (flt_t f [], const flt_t x []) const
<big snippage>

Any help appreciated.

PS: And sory for assuming an especially newbish tone here, <grin>. I
notice that if I know very little and I suppose someone, err like Ken,
knows a lot, I often tend to ask more questions than I should, <smile>.
I'm generally typing this too late at night anyway, but will send this
in the hopes of getting a reply when I wake up.

With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
View the list's information and change your settings at 

Other related posts: