Detect audio out

Im building a Raspberry Pi into an old Tandberg SS12 case to create an audio player out of it. The radio originally has a backlit blue glass in front which I would like to recreate. I have added a led-strip which Im able to turn on and off using GPIO. However, if no music have been played for a while (i.e a minute) I would like to turn the led strip off. And if music is started playing I would like to turn it back on.

I did something similar a few years back on volumio checking for some files in /proc. But now I would like to add this functionality in a container in BalenaOS.

So, is there any way from one container to detect if audio is currently beeing played?

Interesting usecase!

  • Take a look at the balenaSound architecture if you haven’t already
  • IMO you want to tweak the output layer to figure if something is being played. Check out this section of the balenaSound README. Here we talk about how one can subscribe to events from pulseaudio. There are play and stop events that you can listen for, and based on those you could control your GPIO for the desired lighting effect
1 Like

Thanks a lot for the suggestion. That looks very promising. I will check it out and come back with how it went.