Contributor: MARCEL HOOGEVEEN
{
From: marcel.hoogeveen@hacom.wlink.nl (Marcel Hoogeveen)
GR> FFT stands for Fast Fourier Transform. It is a quick way to conver
GR> time domain data (ie oscilliscopy data with time on the x-axis) to
GR> frequency domain (frequency on the x-axis, like a frequency spectrum
GR> analyzer). This is a usefull data analysis method. I would also like
GR> to get some source for this.
This is what i have of FFT source code, it should work if you tweak it a bit.
(It did for me when i used it in my analasis program).
Don't ask me how it works, i know how a DFT works but a FFT well .. just use
the source. :)
}
Program FFT;
Const Twopi=6.283185303;
Type Curve=array[1..nfft] of real;
Var {This is for you to find out}
{ Calculation of the Discrete Fourier Transfor }
{ Using a Fast Fourier Transform algorithm }
{ }
{ XR and XI are array of reals !!! }
{ They contain on entry the input sequence and }
{ on return the transfrom }
{ ISI defines the transform direction }
{ If ISI=-1 then forward, if ISI=1 then invert }
{ }
{ The dimension is 2**M }
Procedure RFFT (VAR XR,XI:Curve; N:integer; ISI:Integer);
Var
M,NV2,LE,LE1,IP,I,J,K,L: Integer;
C,THETA,UR,UI,TR,TI:Real;
Begin
M:=Round(LN(N)/LN(2));
NV2:= N DIV 2;
J:=1;
For I:= 1 to N-1 do
Begin
If (I=N)
End;
End;
If ISI=-1 then
Begin
For I:= 1 TO N do
Begin
XR[I]:=4*XR[I]/N; XI[I]:=4*XI[I]/N;
End;
End;
End;
Begin
For I := 1 to NUMSAM do
Begin
FREAL[I]:=SAMPLEBUFFER[I];
FIMAG[I]:=0;
End;
RFFT(FREAL,FIMAG,NUMSAM,-1);
DC:=FREAL[1]/2;
For I:= 1 to NUMSAM dO
FREAL[I]:=FREAL[I]*FREAL[I]+fIMAG[I]*FIMAG[I];
End.