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

Thread: fft ifft ?

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    8

    fft ifft ?

    hello,

    just found this one

    https://github.com/mozanunal/SimpleDSP/wiki/FFT-IFFT

    I managed to build it so I was wondering why there were no ifft in teensy ?
    and why is the fft in teensy not giving real/img part ?

    regards
    Last edited by phil123456; 09-06-2018 at 06:49 PM.

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    595
    Just as a guess, in many practical engineering applications of the FFT you really only care about the amplitude of the (real) power spectrum. You don't want the additional memory space and data structures to deal with phase, negative frequencies or imaginary values.

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    I want to do more than just display a spectrum on a lcd
    I use puretdata so far and no way you could do ifft without the real/img data

    the magnitude/phase , for my needs, is useless (besides, afaik, fft in teensy audio library does not contain the phase, and there is no ifft either)

    I modify the spectrum, then go back to time domain and create really cool effects that way

    the very base of DSP

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,222
    Quote Originally Posted by phil123456 View Post
    not if you do ifft afaik
    JBeale gave you the real practical answer ("why there were no ifft in teensy ")

    The technical answer is, the audio library that implements the FFT functionality is running on 16 bit
    There is no convincing argument to do FFT based filtering (fft-ifft) on 16 bit.

    However, nobody prohibits to take the existing code and to implement either 32 bit fft/ifft or even float fft/ifft code.
    after all the fft implementation is based on CMSIS code, which provides also 32-bit or float versions.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Quote Originally Posted by phil123456 View Post
    ...so I was wondering why there were no ifft in teensy ?
    and why is the fft in teensy not giving real/img part ?
    Could you be more specific about the "fft in teensy" you're mentioning?

    In the audio library, the FFT object gives only magnitude. It's intended for music visualization.

    In arm_math.h (an older version of CMSIS-DSP), which is used internally by the audio library and also available to you if you include arm_math.h, the FFT functions do process complex numbers for input and output. It does indeed provide inverse FFT.

    So it really does matter which code. Please be more specific.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Quote Originally Posted by WMXZ View Post
    There is no convincing argument to do FFT based filtering (fft-ifft) on 16 bit.
    ??? what ?? why ?
    most wav samples are 44khz 8/16 bits

    most MCU ADC are 12 bits

    what does this have to do with anything ?

  7. #7
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Quote Originally Posted by PaulStoffregen View Post
    Could you be more specific about the "fft in teensy" you're mentioning?

    In the audio library, the FFT object gives only magnitude. It's intended for music visualization.

    In arm_math.h (an older version of CMSIS-DSP), which is used internally by the audio library and also available to you if you include arm_math.h, the FFT functions do process complex numbers for input and output. It does indeed provide inverse FFT.

    So it really does matter which code. Please be more specific.
    ok, then awesome, I'll have a look
    sheers mate

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,222
    Quote Originally Posted by phil123456 View Post
    ??? what ?? why ?
    most wav samples are 44khz 8/16 bits

    most MCU ADC are 12 bits

    what does this have to do with anything ?
    It is all about integer arithmetic (i.e. not floating point) using optimized DSP engines

    a 1024 fixed point FFT must shift the results (scales) by 10 bits to the right ( so you loose up to 10 bit resolution in your input data)
    an additional 1024 fixed point IFFT shifts the results again by 10 bits to the right.
    see also https://www.keil.com/pack/doc/CMSIS/...omplexFFT.html

    So doing 16 point arithmetic (as done in audio library) you shift all weak details into nirvana and keep only strongest signals.

    IOW: the fixed point implementation FFT and IFFT divides always by the number of samples, so IFFT (FFT (x)) will not be x but x/N !

    If you are interested in FFT-based filtering, you must use at least 32 bit FFT , which on Teensy with optimized 16 bit DSP arithmetic is significantly slower, but it can and has been done and presented here on the forum

  9. #9
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    384
    Hi Phil,

    it would be nice to know more about your project.

    I modify the spectrum, then go back to time domain and create really cool effects that way

    the very base of DSP
    Really curious about your cool effects!

    Here is the "very base of DSP" you need (FFT-iFFT chain) programmed by Brian:

    https://forum.pjrc.com/threads/43847...ht=convolution

    Instead of the complex-multiply of the FFT results with the filter mask (consisting of the FFT of the impulse response of the FIR filter) just add your effects.

    Have fun with that!

    Frank DD4WH

  10. #10
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    384
    Hi Walter,

    So doing 16 point arithmetic (as done in audio library) you shift all weak details into nirvana and keep only strongest signals.
    Thanks a lot for that explanation! That is the first time I understand the underlying reason for this!

    All the best,

    Frank DD4WH

  11. #11
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,222
    Quote Originally Posted by DD4WH View Post
    Hi Walter,



    Thanks a lot for that explanation! That is the first time I understand the underlying reason for this!

    All the best,

    Frank DD4WH
    you are welcome
    Walter

  12. #12
    I've been using the CMSIS Version 5.3.0 DSP Library since May 2018 (see github.com/ARM-software/CMSIS_5). I might be the only person on this forum using it. The library allows me to use the 32-bit floating point capability of the Teensy 3.6. I have been able to use it in real-time with 16-bit sample rates out of both ADCs up to around 450 kHz (i-q data). I'm very happy with the performance I am obtaining. Here is the FFT/IFFT performance I am getting with the library:


    # Points Forward rfft Inverse rfft Forward cfft Inverse cfft
    512 201 us 247 us 239 us 294 us
    1024 362 us 454 us 588 us 714 us
    2048 846 us 1066 us 1376 us 1620 us
    4096 1860 us 2304 us 2504 us 2990 us
    Last edited by willie.from.texas; 09-10-2018 at 02:18 AM.

  13. #13
    Member
    Join Date
    Aug 2013
    Location
    Ohio
    Posts
    84
    Hi Willie_from_Texas, what system clock rate are you using to obtain those numbers? At first glance they seem impressive.

  14. #14
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    384
    Chip also did a detailed comparison and speed test with Teensy 3.2 and 3.6, measuring differences between integer and floating point processing and the CMSIS DSP functions:

    http://openaudio.blogspot.com/2016/1...6-is-fast.html

  15. #15
    These results are at the default clock rate of 180 MHz. I'm running in real-time using data from the ADCs. I'm concerned that if I overclock the chip it will affect accuracy of the ADCs. - W

  16. #16
    Quote Originally Posted by DD4WH View Post
    Chip also did a detailed comparison and speed test with Teensy 3.2 and 3.6, measuring differences between integer and floating point processing and the CMSIS DSP functions:

    http://openaudio.blogspot.com/2016/1...6-is-fast.html
    Given the date of 2016 I'm willing to bet this benchmark was done using CMSIS Version 4. The article doesn't state whether or not the FFTs were calculating real or complex data. Assuming real floating point data using an FFT size of 512, the results I obtained are about twice as fast. It would be an interesting comparison for someone running Version 4 to duplicate the cases that I published in the table from my earlier post. -W

  17. #17
    Member
    Join Date
    Aug 2013
    Location
    Ohio
    Posts
    84
    Thanks to all, my co-workers and I appreciate the info.

Posting Permissions

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