Whenever audio is playing, I'd like to close a relay powering a speaker. Where and how can I attach a hook to do that?
1
vote
1
answer
42
views
I'd like to run 32-bit Raspberry Pi OS Bullseye on a Raspberry Pi 2B system headless, with it receiving audio from various sources (e.g. S/PDIF input from TV, through acting as a Bluetooth speaker, or via running Spotify), apply some filters and EQ (using PulseEffects for example), and output balanced audio to the XLR inputs of mains-powered studio monitors (using a Raspberry Pi DAC Pro for example). Hardware selection and software configuration for this is relatively straightforward.
The speakers constantly draw a few watts from the mains, even when idle. It would be nice if I could automate switching power to them on or off depending on whether there's an audible signal being played or not. I could easily build an analog level detection circuit for the task, but I wonder if it's possible to achieve the same in software.
I've looked into ALSA documentation (https://www.alsa-project.org/alsa-doc/alsa-lib/) for a few hours, but I'm in over my head. Searching for similar questions from the past revealed two old yet relevant threads, but unfortunately they lack a satisfactory answer.
On this site: https://unix.stackexchange.com/questions/203963/detect-when-audio-card-is-powered-using-alsa
On the Raspberry Pi forums: [Audio Activation Switch](https://forums.raspberrypi.com/viewtopic.php?t=57808)
Asked by jms
(113 rep)
Jul 13, 2025, 09:01 PM
Last activity: Jul 14, 2025, 12:13 PM
Last activity: Jul 14, 2025, 12:13 PM