Created
May 30, 2018 12:56
-
-
Save ktbaek/3ec2318e92fe553b337229246b9132fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use_bpm 110 | |
## define sounds | |
define :play_kick do |vol| | |
sample :bd_haus, amp: vol * 1.4, beat_stretch: 0.4 | |
end | |
define :play_tom do |vol| | |
with_fx :reverb, room: 0.7 do | |
sample :drum_tom_lo_soft, finish: 0.2, cutoff: 75, amp: vol | |
end | |
end | |
define :play_snare do |vol| | |
sample :drum_snare_soft, amp: vol | |
end | |
define :play_hats do |vol| | |
sample :drum_cymbal_closed, amp: vol * 0.6 | |
end | |
define :play_bass do |note, vol| | |
synth :saw, note: note, cutoff: 70, attack_level: 2, release: 0.3, res: 0.2, detune: 0.15, amp: vol * 0.4 | |
synth :dsaw, note: note, cutoff: 70, release: 0.3, detune: 0.15, res: 0, amp: vol * 0.4 | |
end | |
## functions | |
define :beats do |drum, trigger, at, vol| | |
## the function takes as parameters: | |
## drum = which instrument (drum) to use | |
## trigger = whether the index number or kick (on or off-beat) triggers the drum | |
## at = which indeces or kicks triggers the drum | |
## vol = volume | |
if at.include? trigger | |
send(drum, vol.call) | |
end | |
end | |
define :interval do |kick, swing_pct| | |
## defines interval time and adds swing | |
if (swing_pct < 50) | |
delay = 0 | |
else | |
delay = (swing_pct - 50) * 0.005 | |
end | |
if(kick % 2) == 0 | |
# off beats need to be slightly late for swing | |
sleep (0.25 - delay) | |
else | |
sleep (0.25 + delay) | |
end | |
end | |
## set volume categories (more human feel than using fixed volume settings) | |
ghost = -> { rrand(0.4, 0.6) } | |
normal = -> { rrand(0.8, 1.2) } | |
accent = -> { rrand(1.6, 1.8) } | |
## live loops | |
live_loop :drumbeat do | |
#drum sequencer | |
define :play_beat_bar1 do | |
[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4].each.with_index(1) do |kick, index| | |
beats(:play_kick, kick, at = [1], normal) | |
beats(:play_kick, kick, at = [4], ghost) if rand < 0.2 | |
beats(:play_hats, kick, at = [3], normal) | |
beats(:play_tom, index, at = [7], normal) | |
beats(:play_tom, index, at = [15], normal) if rand < 0.1 | |
beats(:play_snare, index, at = [5, 13], accent) | |
beats(:play_snare, index, at = [16], ghost) | |
beats(:play_hats, kick, at = [1,2,3,4], ghost) if rand < 0.4 | |
interval(kick, 60) | |
end | |
end | |
define :play_beat_bar2 do | |
#drum sequencer | |
[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4].each.with_index(1) do |kick, index| | |
beats(:play_kick, kick, at = [1], normal) | |
beats(:play_kick, kick, at = [4], ghost) if rand < 0.2 | |
beats(:play_hats, kick, at = [3], normal) | |
beats(:play_tom, index, at = [7], normal) | |
beats(:play_tom, index, at = [15], normal) if rand < 0.3 | |
beats(:play_snare, index, at = [5, 13], accent) | |
beats(:play_hats, kick, at = [1,2,3,4], ghost) if rand < 0.4 | |
interval(kick, 60) | |
end | |
end | |
with_fx :lpf, cutoff: 110 do | |
play_beat_bar1 | |
play_beat_bar2 | |
end | |
end | |
live_loop :bass, sync: :drumbeat do | |
tick | |
riff_1 = [:f2, :gs2, :c2] | |
riff_2 = [:d2, :f2, :a1] | |
32.times do | |
play_bass (knit riff_1.choose, 4, riff_2.choose, 4).look, ghost.call if (spread 6, 11, rotate: 3).tick (:spread) | |
sleep 0.25 | |
end | |
end | |
live_loop :zawa do | |
#stop | |
tick | |
sync :drumbeat | |
12.times do | |
synth :zawa, wave: 0, phase: 0.8, release: 4, amp: 0.06, note: (knit :f3, 4, :d3, 4).look, cutoff: (line 60, 120, steps: 6).look | |
sleep 0.5 | |
end | |
end | |
live_loop :piano, sync: :drumbeat do | |
tick | |
use_synth :piano | |
f = (scale :f, :mixolydian).pick(8) | |
d = (scale :d, :mixolydian).pick(8) | |
r1 = [[0.25, 0.5].choose, [0, 0.25, 0.5, 1].choose, [0.25, 0.5].choose] #sets the first three intervals randomly from the given options | |
r2 = r1 + [2 - r1.sum] #sets the last interval to add up to 2 beats | |
with_fx :reverb, room: 0.7, mix: 0.5 do | |
with_fx :lpf, cutoff: 80 do | |
play_pattern_timed (knit f, 16, d, 16).look, r2, release: 0.3, attack: 0.05, amp: normal.call | |
end | |
end | |
end | |
live_loop :piano_2, sync: :drumbeat do | |
tick | |
use_random_seed 102 | |
use_synth :piano | |
f = (scale :f, :mixolydian).pick(8) | |
d = (scale :d, :mixolydian).pick(8) | |
r1 = [[0.25, 0.5].choose, [0, 0.25, 0.5, 1].choose, [0, 0.25, 0.5].choose] | |
r2 = r1 + [2 - r1.sum] | |
with_fx :reverb, room: 0.7, mix: 0.5 do | |
with_fx :lpf, cutoff: 80 do | |
play_pattern_timed (knit f, 16, d, 16).look, r2, release: 0.3, attack: 0.05, amp: normal.call | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment