Smack My Lazer - live coding
In this post I’ll introduce my live coding music environment built on top on Overtone and Leipzig.
TL;DR
This is an example session we’ll be discussing here:
I’m using lots of samples from Major Lazer & DJ Snake - Lean On (feat. MØ) and a beat from Prodigy - Smack My B**ch Up.
Main theme
First things first. To recreate the Lean On main theme we’ll use Leipzig as in previous post. The notes are here:
And can be expressed as:
And I also created a simple “plucky” sound based on square wave with some reverb:
And to wire it up for Leipzig we need to implement live/play
for :plucky
This controls
atom lets us modify live the instrument amp and cutoff frequency.
So it sounds like this:
Sampler
What I’m doing a lot in this video is using a homemade sampler. I stolen some ideas from Sam Aaron’s Sonic Pi sample packs concept ;)
Basically, I have a directory when I put all the samples and use special meaning of samples file name to detect some properties of the sample.
So for example, I have 120_8_smack_beat.wav
which tells my sampler that this file is in 120 BPM, is 8 beats long and is named :smack-beat
.
Because Lean On is ~98 BPM I can compute a correct ratio to match Smack My B**ch Up beat with Lean On melody.
Original beat (120 BPM):
Scaled to 100 BPM with melody:
I can also play only first few beats of some sample by using it like this [0 :lean-chorus 2]
, which means that on time 0
I only want first 2 beats of :lean-chorus
sample. The beat lengths are of course computed from current BPM.
Song state
I found it really easy to manipulate current state of the song represented as a map of independent tracks:
This allows me to modify the current state by using this update-track
function. It just takes a key with track name and a new value of this track. So I can have my plucky
instrument playing while I’m modifying the beat and so on:
It’s also very easy to remove some of the notes as I’m doing just before the chorus to remove last frame from beat and theme:
In Leipzig I can just use live/jam
to loop current state of the song. When I modify something it’ll we activated on next loop (same as :live-loop
in Sonic Pi).
I you want to play around with this stuff, check out my disclojure repo on GitHub.