Skip to content

Instantly share code, notes, and snippets.

@OttoNL
Last active July 14, 2017 14:23
Show Gist options
  • Save OttoNL/5509fa43c9fdc39a3415686db41cfc1e to your computer and use it in GitHub Desktop.
Save OttoNL/5509fa43c9fdc39a3415686db41cfc1e to your computer and use it in GitHub Desktop.
#
# Synth Based Drum Machine by Otto van Zanten
#
use_bpm 93
# 8th notes # 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
kick_rhythm = [1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0]
snare_rhythm = [0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0]
hh_rhythm = [1,0,1,0,1,0,1,1,0,1,1,0,1,0,2,0,1,0,1,0,1,0,1,1,0,1,2,0,1,0,2,0]
# Here you can cue the channels you want to play and program a song structure if you want.
in_thread do
4.times do
cue :kick
cue :snare
cue :hihat
sleep 8
end
end
# Here you can tweak the drum sounds.
def kick
with_fx :reverb, mix: 0.2 do
use_synth :mod_sine
play 30, amp: 4, attack: rt(0.0003), decay: rt(0.0571), sustain_level: 0.54, release: rt(0.1429), mod_wave: 1, mod_pulse_width: 0.275, mod_phase: rt(0.1429)
end
end
def snare
with_fx :reverb, mix: 0.125 do
use_synth :mod_sine
play 30, amp: 0.5, attack: rt(0.0006), release: rt(0.1143), mod_wave: 1, mod_phase: rt(0.1429)
use_synth :noise
play 60, amp: 2, attack: rt(0.0029), decay: rt(0.0286), sustain_level: 0.6, release: rt(0.0286), cutoff: 107
end
end
def hhc
with_fx :hpf, cutoff: 105, mix: 0.6 do
use_synth :noise
play 50, amp: 0.5, attack: rt(0.0029), decay: rt(0.0114), sustain_level: 0.3, release: rt(0.0126), amp: 0.6, cutoff: 130
end
end
def hho
with_fx :hpf, pre_mix: 0.7, cutoff: 100, mix: 0.9 do
use_synth :noise
play 50, amp: 0.6, attack: rt(0.0057), decay: rt(0.1429), sustain_level: 0.58, release: rt(0.1714), cutoff: 126
end
end
# And the code below checks for 1's and 0's at the top of the document and actually triggers the sounds
# The hihat one also checks for 2's, so it has 3 options. 1 is closed hihat, 2 is open hihat.
in_thread do
loop do
sync :kick
for i in kick_rhythm
if i == 1
kick
end
sleep 0.25
end
end
end
in_thread do
loop do
sync :snare
for i in snare_rhythm
if i == 1
snare
end
sleep 0.25
end
end
end
in_thread do
loop do
sync :hihat
for i in hh_rhythm
if i == 1
hhc
elsif i == 2
hho
end
sleep 0.25
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment