Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active January 10, 2016 00:35
Show Gist options
  • Save AlexandreRangel/5f40d501b0786096106e to your computer and use it in GitHub Desktop.
Save AlexandreRangel/5f40d501b0786096106e to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL / www.quasecinema.org
# they tried to capture the light - v11
# Sonic Pi 2.9 / 7-Jan-2016
set_sched_ahead_time! 4
use_random_seed 1
set_volume! 0.75
use_bpm 140
# download sample and change path below
# http://freesound.org/people/ivanbailey/sounds/41343/download/41343__ivanbailey__1234567.wav
load_sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav'
# use_synth :beep # countdown sync
# play 90, attack: 0, sustain: 1, release: 0, amp: 2
# sleep 2
# play 90, attack: 0, sustain: 1, release: 0, amp: 2
# sleep 2
# play 90, attack: 0, sustain: 1, release: 0, amp: 2
# sleep 4
live_loop :metro do
clock = tick
bar = clock / 4
puts "bar : #{bar}"
puts (ring "1 |","2 | |","3 | | |","4 | | | |")[clock]
sleep 1
end #metro
live_loop :track1 do #kick + cymbal
with_fx :distortion, distort: rrand(0.5,0.6) *0.85 do
with_fx :flanger, phase: rrand(0.09,0.1) do
sample :bd_haus, amp: 2, rate: rrand(0.98,1.0)
sample :bd_klub, amp: 1, rate: rrand(0.98,1.0)
sleep 1
sample :bd_tek, amp: 2, rate: rrand(0.92,0.94)
with_fx :echo, phase: rrand(0.01,0.04),
reps: 2, mix: rrand(0.1,0.3) do
sample :drum_cymbal_pedal, amp: rrand(2.2,2.6),
rate: rrand(1.8,2.2) if (rand(100) < 90)
end #fx
sleep 1
sample :bd_haus, amp: 2, rate: rrand(0.92,0.96)
sample :bd_klub, amp: 1, rate: rrand(0.98,1.0)
sleep 1
if one_in(13)
sample :bd_haus, amp: 1, rate: rrand(-0.98,-1.0)
sample :bd_tek, amp: 1, rate: rrand(0.98,1.0)
else
sample :bd_haus, amp: 2, rate: rrand(0.98,1.0)
sample :drum_cymbal_pedal, amp: rrand(2,2.4), rate: rrand(0.98,1.0)
end
end
end
sleep 1
sleep [8,12].choose if one_in(32)
end
live_loop :track7 do #randomSamples2-3
with_fx :slicer, phase: (ring 0.5,1,0.5,4,0.01,1,0.01,2,4)[tick/8],
phase_slide: (ring 0.1,0.5,1,0.5,0.2,0.5,0.01,0.5)[tick/2] do
with_fx :pitch_shift, pitch: ([-24,-12,-12,0,0,0,0,8,12,12,16].choose)+8,
window_size: rrand(0.001,0.1), time_dis: (rrand(0.01,0.2)) do
with_fx :distortion, distort: rrand(0.5,0.8), mix: rrand(0.5,0.66) do
with_fx :flanger, phase: [0.5,1,2,4,8].choose, delay: [0.5,1,2,4,8].choose,
mix: rrand(0.5,0.9) do
with_fx :echo, phase: [1,2,4,4,4,8,8,16].choose, reps: [1,2,3].choose,
mix: rrand(0.4,0.99) do
with_fx :compressor, pre_amp: (rrand(0.3,1.8) * 2.6),
threshold: 0.4, slope_above: 0.266, relax_time: 2 do
sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav',
start: rrand(0.025,0.086), pitch: ([-12,-8,-4,-2,0,2,4,8,12].choose)+12,
window_size: rrand(0.01,0.1), amp: rrand(0.9,1.1) * 2.7, norm: [0].choose,
pan: rrand(-0.7,0.6), pan_slide: [1,1,1,1,2,2,2,4,8].choose,
beat_stretch: [32,32,64,128,32].choose,
attack: [2,4,4,8,8,16,16].choose
end
end
end
end
end
end
with_fx :slicer, phase: (ring 2,1,0.5,4,0.01,1,0.01,0.5)[tick/10],
phase_slide: (ring 0.1,0.5,1,0.5,0.2,0.5,0.01,0.5)[tick/2] do
with_fx :pitch_shift, pitch: [-24,-12,-12,0,0,0,0,8,12,12,16,24].choose,
window_size: rrand(0.001,0.2), time_dis: (rrand(0.01,0.1) / 2) do
with_fx :distortion, distort: rrand(0.3,0.666), mix: rrand(0.5,0.9) do
with_fx :echo, phase: [1,2,4,4,4,8,8,16].choose, reps: [1,2,3].choose,
mix: rrand(0.4,0.99) do
with_fx :compressor, pre_amp: (rrand(0.5,1.8) * 1.8),
threshold: 0.4, slope_above: 0.266, relax_time: 2 do
sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav',
start: rrand(0.025,0.086), pitch: [-12,-8,-4,-2,0,2,4,8,12].choose,
window_size: rrand(0.01,0.2), amp: rrand(0.9,1.1) * 3.3, norm: [0].choose,
pan: rrand(-0.8,0.7), pan_slide: [1,2,4,8,16].choose,
beat_stretch: [32,32,32,64,128].choose,
attack: [2,4,4,8,8,16,16,32].choose
end
end
end
end
end
sleep ([16,24,32,8].choose) /2
sleep 16 if one_in(4)
end
sleep 12
live_loop :track2 do #hat
use_synth :pnoise
play [:C6,:C4,:C3].choose, attack: 0.01, sustain: rrand(0.096,0.14), release: 0.01,
amp: rrand(0.85,0.9) * rrand(2.7,3.2) * 0.75,
pan: rrand(0,0.075), pan_slide: rrand(0.01,0.05)
sleep 0.5
sleep [3,6,9,12,16].choose if one_in([48,64,128,256].choose)
end
live_loop :track5 do #pulse
use_synth [:pulse,:growl,:piano].choose
with_fx :compressor,slope_above: 0.266 do
with_fx :echo, mix: [0,0.25,0.5,0.66].choose do
with_fx :pitch_shift, pitch: [-12,-8,-4,0,4,8,12].choose,
window_size: [0.01,0.01,0.015,0.02,025,0.03,0.0333,0.04,1.0/3,0.05,0.075,0.1].choose do
with_fx :echo, mix: [0,0.5,1.0].choose do
play [:C6, :C4].choose, attack: [0.01,0.05,0.075].choose, sustain: 0.1,
release: 0.01, amp: rrand(0.3,0.8) *2.2
end
end
end
end
sleep 0.5
sleep 3 if one_in([36,48,64,128,256].choose)
end
sleep 12
live_loop :track6 do #randomSample1-Bell
with_fx :distortion, distort: rrand(0.3,0.6), mix: rrand(0.6,0.8) do
with_fx :echo, phase: 4, opt: 2, mix: 0.4 do
with_fx :compressor, pre_amp: rrand(1.8,1.9) * 1.5 do
sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav',
start: rrand(0.075,0.076), pitch: [-4,-2,0,2,4].choose,
window_size: rrand(0.01,0.05), amp: rrand(1,2) if rand(100)>30
sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav',
start: rrand(0.069,0.07), pitch: [-4,-2,0,2,4].choose,
window_size: rrand(0.01,0.05), amp: rrand(1,1.9) if rand(101)>30
sample '/Users/rangel/pisamples/41343__ivanbailey__1234567.wav',
start: rrand(0.064,0.065), pitch: [-36,-24,-12].choose,
window_size: rrand(0.01,0.05), amp: rrand(2.0,2.5) if rand(102)>30
end
end
end
sleep 8
sleep 16 if one_in(3)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment