Sonic Pi is a new musical instrument that you play by writing programs!
Check out the handout! Credit to Charisse.
sample :drum_roll
sleep 6
sample :drum_splash_hard, amp: 1.5use_synth :fm
play :c, attack: 1, decay: 0, sustain: 0, release: 1, amp: 0.5, pan: rrand(-0.5,0.5)live_loop :drums do
4.times do
sample :drum_bass_hard
sleep 0.5
sample :drum_cymbal_closed
sleep 0.5
sample :drum_snare_hard
sleep 0.5
sample :drum_cymbal_closed
sleep 0.5
end
sample :drum_bass_hard
sleep 0.75
sample :drum_bass_hard
sleep 0.25
endlive_loop :bass do
use_synth :tb303
play :c2
sleep 0.5
end
live_loop :riff do
use_synth :pulse
play :c, attack: 0.5, sustain: 0.5, release: 0.5
sleep 1
play :g, pan: rrand(-0.5, 0.5)
sleep 0.5
play :e
sleep 0.5
endlive_loop :my_random_beat do
use_random_seed 220
16.times do
sample :elec_hi_snare if one_in 3
sample :drum_cymbal_closed if one_in 3
sample :drum_cymbal_pedal if one_in 5
sample :bd_haus if one_in 3
sleep 0.125
end
end
live_loop :my_tune do
use_synth :prophet
notes = scale :c4, :minor_pentatonic
use_random_seed 40
6.times do
play notes.choose
sleep [0.25, 0.5].choose
end
enduse_synth :piano
play [:c, :e, :g]
sleep 1
play (chord :c, :major)
sleep 1
live_loop :play do
play (chord :c, :major).tick
sleep 0.5
stop if look > 2
enduse_synth :prophet
14.times do
play (scale :c4, :major, num_octaves: 2).tick
sleep 0.25
endlive_loop :up_and_down do
use_synth :sine
play (scale :c4, :major_pentatonic).reflect.butlast.tick
sleep 0.25
endCredit to mehackit
use_synth :beep
live_loop :chords do
[1, 3, 6, 4].each do |d|
(range -3, 3).each do |i|
play_chord (chord_degree d, :c, :major, 3, invert: i)
sleep 0.25
end
end
endCredit to Adrian Cheater
define :pattern do |p|
return p.ring.look == 'x'
end
use_bpm 90
live_loop :drums do
tick
sample :drum_bass_hard if pattern "x-x-----x-x--x--"
sample :drum_snare_hard if pattern "----x--x-x-xx---"
sample :drum_cymbal_closed
sleep 0.25
endCredit for funk pattern, pattern
with_fx :slicer do
live_loop :breakbeat do
sample :loop_breakbeat, beat_stretch: 2, amp: 2
sleep 2
end
end
with_fx :wobble, phase: 0.25, invert_wave: 1 do
live_loop :melody do
use_random_seed 20
use_synth :fm
8.times do
play (chord :eb5, :minor7).shuffle.tick
sleep 0.5
end
end
endnotes = (scale :e3, :minor_pentatonic)
sn = synth :prophet, note: :e1, release: 8, cutoff: 100
sleep 1
16.times do
control sn, note: notes.tick, pan: rrand(-1, 1)
sleep 0.125
end# chords = [(chord :C, :minor7), (chord :Ab, :major7),
# (chord :Eb, :major7), (chord :Bb, "7")].ring
chords = [(chord :A, :minor), (chord :F, :major),
(chord :G, :major), (chord :C, :major)]
chosen = chords[0]
live_loop :melody do
stop
use_synth :blade
r = [0.25, 0.25, 0.5, 1].choose
play chosen.choose #, attack: 0, release: r
sleep r
end
live_loop :keys do
stop
use_synth :blade
play chosen
sleep 1
end
live_loop :bass do
use_synth :fm
use_octave -2
3.times do
play chosen[0]
sleep 1
end
play chosen[2]
sleep 0.5
play chosen[1]
sleep 0.5
chosen = chords.tick
end
live_loop :perc do
stop
sample :drum_cymbal_closed, amp: 0.5
sleep 0.25
end
live_loop :perc1 do
stop
sample :ambi_choir, release: 5, slice: 0.5
3.times do
sample :drum_bass_hard, amp: 2
sleep 1
end
2.times do
sample :drum_bass_hard, amp: 2
sleep 0.5
end
4.times do
sample :drum_bass_hard, amp: 2
sleep 1
end
endCredit to mehackit
Check out what other people are doing and remix their work! Good places to go are the Sonic Pi tutorial, forums, or other people’s YouTube channels.
Need help tying your song together?
- Drum patterns
- Note names (and sounds!) and chord progressions
- r/DrumKits is a great place to find samples
Need inspiration? Check out these pieces that other people have made.
Other reference material


