Skip to content

Instantly share code, notes, and snippets.

@rap2hpoutre
Last active August 30, 2017 00:15
Show Gist options
  • Save rap2hpoutre/4f4de94024b4e5ce7c5b48c0f2c22e3d to your computer and use it in GitHub Desktop.
Save rap2hpoutre/4f4de94024b4e5ce7c5b48c0f2c22e3d to your computer and use it in GitHub Desktop.
Procedural drum loops
kicks = "D:/Sound/procedural/kicks"
snares = "D:/Sound/procedural/snares"
hh = "D:/Sound/procedural/hats/"
ohh = "D:/Sound/procedural/ohats/"
rides = "D:/Sound/procedural/rides/"
crashes = "D:/Sound/procedural/crashes/"
use_random_seed 401492
define :crash do
m = rand_i(61)
sample crashes, m
end
in_thread(name: :bass_snare) do
loop do
n = rand_i(464)
crash if one_in(15)
4.times do
sample kicks, n if rand > 0.005
sleep 0.25
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand > 0.2
sleep 0.25
sample kicks, n
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
sample kicks, n if rand < 0.02
sleep 0.125
end
n = rand_i(464)
crash if one_in(15)
4.times do
sample kicks, n if rand > 0.005
sleep 0.25
sample kicks, n if rand < 0.2
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
sample kicks, n if rand < 0.2
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
sample kicks, n if rand < 0.2
sleep 0.25
sample kicks, n if rand < 0.2
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
sample kicks, n if rand < 0.2
sleep 0.125
sample kicks, n if rand < 0.005
sleep 0.125
end
n = rand_i(464)
crash if one_in(15)
4.times do
sample kicks, n if rand > 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
sample kicks, n if rand < 0.05
sleep 0.125
end
end
end
in_thread(name: :hihat) do
loop do
# Sample selection
if one_in(7)
smp = rides
n = rand_i(62)
else
smp = hh
n = rand_i(299)
end
if one_in(4)
a = dice(10)
if a == 1
sleep 8
elsif a == 2
64.times do
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.125
end
elsif a == 3
32.times do
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.125
sample smp, n, amp: rrand(0.25, 0.55) if one_in(2)
sleep 0.125
end
elsif a == 4
16.times do
sleep 0.25
sample smp, n, amp: rrand(0.25, 0.55) if one_in(2)
sleep 0.25
end
elsif a == 5
32.times do
sample smp, n, amp: rrand(0.25, 0.55) if one_in(2)
sleep 0.125
sample smp, n, amp: rrand(0.25, 0.55) if one_in(3)
sleep 0.125
end
elsif a == 6
64.times do
sample smp, n, amp: rrand(0, 1)
sleep 0.125
end
elsif a == 7
m = rand_i(64)
32.times do
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.125
sample ohh, m, amp: rrand(0.25, 0.55) if one_in(5)
sleep 0.125
end
elsif a == 8
m = rand_i(64)
16.times do
sleep 0.25
sample ohh, m, amp: rrand(0.25, 0.55) if rand > 0.005
sleep 0.25
end
end
elsif a == 9 || a == 10
m = rand_i(64)
16.times do
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.125
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.125
sample ohh, m, amp: rrand(0.25, 0.55)
sleep 0.25
end
else
32.times do
sample smp, n, amp: rrand(0.25, 0.55)
sleep 0.25
end
end
end
end
in_thread(name: :snare) do
loop do
# Select sample
smp = snares
n = rand_i(464)
# Play riff
a = dice(4)
if a == 1
7.times do
standard_snare_pattern smp, n
end
random_snare_pattern smp, n
elsif a == 2
3.times do
archi_standard_snare_pattern smp, n
standard_snare_pattern smp, n
end
archi_standard_snare_pattern smp, n
random_snare_pattern smp, n
elsif a == 3
2.times do
3.times do
archi_standard_snare_pattern smp, n
end
standard_snare_pattern smp, n
end
elsif a == 4
2.times do
archi_standard_snare_pattern smp, n
standard_snare_pattern smp, n
toasted_snare_pattern smp, n
end
end
end
end
define :archi_standard_snare_pattern do |s, n|
sleep 0.5
sample s,n, sustain: 0.25, release: 0.125
sleep 0.5
end
define :standard_snare_pattern do |s, n|
sleep 0.25
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.05
sleep 0.25
sample s,n, sustain: 0.25, release: 0.125
sleep 0.25
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.1
sleep 0.125
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.1
sleep 0.125
end
define :toasted_snare_pattern do |s, n|
sleep 0.5
sample s,n, sustain: 0.25, release: 0.125
sleep 0.375
sample s,n, sustain: 0.25, amp: rrand(0.7, 1), release: 0.125 if rand < 0.5
sleep 0.25
sample s,n, sustain: 0.25, amp: rrand(0.7, 1), release: 0.125 if rand < 0.5
sleep 0.375
sample s,n, sustain: 0.25, release: 0.125
sleep 0.5
end
define :random_snare_pattern do |s, n|
2.times do
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.5
sleep 0.125
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.1
sleep 0.125
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.2
sleep 0.125
sample s,n, sustain: 0.25, release: 0.125 if rand < 0.1
sleep 0.125
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment