fakufaku / esp32-fft

Vanilla single-precision radix-2 FFT for the ESP32.
168 stars 34 forks source link

How to make it work without destroying the config each time ? #10

Closed brahma-dev closed 2 years ago

brahma-dev commented 2 years ago

I am trying to run fft on two input arrays back and forth.

ft_config_t *fft_analysis = fft_init(4096, FFT_REAL, FFT_FORWARD, fft_input0, fft_output);
//Do something
fft_destroy(fft_analysis);
ft_config_t *fft_analysis = fft_init(4096, FFT_REAL, FFT_FORWARD, fft_input1, fft_output);
//Do something
fft_destroy(fft_analysis);

Both arrays are of same size. Is it possible to use it such that I don't have to run fft_init every time and instead just change the input and run fft_execute ? I want to do so because fft_init takes more time than fft_execute. And I am short on CPU time.

brahma-dev commented 2 years ago

Nevermind. It works.

fft_analysis->input = fft_input0

fakufaku commented 2 years ago

@brahma-dev Yes, it should be possible! You can allocate your own memory for the input and output buffer. Then, you can just update the content of the array and re-run the FFT. fft_init requires some CPU cycles to pre-compute the "twiddle factors" of the FFT, but if you only deal with fixed size, you could pre-compute them at compile time, or create the look-up table in advance. Then you could get rid of fft_init altogether.