← back to coding

Coding music with Sonic Pi

Sonic Pi is a software where you can code music. Very neat!

In → this very fantastic talk "The Art of Code", Dylan Beattie presents a software for making music called "→ Sonic Pi". It's not your typical Digital Audio Workstation, but actually a program that plays music written in code. There is no visual interface of arranging music on tracks, instead the music is played in loops or single commands.
Example:

play :c4
sleep 1

plays the note C4 for one beat.

Everything else is also written in code, for instance the type of synthesizer you want to use, the volume, effects like echo and reverb - all pure code. As long as you are using the samples that are bundled in Sonic Pi, you can send the code to anyone and it will sound the same on their machine or instance of the program.

Now, I'm just starting out and have barely grasped the essentials, let alone the vast possibilities of the software. It's a bit tricky to get used to different play patterns, how to loop, how to have multiple tracks or instruments running at the same time. There is a → very extensive documentation for Sonic Pi and a number of tutorials on how to go from there.

I played around for an evening and came up with this → rather ambient-dark-drone-background piece. Interestingly, this is written in a way that is almost agnostic of song-structure. In a traditional Digital Audio Workstation, you can arrange the instruments or effects on tracks, always forcing the user to visualize the song and the song structure. With Sonic Pi. this layer is missing, all you have is code. I used several parallel loops of effects, drums and synths to create the basic sounds and then let the program decide, with a random function, when to play them.

This takes my understanding of songs away from thinking about "what parts need to be played when?". With Sonic Pi and the loops, it allows me to make a more fluid form of sound, more ambient - maybe something running in the background of a video game. The basic elements fit together, but you hear them in a somewhat randomized order. This creates a sound both infinite and always shifting. In theory, a computer generated song make from parts could simple go on forever, maybe streamed somewhere. I know one example, where Icelandic band Sigur Rós have→  generated the background music for a 24 hour car journey around Iceland from one of their songs. They blended samples into an ethereal piece of computer music. Fascinating!

Next steps with Sonic Pi: playing around more with various samples. I also want to try to turn a time-series into music, for instance my Google Calendar entries. Somehow, this should be possible.