This python3 script takes a collection of audio files and plays them in sequence, looping infinitely, paused or resumed by input on the Pi's GPIO pins.
The script is useful in museum or gallery settings where a small microprocessor is required to generate a looped audio sequence.
An optional transition sound is possible.
By default the script will look for a file in the audio directory named sequence.list to order the audio sequence. If the file is not found, the script will sort the list of files and play in that order.
By default the script will look for a file in the run directory called config.json that configures the script. If the config file is not found, reasonable default will be tried.
- python3
- pygame (http://www.pygame.org/docs/ref/music.html)
- gpiozero
See CONFIG-pi.md for full hints on preparing your Rpi
cd ~
git clone git@github.com:wmodes/pias.git
Ref: https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install
curl https://get.pimoroni.com/phatdac | bash
We can use a test from the repo:
cd ~/pias/experiments
python3 pygame-test.py
You should hear audio through the pHAT DAC external audio port.
Connect your normally open switch to Ground at pin 6 and GPIO2/SDA1 12C at pin 3.
Run the script:
cd ~/pias
python3 pias.py
The script should be waiting for you to depress the play switch.
If you are testing on a machine other than the Rpi, the keyboard will activate and deactivate the audio loop.
Add audio files to ~/pias/data
Configure ~/data/config.py
adding an optional cart_list to order the audio files.
"cart_list" : [
"02_test.mp3",
"03_test.mp3",
"01_test.mp3"
]
without cart_list, the script will create its own based on a sorted list of files in ~/pias/data
If you need the script to run when the Rpi is booted, add the following to /etc/rc.local
# start pias script
/usr/bin/python3 /home/pi/pias/pias.py &>> /var/log/pias.log