As some of you may be aware, when I’m not doing geeky things I am learning to play the piano. Having recently passed my Grade 3 exam I decided to work on something fun over the summer; so I chose ‘Let it Go’ from the Disney film Frozen in hope that this would win me some brownie points with my young nieces next time they visit!
Much to my delight, I also recently discovered a new piece of software on the Raspberry Pi, called Sonic Pi (I’m using V2.0). Brilliant! I can combine both my hobbies into one! After watching a lovely intro video by Carrie Anne Philbin and reading a few tutorials, I understood the idea of how it worked and decided to set myself a challenge! This was to construct ‘Let it Go’ within Sonic Pi and as it also allows multiple threads to run at once, I was able to put together both the left and right hand sections of the piece and I’m really pleased with the end result:
This was a nice task to complete as it enabled me to discover some of the key features of Sonic Pi such as:
- Variables
- Loops
- Functions
- Threads (to run two functions at the same time)
You can see a snippet of the interface of Sonic Pi below, as you can see it has a simple and clean layout which makes it really easy to get started. Sometimes children can be overwhelmed if software has lots of menus and buttons but they shouldn’t have any problem with this!
To play the notes, you simply give the program the MIDI number for each note (eg. Middle C – 60) and the timings. The table below gives the corresponding MIDI numbers for each note:
You can download a copy of my source code here. Apologies for the lack of commenting in my code, however if you’re familiar with any programming language you can probably decipher it fairly easily!
It wasn’t all plain-sailing though . . . Many of the resources for Sonic Pi I found online are for version 1, so I had a few issues at first until I discovered the built-in help which proved to be invaluable for providing examples of syntax and formatting. Another issue I had was that once I added my second thread to play the left hand part my Pi really struggled and Sonic Pi threw a lot of timing errors at me saying it “couldn’t keep up” and sounded awful as many of the notes became misaligned! I was a bit concerned at this point that all my hard work was in vain but after overclocking my Pi to Turbo Mode it worked nicely! Here is a guide on how to do this.
I should also credit the source of the sheet music, which was the easier version of the song transcribed by Joyce Leong, for this and more sheet music check out her excellent website. (Note, I only went up to page 3 for this activity).
For a Getting Started guide to SonicPi V.20 check out the resources from the Raspberry Pi Foundation.
I’m really looking forward to trying this out with some of my students in September, I think this is something that will really engage them and if I notice any budding virtuosos then maybe I’ll enter them into the Sonic Pi Competition as well!