Is it possible to use an SBC as a standalone DAC?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
I'm assuming this is possible but haven't been able to find anything definite. The scenario would be a SBC (probably not a raspberry pi) connected to a DAC via i2s. The audio input would come via USB on the SBC (wow this is a lot acronyms!) I would like to use this: 768kHz/32Bit AK4493EQ DAC, I2S/DSD input - DIYINHK and recreate a higher performing/cheaper Schitt Modi, but I am having issues finding a reasonably priced USB to I2S converter.
 
Last edited:
Well, even that is possible. Kernel has USB audio v.2 gadget driver

linux/gadget-testing.txt at master * torvalds/linux * GitHub


Code:
arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | aplay -D default:CARD=OdroidU3

Re: uac2: diagnosing uac2 audio gadget problems — Linux USB + followups - on imx6

RPi is unsuitable since all peripherals including ethernet are on USB which must be switched to OTG - only serial port remains for communication. But BBB or IMX seem to work relatively OK.

Of course all sorts of problems are to be expected with such setup, definitely not tested well.
 
Well, even that is possible. Kernel has USB audio v.2 gadget driver

linux/gadget-testing.txt at master * torvalds/linux * GitHub


Code:
arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | aplay -D default:CARD=OdroidU3

Re: uac2: diagnosing uac2 audio gadget problems — Linux USB + followups - on imx6

RPi is unsuitable since all peripherals including ethernet are on USB which must be switched to OTG - only serial port remains for communication. But BBB or IMX seem to work relatively OK.

Of course all sorts of problems are to be expected with such setup, definitely not tested well.

Hmmm, that is very interesting. I wonder if a headless Raspberry Pi Zero W (built in WiFi) with OTG USB port could work in this application? Not sure how the BCM43438 is connected into the system...
 
Well what do you know... you CAN do it on a Pi-Zero-W, in fact there is both an Adafruit hardware (to turn the mini OTG port into a male USB connector) and a tutorial explaining how to do it:
Zero Stem for Pi Zero 1.3 and Pi Zero W 1.1 ID: 3945 - $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Overview | Turning your Raspberry PI Zero into a USB Gadget | Adafruit Learning System
The audio gadget option is not explicitly described, but it is mentioned under "Other Modules" in the tutorial.

Cool. The Pi Zero could be a low power DAC with some limited DSP processing capabilities.

@ phofman : do you know when these became available in the mainline kernel, if they are available at this time? The Adafruit people had to compile the USB gadget modules into their own custom kernel back in 2015. Not sure if there have been any updates since then.
 
Last edited:
Well what do you know... you CAN do it on a Pi-Zero-W, in fact there is both an Adafruit hardware (to turn the mini OTG port into a male USB connector) and a tutorial explaining how to do it:
Zero Stem for Pi Zero 1.3 and Pi Zero W 1.1 ID: 3945 - $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Overview | Turning your Raspberry PI Zero into a USB Gadget | Adafruit Learning System
The audio gadget option is not explicitly described, but it is mentioned under "Other Modules" in the tutorial.

Cool. The Pi Zero could be a low power DAC with some limited DSP processing capabilities.

@ phofman : do you know when these became available in the mainline kernel, if they are available at this time? The Adafruit people had to compile the USB gadget modules into their own custom kernel back in 2015. Not sure if there have been any updates since then.


4.4 Raspberry Pi Zero - Gadget Mode - bit.ovh - a piece of my mind
 
On the topic of cheap USB-i2S, Diyinhk has a cm6631 based board at 40$ (30$ each if you buy 2). I'd expect less hassle and better clocks from it than from a sbc. The processing power of the sbc is of little interest if connected by usb to a more powerful device.
 
A PIC32 MCU is not an SBC. An MCU is a more low-level computing unit. An SBC is a "computer" (e.g. that can connect to peripherals like keyboard, mouse, printer, etc.) and that runs an OS, often Linux. See Raspberry Pi for the most common example.

I'm very familiar with the RPI, thank you very much, however, the BCM2835 is not an SBC either but someone managed to put it on a board with few other components and make an SBC with it after all. And a computing unit is a major part of any computer - low level or not.
The example I gave was to show the USB audio interface needed to make this happen which you've already picked upon, not the use of a PIC32.

The problem with using an RPI for this is the same as using the built-in I2S functionality - it's jittery and very susceptible to disruption from other loads. That's where a low level microcontroller or an FPGA is better since you have a much simpler and more predictable OS running.

Another problem is the need for audio clocks to generate a stable I2S signal so you won't have to re-clock down the stream (whether in a master DAC or some Fifo) and adding external input clocks for the RPI and the likes has been very difficult - ask Miero how long it took him to develop his botic kernel for the BBB. However, it's dead simple to add a clock or two to a microcontroller and start using it immediately in your code. I guess the BBB + botic kernel with gadget mode could be the closest option for high quality interface provided you can get external clocks from your DAC.
 
That's where a low level microcontroller or an FPGA is better since you have a much simpler and more predictable OS running.

Theoretically yes, but practically coding the whole USB audio class 2 stack + all the required DSP on MCU is way more complicated than completing that linux gadget driver and using the existing user-space DSP tools (brutefir etc.). Most manufacturers do not code their own USB audio class 2 stack but purchase XMOS license or use Tenor chips with pre-loaded firmware and I perfectly understand their reason :)

I guess the BBB + botic kernel with gadget mode could be the closest option for high quality interface provided you can get external clocks from your DAC.

I assume that is just a question of configuring the SoC I2S device to take clock from an external pin. Since the device uses DMA, I do not see any source of additional jitter in such setup.
 
I just found this today. Looks like the NanoPi H5 line of SBCs can output in 786Khz?! Support I2S 768kHz * blue777/NanoPi-NEO2-I2S_MCLK@6ca18e9 * GitHub

NanoPi-NEO2 の I2SでMCLK出力 & 384kHz, 768kHz, 1536kHz, 8kHz対応 - Qiita (you need to use google translate for this one if you don't speak Japanese :)

Might be worth it to give this one a shot. The Neo2 is $20 so it would be a cheap experiment.


I will also add that the reason I am asking this question is because the only source for these USB -> I2S cards seems to be diyinhk.com. Don't get me wrong, its reasonably priced, but there has to be another way...
 
There are few more options from Europe like the amanero, waveio and i2soverusb modules that a currently available but they all cost about the same. There must be a million amanero clones from China on eBay and the likes that are cheaper if you want to experiment.

But nice find on the NEO2, a lot of people would love to get that working on an Rpi.
 
There are countless ways for the sound output. But the input path - the audio gadget driver - is the missing part. Part of the code was provided by samsung, probably planned for their android phones - that would explain the fixed samplerates for capture and playback. But the question is - can you finish the driver? Or are you willing to hire someone? E.g. through the alsa-devel mailing list subscribed by SoC specialists.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.