Music has always been driven forward in part by the technology used to make it. The piano combined the best features of the harpsichord and clavichord to help concert musicians; the electric guitar made performing and recording different forms of blues, jazz, and rock music possible; and electronic drum machines both facilitated songwriting and spawned entire genres of music in themselves. Code has become a part of so many different ways of making music today: digital audio workstation (DAW) software records and sequences it, digital instruments perform it, and digital consoles at live music venues process and enhance it for your enjoyment. But using Sonic Pi you actually perform the music by writing code, and Sebastien Rannou used this technique to cover one of his favorite songs, "Aerodynamic," by electronic music legends Daft Punk.


Q: To start off, for someone like me who knows little to nothing about code in general, what exactly is happening in this video!? I’ve watched it several times in full, and I’m still not sure!


Sebastien: It's a video where a song by Daft Punk is played from code being edited on the fly. This happens in a software called Sonic Pi, which is a bit like a text editor; you can write code in the middle of the screen and it plays some music according to the recipe you provided. Sometimes you can see the screen blink in pink; this is when the code is evaluated, and Sonic Pi takes up modifications. A bit after that, you'll hear something changing in the music. It's a bit like you were writing a recipe with a pencil and at the same time instantly getting the result in your food.



Q: Among the most famous features of Daft Punk’s music is the extensive use of sampling, i.e. using existing recordings that are re-purposed to create new compositions. In covering a song that is sample based, as is the case with "Aerodynamic" - which is based on a Sister Sledge track - how did you go about doing a cover?


S: This is one of my favorite songs, but the choice of doing this cover was more motivated by the different technical aspects it offers. My initial goal was to write an article about Sonic Pi, so I wanted a song where different features of it could be shown. "Aerodynamic" was good for this purpose, as it's made of distinct parts using different techniques: samples, instruments, audio effects, etc. Recreating the sampled part was especially interesting, as there isn't much more than this, so I had of one of those 'a-ha' moments when I got the sequence right, and it surprised me.


Q: How did you come to use Sonic Pi? Do you feel it has any particular strengths and weaknesses in what it does?

sonic pi logo.png


S: I really like the idea of generating sound from code; I think it makes a lot of sense, as there are many patterns in music which can be expressed in a logical way.


I started playing around with Extempore and Overtone, which are both environments to play music from code. The initial learning curve was harder than I expected, as they implied learning a new language (Extempore comes with its own Scheme and DSL languages, and Overtone uses Clojure). So the initial time spent there was more about learning a new language and environment, so it removes some part of the fun you can have (not the technical fun part, but the musical one). On the other hand, Sonic Pi is really easy to start with: one of its main goals is to offer a platform to teach people how to code, and I think Sam Aaron (the creator of Sonic Pi) did a very good job on this. What's surprising is that, even though it's initially made to teach you how to code, you don't feel limited and can go around and do most of the crazy stuff you need to express musically.


One thing which is a bit hard to get right at the beginning is that live coding environments aren't live in the same way an instrument is: you don't get instant feedback on your live modifications if you tweak a parameter within Sonic Pi, as those are usually caught up to on the next musical measure. So you have to think of what's going to happen in the next bar or two, and try to imagine how it's going to sound. This takes some practice.


sonic pi additive_synthesis.png


Q: There’s quite a bit of discussion about how Daft Punk recorded the “guitar solo” in this track; how did you go about covering it?


S: I don't know much about the theories of how they did the guitar solo part, which I naïvely thought they did digitally. I did a spectral analysis of the track, and isolated each individual note to get their pitch and an approximation of their envelope characteristics (the attack, decay, sustain, and release, essentially how the sound develops over time). Then it was just a matter of using a Sonic Pi instrument that sounded a bit like a guitar, and telling it to play them. I then wrapped it in a reverb and a bitcrusher effect (which downgrades the audio's bit rate and / or sampling rate) to make it sound a bit more metallic. Because the notes are so fast during this solo, it sounds kind of good as is (unlike the sound of the bells at the beginning, more on this later!).


Q: As you were working on your cover, did you run into any notable technical problems, and how did you solve them?:


S: Yes! I spent a lot of time trying to get the bells sound right, but failed. Usually when an instrument plays a note, it has a timbre: this is a sort of signature which can be more or less explained, for instance a violin has a very complex timbre, whereas a wheel organ is way more simple. This complexity is highlighted when you look at audio frequencies when such an instrument plays a note: there is usually one frequency that outweighs others (the frequency of the pitch or the fundamental), and a myriad of others, which correspond to the timbre.


The timbre of the bells at the beginning of "Aerodynamic" is very complex, and it evolves in a non-trivial way. I've tried different approaches to reproducing it, including doing Fourier transforms to extract bands of main frequencies at play at different intervals and converting these to Sonic Pi code (more about this here). Sonic Pi comes with a very simple sine instrument, which plays only one frequency, so the idea was to call this instrument several times using different frequencies all together. I kind of got something that sounded like a bell, but it was far from sounding right. I ended up using the bell instrument that also comes with Sonic Pi, playing it at different octaves at the same time, and wrapping these in a reverb effect. That's kind of a poor solution, but at least I had fun in this adventure!


Q: Have you used Sonic Pi to create original music? If so, how did you feel about that process? If not, how do you imagine it would be?


S: Yes, I have, using different approaches. For example, I tried using only Sonic Pi, which ended up sounding a bit experimental, and then by composing in a DAW software (Digital Audio Workstation, eg Pro Tools) and then sampling that so it can be easily imported into Sonic Pi. With this approach I can then use Sonic Pi as a sequencer and wrap the samples in effects. I did another cover using that method, this time of a Yann Tiersen song, and also a few songs with my band, Camembert Au Lait Crew (SoundCloud). The code can all be found here on github.




Q: Do you have any plans for future music projects using Sonic Pi?


S: There are recent changes in Sonic Pi version 3 which I'm really excited about, especially the support of MIDI, so you can now control external synths with code from Sonic Pi while keeping the ability to turn knobs on your synth. I haven't tried this yet, but it's definitely what I want to do next. Sam Aaron did a live coding session recently showing this and I find it amazing: