balena os, audio issue, upboard

Hi all.
I faced the audio issue on the up-board.
I use the balenablocks/audio but can’t hear anything.
Here is my setup:
Here my setup:

HOST OS VERSION
balenaOS 2.101.11
development
SUPERVISOR VERSION
14.0.14

Docker compouse:

services:
    audio:
        image: balenablocks/audio
        privileged: true
        environment:
            - AUDIO_OUTPUT=alsa_output.usb-soundcard-1.analog-stereo
        volumes:
            - 'pulse:/run/pulse'

    my-audio-app:
        build: ./audio-app
        volumes:
            - 'pulse:/run/pulse'

Here is the output of alpay --list-devices command:

bash-5.1# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Audio [Intel HDMI/DP LPE Audio], device 0: HdmiLpeAudio [Intel HDMI/DP LPE Audi]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Audio [Intel HDMI/DP LPE Audio], device 1: HdmiLpeAudio [Intel HDMI/DP LPE Audi]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Audio [Intel HDMI/DP LPE Audio], device 2: HdmiLpeAudio [Intel HDMI/DP LPE Audi]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: usb-soundcard-1 [USB Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And here is the output of the pactl list short sinks command:

bash-5.1# pactl list short sinks
0       alsa_output.usb-soundcard-1.analog-stereo       module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED

My app is a small nodejs script that tries to play some audio.
I tried to play some audio inside the audio container with the aplay command but no sound play out from the speakers.
I have no idea where the problem can be.
Can you suggest something?

Hi aleksey, since you have

        volumes:
            - 'pulse:/run/pulse'

is it safe to assume you’re using UNIX sockets for the Pulse server? Can you make sure your client container has the PULSE_SERVER environment variable set as well, ideally in the Dockerfile; more details can be found in the the README for the audio block at GitHub - balenablocks/audio: Audio building block for balenaOS, based on pulseaudio. and in particular the Send/receive audio section GitHub - ramirogm/audio: Audio building block for balenaOS, based on pulseaudio.

Otherwise it looks like you’re on the right track assuming your goal is to output audio on the USB soundcard. If you’re still having problems, are you willing to share your client container Dockerfile so we can make sure it’s correct?

Hi @james-cws. My setup still doesn’t work.
Here my client Dockerfile:

FROM balenalib/up-board-node:16-run

ENV PULSE_SERVER=unix:/run/pulse/pulseaudio.socket

RUN install_packages python pkg-config make g++ libpulse-dev

WORKDIR /usr/src
COPY . .

RUN npm install

CMD ["npm", "start"]

Thanks

@james-cws Still looking for help

Hi aleksey, your Dockerfile looks about right, though it’s unclear what your audio source is. Are you able to use a local .wav similar to the example at audio/Dockerfile.template at master · balenablocks/audio · GitHub to get a baseline?

Hi @james-cws. I’m using your audio file. It’s stored in the file system and mapped in a docker container, but after your suggestion, I tried to load it while building. And it still doesn’t work.
Docker file:

FROM balenalib/up-board-node:16-run

ENV PULSE_SERVER=unix:/run/pulse/pulseaudio.socket

RUN install_packages python pkg-config make g++ libpulse-dev
RUN curl https://www.kozco.com/tech/LRMonoPhase4.wav --silent --output sample.wav

WORKDIR /usr/src
COPY . .

RUN npm install

CMD ["npm", "start"]

Hi aleksey, do you get any error messages when trying to play audio manually, ie trying to test the sample.wav using aplay?

The upboard isn’t a supported device for the audio block; you’re welcome to try but it’s going to require some experimentation & I can’t guarantee it will work. I see someone else has tried to get audio working in this balena os - upboard - audio playout issue - #18 by gzett forum thread, could you review the posts there and see if any of the suggestions help?

Hi @james-cws. Thanks. I have read provided thread before starting my thread. I don’t see any error while playing audio through aplay. It looks like it’s playing but I can’t hear anything.

@james-cws Hi. I tried to use same configuration for RaspberryPI 3 and I still can’t hear anything. I tried 2 difference output devices and hear nothing. And with RPI 3 I see some errors and warinigs in terminal.


Do you have some thoughts?

Hi Aleksey,

It looks like you’re trying to validate your configuration for the upboard using a RPi 3? The error you’re seeing re DBUS is likely related to rpi4: snd_bcm2835 kernel module not being loaded on newer balenaOS versions · Issue #100 · balenablocks/audio · GitHub and is (probably) unrelated to the issues you were seeing with the up-board (assuming that you don’t see the same errors on the up-board). You could try some of the proposed solutions in the linked github issue for your RPi 3 or, if the goal is just to verify your configuration, you could test on an older version of balenaOS.

For your up-board, it’s very difficult to say where the issue is - by default, the up-board device tree directs onboard audio to the ADC on the hat header via I2S so it’s possible you may need to manually add support to the OS for your particular USB audio device. You can start your investigation by looking into the output of lsusb and lsmod to see if your USB device is being detected properly & what, if any, driver is being used. It may also be helpful to search around on up-board specific forums or message boards and verify that your USB audio device is supported at all on the up-board.