[fpc-pascal] Good FFT example anywhere?

Bo Berglund bo.berglund at gmail.com
Sun Apr 9 23:54:17 CEST 2017

On Sun, 9 Apr 2017 11:34:53 -0700 (MST), fredvs
<fiens at hotmail.com> wrote:

>> As you can see it uses double, which means you will be OK to supply 
>> both single and integer values, just load the array with them and they
>> will be converted. 
>Many thanks for answer.
>Hmmm, it seems magic and very simple to use.
>Ok, I will try with my audio library. 
>By the way (who knows) did you try it, for example, to isolate some
>frequency from a buffer of sample (like a high-pass filter) ?
>(Of course example are welcome ;-) ).

Forgot to say that the code limits the number of samples like this:

procedure fft (
    NumSamples:   word;   { must be a positive integer power of 2 }


function IsPowerOfTwo ( x: word ): boolean;
var   i, y:  word;
    y := 2;
    for i := 1 to 15 do begin <== Does not go to 16

So you are limited to 32768 since the next multiple of 2 (65536) is
too big to fit inside a word size variable.

Bo Berglund
Developer in Sweden

More information about the fpc-pascal mailing list