Create new audio plugin

Hello all,

We are currently trying out Balena-sound for a DIY boombox project. We use a Raspberry Pi 4, an I2S module (UDA1334, that should be compatible with the I2S audio bonnet from Adafruit I think) and the 7" Raspberry Pi touchscreen. The goal is to display a GUI menu on the screen and use the I2S module to produce some sound.

Also interesting is the Balena-dash kiosk container. This opens the doors to load any webpage e.g. web radio, YouTube, streaming service, etc. The possibilities seem endless. :slight_smile:

Preparing to do some experimentation we created a Balena project, new git repository and put the Balena-sound and Balena-dash projects side by side with git subtrees.

In the project root we have a docker-compose.yml that looks like this:

version: '2'
volumes:
    settings:
    snapcast:
services:
    boombox_main:
        build: ./boombox-app
        ports:
            - "5000:5000"
#    browser:
#        image: balenablocks/browser:raspberrypi4-64
#        privileged: true
#        network_mode: host
    kiosk:
        restart: always
        build: ./balena-dash/kiosk
        privileged: true
        network_mode: host
        ports: 
            - "8080:8080"
        volumes:
            - "settings:/data"
#    scheduler:
#        restart: always
#        build: ./balena-dash/scheduler
#        privileged: true
    audio:
        build: ./balena-sound/core/audio
        privileged: true
        labels:
            io.balena.features.dbus: 1
        ports:
            - "4317:4317"
        volumes:
            - "snapcast:/var/cache/snapcast"
    sound-supervisor:
        build: ./balena-sound/core/sound-supervisor
        network_mode: host
        ports:
            - "3000:3000"
        labels:
            io.balena.features.supervisor-api: 1

Next we tried to create a new audio plugin according to the instructions on: https://sound.balenalabs.io/contributing/architecture/ (Plugin chapter at the bottom). The browser in the Kiosk container does not have a way to send audio to the Audio container via pulse audio, so we need the ALSA bridge I assume.

So we modified the Dockerfile of Kiosk:

# build tohora from source
FROM balenalib/raspberrypi3-golang as builder

RUN go get -d -v github.com/mozz100/tohora/...

WORKDIR /go/src/github.com/mozz100/tohora

RUN go build 


FROM balenablocks/browser:%%BALENA_MACHINE_NAME%%

RUN install_packages cec-utils

COPY --from=builder /go/src/github.com/mozz100/tohora /home/chromium/tohora

COPY launch.sh /home/chromium/

# adding ALSA bridge
# https://sound.balenalabs.io/contributing/architecture/
ENV PULSE_SERVER=tcp:localhost:4317
ENV AUDIO_OUTPUT=balena-sound.input
#debian-setup.sh is a local copy of https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh
COPY debian-setup.sh /home/chromium
RUN /home/chromium/debian-setup.sh
#RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
RUN apt-get install alsa-utils
RUN apt-get install pulseaudio
RUN apt-get install pulseaudio-utils

RUN pulseaudio -D --system

# replace command that runs in start script
COPY alt_start.sh /usr/src/app/
RUN sed -i '$d' /usr/src/app/start.sh
RUN echo ". alt_start.sh"  >> /usr/src/app/start.sh

If we then run the pactl list sinks command, in the Kiosk container, we can see the balena-sound.input sink.

But listing the ALSA devices with aplay -L does not reveal any Balena devices.

We where hoping that there was an ALSA device that we then could provide to the FLAGS (https://github.com/balenablocks/browser) environment variable that routes the audio from the browser to the balena-sound.input so the I2S module plays the sound.

However the sound from the browser is player on the audio jack of the Pi and not the I2S module.

It could also be that I have missed something in the Balena-sound configuration, but the only thing needed is the bellow ‘Custom configuration variable’ in ‘Device configuration’ right?

We’ve been messing around with with the Kiosk container, but can’t seem to get it to work.
Any help is appreciated.

Kind regards,
Woody

Hey Woody

I was just looking at the docs for balenaSound - and I see that the dt overlay that you have mentioned i2s-mmap isn’t there in the supported table here - https://github.com/balenalabs/balena-sound/blob/master/docs/05-audio-interfaces.md#dtoverlay-values

Can you mention how you configured that?

[…] the only thing needed is the bellow ‘Custom configuration variable’ in ‘Device configuration’ right?

I see that the dt overlay that you have mentioned i2s-mmap isn’t there in the supported table here - https://github.com/balenalabs/balena-sound/blob/master/docs/05-audio-interfaces.md#dtoverlay-values

Well, I actually see i2s-mmap listed in the table linked above. But not on its own. Given the earlier explanation that “We use […] an I2S module (UDA1334, that should be compatible with the I2S audio bonnet from Adafruit I think),” the DAC table linked above shows:

DAC Name BALENA_HOST_CONFIG_dtoverlay Working
Adafruit I2S Audio Bonnet “hifiberry-dac”,“i2s-mmap” Yes

So it sounds to me like the BALENA_HOST_CONFIG_dtoverlay variable should be literally set to "hifiberry-dac","i2s-mmap", rather than being set to i2s-mmap. (Also, watch out for “fancy Unicode double quotes” versus standard ASCII double quotes when copying-and-pasting text, as the linked table appears to display the fancy quotes, which would not work.) I don’t have experience with these settings to be honest, I am just pointing out what looks to me like contradictory statements and settings that I have read on this thread, compared to the documentation. :slight_smile: And some further documentation here: https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam

It is probably worth it to try / explore making this change to the value of BALENA_HOST_CONFIG_dtoverlay.

Hi there, balenaSound dev here. Just want to add a few comments and potential ways of approaching this.

First thing is that you don’t need to run or install pulseaudio in your container. The idea is that pulseaudio is running on the audio container and you only need to connect to it from other containers. That is what you do with the ALSA bridge in this case with this commands:

RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
ENV PULSE_SERVER=tcp:localhost:4317 --> note that this should be tcp:audio:4317 if you are *not* using network_mode: host
ENV AUDIO_OUTPUT=balena-sound.input

With this in place, running aplay -L shoud yield:

bash-5.0# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default
    Default ALSA Output (currently PulseAudio Sound Server)

If correctly done, the pulse device will send over the audio to pulseaudio without any extra configuration. You can verify this by running for example:

aplay /usr/share/sounds/alsa/Front_Center.wav

This should output a lady speaking “Front Center” to whatever your default audio output is. I suggest trying with the audio jack first to verify the ALSA bridge is working. And only then get involved with the audio bonnet. I’d follow Paulo’s suggestions as first troubleshooting steps.

Hello All,

First, we want to thank you for your response.

We made some progress on the project. By the suggestion of tmigone, we first tried fixing the kiosk container and make it work on the raspberry pi audio jack. When running the command aplay -L we should see the pulse device and ALSA output as default. This was not the case, even if we put the docker command:

RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh

In the end we just built the functionality of the debian-setup.sh script into the dockerfile of kiosk:
(pulse-alsa.conf and 99-pulse.conf are placed locally and copied into the container when building it.)

# build tohora from source
FROM balenalib/raspberrypi3-golang as builder

RUN go get -d -v github.com/mozz100/tohora/...

WORKDIR /go/src/github.com/mozz100/tohora

RUN go build 


FROM balenablocks/browser:%%BALENA_MACHINE_NAME%%

RUN install_packages cec-utils

COPY --from=builder /go/src/github.com/mozz100/tohora /home/chromium/tohora

COPY launch.sh /home/chromium/

# adding ALSA bridge
# https://sound.balenalabs.io/contributing/architecture/
#RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
RUN apt-get update
RUN apt-get install libasound2-plugins -y
RUN mkdir -p  /usr/share/alsa/
COPY pulse-alsa.conf /usr/share/alsa/pulse-alsa.conf
COPY pulse-alsa.conf /etc/asound.conf
RUN mkdir -p  /etc/alsa/conf.d/
COPY 99-pulse.conf /etc/alsa/conf.d/99-pulse.conf
ENV PULSE_SERVER=tcp:audio:4317
ENV AUDIO_OUTPUT=balena-sound.input
#COPY debian-setup.sh /home/chromium
#RUN /home/chromium/debian-setup.sh
#RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh

RUN apt-get install alsa-utils -y
#RUN apt-get install pulseaudio
#RUN apt-get install pulseaudio-utils

#RUN pulseaudio -D --system

# replace command that runs in start script
COPY alt_start.sh /usr/src/app/
RUN sed -i '$d' /usr/src/app/start.sh
RUN echo ". alt_start.sh"  >> /usr/src/app/start.sh

That seemed to have done the trick, except the default was not ALSA Output. For that we needed also an asound.conf COPY pulse-alsa.conf /etc/asound.conf

(We also removed the network_mode: host and put ENV PULSE_SERVER=tcp:audio:4317)

Then we could see this:

root@44ff7f0:/usr/src# aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
sysdefault:CARD=bcm2835-jack
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
dmix:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
dsnoop:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample snooping device
hw:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
plughw:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions
usbstream:CARD=bcm2835-jack
    bcm2835 Headphones
    USB Stream Output

However there was still no audio playing ( via aplay /usr/share/sounds/alsa/Front_Center.wav or a web radio station via kiosk) :frowning:

First, the audio container was trying to connect to the sound supervisor server (<host_ip>:3000), but was not succeding. It turns out the audio container was connecting to the wrong IP. We fixed it in start.sh by replacing:

#SOUND_SUPERVISOR="$(ip route | awk '/default / { print $3 }'):3000"

(This just took the gateway for the subnet instead of the IP address of the ‘on board’ sound-supervisor.)
with:

SOUND_SUPERVISOR=$BALENA_SUPERVISOR_ADDRESS

For this we also added label io.balena.features.supervisor-api: 1 to the audio container in the docer-compose.yml

Next, we saw this in the logs of the audio container:

29.11.20 21:35:55 (+0100)  audio  
29.11.20 21:35:55 (+0100)  audio  --- Audio ---
29.11.20 21:35:55 (+0100)  audio  Starting audio service with settings:
29.11.20 21:35:55 (+0100)  audio  - Pulse log level: NOTICE
29.11.20 21:35:55 (+0100)  audio  - Default output: AUTO
29.11.20 21:35:55 (+0100)  audio  
29.11.20 21:35:55 (+0100)  audio  Detected audio cards:
29.11.20 21:35:55 (+0100)  audio  0 bcm2835-jack bcm2835_headphonbcm2835Headphones-bcm2835Headphones
29.11.20 21:35:55 (+0100)  audio  
29.11.20 21:35:55 (+0100)  audio  
29.11.20 21:36:27 (+0100)  audio  Setting audio routing rules. Note that this can be changed after startup.
29.11.20 21:36:28 (+0100)  audio  Routing 'balena-sound.input' to 'snapcast'.
29.11.20 21:36:28 (+0100)  audio  Routing 'balena-sound.output' to 'alsa_output.bcm2835-jack.stereo-fallback'.
29.11.20 21:36:29 (+0100)  audio  W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
29.11.20 21:36:31 (+0100)  audio  W: [pulseaudio] module-loopback.c: Cannot set requested sink latency of 66.67 ms, adjusting to 23.22 ms
29.11.20 21:36:31 (+0100)  audio  W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
29.11.20 21:36:31 (+0100)  audio  W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

And the sound-supervisor doing this:

29.11.20 21:35:44 (+0100)  sound-supervisor  Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:36:04 (+0100)  sound-supervisor  Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:36:29 (+0100)  sound-supervisor  Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:37:00 (+0100)  sound-supervisor  Connected to PulseAudio at 192.168.1.112:4317
29.11.20 21:37:00 (+0100)  sound-supervisor  Server protocol version: 33
29.11.20 21:37:00 (+0100)  sound-supervisor  Client protocol version: 33
29.11.20 21:37:05 (+0100)  sound-supervisor  Joining the fleet, requesting master info with fleet-sync...
29.11.20 21:57:01 (+0100)  sound-supervisor  Playback started, announcing 192.168.1.112 as multi-room master!
29.11.20 21:58:46 (+0100)  sound-supervisor  Playback started, announcing 192.168.1.112 as multi-room master!
29.11.20 21:59:05 (+0100)  sound-supervisor  Playback started, announcing 192.168.1.112 as multi-room master!

The Routing 'balena-sound.input' to 'snapcast'. and Routing 'balena-sound.output' to alsa_output.bcm2835-jack.stereo-fallback'. looks ok.

What worries us is this:

29.11.20 21:36:31 (+0100)  audio  W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
29.11.20 21:36:31 (+0100)  audio  W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

We found a couple of posts discussing this issue (albeit for the raspberry pi 3). The workaround to make it 32-bit:

Remove the vc4-kms-v3d dtoverlay setting from the Device Configuration section of your device.

This does not seem to have an effect.

We tried to set DBUS_SYSTEM_BUS_ADDRESS for the audio container:

environment:
            - DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

Adding the label io.balena.features.kernel-modules: '1', does not help.

Also trying out SOUND_MODE STANDALONE doesn’t have an effect.

The sound-supervisor does seem to react to audio being played. When we run: aplay /usr/share/sounds/alsa/Front_Center.wav the log shows:
sound-supervisor Playback started, announcing 192.168.1.112 as multi-room master!

Next thing on the list is to fix the [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 error.
Sugestions are always welcome.

EDIT: Maybe also interesting to know, we use the “balenaOS 2.58.6+rev1” OS on a Raspberry Pi 4

Kind regards,
Woody

Hey Woody, I gave it a shot and got it to work! There are little subtleties that made it hard to figure out but I’ll share them with you now.

First thing is that setting up the audio block correctly in the kiosk container is the only thing you should need to do. The code I shared on my previous message should be enough to do it, keyword being “should”. Turns out that the browser Dockerfile is using rpi-raspbian as the base image. For some reason that I did not fully investigate that image has some configuration that makes this command curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh to fail because of invalid SSL certificates. This was failing silently so that means that the debian-setup.sh script was not being executed. That is why you had to copy the stuff that the script did in order to make it work. Curl has a special flag -k that allows you to bypass SSL verification so that’s a handy workaround. With this in mind, in order to properly set the ALSA bridge you need to add this to your Dockerfile:

RUN curl -skL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
ENV PULSE_SERVER=tcp:audio:4317 # Make sure your kiosk container is not running network_mode: host

Note that AUDIO_OUTPUT is not needed at all, seems like I was a bit sleepy or made a copy paste mistake in my previous message :roll_eyes:

Now, this change should be enough for a proper setup. You can validate it in the following ways:

  • Running aplay -L should show you the pulse device, and the default device should be set to PulseAudio too
  • Running aplay /usr/share/sounds/alsa/Front_Center.wav should work too (Make sure you remove your DAC and any dtoverlay, audio should come out of the audio jack).

If this is not working then there are other problems you need to fix before continuing. The change you described about the SOUND_SUPERVISOR is not correct, note that there is the resin/balena supervisor and then the sound supervisor. There are two separate supervisors if you will and SOUND_SUPERVISOR="$(ip route | awk '/default / { print $3 }'):3000" should be the correct value.

There is another change that I had to make in order for this to work. In the launch.sh script you also need to export the PULSE_SERVER env var on the startx line. This can be done with:

su -c "export DISPLAY=:$DISPLAY && export PULSE_SERVER=tcp:audio:4317 && startx /home/chromium/xstart.sh $CURSOR $OUTPUT" - chromium

Conclusion
This are the steps I took:

  1. Clone balenaSound and balenaDash project code
  2. Copy the kiosk folder from balenaDash over to the balenaSound folder.
  3. Copy the kiosk service section in the balenaDash docker-compose.yml file over to the balenaSound one.
  4. Add the following to the kiosk Dockerfile:
# Audio block setup
RUN curl -skL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
ENV PULSE_SERVER=tcp:audio:4317
  1. Edit the last line of launch.sh likewise:
su -c "export DISPLAY=:$DISPLAY && export PULSE_SERVER=tcp:audio:4317 && startx /home/chromium/xstart.sh $CURSOR $OUTPUT" - chromium

With this changes I can use a youtube video for example, show up in the screen via browser and the audio will go out through balenaSound. Let me know if this helps!

Hi tmigone,

Thanks for your response.

The -k flag does indeed download the script now.

Audio also plays through the audio jack, but we don’t think it’s routed through the pulse audio in the audio container. When it worked, we tried to configure the BALENA_HOST_CONFIG_dtoverlay with "hifiberry-dac","i2s-mmap". But no audio was playing through the I2S module, although it was detected by the audio container:

 audio  --- Audio ---
 audio  Starting audio service with settings:
 audio  - Pulse log level: NOTICE
 audio  - Default output: AUTO
 audio  
 audio  Detected audio cards:
 audio  0 Headphones bcm2835_headphonbcm2835Headphones-bcm2835Headphones
 audio  1 sndrpihifiberry RPi-simple-snd_rpi_hifiberry_dac
 audio  
 audio  
 audio  Waiting for sound supervisor to start
 audio  Setting audio routing rules. Note that this can be changed after startup.
 audio  Routing 'balena-sound.input' to 'snapcast'.
 audio  Routing 'balena-sound.output' to 'alsa_output.dac.stereo-fallback'.
 audio  W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
 audio  W: [pulseaudio] module-loopback.c: Cannot set requested sink latency of 66.67 ms, adjusting to 23.22 ms
 audio  W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
 audio  W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

When we inspected the container and executed aplay -L the default device we saw was the the audio jack:

root@fa1bf4df3784:/usr/src/app# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
default:CARD=bcm2835-jack
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
sysdefault:CARD=bcm2835-jack
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
dmix:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
dsnoop:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample snooping device
hw:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
plughw:CARD=bcm2835-jack,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions
usbstream:CARD=bcm2835-jack
    bcm2835 Headphones
    USB Stream Output
default:CARD=dac
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Default Audio Device
sysdefault:CARD=dac
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Default Audio Device
dmix:CARD=dac,DEV=0
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Direct sample mixing device
dsnoop:CARD=dac,DEV=0
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Direct sample snooping device
hw:CARD=dac,DEV=0
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Direct hardware device without any conversions
plughw:CARD=dac,DEV=0
    snd_rpi_hifiberry_dac, HifiBerry DAC HiFi pcm5102a-hifi-0
    Hardware device with all software conversions
usbstream:CARD=dac
    snd_rpi_hifiberry_dac
    USB Stream Output

That’s why we also put COPY pulse-alsa.conf /etc/asound.conf in the Dockerfile of kiosk, to make pulse default.

Some thoughts on the SOUND_SUPERVISOR variable:
This should hold the local IP address of the device, not my routers address, correct?
Because ip route just list the ip addresses of the gateways to reach.
With awk '/default / { print $3 }' we split the the output of ip route in separate lines, and look for the line starting with default.

In the example output we provided in previous posts, our pi has IP 192.168.1.112.
The commandip route | awk '/default / { print $3 }' will return 192.168.1.1 in my case, but if we want to contact the audio-supervisor api on the device, it should be 192.168.1.112:3000

This is why we changed the command to $BALENA_SUPERVISOR_ADDRESS, because it contains the local IP (provided via the host).

Kind regards,
Woody

Hi Woody, glad to know we are making progress :smiley:

About aplay -L, if you don’t see the default listed there as PulseAudio it’s likely that the audio container is not running on the device. Can you check that?
Here is the output of that command in my case:

root@a5e352f5de07:/usr/src/app# aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
...

About the SOUND_SUPERVISOR, that variable holds the IP address assigned to the sound-supervisor container by the balena engine, not the device one. In my case:

root@a4d20d4ceaf9:/usr/src# ip route
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.4

Now that I think of it, you might have network_mode: host set on your audio container? Is that possible? Because that would explain why PulseAudio is not being listed as default in the kiosk container and why you are getting the device IP when running ip route inside the audio container.

In any case, I uploaded my project here in case it helps: https://github.com/tmigone/kiosk-sound

Hi @tmigone ,

Your right, the audio container was in network_mode: host, which is indeed wrong. If this line in the docker compose is omitted it works with SOUND_SUPERVISOR="$(ip route | awk '/default / { print $3 }'):3000".

A big thank you for sharing your project on github.

First I tried to compare it, to my current project source, to see where I went wrong. But after a day of searching and trying out changes, I was still nowhere.

Then I created a new project from scratch and pushed your code to it. It worked via the RBP4 audio jack! :grin:

(I believe I might have screwed up some environment variable or missed something in the source code of my old project. :grimacing:)

Next setting BALENA_HOST_CONFIG_dtoverlay to “hifiberry-dac”,“i2s-mmap” also worked.
The audio now plays via the UDA1334 module. :slight_smile:

@anujdeshpande and @pdcastro
Like the Adafruit MAX98357 I2S Class-D Mono Amp, you have to wire up the UDA1334 to same pins on the RBP.

MAX98357 (https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp):

  • Amp Vin to Raspbery Pi 5V
  • Amp GND to Raspbery Pi GND
  • Amp DIN to Raspbery Pi #21
  • Amp BCLK to Raspbery Pi #18
  • Amp LRCLK to Raspbery Pi #19

UDA1334 (https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a):

  • Amp Vin to Raspbery Pi 3V or 5V
  • Amp GND to Raspbery Pi GND
  • Amp DIN to Raspbery Pi #21
  • Amp BCLK to Raspbery Pi #18
  • Amp LRCLK to Raspbery Pi #19

So I think you can add it to the supported DAC list.

Thanks again for the help everyone.
Kind regards,
Woody