Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active April 24, 2016 19:54
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/77c861bbcdb2c7299cff88cb61406e11 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/77c861bbcdb2c7299cff88cb61406e11 to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# www.quasecinema.org
# enoch v12
# 22 April 2016
# Sonic Pi 2.10
use_random_seed 3.14
x = 0
y = 0
d3= 0
use_bpm 48 #(96)
set_volume! 0.79
sample_metal = '/Users/rangel/pisamples/metal_box.wav'
#http://www.freesound.org/people/j1987/sounds/178836/
live_loop :metro do
clock = tick(:metro)
bar = clock / 4
puts "bar : #{bar}"
puts (ring "1 |","2 | |","3 | | |","4 | | | |")[clock]
sleep 1
end #metro
#######################################################
with_fx :compressor, slope_above: 0.8, slope_below: 1.333, mix: 0.7 do
#######################################################
live_loop :synth1 do
use_synth :beep
with_fx :whammy, mix: rrand(0.3,0.7) do
with_fx :slicer, phase: [1.0/3,0.25,0.1].choose, mix: 0.75 do
with_fx :echo, phase: 0.25, mix: 0.66 do
with_fx :bitcrusher, bits: [4,6,8,10,12].choose do
play_pattern [:f2,:c1,:f3], release: rrand(2,5),
amp: rrand(0.2,0.6), pan: 1, rate: 0.5,
mod_range: [12,24,36,48,64,128].choose
sleep [0.25,0.5,1,2].choose
end
end
end
end
sleep 2
sleep 100
end
#######################################################
live_loop :synth2 do
with_synth :dsaw do
with_fx :slicer, phase: [1.0/3,0.25,0.1,0.5,0.75,0.9].choose,
mix: rrand(0.75,1.0) do
with_fx :echo, phase: 0.25, mix: 0.66 do
with_fx :bitcrusher, bits: [4,6,8,10,12].choose do
play_pattern [:c2,:c1,:e2], release: rrand(2,5),
amp: rrand(0.10,0.16), pan: 1,
rate: [0.2,0.5,0.8].choose,
mod_range: [12,24,36,34].choose
sleep [0.25,0.5,1,2].choose
end
end
end
end
sleep 2
sleep 100
end
#######################################################
live_loop :synth3 do
sleep 3
with_synth :pulse do
with_fx :slicer, phase: [1.0/3,0.25,0.2,0.5,0.75,0.9].choose,
mix: rrand(0.75,1.0) do
with_fx :distortion, mix: 0.66 do
with_fx :bitcrusher, bits: [4,6,8,10,12].choose do
play_pattern [60+rrand_i(0,12),60+rrand_i(0,30),60+rrand_i(0,12)],
release: rrand_i(1.0,7.0), rate: 0.5,
amp: rrand(0.01,0.12), pan: 1,
mod_range: [3,4,6,12].choose
sleep [1,2,3,5,6,6,8].choose
end
end
end
end
sleep 2
sleep 100
end
#######################################################
m = 0
live_loop :metal do
m = m + (1.0/32)
with_fx :gverb, mix: rrand(0.1,0.5) do
with_fx :whammy, transpose: rrand(-16,16),
grainsize: rrand(0.01,0.1),
mix: rrand(0.01,0.477) do
with_fx :slicer, phase: [0.25/2,0.25,0.5,1,2].choose do
sample sample_metal,
amp: rrand(3,6),
pan: -1, start: rrand(0,0.99),
finish: rrand(0,0.99),
rate: rrand((ring 0.5,0.25,1)[m.to_int],1.5)*[-1,1].choose
sleep 1.0/2
sleep [0,0,0,0,2,2,2,4,4,8].choose
end
end
end
sleep 100
end
#######################################################
live_loop :drums1 do
with_fx :gverb, mix: rrand(0.16,0.18) do
sample :drum_bass_hard, amp: 1.3, pan: -1, rate: rrand(0.97,0.99)
sample :bd_fat, amp: rrand(0,0.5), pan: -1, rate: rrand(0.97,0.99)
end
sleep (ring 0.25,0.25,0.25,0.25,0.25,0.25,0.50) [x] * [2,2,4].choose
x = x + 1
sleep [2,4,8,0,0].choose
sleep 100
end
#######################################################
live_loop :drums2 do # hat
with_fx :echo, mix: rrand(0.3,0.65),
phase: 1.0/[1,2,3,4,5].choose do
sample :drum_cowbell,
amp: rrand(0.5,1.6), pan: -1, rate: rrand(6.47,9.53)
end
sleep (ring 0.25,0.25,0.25,0.25,0.25,0.25,0.50) [y]
y = y + 1
y = y + 1 if one_in(7)
sleep [4,2,0,0].choose
sleep 100
end
#######################################################
live_loop :drums3 do
d3 = d3 + (1.0/32)
sample :bass_trance_c,
amp: [0.4,0.5,0.6,0.7,0.8].choose,
pan: -1,
rate: rrand((ring 1.0,0.5)[d3.to_int],1.53)
sleep 1.0/2
sleep [0,0,2,4].choose
sleep 100
end
#######################################################
end #compressor
#######################################################
live_loop :drums4 do
with_fx :echo, delay: 0.125, mix: 0.2 do
with_fx :ixi_techno, phase: rrand(0.10,0.2),
res: rrand(0.1,0.7), mix: rrand(0.4,0.8) do
sample :drum_cymbal_pedal,
amp: 0.15, rate: rrand(0.35,0.70), pan: -1
end
sleep 1.0/4
end
sleep 4
sleep 100
end
#######################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment