USB interface for multi channel outputs, not just stereo

Big thanks to @alex6679 for all the helps, we have met twice for last two saturdays, unfortunately we still could not spot the reason why my Mac could not work with teensy 4.1 for USB multi-channels. In the beginning I was on OS Ventura (13.x.x) and then updated to Sequoia (15.0.1).

I am posting the screenshots of the spec of my USB and Mac OS here for further debugging and really looking for mac users who can share their experience if they have made it work. cheers.

Screenshot 2024-10-13 at 10.41.23 AM copy.jpg
Screenshot 2024-10-13 at 10.41.40 AM.jpg
 
@AntiLoop Thanks for the idea, I will test it later today. Actually I have been testing with 3.3V power supply not 5V, because I only know the two 2.2k pull up resistor works with the 3.3V, maybe that’s an issue too? And do you know what are the correct pull-up resistors for the 5V?
 
@Weiweiweiwear I thought the Teensy is powered by the usb connection to the Mac? If you are talking about the power supply of the audio codec: I think it's best to disconnect the audio codec from the Teensy. For debugging it's normally best to find a hardware setup and software that is on the one hand as minimalistic as possible and at the same time allows you to reproduce the problem.
 
Ah you are right, yes it’s maybe not so relevant and better to disconnect the cs42448 during USB wise testing. It’s just I can only testify it with the board without you.
 
I can give more details about what we tried:

At our tests we set the number of channels to 2, we chose 44.1kHz as sample rate and 16bit resolution. We used the simple usb input example from my repository. There were no buffer over- or underruns and we received a signal at the Teensy. The problem is that this signal consists of zeros/silence. At the start up of the Teensy we see that the Teensy receives the expected sound signal for a fraction of a second. But then it always switches to zeros.

We switched back to the original usb input code from the T4 core and received the correct signal. The differences between the new usb input and the code from T4 core can be split into two parts: I switched from UAC1 standard to UAC2 and I changed the implementation of the AudioInputUSB class (i.e. how the usb feedback is computed, the behavior at buffer over- and underruns,... ). In order to find out which of these two changes causes the problem, I merged the two implementations. I used the implementation of the UAC1 standard from the T4 core and combined it with the new implementation of the AudioInputUSB class. With this mixed implemenation, we then received the correct signal and I therefore think that the problem is related to the UAC2 standard. Maybe my implementation does not completely comply with the UAC2 standard.

My current problem is: When we debug the Teensy code, everything just looks fine (except that the received signal consists of zeros). I would therefore now focus on the USB host and try to find out, why the Mac sends only silence to the Teensy. We had a look at the MacOs sound settings and here also everything looks fine. The Teensy is detected as a stereo, 16bit, 44.1kHz audio device. We would be very glad if some experienced Mac user can help us. Are there for example some log files similar to linux, that would tell us if there is a problem with the Teensy?

@AntiLoop : Just to make sure that we understood you correctly: You successfully use my implementation of usb input on a Mac? That means on your Mac my UAC2 implemtation doesn't cause problems? Do you also use 2 channels/ 44.1kHz/ 16bit as we did at our tests? Do you know of any sound settings that @Weiweiweiwear could check?
 
@AntiLoop Thanks for the idea, I will test it later today. Actually I have been testing with 3.3V power supply not 5V, because I only know the two 2.2k pull up resistor works with the 3.3V, maybe that’s an issue too? And do you know what are the correct pull-up resistors for the 5V?
Perhaps,the pullup resistor takes part of a RC circuit and can influence the speed response if the circuit is speed sensitive like TDM,look at that:

 
I really appreciate your efforts to help. In our last tests, we removed the audio codec from the Teensy because it wasn't necessary to reproduce the issue. The problem that Weiweiweiwear is facing seems to be related to the USB input, particularly to my implementation of the UAC2 standard.
 
Hummm if there's any "conventional" test code or other test method for USB audio multichannel I can test with in any existed library or example code?
 
Hi all and @alex6679

Thanks for all the helps again, I have tested my teensy 4.1 and CS42448 on a PC and its working all great, now back to Mac and capture my USB packets. I have found a way to capture USB packets with Wireshark on Mac, hope the attached file helps, let me know if you need a longer capture since the file size limitation here!
  1. common+R under rebooting
  2. enter "csrutil disable"
  3. go back so OS and enter "sudo ifconfig XHC20 up"
  4. go to system report and find your USB device and copy the location ID
  5. go to XHC20 in your Wireshark, enter your device location ID
  6. send datas to your device and start capturing
 

Attachments

  • weiweiwei_Teensy4_USB.json.zip
    267.5 KB · Views: 36
Hello everyone,

It's been a while, and I just wanted to give a quick update on the status of the multi-channel USB audio interface.

The good news: I tested the interface today on my Samsung smartphone (Android 14), and it worked right away.

Unfortunately, we haven't been able to solve @Weiweiweiwear's problem with macOS. The difficulty is that, from the T4's perspective, the interface seems to be working: There are no buffer over- or underflows, and audio data is being received. However, the Mac mutes the audio signal after a few seconds.
We also analyzed the USB communication with Wireshark, but found nothing unusual. You can even pinpoint the exact moment when the Mac mutes the signal, but unfortunately, I couldn't find any indications in the USB communication right before that to suggest what might be going wrong.
Additionally, we know that @toyosm is successfully using the interface with his Mac. So, it seems that not every Mac (or maybe not every macOS version?) has an issue with the USB audio interface.

I think we'll just have to wait until more Mac users encounter the same problem with the new USB audio interface. Maybe they can provide additional clues that will help us understand the issue.
 
Yes, it’s so close, but would be really convincing if we could get to the bottom of the MacOS issue. Not sure if this is relevant?

So tempted to bag a MacBook to try it myself, but don’t really have any other use for one and it’s a bit spendy for just one issue I might not even encounter :unsure:
 
I'm not sure if the issue you found is related. One reason that suggests it might not be is that I implemented a mixed version of both the new and old USB audio interfaces. It uses the UAC1 standard from the current T4 implementation, but most of the other code is based on my own implementation. This version worked without issues.

I just checked an online marketplace for a used MacBook. I’d be willing to spend around 50 euros for a MacBook that I could potentially use to reproduce the issue. However, the only option I found in that price range had a broken battery (which would be fine for me) and was a 2010 model. I don’t think it makes much sense to invest in such an old device.
 
Just flailing around, really, no expectation it was related ... hope, maybe :)

I was looking at more recent Macs, as the one @Weiweiweiwear has seems rather good in terms of spec, but they're definitely in the £250 - £500 range, and at the lower end often don't come with a PSU! I could justify it if I'd use it, but I'm already at one desktop and two laptops...
 
I'm running an 2021 M1 Max 32GB and am super willing to test and debug. Any clues on what I should look out for/try? Maybe we could get a small 3-5 bullet list in here with what to test and what to report? Any way I can help out I'll be glad to hear and maybe that'll make it easier for others as well.
 
That would be great - thanks in advance for your help.
  • The installation instructions are in the ReadMe of @alex6679 's repo, which can be found here.
    • Test #1: can you download it OK
    • Test #2: can you install it
  • Load up the USBmultiChannelTest.ino sketch that's included in the repo
    • It needs some sort of audio hardware on the Teensy; currently configured for the SGTL5000 audio adaptor...
    • ...with its address set to HIGH - you will probably need to change this (line 95); or ...
    • ...edit to configure to use your Teensy audio hardware (TDM, MQS or whatever)
    • Use the Arduino IDE's Tools menu to configure a USB Type which includes Audio, and 8 USB channels
    • Test #3: does it compile OK
  • Run the compiled sketch
    • Test #4: does your computer see the 8i8o USB device
    • Test #5: can you hear audio on your Teensy audio device's left channel (220Hz triangle wave)
    • Test #6: if you record from the 8 input channels, do you get 220Hz, 330Hz ... 990Hz triangle waves
    • (Test #6a: are they completely clean if you record for > 2 minutes or so)
    • Test #7: if you play 8-channel audio from your computer, do you hear a mono mix of the 8 channels on your Teensy audio device's right channel
This is all just off the top of my head - Future Reader, please check later posts for possible revisions and corrections :)
 
Thanks a lot for your help, @wll3mx!

If you have an SGTL5000, you can run the tests suggested by @h4yn0nnym0u5e . However, if you don’t have an SGTL5000, you can use main_usbInput.cpp instead, as it doesn’t require any additional hardware.

To test using this example, follow these steps:
  1. Make sure you have followed the installation instructions.
  2. Copy main_usbInput.cpp, plotter.h, and plotter.cpp into the same folder.
  3. Rename main_usbInput.cpp to main_usbInput.ino.
  4. Open main_usbInput.ino in the Arduino IDE.
  5. In the Arduino IDE, go to Tools > USB Type and select an option that includes Audio and 8 USB channels.
  6. Compile and upload the sketch.
Testing:

Test #1: Check if the Teensy appears as an 8-in, 8-out audio interface on your Mac. If it does, select the Teensy as the Mac’s audio output device.

Test #2: Play some audio (e.g., a YouTube video or music). Open the Serial Plotter in the Arduino IDE. If everything is working correctly, you should see the waveform of the audio being played.
On @Weiweiweiwear’s Mac, this test failed. The waveform appeared for a few seconds, but then the Mac muted the signal, causing the plotter to display a flat line at y = 0.
 
Yup, still interested. It's not the money, I could spring for a new Mac Mini if needed, just that I really don't need yet another machine! I've now got a Win 10 desktop (which is staying that way, because Win 11 sucks), a Win 11 laptop (nice machine, OS sucks), and an Ubuntu laptop (old, supported by Ubuntu, but not by Nvidia :( ).

@wll3mx , are you still out there?
 
I am on a Mac and I have been wanting to try this for a long time.
The caveat is that I am on quite an old System (Mojave) with Intel Mac. I am now trying it on this system, but I can potentially also give it a go on a newer laptop, just so we get a better understanding if the issues that you guys have observed are related to specific OS versions.

I am struggling a bit with the installation instructions, since I am still relatively new to Arduino. So it would be great if you can guide me through this:

- On my system the relevant files are here: ~/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/
- in the platform.txt I had to uncomment/comment some lines to get the "Arduino Boards Manager" config rather than "teensyduino installer", I am assuming that this is due to the way I installed teensyduino in the first place
- with these changes, I can compile and run my own app, which uses 2-channel usb audio. I believe this using your new Usb audio implementation.
- However I don't get the additional menu entries in the Tools menu, so I can not change to 8 channel output, and therefore I can not compile your USBmultiChannelTest
- It seems to me that my system is not picking up boards.local.txt at all. I tried copying its contents into the boards.txt. I also tried putting a boards.txt into ~/Documents/Arduino/hardware/avr/ and similar locations (I read on some forum that this where this file should be on Mac)

Any idea where I need to put boards.local.txt or if I need to wipe some cache?

UPDATE: ok I figured it out literally 5 seconds after posting this: when putting an entire copy of the 'avr' folder into '~/Documents/Arduino/hardware/avr/', it appears as a different board in the IDE (Teensyduino rather than Teensy in my case), and when selecting this board, I get the additional Menu entries.
I have to play around with this more, but on the first attempt I could successfully record multi-channel USB audio into my DAW from the teensy. Have not observed any audio glitches, or noticed that it would stop sending data after a while...
Looking forward to integrating this into my synth project! I hope it is not too heavy on the CPU.
 
Last edited:
@electricat that’s good news, gives us another data point.

Thinking about narrowing down the circumstances the provoke the issue, it’d be good to know the exact Mac model (e.g. the Annnn number) and MacOS name and version, plus the sample rate and channel count the Teensy is set up for. Given other observations, the CPU load for coreaudiod would be interesting, too - it was crazy high for @Weiweiweiwear.

@alex6679, can you think of any other metrics that might be useful?

@toyosm, @wll3mx, if you have a chance to post that data for the systems you’ve tested, it might well help.
 
@electricat Thanks for testing and for the good news!
@h4yn0nnym0u5e I can't think of any additional information that would be helpful. We tested stereo and 8-channel audio on @Weiweiweiwear's Mac, using both 16-bit and 24-bit configurations. It didn’t seem to make a difference, but it's still useful to know the exact setup that was tested.
 
Back
Top