Skip to content

Instantly share code, notes, and snippets.

@interstar
Last active October 22, 2021 03:20
Show Gist options
  • Save interstar/e35b752325280cc8454cdee74a7bfb99 to your computer and use it in GitHub Desktop.
Save interstar/e35b752325280cc8454cdee74a7bfb99 to your computer and use it in GitHub Desktop.
UK Drill in Sonic Pi
# UK Drill Beat in Sonic Pi
# Tutorial : https://www.youtube.com/watch?v=ELA339I4NwY
# Note : this Sonic Pi Sketch relies on you having certain drill type drum samples
# Put them in the directory referenced in the variable called sampleKit
# you'll need samples called hat.wav, hat2.wav, kick.wav, snare.wav and noise.wav
define :flatfifth do |c|
c2 = c.map{|n| n}
c2[2] = c2[2]-1
return c2
end
define :sadden do | c |
c2 = c.map{|n| n}
c2[1] = c2[1]+12
c2 = c2 + [c2[1]+7]
return c2
end
define :shift do | c, d |
c2 = c.map{|n| n+d}
return c2
end
use_bpm 142
# NOTE : Make a path to your own sample directory here ... you'll need samples called
# hat.wav, hat2.wav, kick.wav, snare.wav and noise.wav
sampleKit = "D:/new_composing/shared_resources/samples/User/kits/teaching"
chordLength = 8
c1 = chord("Ds3","minor")
c2 = shift(c1,3)
cs = [c1, sadden(c1), shift(c1,-7), flatfifth(c1),
c2, sadden(c2), shift(c2,-1),flatfifth(shift(c2,-1))]
currentChord = 0
section = 0
# CHORDS
with_fx :level, amp: 0.4 do
with_fx :reverb, mix: 0.3 do
with_fx :krush, mix: 0.1 do
with_synth :blade do
live_loop :x do
cs.each { | c |
currentChord = c
play_chord c, attack: 2, decay: 7
sleep chordLength
}
end
live_loop :y do
cs.each { | c |
play_chord c, attack: 5, decay: 3, amp: 1.5
sleep chordLength
}
end
end
end
end
end
# HIGH "STRINGS"
with_fx :reverb do
with_synth :dsaw do
sv = 0.1
live_loop :hisaw do
if currentChord != 0 then
play currentChord.choose+12, attack: 1, release: 0.6,
sustain: 0.5, decay: 0.8, amp: sv*[1,1,0].choose
sleep 1
play currentChord.choose+12, attack: 1, release: 0,
sustain: 0.5, decay: 0.3, amp: sv*[1,1,0,0,0].choose
sleep 0.5
play currentChord.choose+12, attack: 1, release: 0,
sustain: 0.5, decay: 0.3, amp: sv*0.8*[1,0,0,0].choose
sleep 0.5
else
sleep 1
end
end
end
end
# PIANO
with_fx :gverb, mix: 0.1 do
with_fx :flanger, mix: 0.5 do
with_synth :piano do
live_loop :piano do
sv = ([1]*16 + [0]*16).ring().tick(:piano1)
sv2 = ([1]*16 + [1,0,0,0]*4).ring().tick(:piano3)
if currentChord != 0 then
play currentChord[0]+12, release: 0.8, sustain: 0.5, decay: 0.5, amp: sv2
sleep 3
play currentChord.choose+12, release: 0.8, sustain: 0.5, decay: 0.3, amp: sv
sleep 1
play currentChord.choose+12, release: 0.8, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2
play currentChord.choose+12, release: 0.8, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2
if [0,1,0].ring().tick(:piano2) == 0 then
play currentChord.choose+12, release: 0, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2
else
play currentChord[1]+12, release: 0.6, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2/3.0
play currentChord[2]+12, release: 0.6, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2/3.0
play currentChord[0]+12, release: 0.6, sustain: 0.5, decay: 0.3, amp: sv*0.8
sleep 2/3.0
end
else
sleep 4
end
end
end
end
end
# MAIN HATS (tresillo)
live_loop :hats do
([1,0,0,1,0,0,1,0]*15 +
[1,0,1,0,1,0,1,0,
1,0,0,0,1,0,1,1,]).each {|v|
sample sampleKit, "hat.wav", amp: 0.6*v, rate: 1.1, decay: 0.04, sustain: 0, release: 0
sleep 0.25
}
end
# HATS 2
with_fx :panslicer, phase: 0.5, smooth_down: 0.1 do
live_loop :hats2 do
x = [1,1,0,0,0,0,2,0,0,0].choose
if x == 1 then
[1,1,1,0].each {
sample sampleKit, "hat2.wav", amp: 0.6
sleep 0.125
}
elsif x == 2 then
[1,1,1,1,1,1,1,1,1,1,1,1].each {
sample sampleKit, "hat2.wav", amp: 0.8
sleep 0.333
}
sleep 4
else
sleep 3
end
end
end
# SNARE
live_loop :snares do
[0,0, 0,0, 1,0, 0,0, 0,0, 0,0, 0,0, 1,0,
0,0, 0,0, 1,0, 0,0, 0,0, 0,0, 0.5,0, 1,0.25, ].each {|v|
sample sampleKit, "snare.wav", amp: 1.8*v
sleep 0.5
}
end
# KICKS
live_loop :kicks do
[1,0,0,[0,0,0.8].choose(), 0,0,1,0,
1,[0,0,0.7].choose(),0,0, 0,1,1,[0,0,0.5].choose(), ].each {|v|
sample sampleKit, "kick.wav", amp: 3*v, decay: 0.1, sustain: 0, release: 0
sleep 1
}
end
# 808
with_fx :level, amp: 0.5 do
with_fx :distortion, mix: 0.8 do
with_fx :reverb do
live_loop :an808 do
[1,0,0,1, 0,0,1,0,
1,0,0,1, 0,0,[1,2].choose,1,
].each {|v|
if v == 0 then
sleep 2
elsif v == 1
r = currentChord[0]-68 #+48
if r < -5 then r = r + 12 end
sample :bd_boom, amp: 5*v, attack: 0.2, decay: 8,
sustain: 1.7*v, rpitch: r
sleep 2
else
r = currentChord[0]-68 #+48
if r < -5 then r = r + 12 end
sample :bd_boom, amp: 4*v, attack: 0.2, decay: 0.1,
sustain: 0, rpitch: r
sleep 1
r = r + 24
sample :bd_boom, amp: 4*v, attack: 0.2, decay: 0.1,
sustain: 0, rpitch: r
sleep 0.5
r = r - 12
sample :bd_boom, amp: 4*v, attack: 0.1, decay: 8,
sustain: 1.7*v, rpitch: r
sleep 0.5
end
}
end
end
end
end
# NOISE
with_fx :bitcrusher do
live_loop :noises do
sleep 24
sample sampleKit, "noise.wav", rate: [1,0.5,1.3,1.9].choose, amp: 2.5
sleep 8
sleep 32
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment