Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: deskwizard on November 04, 2014, 12:17:22 AM

Title: Toggle GPIO high while audio is played
Post by: deskwizard on November 04, 2014, 12:17:22 AM
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
Title: Re: Toggle GPIO high while audio is played
Post by: JohnS on November 05, 2014, 07:15:44 PM
Just use a GPIO....

What's your problem???

John
Title: Re: Toggle GPIO high while audio is played
Post by: 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.

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

DW
Title: Re: Toggle GPIO high while audio is played
Post by: martinayotte on November 06, 2014, 04:27:41 PM
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.
Title: Re: Toggle GPIO high while audio is played
Post by: MBR on November 06, 2014, 05:48:31 PM
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).
Title: Re: Toggle GPIO high while audio is played
Post by: deskwizard on November 06, 2014, 06:16:44 PM
Thanks everyone for the tips!
I'll look into that when time permits.

DW