I've attached an FFT test program with source code for B4R.
I am using B4R 2.51. My MCU is an 80MHz Wemos board.
The FFT is fast. It uses a pre-computed coefficient lookup table. It performs a double precision complex FFT.
The FFT code is in its own module and includes copy / Blackman window, scale, and magnitude squared subroutines.
I generate an integer test waveform to simulate A/D data acquisition.
With a 2000Hz sample rate and 64 sample FFT, I measure a 4.6 millisecond FFT compute time (copy/window, fft, scale, mag squared) on my MCU. This seems to easily support real-time processing of A/D audio.
*** Added Later ***
Unreal !!!
I found an error in the code for FFT.bas
This error has been in this code for almost 3 decades.
I am using B4R 2.51. My MCU is an 80MHz Wemos board.
The FFT is fast. It uses a pre-computed coefficient lookup table. It performs a double precision complex FFT.
The FFT code is in its own module and includes copy / Blackman window, scale, and magnitude squared subroutines.
I generate an integer test waveform to simulate A/D data acquisition.
With a 2000Hz sample rate and 64 sample FFT, I measure a 4.6 millisecond FFT compute time (copy/window, fft, scale, mag squared) on my MCU. This seems to easily support real-time processing of A/D audio.
*** Added Later ***
Unreal !!!
I found an error in the code for FFT.bas
B4X:
Sub ScaleFFT(x() As Double, y() As Double, scl As Double, n As Int) ' Calc magnitude square root
For i=0 To n - 1
x(i) = x(i) * scl
y(i) = y(i) * scl ' <-- should be y(i) = y(i) * scl, NOT y(i) = x(i) * scl
Next
End Sub
This error has been in this code for almost 3 decades.
Attachments
Last edited: