Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Created June 5, 2016 23:41
Show Gist options
  • Save AlexandreRangel/3839e31af4db4bb20d85f6dce16b4754 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/3839e31af4db4bb20d85f6dce16b4754 to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# www.quasecinema.org
# "glitter v19"
# 5 June 2016
# Sonic Pi 2.10
use_bpm 72
t = Time.new
myt = (t.year * t.month * t.day * t.hour * t.min * t.sec)
puts myt
use_random_seed myt
set_volume! 0.7
set_sched_ahead_time! 2
sample_woosh = '/Users/rangel/pisamples/woosh.wav' #http://www.freesound.org/people/alex@vsi.tv/sounds/170522/
load_samples [sample_woosh,:bd_klub,:bd_haus]
sample sample_woosh, amp: 2
sleep 3.0
with_fx :slicer, phase: 0.8, phase_offset: 0.0,
smooth_up: 0.05, smooth_down: 0.05, mix: 0.6 do
with_fx :normaliser, mix: 0.4444 do
with_fx :compressor, mix: 0.9,
slope_below: 1.777, slope_above: 0.4444,
clamp_time: 0.05, threshold: 0.7 do
with_fx :echo, phase: 1.0/3, mix: 0.333 do
live_loop :glitter1 do
with_fx :pitch_shift, pitch: [-1,-2].choose,
window_size: rrand(0.0001,0.1) do
with_fx [:flanger,:ixi_techno,:compressor].choose,
phase: [2,4,8].choose, mix: 0.333 do
#slow
slowfactor = rrand(1,5)
with_fx :whammy, transpose: -4, mix: 0.5 do
with_fx [:tanh,:wobble].choose, mix: rrand(0.01,0.333) do
with_fx :pitch_shift, pitch: rrand(-8,4),
window_size: rrand(0.0001,0.1) do
sample sample_woosh, rate: 1.0 / slowfactor,
attack: rrand(4.2,12.4), release: rrand(4.2,8.4),
pan: rrand(-0.66,0.66), pan_slide: [0.25,0.5,1,2,4,6].choose,
amp: 2.0*(slowfactor/2.8)
end
end
end
sleep (((sample_duration sample_woosh) * (slowfactor)) * (1.0/3)).to_f
#fast
if one_in(3)
slowfactor = rrand(5,20)
with_fx :whammy, transpose: 4, mix: 0.5 do
with_fx :panslicer, phase: [0.5,1,2,4].choose,
smooth: [1,2].choose, mix: 0.5 do
with_fx :octaver, mix: 0.5 do
with_fx [:krush,:tanh].choose, mix: rrand(0.01,0.333) do
with_fx :pitch_shift, pitch: rrand(-4,16),
window_size: rrand(0.0001,0.1) do
sample sample_woosh, rate: 1.0 / slowfactor * [-1,1].choose,
attack: rrand(4.2,8.4), release: rrand(4.2,8.4),
pan: rrand(-0.77,0.77), pan_slide: [0.25,0.5,1,2,4].choose,
amp: 2.0*(slowfactor/2.8)
end
end
end
end
end
end
sleep (((sample_duration sample_woosh) * (slowfactor)) * (1.0/3)).to_f
end
end
end
end
sleep 2
#
with_fx :echo, phase: 1.0/2, mix: 0.333 do
live_loop :glitter2 do
with_fx :rbpf, centre: rrand(80,110), centre_slide: 4,
res: rrand(0.3,0.6), mix: 0.333 do
#slow
slowfactor = rrand(1,6)
with_fx :pitch_shift, pitch: [1,2].choose,
window_size: rrand(0.0001,0.1) do
with_fx [:ixi_techno,:flanger,:compressor].choose,
phase: [2,4,8,16].choose, mix: 0.333 do
with_fx :whammy, transpose: -8, mix: 0.5 do
with_fx :tanh, mix: rrand(0.01,0.4444) do
with_fx :pitch_shift, pitch: rrand(-8,4),
window_size: rrand(0.0001,0.1) do
sample sample_woosh, rate: 1.0 / slowfactor,
attack: rrand(4.2,8.4), release: rrand(4.2,8.4),
pan: rrand(-0.7,0.7), pan_slide: [0.25,0.5,1,2,4,6].choose,
amp: 1.8*(slowfactor/2.4)
end
end
end
sleep (((sample_duration sample_woosh) * (slowfactor)) * (1.0/3)).to_f
#fast
if one_in(3)
slowfactor = rrand(6,21)
with_fx :whammy, transpose: 8, mix: 0.5 do
with_fx :panslicer, phase: [0.5,1,2,4].choose,
smooth: [1,2].choose, mix: 0.5 do
with_fx :octaver, mix: 0.5 do
with_fx :tanh, mix: rrand(0.01,0.4444) do
with_fx :pitch_shift, pitch: rrand(-4,16),
window_size: rrand(0.0001,0.1) do
sample sample_woosh, rate: 1.0 / slowfactor * [-1,1].choose,
attack: rrand(4.2,8.4), release: rrand(4.2,8.4),
pan: rrand(-0.7,0.7), pan_slide: [0.25,0.5,1,2,4].choose,
amp: 1.8*(slowfactor/2.4)
end
end
end
end
end
sleep (((sample_duration sample_woosh) * (slowfactor)) * (1.0/3)).to_f
end
end
end
end
end
end
end
end
end
sleep 20
sleep 0.8
k=0
live_loop :kick1 do
ampkick = 1.3
sample :bd_klub, amp: rrand(3.3,3.5) *ampkick
sleep 1
with_fx :pitch_shift, pitch: rrand([-4,-2].choose,[2,4].choose),
pitch_slide: [0.5,1].choose,
window_size: rrand(0.07,0.09),
mix: ring(0.1,0.1,0.1,0.88888888)[k] do
with_fx :echo, phase: ring(0.25,0.333,0.25,rrand(0.02,0.2))[k],
decay: ring(0.5,0.4,0.5,[1,2,3,4,8].choose)[k],
mix: ring(0.25,0.333,0.25,0.333)[k] do
sample :bd_haus, amp: 1.73 *ampkick
end
end
sleep 1
k=k+1
end
live_loop :melody do
with_bpm 15 do
with_fx :echo, phase: rrand(0.1,1) do
with_fx :flanger, phase: [0.1,0.2,0.5,1].choose do
use_synth :chipbass
play rrand(50,70), attack: 2, release: 0
sleep 1
use_synth :prophet
play rrand(52,72), attack: 2, release: 0
sleep 8 if one_in(6)
end
end
end
end
sleep 1
k2=0
live_loop :kick2 do
with_fx :echo, phase: 0.5,
mix: ring(0,0.5,0,0.5,0,1)[k2] do
with_fx :distortion, mix: rrand(0.4,0.6) do
sample :bd_fat, amp: rrand(5,7), rate: rrand(0.9,1.0)
end
end
sleep 2
end
sleep 0.2
h=0
live_loop :hat do
use_synth :cnoise
with_fx :echo, phase: 0.25 do
play ring(60,60,60,80)[h], attack: 0.1, release: rrand(0.001,0.08), amp: rrand(1.9,2.1) *0.8
end
sleep (ring 1.5,1.5,1.5,1)[(h/2).to_i]
h=h+1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment