I’m looking for a microcontroller with a USB peripheral and software libraries for implementing a sound card (audio device class). The output is going to be I2S. [...] My priority is the ease of use of the USB libraries.
Well,
Teensy 4.0 has two I²S outputs (one with 1-4 outputs AKA 2/4/6/8 channels, the other with 1 output), and a dedicated
library with a
graphical design tool (albeit designed for 44.1kHz sample rates). Basically, you can create a 44.1kHz stereo 16bit USB sound card quite easily. For a straight USB → I2S, the audio library handles everything, so you only need
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioInputUSB usb1;
AudioOutputI2S i2s1;
AudioConnection patchCord1(usb1, 0, i2s1, 0);
AudioConnection patchCord2(usb1, 1, i2s1, 1);
void setup(void) {
}
void loop() {
// Host volume setting is described by usb1.volume(), returning a value between 0.0f and 1.0f
}
The development is done in the Arduino environment, using the
Teensyduino add-on.
Even the USB device type is selected in the IDE from a menu (in this case, either Audio or Serial+MIDI+Audio), so it is
easy to get going.
The sources for the Teensy Audio library are
here, so if you want multichannel audio support (4-8 channels, each 16bit 44.1kHz/48kHz), with output to two I²S ports (one with 1-4 data outputs and 1 input, the other with 1 output and 1 input), you may need to edit the libraries; but there is also a Teensy-only forum at
forum.pjrc.com where you can get help if you get stuck (but be prepared to show your own efforts first; even there, nobody will write the code
for you). There is also support for SPDIF input and output, and several codecs (ADCs and DACs). Note that for I²S, you do not need any additional boards (audio shields or anything).
Depending on exactly how you intend to connect the I²S device to the USB microcontroller, I would be very careful about ground loops. I assume your mixer does not derive its power from your PC, so signal isolation is something you could consider. For SPI, I'd recommend
TI ISO7741 (2.25V to 5.5V on either side, so also works as a level shifter); for one output I²S, ISO7740; for three-output I²S (six channels),
ISO7760. These are very easy to use, cheap (2-3 € in singles at Mouser) and only require a 100nF = 0.1µF bypass capacitor between VCC and ground on each side of the chip. (Both sides need their own supply and ground, of course.)
(For the MCLK (11-16 MHz audio clock), a 100 Ohm resistor in series is a good idea, to keep out noise.)
I would design a separate carrier board for this, on top of which you solder a Teensy 4.0 on pins. If you want to design your own Teensy 4.x -compatible board, PJRC will even sell the proprietary bootloader chip for $6.25. It is not open hardware, but Paul and Robin are good, friendly people; and the library code is quite excellent (especially compared to typical Arduino libraries).