Q31 in analyze_fft1024

Status
Not open for further replies.

Pedrucius

Member
Hello everyone,

I've recently joined a project which we need to do some FFT calculations over some data. Pretty common.... but the resolution of Q15 seems not to be enough, so we've decided to change the code of analyze_fft1024.h and analyze_fft1024.cpp to support Q31 numbers. I'm a newbie in this, so I would appreciate some help to understand what I'm doing wrong. I did a fast research in this forum, but didn't find anything about it...

The results are here (The Q31 should be very similar to the Q15):
Q31-Q15.jpg

My question is: What do I need to change in the .h and .cpp files? I've made some changes but the results are not similar to the old ones...
Here is what I've changed, basically replace some int16_t with int32_t:

Code:
//ANALYZE_FFT1024.H NEW VALUES
extern const int32_t AudioWindowHanning1024[];
arm_cfft_radix4_init_q31(&fft_inst, 1024, 0, 1);
void windowFunction(const int32_t *w){//same code}
uint32_t output[512] __attribute__ ((aligned (4)));
const int32_t *window;
int32_t buffer[2048] __attribute__ ((aligned (4)));
arm_cfft_radix4_instance_q31 fft_inst;

And...

Code:
//ANALYZE_FFT1024.CPP NEW VALUES
arm_cfft_radix4_q31(&fft_inst, buffer);

Probably, I need to change the "copy_to_fft_buffer" function as well...

Thank you.
 
Last edited:
Isn't the AudioWindowHanning1024 for 16bit values or did you change them to q31 values, not sure if that matters. I think the best way to test this would be to remove the Audio library from the equation and focus on the CMSIS-DSP fft functions. What I mean is just feed the fft's (q15 and q31) static data (q15) and see if they agree with each other, then add a window to that data and see if they agree again. The problem with using the audio library to debug this is the input data is streaming and you can't slow it down to debug it since that screws up the input data itself.

Oh ya look at that magnitude squared code in the update function, it's got to changed also since its hard coded for q15 values. Like I said just make sketch and bring out the FFT functions and support code outside of the Audio library and use static input data to so you can see whats going on. I usually just feed the fft's a sine wave or something simple at first.
 
Thanks for the advice! I'll try to see the output without the Audio library. It seems the right approach.
If it works, I'll check the Audio functions.
 
I've tested the CMSIS-DSP functions, outside the library, as duff said. The values are fine. So, I need to work in the Audio library code to get this to work.
 
Status
Not open for further replies.
Back
Top