bmillier
Well-known member
I've written a floating point FFT-based convolution filter object for the Teensy Audio library. It is basically a 513-tap convolution filter performed by converting the signal & filter mask into the frequency domain where the convolution function can be performed much more quickly. In other words, the convolution/filtering can be done in real time at the 44,100 Hz sample rate used in the Audio library. I based my code on the excellent work done by Frank, DD4WH on his convolution SDR (posted on this forum). Note that a conventional FIR filter object already exists in the Teensy Audio library, but it is limited to 200 taps, and is done using fixed-point math.
Besides standard 513-tap FIR filtering applications, this routine can be used to do guitar amplifier cabinet simulation, such as is found in commercial DAW plug-ins, for example. In this case the "impulse" file (a WAV file) is used in place of the 513 point FIR filter coefficient array.
The convolution routine is done in floating point, which eliminates the limitations imposed by the fixed-point (Q15) routines generally used in the Teensy audio library. However, this means that some modifications must be made to the Teensyduino distribution- to add the floating point CMSIS DSP routines needed for this object. These modifications are identical to those needed for the DD4WH SDR project also found in this forum. A link to these instructions are contained in the repository I've created on Github for this FFT/convolution routine, at
https://github.com/bmillier/Teensy-FFT-Convolution-Filter
In the repository I've included the .cpp and .h files needed for this library object, as well as 2 examples:
1) a 513-tap FIR filter example
2) a guitar amplifier cabinet simulation example (uses the Teensy 3.6's on-board SD socket to host an SD card containing the cabinet simulation WAV file(s).
While the FFT-based convolution routine is very efficient, it does require 64% of the processor's execution capacity for 1 out of every 4 audio update cycles (the FFT/convolution processing must be done in 512 sample blocks, while the audio library works in blocks of 128 samples). Therefore, there definitely are limits on how many additional audio blocks you could use for your application.
I developed my audio library code by first modifiying DD4WH's "inline" SDR sketch code to perform only the FFT/convolution that I needed. I haven't included my sketch-based (in-line code) version of the routine in the repository, but could add it if people were interested in developing guitar amplifier cabinet simulation for the Teensy, without actually adding this new object to the Teensy Audio library.
I used the following source extensively in understanding what the underlying theory of FFT/convolution was all about. If, like me, you are not a math wizard, this is the best treatment of the subject I have come across.
The Scientist and Engineer's Guide to Digital Signal Processing
By Steven W. Smith, Ph.D.
found at www.dspguide.com
You can buy the book, or read the various chapters in PDF, for free, at that website. Thanks Dr. Smith for this excellent book!
Besides standard 513-tap FIR filtering applications, this routine can be used to do guitar amplifier cabinet simulation, such as is found in commercial DAW plug-ins, for example. In this case the "impulse" file (a WAV file) is used in place of the 513 point FIR filter coefficient array.
The convolution routine is done in floating point, which eliminates the limitations imposed by the fixed-point (Q15) routines generally used in the Teensy audio library. However, this means that some modifications must be made to the Teensyduino distribution- to add the floating point CMSIS DSP routines needed for this object. These modifications are identical to those needed for the DD4WH SDR project also found in this forum. A link to these instructions are contained in the repository I've created on Github for this FFT/convolution routine, at
https://github.com/bmillier/Teensy-FFT-Convolution-Filter
In the repository I've included the .cpp and .h files needed for this library object, as well as 2 examples:
1) a 513-tap FIR filter example
2) a guitar amplifier cabinet simulation example (uses the Teensy 3.6's on-board SD socket to host an SD card containing the cabinet simulation WAV file(s).
While the FFT-based convolution routine is very efficient, it does require 64% of the processor's execution capacity for 1 out of every 4 audio update cycles (the FFT/convolution processing must be done in 512 sample blocks, while the audio library works in blocks of 128 samples). Therefore, there definitely are limits on how many additional audio blocks you could use for your application.
I developed my audio library code by first modifiying DD4WH's "inline" SDR sketch code to perform only the FFT/convolution that I needed. I haven't included my sketch-based (in-line code) version of the routine in the repository, but could add it if people were interested in developing guitar amplifier cabinet simulation for the Teensy, without actually adding this new object to the Teensy Audio library.
I used the following source extensively in understanding what the underlying theory of FFT/convolution was all about. If, like me, you are not a math wizard, this is the best treatment of the subject I have come across.
The Scientist and Engineer's Guide to Digital Signal Processing
By Steven W. Smith, Ph.D.
found at www.dspguide.com
You can buy the book, or read the various chapters in PDF, for free, at that website. Thanks Dr. Smith for this excellent book!