04 March 2016
The March 2016 issue of The MagPi is out now, featuring my project Clef Hero. The game uses the Piano Hat, a tiny music keyboard that fits on the top of the Raspberry Pi, to teach you to read sheet music. I made it for myself first of all, but it provides a good example of how the Piano Hat works and will hopefully help others to learn too. I don't read music fluently, especially around the leger lines, and many years ago I learned chord fingering using a program I wrote for the Amstrad CPC (pictured, right), playing my keyboard while watching the computer screen.
In the Clef Hero game, you are shown the treble stave and notes appear on it, which you then have to hit on the keyboard. The keyboard only has one octave on it, so the same key is reused for the same note in different octaves. The game starts easy with a small selection of notes, but gradually adds more notes and introduces sharps and flats until you're working with the full stave.
For its musical notes, the project uses Sonic Pi, so my tutorial also explains how you can use Sonic Pi to generate a scale and then use Audacity to turn it into separate note files that Clef Hero can play. You can find a guide to note numbers in Sonic Pi here.
The game is written in Python, using Pygame Zero.
Here are the links you need:
- Download The MagPi here - it's free as a PDF, but you can support the Raspberry Pi Foundation's educational mission by buying it in print or through the Apple App Store and Google Play Store.
- Download the Clef Hero Python code. - It downloads as a text file. Rename it to clef.py.
- Download the Sonic Pi code. - It also downloads as a text file. Rename it to listing1 or copy and paste it into Sonic Pi.
For more information on Sonic Pi and Python, take a look at the book I co-wrote with Mike Cook, Raspberry Pi For Dummies.
With thanks to Gerd Altmann who created the background design I'm using here.