# balena os - upboard - audio playout issue

**URL:** <https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907>\
**Category:** balenaOS\
**Tags:** docker, sound\
**Created:** [August 20, 2021, 8:26am UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907 "2021-08-20T08:26:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gzett](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gzett](https://forums.balena.io/u/gzett)\
**Post date:** [August 20, 2021, 8:26am UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/1 "2021-08-20T08:26:56Z")

</div>

Hi all!  
I’m working on a small project with a text-to-speech microservice.  
We use an upboard cht01, with a usb sound card plugged in.

this is lsusb output on balena os host

```auto
Bus 001 Device 004: ID 0424:2530 Standard Microsystems Corp.

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Bus 001 Device 002: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter

Bus 001 Device 003: ID 0424:4603 Standard Microsystems Corp.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

```

I also listed /dev content with and without plugged usb, and I notice that the only difference is hidraw0.

After that I create a docker compose in order to get a docker container with audio support, with a small node script to playout a local file by [audio-play](https://www.npmjs.com/package/audio-play), [audio-buffer-from](https://www.npmjs.com/package/audio-buffer-from) and [audio-loader](https://www.npmjs.com/package/audio-loader) npm packages

This is the docker compose

```auto
version: "2"
services:
  test:
    container_name: test
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - UDEV=1
    privileged: true
    devices:
      - "/dev/snd:/dev/snd"
      - "/dev/hidraw0:/dev/hidraw0"
    network_mode: host

```

and this is the dockerfile

```auto
FROM node:16.6-alpine
RUN adduser -S appuser

WORKDIR /usr/src/app

RUN apk update && \
  apk upgrade && \
  apk add \
  espeak \
  vorbis-tools \
  sox \
  alsa-utils \
  alsa-lib \
  pulseaudio \
  pulseaudio-alsa \
  pulseaudio-utils \
  curl \
  rm -rf /var/cache/apk/*

COPY package*.json ./
RUN npm i
COPY . .

RUN addgroup appuser audio
RUN addgroup appuser pulse
RUN addgroup appuser pulse-access

USER appuser

RUN pulseaudio --start

CMD tail -f /dev/null

```

in the docker container I can get available sound cards by aplay --list-devices command, but unluckily, it seems there is no sound card available.

```auto
aplay --list-devices
aplay: device_list:274: no soundcards found...

```

I think it’s just a docker compose device mount issue, but I have no idea about how to make it working… any helps?  
Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![vipulgupta2048](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@vipulgupta2048](https://forums.balena.io/u/vipulgupta2048)\
**Post date:** [August 20, 2021, 8:43am UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/4 "2021-08-20T08:43:30Z")

</div>

Hello folks,  
Not sure if it would help or you already checked it out, but would our Audio block help in this case? It’s not supported on Upboard but maybe you can use it as a reference? [GitHub - balenablocks/audio: Audio building block, based on pulseaudio.](https://github.com/balenablocks/audio)

---

<div class="post-metadata">

**Author:** ![gzett](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gzett](https://forums.balena.io/u/gzett)\
**Post date:** [August 20, 2021, 9:01am UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/6 "2021-08-20T09:01:54Z")

</div>

great! thanks, I’ll check it out

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [August 20, 2021, 1:16pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/8 "2021-08-20T13:16:09Z")

</div>

Hello there, audio block dev here. I think you should def try the audio block or at least check it’s code for useful parts, it’s a pulseaudio based audio server so it’s probably close to what you want. Upboards are not supported but because I don’t have one and haven’t tested it, it’s likely it works just fine.

Regarding your problem, it does look like the device is not being picked up as a sound card by alsa. What are the contents of `/proc/asound/cards`?

---

<div class="post-metadata">

**Author:** ![gzett](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gzett](https://forums.balena.io/u/gzett)\
**Post date:** [August 20, 2021, 1:56pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/10 "2021-08-20T13:56:21Z")

</div>

hi @tmigone . thanks for your reply. in balena os host that folder seems empty, while in docker container it doesn’t exists

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [September 23, 2021, 1:25pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/12 "2021-09-23T13:25:14Z")

</div>

Hi @gzett, sorry I missed this ping and just noticed it.

That is super weird. Can you list the contents of the parent folde? Run `ls -al /proc/asound` in the HostOS. Also, what version of balenaOS are you using?

---

<div class="post-metadata">

**Author:** ![gzett](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gzett](https://forums.balena.io/u/gzett)\
**Post date:** [September 23, 2021, 2:38pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/14 "2021-09-23T14:38:54Z")

</div>

Balena OS version is

```auto
HOST OS VERSION
balenaOS 2.54.2+rev1
development
SUPERVISOR VERSION
11.12.4

```

and this is the command output

```auto
root@a38b613:~# ls -al /proc/asound                   
total 0
dr-xr-xr-x 6 root root 0 Sep 23 14:35 .
dr-xr-xr-x 139 root root 0 Sep 23 14:33 ..
lrwxrwxrwx 1 root root 5 Sep 23 14:35 Audio -> card0
lrwxrwxrwx 1 root root 5 Sep 23 14:35 Device -> card1
lrwxrwxrwx 1 root root 5 Sep 23 14:35 bytchtnocodec -> card2
dr-xr-xr-x 5 root root 0 Sep 23 14:35 card0
dr-xr-xr-x 4 root root 0 Sep 23 14:35 card1
dr-xr-xr-x 6 root root 0 Sep 23 14:35 card2
-r--r--r-- 1 root root 0 Sep 23 14:35 cards
-r--r--r-- 1 root root 0 Sep 23 14:35 devices
-r--r--r-- 1 root root 0 Sep 23 14:35 hwdep
-r--r--r-- 1 root root 0 Sep 23 14:35 modules
-r--r--r-- 1 root root 0 Sep 23 14:35 pcm
dr-xr-xr-x 2 root root 0 Sep 23 14:35 seq
-r--r--r-- 1 root root 0 Sep 23 14:35 timers
-r--r--r-- 1 root root 0 Sep 23 14:35 version

```

thanks 🙂

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [September 30, 2021, 2:40pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/16 "2021-09-30T14:40:24Z")

</div>

Hi @gzett, it looks like the hostOS is detecting the card (assuming it’s card1 listed there). We can confirm that if you share the output of `cat /proc/asound/cards` (again, run it on the hostOS).

If so, then it might be that the mapping to the container is somehow not working properly. Can you try deploying another container in privileged mode running debian and share the output of: `ls -al /proc/asound` and `cat /proc/asound/cards`. Here is a sample `docker-compose.yml` file you can use:

```auto
version: '2'

services:

  test:
    image: balenalib/up-board-debian
    privileged: true

```

---

<div class="post-metadata">

**Author:** ![gzett](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gzett](https://forums.balena.io/u/gzett)\
**Post date:** [October 6, 2021, 1:27pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/18 "2021-10-06T13:27:09Z")

</div>

Hi @tmigone , sorry for the late reply

this is `cat /proc/asound/cards` output in the host OS:

```auto
root@a38b613:~# cat /proc/asound/cards
 0 [Audio]: HdmiLpeAudio - Intel HDMI/DP LPE Audio
                      Intel HDMI/DP LPE Audio
 1 [Device]: USB-Audio - C-Media USB Audio Device
                      C-Media USB Audio Device at usb-0000:00:14.0-3, full speed
 2 [bytchtnocodec]: bytcht-nocodec - bytcht-nocodec
                      AAEON-UP_CHT01-V1.0-UP_CHT01

```

then I create a container like suggested and this is the results:

```auto
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 6 root root 0 Oct 6 13:22 .
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 132 root root 0 Oct 6 13:22 ..
[Logs] [10/6/2021, 3:22:01 PM] [test] lrwxrwxrwx 1 root root 5 Oct 6 13:22 Audio -> card0
[Logs] [10/6/2021, 3:22:01 PM] [test] lrwxrwxrwx 1 root root 5 Oct 6 13:22 bytchtnocodec -> card2
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 5 root root 0 Oct 6 13:22 card0
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 4 root root 0 Oct 6 13:22 card1
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 6 root root 0 Oct 6 13:22 card2
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 cards
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 devices
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 hwdep
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 modules
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 pcm
[Logs] [10/6/2021, 3:22:01 PM] [test] dr-xr-xr-x 2 root root 0 Oct 6 13:22 seq
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 timers
[Logs] [10/6/2021, 3:22:01 PM] [test] lrwxrwxrwx 1 root root 5 Oct 6 13:22 usb-soundcard-1 -> card1
[Logs] [10/6/2021, 3:22:01 PM] [test] -r--r--r-- 1 root root 0 Oct 6 13:22 version

```

```auto
[Logs] [10/6/2021, 3:22:01 PM] [test] 0 [Audio]: HdmiLpeAudio - Intel HDMI/DP LPE Audio
[Logs] [10/6/2021, 3:22:01 PM] [test] Intel HDMI/DP LPE Audio
[Logs] [10/6/2021, 3:22:01 PM] [test] 1 [usb-soundcard-1]: USB-Audio - C-Media USB Audio Device
[Logs] [10/6/2021, 3:22:01 PM] [test] C-Media USB Audio Device at usb-0000:00:14.0-3, full speed
[Logs] [10/6/2021, 3:22:01 PM] [test] 2 [bytchtnocodec]: bytcht-nocodec - bytcht-nocodec
[Logs] [10/6/2021, 3:22:01 PM] [test] AAEON-UP_CHT01-V1.0-UP_CHT01

```

I also execute `cat /proc/asound/cards` in the hostOS:

```auto
root@a38b613:~# cat /proc/asound/cards
 0 [Audio]: HdmiLpeAudio - Intel HDMI/DP LPE Audio
                      Intel HDMI/DP LPE Audio
 1 [usb-soundcard-1]: USB-Audio - C-Media USB Audio Device
                      C-Media USB Audio Device at usb-0000:00:14.0-3, full speed
 2 [bytchtnocodec]: bytcht-nocodec - bytcht-nocodec
                      AAEON-UP_CHT01-V1.0-UP_CHT01

```

thanks for your support 🙂

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [December 15, 2021, 12:40pm UTC](https://forums.balena.io/t/balena-os-upboard-audio-playout-issue/344907/20 "2021-12-15T12:40:16Z")

</div>

@gzett, sorry for the delayed response only just seeing this. Were you able to figure this out? The output you shared indicates that the containers are seeing the sound cards correctly, so I’m not sure why `aplay` is not picking them up. Do you get the same problem (aplay not listing devices) on this later test container?
