FFTAnalyzer will eat your PROGMEM

If you want to use FFTAnalyzer from ArduinoSound, it will eat your PROGMEM like there is no tomorrow. My went from 9% to 68%.

Program size: 177,348 bytes (used 68% of a 262,144 byte maximum) (4.77 secs)
Minimum Memory Usage: 4248 bytes (13% of a 32768 byte maximum)

The culprit is arm_rfft_init_q31 function required for FFT calculations https://raw.githubusercontent.com/ARM-software/CMSIS/master/CMSIS/DSP_Lib/Source/TransformFunctions/arm_rfft_init_q31.c

It contains large precalculated tables (see source), which you dont need. The tables are for the largest FFT size which you never going to use on MCU. It would have been nice if they had a separate function for FFT size. I'm playing with FFT size of 32, the smallest, 2 precalculated tables should be 64+64 ints in size in my case but instead are 8192+8192.

So, the solution is to copy the function and modify it locally. Now I'm down to a reasonable size, not 9% but...

Program size: 47,172 bytes (used 18% of a 262,144 byte maximum) (3.46 secs)
Minimum Memory Usage: 4248 bytes (13% of a 32768 byte maximum)


It looks beautiful!

Very nice. Can you share your code?

My code is rather large as I modified I2S and AudioInI2S to output master (still in progress), I might put it on github when finished.

Cool, please share the link here too, if you remember to.

1 Like

Sweet, thanks.
Hope it gets lots of downloads.

Sorry I simplified the code, only need updated I2S class to add to Arduino/libraries from GitHub - KillzoneKid/ArduinoCore-samd: Arduino Core for SAMD21 CPU to output master clock, no need for ArduinoSound modifications. Then call I2S.enableMasterClock() before initialising AudioInI2S, for example:

if (!AudioInI2S.begin(48000, 32))

This will output 12Mhz clock on I2S_MCK[0] and adjust all other lines accordingly.

Here is the function in question, modified