USB interface for multi channel outputs, not just stereo

When using Windows MME and Stereo capture, the recorded files have a much lower level (-15dB). I cannot find any attenuations in Windows, but they must be there. When using Windows WASAPI and capturing all 8 channels in mono, the recorded levels are very close to the played level. A -1.5dB pad was added to bring the recorded level to -0.3dB below the played level. Right now, I only have a dual channel wing board so I need to complete an 8 channel prototype. Also, ASIO4ALL might be an option for the Teensy that might need additional investigation.

With regards to the DC offset, the caps/resistors fixed that and the HPF was removed from the sketch.

This is going nicely... Someone should make a PCB Shield (Palmer?) that sits on the risers with all the caps and resistors in place. My two channel prototype is a birds nest and the 8 channel will be worse.

1792288918330.png
1792288939598.png

1792288992670.png


Latency still needs to be checked, but I'll try the ASIO4All first.
 
More information about round trip latency (RTL). First, the ASIO4All worked well and all Teensy USB 8 ins and 8 outs are addressable from VST Host (Cantabile).

My normal rig uses a Lexicon Alpha (obsolete but cheap and I admit slow...). The analog output was looped into the input and both the output and input were recorded to a single *.wav. An on/off 100 Hz 44.1kHz-16bit signal was sent to the output. The difference in the start of the output wave form compared to the start of the input wave form would be the round trip latency which is going through the DAC then back through the ADC (this is two digital/analog conversions). The same program and ASIO4All drivers were used for both the Alpha and the Teensy.

The Alpha is operated with a 256 sample ASIO buffer. The measured latency is 29ms or 1,280 samples. This is a dual conversion latency, so the one way latency is about 15ms which is above desired of 10ms. I can attest that whatever the actually latency is, I cannot hear it. This measurement is surprisingly high; I was expecting RTL of half of this, but this is a relative comparison, not an absolute. A "best in class" RME Babyface has an RTL of 12.2ms at 256 sample buffer, but this is measured under a better controlled real-time environment. My method is an old laptop with a converter laying on the carpet... Or it could mean that my obsolete interface is has 2.5 RTL of a modern interface. Probably a little of both.

To get the same loop latency out of the Teensy, the Software host has to be 128 samples (half) and the Teensy has to be complied with 16 audio block size. At these conditions, the round tip latency is 28ms. Thus, I'd say the latency of the Teensy system is double the latency of the Alpha because the Teensy ASIO buffer has to be halved to get comparable results. When the ASIO buffer is 128 and the Teensy Block size is increased to 128 samples, the latency increase to 38ms.

If listening, the Teensy high latency really doesn't matter. If performing, the higher latency might matter. I've not used the Teensy during performance, but I'll work toward that. Once gain, I'd say the Teensy Audio latency might be higher than desired for live performance. Maybe my code needs improvement? IDK... Maybe the latency through the Teensy combined with more latency through the digital converter chips is high? Maybe my measurement method needs to improvement, too.

The 256 sample block size never worked. The captured waves were quite broken. Upper two waves are stereo output; lower two waves are stereo input.
1792345115921.png


A typical recording looked like this. In this case, the output is the bottom wave and the input is the top wave. The difference is the RTL. This is a 100 Hz sine in a 44.1kHz sample rate. There area about 5.5 complete 100 Hz cycles in the output before the input registers. About 5.5 100Hz waves is about 55ms (this is a high latency). This case was the Teensy with 128 sample block size and 512 sample buffer (worst case).
1792345245625.png


Update: Was able to improve the RTL with modifications to two files in the library.

usb_audio_inteface.h
#define TARGET_RX_BUFFER_TIME_S 0.0005f
//targeted buffered time (latency) in seconds - Default is 0.0018f
#define TARGET_TX_BUFFER_TIME_S 0.0008f
//targeted buffered time (latency) in seconds - Default is 0.0035f

usb_desc.h
// LATENCY EXPERIMENT: force the high-speed audio polling interval instead of using the
// longest one that fits the bandwidth (which is 1 ms here: 8 ch x 2 bytes x 45 samples
// = 720 bytes/ms). Values: 1 = 125 us, 2 = 250 us, 3 = 500 us, 4 = 1 ms.
// Everything below (packet sizes, frames per second) follows from this value.
// Remove these two lines to go back to the automatic choice.
#undef AUDIO_POLLING_INTERVAL_480
#define AUDIO_POLLING_INTERVAL_480 1

These were suggested by Claude and they improve RTL. usb_desc.h lines are entered after the if/then to force usb polling to be 125us.

The original Teensy RTL was 33ms with 256 ASIO samples and 16 Audio Blocks
With above changes and same samples/blocks, RTL is down to 27ms (this is as good as the Alpha)
If the Teensy will run at 128 samples, the RTL will be at 22 ms

The sine wave captures look good (no glitches); however, long term stability has not been tested. Backup files before changes (also need to delete the Arduino cores to force a recompile if library files are changed):

Important: these constants are compiled into core files, so Arduino must rebuild the core after you change them. Clear Arduino’s temporary build cache (%TEMP%\arduino for IDE 2.x)
 
Last edited:
Thank you for posting measurements of latency. With 256 sample buffer @44.1kHz buffer alone gives (256/44100) 5.8ms latency. Round trip is 11.6ms (pretty much what you are getting from RME), so 29ms is actually expected from ASIO4All, as ASIO4ALL is a wrapper that uses WASAPI and that adds extra latency. Only dedicated ASIO driver that totally skips Windows processing would be able to deliver better latency.
I have Yamaha Motif XS that has Firewire interface and it has 3.9ms input latency and 6.1ms output latency with 128 sample buffer.
The problem is not on Teensy side, but rather the fact that it goes thru several layers on Windows (WASAPI->ASIO4ALL)
 
I agree. After additional tests with a USB digital loop from output to input (no Teensy), the RTL with 64 sample buffer was 17 ms (this is Windows only). When the Teensy and it's analog loop were added, the RTL increased to 20 ms. Only 3ms additional delay through the Teensy seems TGTBT, but that's the measurement. Even at 128, 192, and 256 sample buffers, the Teensy loop only added 2-3 ms to the RTL. These are all with the 16 sample Audio Block side in IDE (that seems to be working well).

Without proprietary ASIO drivers, who/how/what can Windows latency be improved? Seems that's a RTL brick wall for now. All those little tweaks on the Teensy RX, DX, USB Polling don't really improve in relation to the Windows latency.

All I know to do is attach the Teensy system to the live performance rig and see how it behaves and feels. Latency is really noticeable when using a microphone input processed through a VST vocoder. The brain really picks up a vocal latency. I'm hoping my experiments are inflating RTL and it's not that bad in a live performance.
 
Only 3ms additional delay through the Teensy seems TGTBT, but that's the measurement.
That sounds plausible. The target receiver latency in the Teensy code is set to 1.8ms; I can’t really follow all the code, but presumably there’s a similar or smaller transmit latency. The USB packets are at 125μs microframe intervals, which inherently adds 0.25ms to the round trip. A 16-sample audio block adds 0.362ms (maybe? Perhaps not…).

All in all I think it’s a really nice piece of work. It was hoped to be in 1.62, but didn’t make it. The 1.63 campaign hasn’t even started yet, 4 months after 1.62 was released, so this just becomes yet another of the currently 101 PRs for cores alone, awaiting the lofty attention of the One True Wizard Of Teensyduino, who’s currently off on a Mysterious Quest.
 
The prototype stereo board has been used during solo practices with no issues. I don't feel any more latency, even with a vocoder. All the caps, resistors, connectors, etc. would not fit on a 0.1"x0.1" prototype board that was about the same size as the 8x8 teensy board. Going with an oshpark pcb and will try my hand at soldering SMD resistors on the bottom out of the way. Top and bottom design is below. Central sixteen JST headers (two columns) will wire to XLRs. If I had known how easy KiCad and oshpark were, I'd have gotten rid of prototype boards years ago! Palmerr223, the 8x8 designer, has confirmed that the output phase needs to be reversed, so this shield does this inversion. That would only be needed if one is worried about phase.
1793475470270.png
1793475501291.png
 
Last edited:
Back
Top