Sonic Pi is a live coding platform created by Sam Aaron, at University of Cambridge Computer Laboratory, in 2012 as a low-cost programmable computing platform for Raspberry Pi. Since it was originally created to make programming in Raspberry Pi more accessible, it is beginner-friendly and has friendly UI and documentation.
Sonic Pi is also popular among live coding DJs and used by multiple artists. DJ_Dave is one of the artists who actively use Sonic Pi to create electronic music. Below is a live coded music she created using Sonic Pi.
I also experimented with Sonic Pi and created a edit of a track – Free Your Mind by Eden Burns. I also used some custom samples of bass drums and claps for the beat. The following is the code:
s = [path_to_main_track] # this is the path to the music file
ukgclap = [path_to_sample_dir]
ukghh = [path_to_sample_dir]
use_bpm 124
##| start
in_thread do
sample s, start: 0.6542207792, finish: 0.7045454545, amp: 0.5, decay: 3
sleep 8*4
set :beat, 1
end
live_loop :sbd do
sample s, onset: 0, amp: 1.6
sleep 1
end
##| play beat
sync :beat
live_loop :clap do
sleep 1
sample ukgclap, "ukgclap_8", amp: 0.7
sleep 1
end
live_loop :shh do
sleep 0.5
sample ukghh, "ukghh_1", amp: 0.7
sleep 0.5
end
##| intro
in_thread do
sample s, start: 0.163961039, finish: 0.2142857143, amp: 0.85
sleep 8*4
set :mainBeat, 1
end
##| play main
live_loop :main do
sync :mainBeat
sample s, start: 0.3022727273, finish: 0.4029220779
sleep 8*16
end
Here, I chopped up different parts of the track and reordered with a coded house beat using custom samples. The hardest part was to make the set: and sync: work properly with the threads. I also had to calculate the bars manually to figure out the sleep time. I wonder if there is a better way to do this.
While the last block is being halfway played, I also executed the following code in another buffer of Sonic Pi:
s = [path_to_main_track] # this is the path to the music file
2.times do
with_fx :reverb, phase: 0.2, decay: 5, mix: 0.75 do
sample s, start: 0.6542207792, finish: 0.7045454545, amp: 0.5, decay: 3, rpitch: 1.3
sleep 8*4
end
end
It plays the vocal in a somewhat distorted way as it overlaps with the vocal that were already being played by the main block.