Hi there, i’m trying to switch a relais to power up my amp when sound is playing. Audio is playing on my DAC. The DAC is audio card 1. The pin I want to switch is GPIO4 (pin 7). How can I get this to work. Can someone help me with this?
Hello! How is the DAC connected to your Raspberry Pi? Is it through USB? If so, you could probably use Python (or a preferred language) to read data coming in from the serial port and then use it to switch the GPIO pins. Can you provide a schematic or the type of DAC which you are using?
There are quite a few options for detecting audio. One way is to check whether your sound card is outputting a signal. This might be a way to do it detect audio output - Raspberry Pi Forums .
It seems like your audio shield is comapitable with alsamixer. I would look into alsamixer and see if you can use it to check whether your speaker is making noise and then see how you can access the data from alsamixer using python. Here is a tool for accessing alsa using python: GitHub - larsimmisch/pyalsaaudio: ALSA wrappers for Python