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.