Skip to content

Instantly share code, notes, and snippets.

@klahrich
Last active April 10, 2017 02:50
Show Gist options
  • Save klahrich/5da6bc2a6b4ea0dd67bd9bff3e85a3ca to your computer and use it in GitHub Desktop.
Save klahrich/5da6bc2a6b4ea0dd67bd9bff3e85a3ca to your computer and use it in GitHub Desktop.
#orientalmati
use_bpm 50
k = 0
#main loop beat duration, in seconds
m = 2
live_loop :main do
sleep m
k = k + 1
end
#######################
### basic drum kick ###
#######################
loop0 = Hash.new(){}
loop0[:alive] = lambda {k >= 4}
loop0[:beats] = lambda {4}
loop0[:amp] = lambda {k==15 ? 0 : 1}
live_loop :loop0 do
sync :main
if loop0[:alive].call()
with_fx :distortion do
loop0[:beats].call().times do
sample :drum_heavy_kick, amp: loop0[:amp]
sleep m/loop0[:beats].call().to_f
end
end
end
end
########################
### cymbal with echo ###
########################
loop0b = Hash.new(){}
loop0b[:alive] = lambda {k >= 4 && k <8}
live_loop :loop0b do
sync :main
if loop0b[:alive].call()
with_fx :krush do
with_fx :echo, phase:0.125 do
2.times do
sample :drum_cymbal_hard, rate:4, amp:0.5
sleep m/2.0
end
end
end
end
end
########################
### The main theme ###
########################
loop1 = Hash.new{}
loop1[:active] = lambda {k < 16}
loop1[:instr] = lambda {k < 8 ? :prophet : :piano}
loop1[:notes1a] = [:C3, :rest, :rest, :Ds3,
:rest, :rest, :C3, :rest,
:rest, :Ds3, :rest, :rest,
:C3, :rest, :C3, :rest]*2
loop1[:notes2a] = [:C3, :rest, :rest, :F3,
:rest, :rest, :C3, :rest,
:rest, :F3, :rest, :rest,
:C3, :rest, :C3, :rest]*2
loop1[:notesa] = (loop1[:notes1a] + loop1[:notes2a]).ring
loop1[:notes1b] = [:C4, :rest, :rest, :Ds4,
:rest, :rest, :C4, :rest,
:rest, :Ds4, :rest, :rest,
:C4, :rest, :C4, :rest]*2
loop1[:notes2b] = [:C4, :rest, :rest, :F4,
:rest, :rest, :C4, :rest,
:rest, :F4, :rest, :rest,
:C4, :rest, :C4, :rest]*2
loop1[:notesb] = (loop1[:notes1b] + loop1[:notes2b]).ring
loop1[:notes] = lambda {k < 8 ? loop1[:notesa] : loop1[:notesb]}
loop1[:cutoff] =
lambda{
k < 4 ? 70 : (k < 8 ? 80 : 90)
}
#over how many beats do we want this loop to run
loop1[:beats] = 4
loop1[:amp] = lambda {k==15 ? 0 : 1}
live_loop :loop1 do
sync :main
if loop1[:active].call()
with_fx :echo, phase:0.25, mix:0.5 do
loop1[:notes].call().length.times do
synth loop1[:instr].call(), note: loop1[:notes].call().tick, cutoff:loop1[:cutoff].call(),
amp: loop1[:amp].call()
sleep (m * loop1[:beats])/loop1[:notes].call().length.to_f
end
end
end
end
###############################
### Closed rythmic cymbal ###
###############################
loop2 = Hash.new{}
loop2[:instr] = :drum_cymbal_closed
loop2[:notes] = ([120, 100]*8).ring
loop2[:beats] = 1
loop2[:alive] = lambda { k >= 8 }
live_loop :loop2 do
sync :main
if loop2[:alive].call()
loop2[:notes].length.times do
sample loop2[:instr], cutoff: loop2[:notes].tick, amp:[0.75,1].choose
sleep (m * loop2[:beats])/loop2[:notes].length.to_f
end
end
end
##################################
### Strong/heavy pulse (bass) ###
##################################
loop3 = Hash.new(){}
loop3[:hits] = ([true, false, false, true,
false, false, true, false,
true, false, false, true,
false, false, false, false]).ring
loop3[:instr] = :bass_voxy_hit_c
loop3[:rate] = ([1]*32 + [1.25]*32).ring
loop3[:alive] = lambda { k >= 4 }
loop3[:beats] = 1
loop3[:fx] = lambda {k < 8 ? :gverb : :reverb}
live_loop :loop3 do
sync :main
if loop3[:alive].call()
with_fx loop3[:fx].call() do
loop3[:hits].length.times do
sample loop3[:instr] if loop3[:hits].tick
sleep (m * loop3[:beats])/loop3[:hits].length.to_f
end
end
end
end
#####################
### Lunar landing ###
#####################
loop4 = Hash.new(){}
loop4[:alive] = lambda {k >= 8}
live_loop :loop4 do
sync :main
if loop4[:alive].call()
with_fx :echo do
sleep 2 * m
sample :ambi_lunar_land, rate:6, attack:1, sustain:4, amp:1
sleep 2 * m
end
end
end
####################
### Crash cymbal ###
####################
loop5 = Hash.new(){}
loop5[:alive] = lambda {k >= 8}
live_loop :loop5 do
sync :main
if loop5[:alive].call()
with_fx :echo, phase:0.125, mix:0.5 do
sample :drum_splash_hard , rate:0.5, release:2, amp:0.25
sleep 4*m
end
end
end
#####################################
### Wooden (snare) sound, rythmic ###
#####################################
loop6 = Hash.new(){}
loop6[:alive] = lambda {k >= 8}
loop6[:hits] = ([false, false, false, true,
false, false, true, false,
false, true, false, true,
false, false, true, false]).ring
loop6[:beats] = 1
live_loop :loop6 do
sync :main
if loop6[:alive].call()
with_fx :krush, mix:0.25 do
loop6[:hits].length.times do
sample :perc_snap, rate:0.5, amp:0.85, cutoff:110 if loop6[:hits].tick
sleep (m * loop6[:beats])/loop6[:hits].length.to_f
end
end
end
end
##########################
### The second melody ###
##########################
loop7 = Hash.new(){}
loop7[:alive] = lambda {k >= 8 && k!=15 && k < 24}
loop7[:notes1] = ([:C3, :rest, :rest, :rest,
:rest, :rest, :G2, :rest,
:C3, :rest, :Ds3, :rest,
:C3, :rest, :G2, :rest])*2
loop7[:notes2] = ([:D3, :rest, :rest, :rest,
:rest, :rest, :G2, :rest,
:D3, :rest, :Ds3, :rest,
:D3, :rest, :G2, :rest] +
[:D3, :rest, :rest, :rest,
:rest, :rest, :G2, :rest,
:D3, :rest, :F3, :rest,
:Ds3, :rest, :D3, :rest])
loop7[:notes] = (loop7[:notes1] + loop7[:notes2]).ring
loop7[:beats] = 4
loop7[:instr] = :prophet
loop7[:amp] = lambda {k==15 ? 0 : 0.5}
live_loop :loop7 do
sync :main
if loop7[:alive].call()
#with_fx :slicer, phase:0.5, wave:2 do
#with_fx :ixi_techno, phase:2, mix:0.5 do
loop7[:notes].length.times do
synth loop7[:instr], note: loop7[:notes].tick, amp: loop7[:amp].call(), cutoff:80
sleep (m * loop7[:beats])/loop7[:notes].length.to_f
end
#end
#end
end
end
#########################
### The third melody ###
#########################
loop8 = Hash.new(){}
loop8[:alive] = lambda {k >= 16 && k < 24}
loop8[:notes] = [:G4, :rest, :rest, :C4,
:rest, :rest, :G4, :rest,
:rest, :rest, :rest, :rest,
:rest, :rest, :rest, :rest,
:G4, :rest, :rest, :C4,
:rest, :rest, :G4, :rest,
:rest, :rest, :G4, :rest,
:Gs4, :rest, :G4, :rest,
:F4, :rest, :rest, :C4,
:rest, :rest, :F4, :rest,
:rest, :rest, :rest, :rest,
:rest, :rest, :rest, :rest,
:F4, :rest, :rest, :C4,
:rest, :rest, :F4, :rest,
:rest, :rest, :F4, :rest,
:G4, :rest, :Gs4, :rest].ring
loop8[:beats] = 4
loop8[:instr] = :prophet
live_loop :loop8 do
sync :main
if loop8[:alive].call()
with_fx :echo, phase:0.5, mix:0.25 do
with_fx :slicer, phase:0.125, mix:0.25 do
with_fx :gverb do
loop8[:notes].length.times do
synth loop8[:instr], note: loop8[:notes].tick, amp:0.4, cutof:70
sleep (m * loop8[:beats])/loop8[:notes].length.to_f
end
end
end
end
end
end
##############################
### Third melody - support ###
##############################
loop8b = Hash.new(){}
loop8b[:alive] = lambda {k >= 16 && k < 24}
loop8b[:notes] = [:C2, :rest, :C2, :rest,
:rest, :rest, :G2, :rest,
:rest, :rest, :rest, :rest,
:rest, :rest, :G1, :rest,
:C2, :rest, :C2, :rest,
:rest, :rest, :G2, :rest,
:rest, :rest, :rest, :rest,
:Ds2, :rest, :rest, :rest,
:Gs2, :rest, :Gs2, :rest,
:rest, :rest, :F2, :rest,
:rest, :rest, :rest, :rest,
:rest, :rest, :F1, :rest,
:C2, :rest, :C2, :rest,
:rest, :rest, :F2, :rest,
:rest, :rest, :rest, :rest,
:D2, :rest, :rest, :rest].ring
loop8b[:beats] = 4
loop8b[:instr] = :piano
live_loop :loop8b do
sync :main
if loop8b[:alive].call()
#with_fx :echo, phase:0.5, mix:0.25 do
with_fx :flanger, phase:0.125, mix:0.75 do
with_fx :reverb, mix:0.25 do
loop8b[:notes].length.times do
synth loop8b[:instr], note: loop8b[:notes].tick, amp:0.75, cutof:100
sleep (m * loop8b[:beats])/loop8b[:notes].length.to_f
end
end
end
#end
end
end
#############################
### Rythmic echoed snare ###
#############################
loop9 = Hash.new(){}
loop9[:alive] = lambda {k >= 16 && k < 24}
loop9[:hits] = ([true, false, false, true,
false, false, true, false,
true, false, false, true,
true, false, false, false]).ring
loop9[:beats] = 1
live_loop :loop9 do
sync :main
if loop9[:alive].call()
with_fx :echo, mix:0.5, phase:0.25 do
with_fx :krush, mix:0.10 do
loop9[:hits].length.times do
sample :drum_snare_hard, amp:0.4, cutoff:[110,120].choose if loop9[:hits].tick
sleep (m * loop9[:beats])/loop9[:hits].length.to_f
end
end
end
end
end
########################
### Drum transition ###
########################
loop10 = Hash.new(){}
loop10[:alive] = lambda {k==15}
loop10[:hits] = ([true, false, false, true,
false, false, true, false,
true, false, false, true,
true, false, true, true]).ring
loop10[:beats] = 1
live_loop :loop10 do
sync :main
if loop10[:alive].call()
with_fx :echo, mix:0.25, phase:0.5 do
with_fx :krush, mix:0.5 do
loop10[:hits].length.times do
sample :drum_snare_hard, rate:0.9, amp:1 if loop10[:hits].tick
sleep (m * loop10[:beats])/loop10[:hits].length.to_f
end
end
end
end
end
########################
### Transition woosh ###
########################
loop14 = Hash.new(){}
live_loop :loop14 do
sync :main
if k == 23
with_fx :krush, gain:2 do
sample :ambi_dark_woosh, rate:1, amp:1.5
sleep m
end
end
end
#############################
### Part 2 - beat (kick) ###
#############################
loop11 = Hash.new(){}
loop11[:alive] = lambda {k >= 24}
loop11[:hits] = ([false, false, false, true,
false, false, true, false,
false, true, false, true,
false, false, true, false]).ring
loop11[:beats] = 1
live_loop :loop11 do
sync :main
if loop11[:alive].call()
with_fx :echo, mix:0.125, phase:0.125 do
loop11[:hits].length.times do
sample :perc_snap, rate:0.5, amp:0.85, cutoff:110 if loop11[:hits].tick
sleep (m * loop11[:beats])/loop11[:hits].length.to_f
end
end
end
end
##############################
### Part 2 - beat (snare) ###
##############################
loop12 = Hash.new(){}
loop12[:alive] = lambda {k >= 24}
loop12[:hits] = ([true, false, false, true,
true, false, true, false,
true, true, false, true,
true, false, true, false]).ring
loop12[:beats] = 1
live_loop :loop12 do
sync :main
if loop12[:alive].call()
loop12[:hits].length.times do
sample :drum_heavy_kick, rate:1, amp:0.85, cutoff: [95, 80].choose if loop12[:hits].tick
sleep (m * loop12[:beats])/loop12[:hits].length.to_f
end
end
end
##################################
### Part 2 - background notes ###
##################################
loop13 = Hash.new(){}
loop13[:alive] = lambda {k >= 26}
loop13[:notes1] = ([:rest, :rest, :C5, :rest,
:rest, :C5, :rest, :rest,
:C5, :rest, :C5, :rest,
:C5, :rest, :rest, :rest])*4
loop13[:notes2] = ([:rest, :rest, :D5, :rest,
:rest, :D5, :rest, :D5,
:rest, :D5, :rest, :D5,
:rest, :D5, :rest, :D5])*4
loop13[:notes] = (loop13[:notes1] + loop13[:notes2]).ring
loop13[:beats] = 4
loop13[:instr] = :prophet
loop13[:amp] = lambda {k==15 ? 0 : 0.5}
live_loop :loop13 do
sync :main
if loop13[:alive].call()
with_fx :slicer, phase:0.125, wave:0 do
with_fx :echo, phase:0.25, mix:0.5 do |e|
loop13[:notes].length.times do |i|
if i % 32 == 7 || i % 32 == 8 || i % 32 == 16 || i % 32 == 17 || i % 32 == 20 || i % 32 == 21 || i % 32 >= 31
control e, amp:0
else
control e, amp:0.75
end
synth loop13[:instr], note: loop13[:notes].tick, amp: loop13[:amp].call(), cutoff:[70, 80, 90].choose
sleep (m * loop13[:beats])/loop13[:notes].length.to_f
end
end
end
end
end
###############################
### Part 2 - closed cymbal ###
###############################
loop15 = Hash.new(){}
loop15[:alive] = lambda {k >= 26}
loop15[:hits] = ([false, true, true, false,
true, false, true, false,
true, true, false, true,
true, false, true, true]).ring
loop15[:beats] = 1
live_loop :loop15 do
sync :main
if loop15[:alive].call()
loop15[:hits].length.times do
sample :drum_cymbal_closed, rate:[0.75, 1].choose, amp:0.85 if loop15[:hits].tick
sleep (m * loop15[:beats])/loop15[:hits].length.to_f
end
end
end
########################
### Part 2 - Djembe ###
########################
djembe = "C:/Users/karim/Documents/Sonic PI/wav/djembe"
use_random_seed(3)
loop16 = Hash.new(){}
loop16[:alive] = lambda {k >= 30 && k != 33}
loop16[:beats] = 1
live_loop :loop16 do
sync :main
if loop16[:alive].call()
with_fx :echo, mix:0.1, phase:0.5 do
16.times do
sample djembe, [0,1,2,3,4,8,9].choose, amp:[12,12,12,8,15].choose if [true,true,true,false,false].choose
sleep 0.125
end
end
end
end
#####################################
### Part 2 - Djembe - Transition ###
#####################################
loop16b = Hash.new(){}
loop16b[:alive] = lambda {k == 33}
loop16b[:beats] = 1
live_loop :loop16b do
sync :main
if loop16b[:alive].call()
use_random_seed(16)
num_hits = 8
hits = ring(true, true, true, true,
true, false, true, true,
false, true, true, false,
false, true, true, false)
notes = ring(4,3,8,3,
3,0,4,3,
0,4,3,0,
0,3,3,0)
with_fx :reverb do |fx|
16.times do
hit = hits.tick
note = notes.look
sample djembe, note, amp:18 if hit
sleep 0.125
end
end
end
end
##################################
### Part 2 - Oud - Transition ###
##################################
oud = "C:/Users/karim/Documents/Sonic PI/wav/oud"
loop17a = Hash.new(){}
loop17a[:alive] = lambda {k == 33}
loop17a[:beats] = 1
live_loop :loop17a do
sync :main
if loop17a[:alive].call()
use_random_seed(16)
num_hits = 8
hits = rand_bool_ring(16, num_hits)
notes = rand_ring([1,2,3], 16)
with_fx :ixi_techno, phase:4 do |fx|
16.times do |i|
hit = hits.tick
note = notes.look
sample oud, note, amp:2, rate:1 if hit
sleep 0.125
end
end
end
end
#####################
### Part 2 - Oud ###
#####################
loop17 = Hash.new(){}
loop17[:alive] = lambda {k >= 34}
loop17[:beats] = 1
live_loop :loop17 do
sync :main
if loop17[:alive].call()
64.times do |i|
use_random_seed(6 +(i/4)*2)
num_hits = rrand_i(8,10)
2.times do
hits = rand_bool_ring(16, num_hits)
notes = rand_ring([0,1,2,3,4], 16)
2.times do
16.times do
hit = hits.tick
note = notes.look
sample oud, note, amp:3, rate:1 if hit
sleep 0.125
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment