Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active January 4, 2016 05:10
Show Gist options
  • Save AlexandreRangel/0fcc99eeb7b71c475a5f to your computer and use it in GitHub Desktop.
Save AlexandreRangel/0fcc99eeb7b71c475a5f to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL / www.quasecinema.org
# they tried to capture the light - v03
# Sonic Pi 2.9 / 4-Jan-2016
set_volume! 0.5
use_bpm 120
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 :audio do
with_fx :compressor, amp: 1.5 do
with_fx :pitch_shift, pitch: [-8,-4,4,8,12].choose, window_size: rrand(0.001,0.1) do
with_fx :slicer, phase: (ring 0.25, 0.15, 0.25, 1.0/3)[tick] do
with_fx :compressor do
with_fx :distortion, distort: rrand(0.2,0.8) do
with_fx :flanger, phase: [0.1,0.25,1.0/3,0.5,1,2,4,8].choose do
with_fx :bitcrusher, bits: rrand_i(4,16) do
with_fx :echo, phase: [2,2,2,2,4,4,4,8,16,32].choose do
with_fx :echo, phase: [0.1,0.2,0.5,1,2].choose, mix: rrand(0.2,0.8) do
synth :sound_in, attack: 2, sustain: 0, release: 2, amp: 0.1
end
end
end
end
end
end
end
end
end
sleep 4
end
live_loop :kick do
sample :bd_haus, amp: 2, rate: rrand(0.98,1.0)
sleep 1
sample :bd_haus, amp: 2, rate: rrand(0.92,0.94)
sleep 1
sample :bd_haus, amp: 2, rate: rrand(0.92,0.96)
sleep 1
if one_in(6)
sample :bd_haus, amp: 2, rate: rrand(-0.98,-1.0)
else
sample :bd_haus, amp: 2, rate: rrand(0.98,1.0)
end
sleep 1
end
live_loop :hat do
use_synth :pnoise
play [:C6, :C4].choose, attack: 0.01, sustain: 0.1, release: 0.01, amp: 0.7
use_synth :pulse
with_fx :echo, mix: [0,0.25,0.5,1.0].choose do
with_fx :pitch_shift, pitch: [-12,-8,-4,0,4,8,12].choose,
window_size: [0.01,0.01,0.25,1.0/3,0.05,0.75,0.1].choose do
with_fx :echo, mix: [0,0.5,1.0].choose do
play [:C6, :C4].choose, attack: 0.01, sustain: 0.1, release: 0.01,
amp: rrand(0.3,0.92)
end
end
end
sleep 0.5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment