Toggle GPIO high while audio is played

Started by deskwizard, November 04, 2014, 12:17:22 AM

Previous topic - Next topic

deskwizard

Good afternoon,

I was wondering if anyone had any idea on how to toggle a GPIO while audio is being played.
I would use it to lower the volume from other sources while audio is being played on the A20 board...

Think lower FM radio output while A20 talks navigation instructions.

Like I said, if anyone has an idea, hit me up!

Thanks,
DW

JohnS

Just use a GPIO....

What's your problem???

John

deskwizard

My problem is as written, I want (for example) the GPIO to be high while audio is being played and low while it is not.

I'll try to play with the audio HAL to see if I could add that functionality.

DW

martinayotte

You can also use small analog circuit that provide logic level output when sound is present, with potentiometers to adjust trigger level and delay duration.

MBR

Quote from: deskwizard on November 06, 2014, 05:06:49 AM
My problem is as written, I want (for example) the GPIO to be high while audio is being played and low while it is not.

When a sound is played through the audio device, the device generates hardware interrupts. So when you watch the correct line in the /proc/interrupts file, you can get the difference from the last read and if the difference is nonzero, the audio device is playing something. Just watch the interrupts (using someting like watch -n 1 cat /proc/interupts ) while playing (something like play -n synth 0 sine 1000 )  to get the correct line (on my A13, it's named dma_irq).

deskwizard

Thanks everyone for the tips!
I'll look into that when time permits.

DW