Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlexandreRangel/9623c376bfed39144e9c to your computer and use it in GitHub Desktop.
Save AlexandreRangel/9623c376bfed39144e9c to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# things do not exist independent of causation v06
# www.quasecinema.org
# 17-Jan-2015
# Sonic Pi 2.12
use_bpm 136
startClock = 0 # 0 to start song at beginning
clock = 0 # global var
bar = 0 # global var
set_volume! 1.0
t = Time.new
use_random_seed = (t.year + t.month + t.day + t.hour + t.min + t.sec)
# download sample from link below and rename to waves.aif
# http://freesound.org/people/ngarvey/sounds/47964/dowload/47964__ngarvey__waves-on-to-rocks.aif
myWave = '/Users/rangel/Documents/SamplesPi/waves.aif' # your path here
load_sample myWave
#############################################################
#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
cue :metro
sleep 0.5
clock = startClock + tick
bar = clock / 4
puts "bar : #{bar}"
puts (ring "1 |","2 | |","3 | | |","4 | | | |")[clock]
end #metro
#############################################################
live_loop :track5 do #boom
use_synth :growl
with_fx :pitch_shift, pitch: (ring -12,-12,-12,-6)[tick],
window_size: rrand(0.0001,0.055) do
play 80, detune: rrand(-100,100),
sustain: (ring 1,1,1,2)[tick] * 2.5,
pan: rrand(-0.3,0.3), pan_slide: 3,
amp: rrand(3,4) * 0.8
end
sleep 3
with_fx :pitch_shift, pitch: (ring -24,-12,-12,-6)[tick],
window_size: rrand(0.0001,0.01), time_dis: rrand(0.0001,0.001),
time_dis_slide: rrand(0.01,0.02), _slide_shape: [3,4].choose do
play 80, detune: rrand(-100,100),
sustain: (ring 1,1,1,2)[tick],
amp: rrand(2,4) * 0.8
end
sleep 3
with_fx :pitch_shift, pitch: (ring -12,-6,0,12,24)[tick],
window_size: rrand(0.0001,0.001), time_dis: rrand(0.0001,0.0005) do
play 90, detune: rrand(-100,100),
sustain: (ring 1,1,1,2)[tick],
pan: rrand(-0.3,0.3), pan_slide: 3,
amp: rrand(0,2) * 0.8
end
sleep 3
end
#############################################################
sleep 1
#############################################################
live_loop :track6 do #boom2
use_synth :hollow
with_fx :flanger, phase: rrand(0.01,1), mix: 0.333 do
with_fx :echo, phase: 1.0/3 do
with_fx :pitch_shift, pitch: (ring 16,-4,18,-8)[tick],
window_size: rrand(0.005,0.025) do
play 80, detune: rrand(-100,100),
sustain: (ring 1,1,1,2)[tick],
release: 16,
amp: rrand(1.0,1.333) * 1
end #fx
end #fx
end #fx
sleep 1.5 * rand(10)
end
live_loop :track7 do
with_fx :slicer, phase: ring(1,0.5,0.25,0.1)[bar] do
with_fx :pitch_shift, pitch: (ring -16,-8,-4)[tick],
window_size: rrand(0.0001,0.0005) do
sample myWave, amp: 1.5
end
end
with_fx :slicer, phase: ring(1,0.5,0.25,0.1)[bar-1] do
with_fx :pitch_shift, pitch: (ring -4,-8,-16)[tick],
window_size: rrand(0.0001,0.0004) do
sample myWave,
rate: -1, amp: 0.75
end
end
sleep sample_duration myWave
end
#############################################################
#live_loop :track8 do #waves
#
# with_fx :pitch_shift, pitch: (ring -16,-8,-4)[tick],
# window_size: rrand(0.0001,0.0005) do
# sample :mySamples__waves, amp: 1.5 * 1.25 * ([0,0,0,1].choose)
# end
#
# with_fx :pitch_shift, pitch: (ring -4,-8,-16)[tick],
# window_size: rrand(0.0001,0.0004) do
# sample :mySamples__waves,
# rate: -1, amp: 0.75 * 1.25 * ([1,0,0,0].choose)
# end
#
# sleep sample_duration :mySamples__waves
#
#end
#############################################################
live_loop :track1 do #kick
if bar > 24
with_fx :bitcrusher, bits: (ring 10,10,8)[tick], mix: 0.3 do
with_fx :flanger, mix: 0.3 do
sample :bd_klub, amp: rrand(0.9,1.0) * 0.9
sample :bd_haus, amp: rrand(0.9,1.0) * 0.9
end
end
end #if
sleep 1.5 / (ring 2,2,2,2,2,3)[tick]
end
#############################################################
sleep 0.5
#############################################################
live_loop :track2 do #tss
if bar > 36
sleep (0.5/3)
with_fx :flanger do
with_fx :slicer, phase: [0.1,0.2,0.5,0.75].choose do
#with_fx :echo, phase: 1.0/(ring 4,2,8,0.5)[tick] do
use_synth :pnoise
play 120, attack: 0, sustain: 0.1, release: (ring 0.25,0.1,0.1,0.1)[tick],
detune: rrand(-36,22),
amp: (ring 1,1.2,1,0.5)[tick] * 1.5
#end
end
end
end #if
sleep (0.5/3) * 2
end
#############################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment