Sunday, 6 October 2013

Coding Music on a Raspberry Pi using Sonic Pi

Are you the creative type? I know I am, but I've never really been the musical type. Learning a musical instrument always seemed terribly hard work. I take my hat off to anyone that can play more than a tambourine. I love music, doesn't everybody?

Imagine my excitement then when I was introduced to Sonic Pi by +Sam Aaron, an application for the Raspberry Pi that lets your program music! 

What you will need:

  • A Raspberry Pi and peripherals (mouse, keyboard, SD card, monitor, that type of thing!)
  • some headphones or a mini speaker that will plug into the sound jack port on your Pi.
  • The latest version of NOOBS.
  • Your imagination!
You will find the Sonic Pi application on the main menu of the latest version of NOOBS, under 'Programming'. When you first run the software you will need to re size the window to fill the screen so you can see all parts of the interface.

To play a note in Sonic Pi type 'play' followed by a MIDI note number:
play 60

To add timings between the notes type 'sleep' followed by the amount of time. e.g. 1 for one second, 0.5 for half a second, and so on:
sleep 0.5

To repeat or loop a a sequence use:
3.times do 
  play 60 
  sleep 0.5 

To add new synths use:
with_synth "fm"

Learn Sonic Pi at School!

As you may know I am a high school/secondary school computing and ICT teacher, so together with Sam who created Sonic Pi, we wrote a scheme of work that can be taught in schools. Here is a post all about it by +Raspberry Pi with a picture of me teaching it in my school:

Why not ask your teachers about it?

No comments:

Post a Comment