Other

Practical Classroom Tech: Life of Pi

Music is an excellent cross-curricular subject, and this is particularly true with computer science. Many music teachers might be worried about coding with students in music lessons – but Sam Aaron, University of Cambridge computer science researcher and electronic musician, is here to explain its benefits.
 Sam Aaron live coding
Sam Aaron live coding

The laser beams sliced through the wafts of smoke as the subwoofer pumped bass deep into the bodies of the crowd. The atmosphere was ripe with a heady mix of synths – but something wasn't quite right. Projected in bright colours above the DJ booth was futuristic text, moving, dancing and flashing. These weren't fancy visuals – it was merely a projection of code. The occupant of the DJ booth wasn't spinning records – she was editing and evaluating code using Sonic Pi. Live. This was live coding.

This may sound like a far-fetched story from a futuristic music festival, but coding music like this – often called live coding – is a growing trend. This approach to manipulating code isn't just useful for performance, it's also a fabulous way of engaging a new generation of coders in the classroom.

Using code as its main interface, Sonic Pi takes a different approach to traditional musical instruments. It enables students to write code live to create the kinds of music they're typically used to listening to. If this claim sounds a little ambitious, take a look at this quote from the Rolling Stone magazine covering a recent Sonic Pi performance at Moogfest, USA:

‘[The set] – which sounded like Electric Caféera Kraftwerk, a little bit of Aphex Twin, and some Eighties electro – was constructed through typing and deleting lines of code. The shadowy DJ sets, knob-tweaking noise and fogbank ambient of many performers was completely demystified and turned into simple numbers and letters that you could see in action […] it truly seemed less like a performance and more like an invitation to code your own adventure.’

(www.tinyurl.com/mt-march-rollingstone)

POWERFUL YET SIMPLE

Of course, there is very limited educational value in a system that's powerful yet incredibly difficult to learn. Luckily, Sonic Pi was conceived and built within classrooms in close collaboration with teachers, and it has the benefit of many design iterations, based on hundreds of hours of student observation. Simplicity has even been baked into the core design philosophy by only allowing features that are easily understood by and taught to a ten-year-old.

For example to get started, you only need to learn two simple commands: ‘play’, which allows you to play different notes; and ‘sleep’, which allows you to choose how long to wait before playing the next note:

  • play 70
  • sleep 1
  • play 75
  • sleep 2
  • play 72
  • sleep 1
  • play 82

 

What's exciting here from a musical perspective is that with just ‘play’ and ‘sleep’ you have access to most Western music. In other words, with just two commands you can recreate any known melody or rhythm – and of course you're entirely free to compose your own.

Once you've mastered ‘play’ and ‘sleep’, the next command to learn is ‘sample’. ‘Sample’ gives you the ability to play any pre-recorded sound. There are a large number of built-in recordings to use such as drums, guitars, and atmospheric noises. However, the real fun starts when you record your own sounds to play back and manipulate. From there you can easily add studio effects such as reverb and distortion, hook up traditional instruments through your sound card, and even trigger external instruments with MIDI.

The exciting thing is that that there are a number of computing concepts which aren't immediately noticeable in traditional Western music. For example, functions let you give names to sections of compositions that can in turn be used to create new higher-level sections. This allows you to compose at the level natural to your compositional thinking rather than at the level of the instrumentalist who will play your piece. You can easily include deterministic randomisation that allows you to discover and revisit new melodies and rhythms. You can even treat the score as an instrument and modify it as it runs (which is what we call live coding).

If you are excited about this new approach to engaging students with computing, you can get the app from www.sonic-pi.net. It is completely free and cross-platform, working identically on Windows, Mac, and Raspberry Pi. It even comes with a complete built-in tutorial that assumes you know nothing about either code or music, so download it and have fun! (Tech Ed. – I let my pupils work through the tutorials on their own and none of them got stuck!)




Related