Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


USB Audio Gadget (Raspberry as USB DSP/DAC)
#4
@Nutul
You can use your Pi as USB device for your computer/tablet/other streamer or whatever device that support USB UAC audio devices.
In combination with CamillaDSP that is very a very flexible DSP solution. Reason for enough people to use usb device 'input device > camilladsp > output' as a standalone solution.

@challenge
I have a very restricted version setup of the usb gadget working. My personal use case is running REW from laptop directly on Pi based I2S dac.
For music streaming I use the moode core functionality :-)

For configuration of the usb gadget I use [url= https://github.com/linux-usb-gadgets/gt]gt[/url] in combination with libusbg:
Code:
# personal build from libusgbx and gt as pacakge:
sudo apt install ./libusbgx_0.2.0~git20230410.721e3a1-1moode1_arm64.deb ./gt_0.0.1-1moode1_arm64.deb

sudo bash -c 'echo "dtoverlay=dwc2,dr_mode=peripheral" >> /boot/config.txt'
sudo bash -c 'echo "libcomposite" >> /etc/modules'
sudo reboot

# and after the reboot load agadget schemea
sudo gt load ./uac.scheme g1
Down side is that gt currently doesn't setting up usb uac gadgets with multiple samplerate support. Still on my list to do fix that, but wasn't very trival to do.

An example scheme for an UAC USB gadget configuration:
Code:
attrs :
{
   idVendor = 0x1D6B;
   idProduct = 0x104;
};
strings = (
       {
               lang = 0x409;
               manufacturer = "moode";
               product = "moode-player";
       }
);
functions :
{
   uac2_usb0 :
   {
       instance = "usb0";
       type = "uac2";
       attrs :
       {
           c_chmask = 3;
           c_srate = 44100;
           c_ssize = 3;
           p_chmask = 0;
           p_srate = 44100;
           p_ssize = 3;
       };
   };
};
configs = (
   {
       id = 1;
       name = "c";
       functions = (
           {
               name = "uac2.usb0";
               function = "uac2_usb0";
           } );
       p_ssize = "3";
   }
);
Normally with moode CamalliaDSP is controlled by alsa_cdsp (cammiladsp doesn't run as a service).
Found using the usb gadget as an MPD input to slow and has a few other quirks.
But in case of the usb gadget is more desirable, when usb gadget activity is detected,  to start the camilladsp systemd service instead.


Required, over-simplified, steps:
* setup usb gadget mode support
* gt/libusbg multiple sample rate support for generating gadget configs
* detect gadget use
* when active use it to change the default camilladsp config start the camilladsp service 
* and when stop reverse it again
* and some gui support for it to
Reply


Messages In This Thread
RE: USB Audio Gadget (Raspberry as USB DSP/DAC) - by bitlab - 07-02-2023, 12:26 PM

Forum Jump: