Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Created October 16, 2016 22:52
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/fe17a5fc6a0ebe68dfdf038dab61eed5 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/fe17a5fc6a0ebe68dfdf038dab61eed5 to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL 'shapeshifter' v13
# www.quasecinema.org
# 16-Out-2016
# Sonic Pi 2.11 dev
#delay = 1 # does arrangement
delay = 0 # full on
myBPM = 36
use_bpm myBPM
clock = 0
t = Time.new
set_volume! 0.6
################################################################
live_loop :metro1 do
with_bpm myBPM do
myBPM = 72 if (clock/4) < 23 #medium
myBPM = 36 if (clock/4) < 11 #slow
myBPM = 144 if (clock/4) > 23 #fast
clock = tick
puts "bpm: #{myBPM}, bar: #{clock/4}, beat: #{clock}"
x = (ring "1 |","2 | |","3 | | |","4 | | | |")[clock]
puts x
#puts "sec : #{t.sec}"
sleep 1
end
end #metro1
live_loop :metro2 do
with_bpm myBPM do
sleep 0.5
end
end #metro2
with_fx :compressor, threshold: 0.55, mix: 0.9,
slope_above: 0.66, slope_below: 1.18 do
################################################################
live_loop :hoover do
with_bpm myBPM do
sync :metro1
use_synth :hoover
if one_in(2)
play chord(:a5, :minor).choose,
release: [6,8,12,16].choose,
attack: 2, sustain: 2,
amp: rrand(0.2,0.24),
pan: rrand(-0.7,0.7), pan_slide: [2,4].choose
end #if
sleep 4
if one_in(2)
play chord(:c4, :m13).choose,
release: [6,8,12,16].choose, attack: 2, sustain: 2,
amp: rrand(0.2,0.22),
pan: rrand(-0.7,0.7), pan_slide: [2,4].choose
end #if
sleep [4,8,16,32].choose
end
end #hoover
################################################################
#delay start
sleep 4
################################################################
live_loop :beep2 do
with_bpm myBPM do
sync :metro1
use_synth :growl
with_fx :krush, phase: (ring 0.2,3,0.5,1)[clock/2],
mix: rrand(0.6,0.8) do
play (ring 51,51,39,63)[tick] - 32 + ((t.sec)),
attack: (ring 2,0.1,1,0.1)[clock/4],
release: [1,2,3,4,8,16].choose,
amp: (ring 1.66, 1)[clock/3] * rrand(1.1,1.4) - ((t.sec/60 * 2))
end #fx
sleep (ring 1,2,0.5,1,0.5)[clock/2] * 4
end
end #beep2
################################################################
sleep 16 if delay = 1 #delay start ?
################################################################
live_loop :ride1 do
with_bpm myBPM do
sync :metro1
with_fx :echo,
phase: (ring 1.5, 2, 3, 2)[clock/4], mix: 0.5, reps: 2 do
use_synth :noise
play 60, amp: 0.10, attack: 0.2,
release: rrand(1.0,1.3),
pan: rrand(-1,1), pan_slide: 0.25
sleep 3
use_synth :gnoise
play 60, amp: 0.2, attack: 0.1,
release: rrand(1.1,1.3),
pan: rrand(-1,1), pan_slide: 0.05
sleep 9.0 / 2
end #fx
end
end #ride
################################################################
sleep 16 if delay = 1 #delay start ?
################################################################
with_fx :slicer, phase: 0.25, mix: 0.5,
smooth_up: 0.1, smooth_down: 0.1 do
with_fx :slicer, phase: 0.5 do
with_fx :echo, phase: 0.14, mix: 0.8 do
live_loop :beep1 do
with_bpm myBPM do
sync :metro2
myScale = scale_names.choose
use_synth [:pulse,:growl,:beep,:growl,:prophet].choose
if one_in(2)
with_fx :echo, phase: (ring 0.2,3,0.5,1)[clock/3], reps: 2 do
with_fx :pitch_shift, pitch: [-8,-4,0,0,4,8].choose,
window_size: (rrand(0.001,0.05) + (t.sec/[1000,2000,600].choose)) do
x = (ring 51,51,39,63)[clock/2] + (t.sec/(ring 2,3,10)[tick])
play_pattern scale(x, myScale),
release: 0.1,
amp: (ring 1.333, 1)[clock/3] * 2.4
end #fx
end #fx
else
with_fx :echo, phase: (ring 0.2,3,0.5,1)[clock/3], reps: 2 do
x = (ring 51,51,39,63)[clock/2] + (t.sec/(ring 2,3,10)[tick])
play_pattern scale(x, myScale),
release: 0.1,
amp: (ring 1.6, 0.8)[clock/3] * 2
end #fx
end #if
sleep (ring 2,1,0.5)[clock/4] * 1
end #beep1
end
end
end
end
################################################################
sleep 16 if delay = 1 #delay start ?
################################################################
live_loop :kick do
with_bpm myBPM do
x = tick
sync :metro2
sample :bd_haus,
amp: (ring 0.2,0.8,0.2,1)[x] + 4
sample :bd_klub, amp: (ring 1.1,0.7,1.5,0.6)[x] + 7
sleep (ring 1,2,1,1, 1,1,1,1, 1,1,1,2, 1,1,1,1, 1,1,1,2, 1,1,1,1)[x/24]
end #myBPM
end #kick
################################################################
live_loop :bass do
sync :metro1
with_fx :slicer, phase: (ring 0.5,0.2,0.5,0.1)[tick/4] do
with_fx :bitcrusher, sample_rate: rrand(6000,40000) do
with_fx :normaliser, level: 4, mix: 0.7 do
with_fx :flanger,
phase: (ring 0.02,1,0.05,0.2,0.5,0.75)[tick/4] do
sample [:bass_thick_c, :bass_hit_c].choose,
finish: 0.2, rate: 1.0/[2,3].choose, amp: 2.8
end #fx
end #fx
end #fx
end #fx
sleep 3
end
################################################################
live_loop :ride2 do
with_bpm myBPM do
t = Time.new
with_fx :slicer, phase: 0.5 do
use_synth :prophet
play ( (t.sec/3) + 36 - rand_i(36)),
sustain: 4, release: 4, amp: rrand(1,6),
pan: rrand(-0.75,0.75), pan_slide: 0.15
end #fx
sleep (ring 3,3,6, 3,3,12)[clock/2] * 4.0
end #myBPM
end #bass
################################################################
live_loop :ride3 do
use_synth :cnoise
with_bpm myBPM do
play 60, release: 0.05,
amp: (ring 2,1.7,1.3,1.7)[tick] - 1.2,
pan: rrand(-0.75,0.75), pan_slide: 0.15
sleep (ring 3,3,6, 3,3,1.5)[clock/24] / 2.0
end #myBPM
end #ride 3
################################################################
end #compressor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment