kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.62k stars 248 forks source link

Report DFT progress #179

Open xkzl opened 1 year ago

xkzl commented 1 year ago

Hello,

I would like to make a progress bar when computing large Fourier transform. This would be a great feature.. Knowing the total number of Fourier coefficients to compute and the typical FFT flow graphs.. Is there any possibility to use a signal handler to report the computational progress of the calculation ?

Cheers, Marco

dancazarin commented 1 year ago

Hello Marco, I think it's not possible without modifying KFR sources. Progress callback is not implemented because most of FFT sizes typical for audio take micro- or milliseconds. But for larger data this would be very reasonable and good to have. Internally KFR do calculations in 'stages' or passes. Each pass can report when it starts end finishes. This won't give maximum accuracy but at least it's what is relatively easy to implement. Could you try to add simple printf before every call to stages[...]->execute here and check if the frequency of printing is enough for your use case: https://github.com/kfrlib/kfr/blob/master/include/kfr/dft/fft.hpp#L243 If it turns out not to be enough, then precise progress reporting will be much harder to implement without affecting performance in highly optimized pass functions (but still possible).

xkzl commented 1 year ago

Hi Dan,

I am going to give it a try. It is exactly what I need I think. Thank you for pointing me out the location.

Cheers, M.