Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active March 13, 2016 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexandreRangel/0744eec78194a36efa42 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/0744eec78194a36efa42 to your computer and use it in GitHub Desktop.
# Alexandre rANGEL
# "the book of changes" (v16)
# www.quasecinema.org
# 13-Mar-2016
# Sonic Pi 2.9
# video: https://www.youtube.com/watch?v=Fl-bDokHL5g
arrangement = true
mybpmbase = 240
mybpm = mybpmbase
use_bpm mybpm
startClock = 0 # 0 to start song at beginning
clock = startClock # global var
bar = 0 # global var
set_sched_ahead_time! 2
set_volume! 0.80
t = Time.new
x = ((t.year - t.month - t.day - t.hour - t.min - t.sec) / 1.0).to_int
puts "x = #{x}"
use_random_seed = x
# http://www.freesound.org/people/Jovica/sounds/86578/
# http://www.freesound.org/people/patchen/sounds/24670/
# download samples, rename to dirty80bpm.wav and madrid.wav
# and put it in your path, defined here:
use_sample_pack_as '/Users/rangel/pisamples', :mySamples
load_samples [:mySamples__dirty80bpm,:mySamples__madrid]
load_samples [:bd_fat,:bd_haus,:bd_pure]
################################################################
live_loop :metro do
mybpm = mybpmbase #* (ring 2,2,2,2,2,2,4,2)[tick/128]
mybpm = mybpmbase * 2 if 1 == (ring 0,0,0,0,0,1,1,0)[tick/192]
mybpm = mybpmbase / 32 if bar == 0
mybpm = mybpmbase / 16 if bar == 1
mybpm = mybpmbase / 8 if bar == 2
mybpm = mybpmbase / 2 if bar == 3 or bar == 4
mybpm = mybpmbase / 2 if bar % 63 == 0 or bar % 64 == 0
with_bpm mybpm do
cue :metro
sleep 0.5
clock = startClock + tick
bar = (clock / 4) + 1
puts "let's go!" if clock < 1
puts "bar : #{bar}, bpm: #{mybpm}"
puts ring( "1 !","2 ! !","3 ! ! !","4 ! ! ! !")[clock]
end #mybpm
end #metro
live_loop :metro2 do
with_bpm mybpm do
cue :metro2
sleep 0.5
end
end #metro2
#dirty intro##################################################
with_fx :echo, phase: 8, mix: 0.25, reps: 3 do
with_fx :echo, phase: 4, mix: 0.66 do
with_fx :lpf, cutoff: 75 do
sample :mySamples__dirty80bpm,
finish: (1.0 / 8.0), amp: 0.80
end #lpf
end #echo
end #echo
sleep ((sample_duration :mySamples__dirty80bpm) /8.0)
################################################################
live_loop :dirty do
with_bpm mybpm do
grid = 1.0 / [16.0,32.0,32.0,64.0,1024.0,2048.0].choose
x = grid*(rrand_i(0.0,grid).to_int)
if one_in(3) or one_in(5) or one_in(7) or one_in(9)
with_fx :lpf,
cutoff: rrand([[0,32,64].choose,72,96].choose,[102,110,120].choose),
cutoff_slide: 1.0/[8.0,4.0,2.0,1.0,0.5].choose do
with_fx :compressor, slope_below: 4.0, slope_above: 0.9, mix: 0.8 do
with_bpm 40 do
sample :mySamples__dirty80bpm, start: x, finish: x+grid,
rate: (ring 1,1,1,-1,1,1,1,-2)[tick/6]/(ring 4.0,2.0,2.0,1.0,1.0,1.0,1.0,0.5)[tick/6],
window_size: rrand(0.0001,0.0003), amp: rrand(2.0,3.6) * 1.2
sleep (sample_duration :mySamples__dirty80bpm)*grid *(ring 4,2,2,1,3,1,3,0.5)[tick/6]
end
end #compressor
end #lpf
else
sleep (sample_duration :mySamples__dirty80bpm)*grid *(ring 4,2,2,1,1,1,1,0.5)[tick/6]
end #if
end #bpm
end #dirty
################################################################
live_loop :madrid do
with_bpm mybpm do
with_fx :compressor, slope_below: 1.3, mix: 0.333 do
with_fx :slicer, phase: (ring 1,0.25)[tick/32],
mix: (ring 0,0.8,0,0.8)[tick/16] do
with_bpm 40 do
if one_in(4) or one_in(5) or one_in(6)
with_fx :echo, phase: (ring 0.5,1,2,0.25)[tick/2], reps: 2 do
grid = 1.0 / [16.0,32.0,32.0,64.0,128.0].choose
x = grid*(rrand_i(0.0,grid).to_int)
with_fx :pitch_shift, pitch: -16-[3,5,7].choose,
pitch_slide: 0.5,
window_size: rrand(0.0001,0.0005) do
with_fx :pitch_shift, pitch: -16-[3,5,7].choose,
pitch_slide: 0.5,
window_size: rrand(0.001,0.002) do
sample :mySamples__madrid, start: x, finish: x+grid,
rate: (ring 1,1,1,0.5,1,1,1,0.5)[tick/2]*(ring 4,2,2,1,1,1,1,0.5)[tick/2],
window_size: rrand(0.0001,0.0003),
pitch: [-48,-36,-24,-16].choose - [2,3,5,7].choose,
attack: 1, release: 2,
pan: rrand(-0.6,0.7), pan_slide: [0.25,0.5,1,2].choose,
amp: rrand(0.6,0.8)*rrand(1.0,1.11)
end #pitch_shift
end #pitch_shift
end #if
if one_in(2) or one_in(4) or one_in(6)
grid = 1.0 / [16.0,32.0,32.0,64.0,128.0].choose
x = grid*(rrand_i(0.0,grid).to_int)
with_fx :pitch_shift, pitch: -16-[3,5,7].choose,
pitch_slide: 0.5,
window_size: rrand(0.0001,0.001) do
with_fx :flanger, phase: (ring 0.5,1,2,0.25,4,8)[tick/5] do
sample :mySamples__madrid, start: x, finish: x+grid,
rate: (ring 1,1,1,0.5,1,1,1,0.5)[tick/2]*(ring 4,2,2,1,1,1,1,0.5)[tick/2],
window_size: rrand(0.0001,0.0003),
pitch: [-48,-36,-24,-16].choose - [2,3,5,7].choose - 16,
attack: 2, release: 1,
pan: rrand(-0.65,0.55), pan_slide: 1.0/[1,2,4,8].choose,
amp: rrand(0.6,0.8)*rrand(1.0,1.1)
end #flanger
end #pitch_shift
end #if
end
grid = 1.0 / [16.0,32.0,32.0,64.0,128.0].choose
x = grid*(rrand_i(0.0,grid).to_int)
sleep (sample_duration :mySamples__madrid)*grid *(ring 2,2,4,4,1,1,2,2)[tick/2] /4.0
end #echo
end #slicer
end #compressor
end #bpm
end #madrid
################################################################
sleep 0.5
################################################################
live_loop :kick do
if bar > 23
with_fx :lpf, cutoff: rrand(110,130), mix: 0.84 do
with_fx :distortion, distort: rrand(0.4,0.7), mix: 0.5 do
sample :bd_haus, amp: rrand(2,2.15) *0.666
end
with_fx :distortion, distort: rrand(0.6,0.8), mix: 0.5 do
sample :bd_pure, amp: rrand(1.6,2.0) *0.666
end
end
end #lpf
sleep 2
if bar > 15
with_fx :echo, phase: 1.0/(ring 6,2,4,2)[tick/2], reps: 2, mix: 0.66 do
with_fx :distortion, distort: rrand(0.6,0.8), mix: 0.7 do
sample :bd_fat, amp: rrand(0.8,0.9)
end #distortion
end #echo
end
sleep 2
end #kick
################################################################
sleep 0.5
################################################################
with_fx :flanger, phase: (ring 32,16,2,4)[tick/64],
wave: (ring 1,2,3,4)[tick/256],
mix: 0.4 do
live_loop :hat do
if bar > 47
if rand(100) > 12
8.times do
with_fx :lpf, cutoff: rrand([100,110].choose,117), mix: 0.80 do
use_synth (ring :cnoise,:pnoise,:pnoise,:pnoise)[tick]
play 60, attack: 0.05, release: 0.1, amp: rrand(0.5,0.6)
end #lpf
sleep 0.5
end #32times
end #if rand
if rand(100) > 75
with_fx :lpf, cutoff: rrand(90,110), mix: 0.80 do
16.times do
use_synth (ring :cnoise,:pnoise,:pnoise,:pnoise)[tick]
play 60, attack: 0.05, release: 0.1, amp: rrand(0.44,0.48)
sleep 0.25
end #32times
end #lpf
sleep 1
end #if rand
if rand(100) > 80
with_fx :lpf, cutoff: rrand(90,100),
cutoff_slide: [0.1,0.2].choose, mix: 0.80 do
32.times do
use_synth (ring :cnoise,:pnoise,:pnoise,:pnoise)[tick]
play 60, attack: 0.03, release: 0.075, amp: rrand(0.52,0.57)
sleep 1.0/4.0 #0.25
end #32times
end #lpf
end #if rand
end #if bar
sleep 0.5
if one_in(5)
with_fx :pitch_shift, pitch: rrand(1,16),
window_size: 0.01 do
with_fx :distortion, distort: 0.99, mix: 0.8 do
sample :drum_cymbal_closed, rate: rrand(0.98,1.02),
attack: 0.25, release: 0.25,
amp: 0.3
end
end
with_fx :pitch_shift, pitch: rrand(0,16),
window_size: 0.01 do
with_fx :distortion, distort: 0.99, mix: 0.8 do
sample :drum_cymbal_closed, rate: rrand(0.98,1.02),
attack: 0.25, release: 0.25,
amp: rrand(0.3,0.5) *0.444
end
end
sleep 1
end
if one_in(7)
with_fx :pitch_shift, pitch: rrand(-16,16),
window_size: 0.02 do
with_fx :distortion, distort: 0.66, mix: 0.5 do
sample :drum_cymbal_open,
start: rrand(0.2,0.4),
rate: rrand(0.6,1.0),
attack: 0.33, release: 0.77,
amp: rrand(0.3,0.5) *0.444
end
end
end
sleep 4.5
end #hat
end #flanger
################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment