espressif / esp-dsp

DSP library for ESP-IDF
Apache License 2.0
465 stars 87 forks source link

Bug: dsps_fft4r_fc32() returns incorrect values for specific number of samples (e.g. 1024, 256, 64) #23

Closed Vvard closed 3 years ago

Vvard commented 3 years ago

The results can be reproduced by running standard fft4real example. Below are examples of correct (#define N_SAMPLES 2048 ) and incorrect (#define N_SAMPLES 1024 ) results. Incorrect results occur also at 256, 64 number of samples.

define N_SAMPLES 2048

2048Sample

define N_SAMPLES 1024

1024Sample

dmitry1945 commented 3 years ago

Hi @Vvard ,

The result is correct. In example we are using FFT radix-2 and radix-4. The real N samples converted to N/2 complex samples. Then samples processed by FFT and then converted back to real spectrum. If you use 1024 input samples, then 512 complex samples could not be processed by FFT radix-4, and will be processed only by radix-2. And you see correct result for radix-2 and wrong result for radix-4.

Regards, Dmitry

Vvard commented 3 years ago

Hi @dmitry1945 ,

Thank you for pointing the error. And it would be nice if fft4r would return an error, that specific numbers of samples are not supported.

Regards, Vard