One of our most popular examples for the Pi Cap is touch-mp3, which allows you to play different audio tracks by touching the Pi Cap’s electrodes. By default, it is set up with 12 different instrument sound effects, but in this tutorial, we will show you how to change these 12 tracks to whatever you like.
First, we will gather together the audio files on our computer. We will then SSH into the Pi, to remove the currently existing files. Next, we will copy the files from our computer to the Pi via SSH.
If you don’t want to use SSH and the terminal, you can also use a monitor, keyboard and mouse connected to your Raspberry Pi to move the files manually.
Prepare the tracks
First, make sure that you have all the tracks you want the Pi Cap to play saved onto the computer that you will SSH into the Pi from.
There are two conditions for the tracks to work with the Pi Cap: They all need to be MP3 tracks and they need to have specific names so that they match with the electrodes on the Pi Cap. The track that is going to be played with electrode E0 needs to be named TRACK000.mp3, the second TRACK001.mp3 for E1 and so on, up to TRACK011.mp3 for E11. If your sound files aren’t in the MP3 format, you can use any online converter, for example, Media.io.
Prepare the Pi
After you’ve SSH’d into the Pi, head to the right folder by entering
Remove all of the tracks by entering “rm *.MP3”. You can now copy the new MP3 files into this folder.
Copy files from your computer to the Pi
Back on your computer (not the Raspberry Pi), you can copy the files to the Pi: Open your Terminal window and head to the folder where you have saved the tracks. Then, simply enter
scp *.mp3 email@example.com:PiCapExamples/cpp/picap-touch-mp3-cpp/tracks/
You need to enter the password of the Pi. This should copy all the files.
Run the code
Now we can test our work! SSH back into the Pi, and enter
The Pi will run the code and touching the electrodes will play your new sounds!
In this tutorial, we used the C++ code, but the same methods apply to the Python or Node example programs, just make sure to head to the correct folder location.
If you have any questions or you just want to share your project with us, you can send us an email at info@bareconductive or contact us via Instagram or Twitter.