Well you can, and here is the code to prove it (in this case for an aperture of 1024 samples)! Firstly we need some initialisation, that's done just once so it doesn't count towards the number of statements per Fourier Transform (do sufficiently many and the contribution to the average from the initialisation tends to zero):
Code: Select all
Aperture% = 1024
DIM In(Aperture%-1), Out(Aperture%-1), DFT(Aperture%-1, Aperture%-1)
REM. Prepare DFT coefficients:
FOR I% = 0 TO Aperture%-2 STEP 2
r = -PI*I%/Aperture%
FOR J% = 0 TO Aperture%-1
DFT(I%+0,J%) = COS(r*J%)
DFT(I%+1,J%) = SIN(r*J%)
NEXT
NEXT I%
Code: Select all
Out() = DFT() . In()
Well almost. In practice you will probably want to apply a window function (e.g. Hanning) to the input data, and if you want the magnitudes of the spectral components you will need to calculate SQR(real^2 + imaginary^2) but these are strictly not part of the Fourier Transform.