Real Time Audio Processing

I've not yet even tried venturing into this area of C++ yet... But do 'the people in the know' see the Teensy 4.1 as a viable microcontroller for a project aimed at real-time audio processing?

I'm thinking of creating a project that would take in audio via a 1/4" jack, process multiple effects in realtime such as reverb, delays, EQ's, distortions (stacked on top of each other), then output the final audio with, let's call it 'very useable', low latency? Suitable enough in terms of latency/audio quality for live performance, for example? If so I will plan on learning about/writing those effects myself which will be an awesome project to tackle.

On top of this there would be a display to run, and some buttons/knobs as controls.

Is the T4.1 geared up for this sort of job already? Or am I being a little too optimistic here?

Thanks!

Steve
 
Last edited:
I'm not really up on the stuff, but I've seen some Teensy sync and sound projects:

You might want to look through the original video for the audio library. While it used a Teensy 3.2, the Teensy 4.1 should support everything (note, the pinouts for the audio shields are different). Also look at the audio design tool for designing the connections between the inputs, effects, and outputs:
 
It's ok for this but not excellent. ~7ms is the loopback time between analog input and analog output. It's enough for real time musical processing. I use it this way, others use it this way. But I've seen other projects get closer to ~3ms. This is with the audio library by the way. Apparently the hardware is capable of faster speeds, with optimized code. I also think the bitrate (16 bits) has something to do with limiting the theoretical speed of I'm not mistaken.
 
The audio block size and latency of the codec contribute to the delay. Bit depth has no effect.
The default block size is 128 samples which is 2.9ms at 44.1kSPS. You can reduce the block
size for lower latency(*) at the expense of increased CPU usage. On the T4.x there's usually no
shortage of processor power.

(*) Some audio components don't work at different block sizes though.
 
Some of us have done extensions to the audio library in order to support floating point math, instead of just the fixed point math used by the Teensy audio library. In some of these libraries, the sample rate and block size can be changed, unlike the Teensy audio library.

One such library is the Open Audio library (which helped create originally). Here's an example sketch where you can see where to set the sample rate and block size: https://github.com/chipaudette/Open...lob/master/examples/TestBiquad/TestBiquad.ino

Another library is the Tympan library, which is aimed at supporting the Tympan audio hardware (a Teensy at heart) but it can be used with any hardware. Here's a sketch that shows how to change the sample rate and block size: https://github.com/Tympan/Tympan_Li...1-Basic/ChangeSampleRate/ChangeSampleRate.ino

Minimum latency would be achieved through the shortest block size and fastest sample rate. Tympan can run up to 96 kHz and probably would function at block sizes of 1 or 2 samples (I've only ever gone down to 8). If you're using the Teensy audio adapter (STGL5000), I'm not sure what sample rate you can go up to, but you can totally still use the shorter blocks.

Have fun!

Chip
 
Back
Top