Forum Rule: Always post complete source code & details to reproduce any issue!

fft ifft ?
hello,
just found this one
https://github.com/mozanunal/SimpleDSP/wiki/FFTIFFT
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; 09062018 at 06:49 PM.

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.

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

Originally Posted by
phil123456
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 (fftifft) 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 32bit or float versions.

Senior Member
Originally Posted by
phil123456
...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 CMSISDSP), 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.

Originally Posted by
WMXZ
There is no convincing argument to do FFT based filtering (fftifft) 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 ?

Originally Posted by
PaulStoffregen
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 CMSISDSP), 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

Originally Posted by
phil123456
??? 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 FFTbased 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

Senior Member
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 (FFTiFFT chain) programmed by Brian:
https://forum.pjrc.com/threads/43847...ht=convolution
Instead of the complexmultiply 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

Senior Member
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

Originally Posted by
DD4WH
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

I've been using the CMSIS Version 5.3.0 DSP Library since May 2018 (see github.com/ARMsoftware/CMSIS_5). I might be the only person on this forum using it. The library allows me to use the 32bit floating point capability of the Teensy 3.6. I have been able to use it in realtime with 16bit sample rates out of both ADCs up to around 450 kHz (iq 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; 09102018 at 02:18 AM.

Hi Willie_from_Texas, what system clock rate are you using to obtain those numbers? At first glance they seem impressive.

Senior Member
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...6isfast.html

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

Originally Posted by
DD4WH
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

Thanks to all, my coworkers 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

Forum Rules