Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Q31 in analyze_fft1024

  1. #1
    Junior Member
    Join Date
    Jun 2017

    Q31 in analyze_fft1024

    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):
    Click image for larger version. 

Name:	Q31-Q15.jpg 
Views:	85 
Size:	73.3 KB 
ID:	10868

    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:

    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;

    arm_cfft_radix4_q31(&fft_inst, buffer);
    Probably, I need to change the "copy_to_fft_buffer" function as well...

    Thank you.
    Last edited by Pedrucius; 06-23-2017 at 06:29 PM.

  2. #2
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Las Vegas
    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.

  3. #3
    Junior Member
    Join Date
    Jun 2017
    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.

  4. #4
    Junior Member
    Join Date
    Jun 2017
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts