2

I want to use Raspberry Pi Zero as a USB DAC with switchable sample rate. Maximum resolution should be 96/24 with all 4 common rates ie. 44.1, 48, 88.2 an 96 kHz supported. It should also work with Windows. I don't care about volume control but it would be nice to have it.

I tried to connect Raspberry as a DAC to a smartphone and it worked up to 48 kHz. Since the script I managed to download did not implement "clock entities", it only had one sample rate and, albeit detected, did not start on Windows. Later I changed it to UAC1, Windows error disappeared but didn't play.

By the way, Raspberry seems to have timing problems with USB DACs connected in OTG mode; the only one fully working for me was PCM2704. USB itself is fast enough and DLNA works via RNDIS all the way to 192/32, consuming <25% CPU.

This is the script:

#!/bin/bash -e

modprobe libcomposite

cd /sys/kernel/config/usb_gadget/ mkdir g1 && cd g1

echo 0x1d6b > idVendor # Linux Foundation echo 0x0104 > idProduct # Multifunction Composite Gadget echo 0x0100 > bcdDevice # v1.0.0 echo 0x0200 > bcdUSB # USB 2.0 echo 0x01 > bDeviceClass echo 0x02 > bDeviceSubClass echo 0x20 > bDeviceProtocol

mkdir -p strings/0x409 echo "deadbeef00115599" > strings/0x409/serialnumber echo "irq5 labs" > strings/0x409/manufacturer echo "Pi Zero Gadget" > strings/0x409/product

mkdir -p functions/uac2.usb0 # audio echo 3 > functions/uac2.usb0/c_chmask echo 48000 > functions/uac2.usb0/c_srate echo 4 > functions/uac2.usb0/c_ssize echo 3 > functions/uac2.usb0/p_chmask echo 48000 > functions/uac2.usb0/p_srate echo 4 > functions/uac2.usb0/p_ssize

mkdir -p configs/c.1 echo 250 > configs/c.1/MaxPower mkdir -p configs/c.1/strings/0x409 echo "Audio" > configs/c.1/strings/0x409/configuration ln -s functions/uac2.usb0 configs/c.1/

echo 1 > os_desc/use echo 0xcd > os_desc/b_vendor_code echo MSFT100 > os_desc/qw_sign ln -s configs/c.1 os_desc

#udevadm settle -t 5 || : ls /sys/class/udc/ > UDC

So the question is, what to change in the script, or what other method to use to achieve at least UAC1 USB audio gadget with switchable sample rates?

qduaty1
  • 21
  • 3

0 Answers0