Teensy digital mixer, will 4.1 have enough processing power?

arthurdb

Member
Hello everyone,

I want to build a 4 in 6 out i2s digital audio mixer for live use. I have a strong background in analog electronics and some experience with bare metal mcu as well as with the arduino platform.

Since this is for live music, I need latency to be very low, ideally 1ms or under (I probably could live with only 2-3ms). It seems that that is easily achievable with the Teensy by reducing the audio block size.

So anyways, I would like a 4 band fully parametric eq and compressor for each input channel, a parallel reverb bus (ideally stereo and also with 4 band eq), and three independent stereo mix outputs, as well as metering for all inputs and outputs. That would be more or less the bare minimum to make it worth it to go digital instead of keeping the design fully analog. Is this a realistic goal for the Teensy 4.1 (4 compressors, 4 or 5 four band eqs, 13 mixer objects, 10 peak and/or rms detectors)?

Can I count on some processing headroom for additional features and the user interface (which I plan to keep simple, with a bunch of switches and encoders and a 4 x 20 lcd for display, beside I don't mind using a seperate mcu to handle the user interface)

Other features which I'd be interested in implementing : stereo eq and maybe limiting for all three outputs, peak detection for every stages, 4 channel recording to sd card (although 2 channel would already be pretty cool), pink noise generator, usb audio in/out...

I've found some other digital mixer projects based on the Teensy 4 but it didn't really help to give a sense if what I'm trying to do is actually achievable.
 
Yes it is totally achievable from processing standpoint. I have implemented a synth that runs 24 band-limited oscillators, 16 ZDF 24db/Oct ladder filters, 24 LFOs, 32 envelope generators, 3 way ensamble chorus, phaser, delay, reverb, 3 band parametric eq, 128 biquad formant filters, all in realtime with 128 sample buffer (2.9ms latency). I am not using Teensy Audio library though (for reasons other than performance). The problem might be with SD card as they are notoriously slow with writing and unpredictable delays.
 
Last edited:
The stock audio library, using the PJRC Audio Adapter, has an in to out latency of about 6.4ms. I know this from measuring it myself. Obviously you’d need to reduce the audio block size to get to your desired latency, as you say, but 32 samples should do it. Lower than 16 you may find some blocks don’t work properly. Your results may depend on how you implement the 4i6o hardware, too.

Bear in mind the library is only 16 bit, so compression and limiting may be slightly problematic. There is a float-based variant out there, which can inter-operate with the integer library, which you might want to investigate. It doesn’t have all the modules, but could be handy for the front-end stuff.

I’ve put in considerable work to create a robust SD card playback and recording capability, which you may want to consider. TBH I can’t recall if it’s been tested with different block sizes, but I’m happy to provide support on that thread if you find it misbehaves. It can record multiple WAV files of up to 8 channels; if you get seriously ambitious then it may be helpful to fit PSRAM for buffering when the SD card decides to hit you with a long delay.
 
I just had a bit of a play. Reducing the block size to 16 samples I got the in-to-out latency down to about 1.3ms. I think just under half of that is down to the SGTL5000, so as noted you may get differing results with other hardware.

I also tried my record and playback test, which records 16 synthesized audio channels to 3 WAV files of 4, 6 and 8 channels each, then plays the results back (the 6- and 8-channel files have no audio on one track each, but of course silence still has to be written to the file, and then read out). After changing to a better SD card (SanDisk Ultra SDXC 64Gb Class 10 A1), everything worked fine with the 16-sample audio blocks. I did have PSRAM fitted, and used about 1.7Mbyte of it for buffers. That might be overkill, it works out at about 370ms buffer for playback, and double that for record. If that doesn't work (as the Kingston 16GB card didn't...) then your SD card has issues, or the rest of your software needs a good looking at...
 
FWIW: I did not find any information about built-in antialiasing/interpolation filters in SGTL5000 data sheet, but the other popular DAC PCM5102 has two user-selectable antialias/interpolation filters that are very precisely documented. One is normal linear phase FIR that has 22 sample filter group delay (about 0.5ms at 44.1) and the other is "low latency" minimal phase filter that has delay of 3.5 samples (that is only for Digital->Analog side, not round trip).
 
Thanks for your input and tips. That's encouraging to hear.

Yes, I realize recording to SD is a finicky business, glad to know there's a solid library out there. I'll be sure to check it out.

The low latency setting for the PCM51xx chips is incredibly low, good to know.

I did not find ADCs that are quite as fast but the PCM1862(/3/4/5) has a low latency setting of 10 sample which is already excellent (PCM1864/5 supporting 4 output channels).

I am also considering the CS4272 2 in 2 out codec, but it's quite expensive, or PCM1808 2 ch adc. However both need +5V for the analog supply, and adding a clean 5v supply adds some complexity to the overall system.
 
IMHO, separate 5V analog supply is worth the trouble. Separate supplies lead to better THD+SNR. If you want any analog circuitry (preamps/ output buffers) the choice of 5V opamps specifically targeted for audio is wider.
 
I've just been playing with the multi-channel USB code, since I know the stock audio library does not work with the reduced audio block size needed for low latency. As it stands right now it's not working with super-small blocks, but it appears to be designed to do so; with luck it's a fairly straightforward fix. You may want to watch that thread for updates.

For multi-channel work TDM parts are possibly worth looking at. This thread covers a project using the TLV320AIC3104, and has resulted in a product you can buy (unless you're in the USA - see the Tindie page...). Looks like the chip latency is (17+21)/fs, which isn't outstanding, but it's quite a good way to try stuff out using just a single PCBA plus signal conditioning of your choice.
 
IMHO, separate 5V analog supply is worth the trouble. Separate supplies lead to better THD+SNR. If you want any analog circuitry (preamps/ output buffers) the choice of 5V opamps specifically targeted for audio is wider.
Well I was planning on +/-12 or 15V for the analog front end and separate 3.3v supplies, LDO-regulated from a unique 5v (which would also power the teensy). But if I need a well regulated and clean 5v supply for the converters... then I need a 7 volt supply or something, which means either wasting a ton (relatively speaking) for the 3.3V stuff or keeping a seperate 5V supply... I mean, it's not a huge deal but it does add some complexity.

That said, I think I'll go this route. I want to solder myself and I'm not too comfortable with hot air so I want pinned packages, and I've decided to stick to 2 in 2 out codecs rather than dealing with seperate chips for ins and outs. So will probably choose to go with the CS4272. I've also found the AK4621 which has similar latency (around 20/fs in+out).

This thread covers a project using the TLV320AIC3104, and has resulted in a product you can buy (unless you're in the USA - see the Tindie page...).

One pcb left.... it's very tempting
 
+/-12V is overkill, IMHO. Most modern good converters use 5V for analog side, so using 5V for opamps too is obvious choice.
 
As a side note, I've found two other chips with a very low latency setting, in a hand-soldering friendly package (tssop-16 with 0.65mm pitch):

AK4432: 2ch DAC - 1/5.6fs (sharp roll-off) or 1/5.2fs (slow roll-off). THD+N at -91dB, 108dB DR
AK5727: 2ch ADC - 1/5.5fs. THD+N at -94dB, 102dB DR

Which sums to around 0.25ms latency at 44.1KHz

Both support TDM, and require 3.3V for the analog section, and are single ended only.
 
Yes it's ridiculously low. IMO, the biggest selling point for those chips is the 0.65mm pitch ;)

However things do add up, especially if you consider the rather reasonnable use-case of plugging a digital instrument with a couple of digital pedals into a digital mixer into a speaker with dsp and time for the sound waves to come back to you.

But yes, half a millisecond will not make a difference.
 
Back
Top