BalenaSound USB Sound card

Hello. I would like to use an external USB sound card as audio output. How can I do that?

Please check this thread Help with balena-sound and usb sound card configuration and this github issue https://github.com/balena-io-projects/balena-sound/issues/9

You need to create an /etc/asound.conf configuration file.

How can I do that?

https://github.com/balena-io-projects/balena-sound/issues/9 should explain all the steps to create the file. The relevant part would be:

In the meantime, I created an /etc/asound.conf like you mentioned and just added the lines below, substituting "card 1" with the number you want listed via aplay -l.

Create the file with nano /etc/asound.conf or whatever text editor you like, and add the block below. Restart and the chosen card will be selected in alsamixer.

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}
This worked fine for me, though if you want to switch between cards when you have multiple connected you'll need to switch the number manually.

Let me know if you run into any issues with these steps

Where should I enter the command?
EDIT: I found it and it works perfect

I posted this as an issue on github. The response was great. I posted a more step by step approach on how to configure this on github. The least I can do to repay a very supportive community.

Hi guys !

I’m looking BalenaSound to replace my actual multiroom audio.

I have system based on Topping D10 Dac (really nice dac by the way). Connected over usb.

Should I used this workaround ? Or do I post a request in git to add support as a dac ?
I don’t know the difference between both options (dac category and the USB stuff) both look like dac for me but maybe dac in the project mean hardware connected through gpio.

Thank you

hi @tdesaules

you’re right, the readme mentions DAC (connected over gpio) while in your case the usb sound card stuff mentioned in this thread should apply.

also have a look at the github issue mentioned by @yn1v that has a bunch of examples / instructions too.

If you’re feeling up to it maybe you can add this as a feature and send a PR :slight_smile:

Hi guys,

I have just setup my Balena Sound device:)

The audio works with the stock raspberry pi jack but i would like to have it output through my Behringer XR18 Mixer which has a usb interface.

I have it plugged into a usb port but when i run the command aplay --list-devices it only returns the internal jack and hdmi - No USB devices.

Can provide logs if anyone is interested.
Still very much a newby so excuse my ignorance if the answer is staring me in the face.

Hey there! Can you show us the output of lsusb with the Behringer XR18 Mixer plugged in and on?

Hi,

I Finish the configuration about my single node setup (waiting the other raspberry)
Just for info I setup the RPi with a Topping D10 USB Dac.

I configure alsa in the “bluetooth-audio” container.

My Usb DAC is named D10 in the container :

    root@6dad1f1:/# cat /proc/asound/D10/stream0
    Topping D10 at usb-3f980000.usb-1.1.3, high speed : USB Audio

    Playback:
      Status: Running
        Interface = 1
        Altset = 1
        Packet Size = 72
        Momentary freq = 44100 Hz (0x5.8330)
        Feedback Format = 16.16
      Interface 1
        Altset 1
        Format: S32_LE
        Channels: 2
        Endpoint: 1 OUT (ASYNC)
        Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
        Data packet interval: 125 us
      Interface 1
        Altset 2
        Format: S32_LE
        Channels: 2
        Endpoint: 1 OUT (ASYNC)
        Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
        Data packet interval: 125 us
      Interface 1
        Altset 3
        Format: SPECIAL DSD_U32_BE
        Channels: 2
        Endpoint: 1 OUT (ASYNC)
        Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
        Data packet interval: 125 us

asoung.conf with the dmix to 48khz disable and S32_LE enabled

    pcm.default_device {
      type hw
      card "D10"
      device 0
    }

    pcm.!default {
      type plug
      slave {
        format S32_LE
        pcm "default_device"
      }
    }

    ctl.!default {
      type hw
      card "D10"
    }

Work fine I play a wav directly from the container to ensure it with aplay.

I still get the dmix from spotify to 48Khz strange I know spotify song are 44.1Khz and 320kbit/s in premium.

Could you confirm that raspotify is configured like that ? It look so from the dockerfile but in the /etc/default/raspotify I can find BITRATE still comment :

exec /usr/bin/librespot --name "$DEVICE_NAME" $SPOTIFY_BACKEND --bitrate 320 --cache /var/cache/raspotify --enable-volume-normalisation --linear-volume --initial-volume=$SYSTEM_OUTPUT_VOLUME $SPOTIFY_CREDENTIALS $SPOTIFY_DEVICE

When I will receive the other RPi I will take a look to the snapcast part.
I just found this conf on this part :

sampleformat 44100:16:2 

Should probably be 44.1Khz / 16 bit / Stereo (need more research)

Hey, thanks for sharing your progress.

Where are you seeing Spotify is streaming at 48 kHz? It should be as you say 44.1 kHz.
Regarding the snapcast question, your assumption is correct, snapcast will stream 44.1 kHz / 16bit / stereo audio to it’s clients.

Hi,

From my DAC I can see PCM 48.
It come from the dmix configuration in alsa.

probably this : cat usr/share/alsa/alsa.conf | grep rate

defaults.pcm.dmix.rate 48000

this is why I just send the same /etc/asound.conf file to the spotiy container. After that I can see the correct 44.1 KHz as well.

Will read some doc / code on the snapcast project to uderstand how it work.

thank you

Hey there
Thanks for the update and your work on this.

Really looking forward to your progress.
Keep us posted!
Cheers :slight_smile:

I’m in the terminal from my balenaCloud dashboard. I’ve started a Bluetooth-audio terminal. I create the asound.conf file, save, check etc with ls command, see asound.conf, restart my device from dashboard, no audio from usb dac, check etc with ls, asound.conf is gone.

I saw in the other thread to edit the Dockerfile.template. Where/how do I do that?

Hi @COVIDkid. Welcome to the forums. There is a Dockerfile.template is in each subdirectory of each service in the project source code. You can modify the Dockerfile and then repush your application to deploy the new version.

If you’re new to balena, docker, etc, I suggest you look at the balena primer on our documentation site.

Good luck!
James.

Thanks for responding so quickly. My main concern is that using nano asound.conf within etc creates a file that does not exist after restarting my device. Am I completely missing something here?

Yes, the contents of the container are temporary. You need to change the project source to build that file into a new container and deploy it.

Hi there,
I have been able to make my usb dac work !
All I did after a fresh deployment, was to disable the onboard audio out in the “fleet configuration” part, overriding “Define DT parameters” :
before: RESIN_HOST_CONFIG_dtparam “i2c_arm=on”,“spi=on”,“audio=on”
after: RESIN_HOST_CONFIG_dtparam “i2c_arm=on”,“spi=on”,“audio=off”
…followed by poweroff, unplug power cable, then plug power.
You can then verify in the bluetooth-audio with “aplay -l” that ALSA device is gone (I booted my pi4 with the USB-DAC plugged)
tip found in the documentation here https://github.com/balenalabs/balena-sound/blob/master/DAC_configuration.md
I hope that it will work for you as well.

1 Like