ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
454 stars 122 forks source link

Fixed Point Hanning Window Generation #182

Open AdamC19 opened 2 weeks ago

AdamC19 commented 2 weeks ago

Apologies if this has been brought up here before, but I didn't find it.

CMSIS-DSP provides functions for generating variable-length Hanning window vectors for floating point numbers. However, if one needs a Hanning window consisting of fixed point numbers, the workflow would be to first generate a floating point window vector, then convert it to fixed point using arm_float_to_q31 or related functions. (Then apply the window using fixed point vector multiplication functions: arm_mult_31 etc.)

For large window sizes, this strikes me as an inefficient use of RAM in a resource constrained system, especially if it needs to be statically allocated. And for a large window size, dynamic allocation followed by freeing seems like a bad idea and sometimes not even practical.

The background for this request comes from a project I'm working on that needs to apply a window to an 8192-word q15_t sample buffer (for feeding to a real-valued FFT). My target has only just enough RAM to reasonably support this along with the other things it needs to do. Some approaches I've thought of:

Unless a better solution comes up, I'm going to create this functionality myself. So if this request/addition/feature seems desirable and sensible for CMSIS-DSP, I'm willing to assist in feature addition. Although I've done a token amount of software work professionally, I've never contributed to a serious open source project before. There may be a bit of a learning curve there.

Finally, while this is not necessarily a forum for problem-solving help, I'm open to hearing anyone's ideas on solutions for this, or re-direction to more appropriate forums. Thanks!

christophe0606 commented 2 weeks ago

@AdamC19 If you have enough non volatile memory, you can generate a table of pre-computed Hanning coefficients for use at runtime.

We do not currently have plans to provide fixed point versions of the windowing functions (because of other things to fix in the library before).