What is Sonic Pi?
Sonic Pi is a a (live) coding tool, created by Sam Aaron for writing music using the Ruby programming language. It’s changed the whole art of making music for me because I can now include algorithmic elements to generate music rather than using a physical device (like a guitar/bass/piano) or by using a graphical sequencer (like Ableton). That makes it a super creative way to create music, experiment with sound using code.
If you’re a musician looking to learn to code or a coder looking to learn music then this is a great tool for you.
You can download Sonic Pi from https://sonic-pi.net and it looks something like this (on OSX).
Over the course of this year I’m aiming to do a workshop and talk on this subject, how it works and how to get into Sonic Pi.
Sonic Pi can be based around synthesised sounds generated from a software based device, but it can also be based around sampled sounds/loops created by yourself or others.
You can find a full list of all the synthesisers here to explore later.
Let’s start using the blade synth, and explore playing some notes. The numbers here correspond to notes within octaves on a standard musical piano. Chart as follows. Middle C on a piano would be 60 here.
To play this, use⌘ + R or use the “Run” button.
Now lets play a set of chord (a group of notes sounding together
That forms a very basic introduction to playing notes with Sonic Pi.
Rather than using the synth devices, we can also play samples. Sonic Pi has a number of built in samples, but you can also import your own.
The full list of samples can be found here
The Live Coding Music Synth for Everyone. Contribute to samaaron/sonic-pi development by creating an account on GitHub.
Let’s just use a (fairly standard) Amen break, that’s pretty standard in Drum and Bass. It also has a cool history.
Alternatively we could use the a kick drum sample and create a loop to play this a number of times.
use_sample_bpm :drum_heavy_kick4.times do |n|
We can also alter a number of parameters around the sample, let’s pick a longer one though (ambi_lunar_land).
Pan — Pan a sound to the left speaker (-1) or the right(1).
sample :ambi_dark_woosh, pan: -1
sample :ambi_choir, pan: 1
Attack/Release — Fade a sample in (alter the attack) and out (alter the release. For more on ADSR, see this article.
sample :ambi_dark_woosh, attack: 0.75, release: 0.75
There’s loads more we can do with Sonic Pi, but that’s good enough to start. Next time we’ll look at structure, randomisation and variation in part 2.
The Sonic Pi cheatsheet is great if you want to take this further.