[colug-432] raspberrypi python audio playback
Rick Hornsby
richardjhornsby at gmail.com
Mon Jun 5 18:05:38 EDT 2017
Looking for some Pi/Python advice.
Building a simple project with my Pi (2B) - step on a pressure pad, it turns on a light and plays some sound. Step off the pad, lights out and the sound/music stops.
I have the 120VAC relays working, that part wasn't too bad. The audio is a bigger issue though. I need to be able to do this in python, and making system calls to mpg123 or omxplayer won't work because I need to be able to gracefully stop the audio playback. I can get audio to play back via the 3.5mm jack from omxplayer, if I set the output device correctly. However, there doesn't seem to be a way to make this persist across reboots. You have to use raspi-config or the amixer command again.
Secondly, while pygame looks like a good candidate for the audio playback from within Python, I can't get any audio to play, regardless of what you do with raspi-config. My guess is that the audio is still being sent over HDMI, and not over the 3.5mm output.
* Is there a way to get pygame to send audio to a specific device on the Pi?
* Is there another python-based solution that makes sense? I have to be able to gracefully (fade out) stop the music, and obviously the playback can't be a blocking call.
* As a last resort, is there an inexpensive way to get just the HDMI audio? Converters run around $90 at Microcenter. That's a lot of money for this simple project and if I only need the audio.
thanks!
More information about the colug-432
mailing list