Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Created August 28, 2016 21:20
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/5a3c97cb8e4b215c5aa9f1edbf62a88b to your computer and use it in GitHub Desktop.
Save AlexandreRangel/5a3c97cb8e4b215c5aa9f1edbf62a88b to your computer and use it in GitHub Desktop.
Sonic Pi music code
# 'once upon a morning v21' Sonic Pi 2.11 dev
# Alexandre rANGEL www.quasecinema.org
#http://www.freesound.org/people/csengeri/sounds/188765/ (convert mp3 to wav)
thunder = "/Users/rangel/Documents/SamplesPi/thunderstorm.wav"
load_sample thunder
use_bpm 46
set_sched_ahead_time! 2
# countdown sync
##| 3.times do
##| use_synth :beep
##| play 90, attack: 0, sustain: 1.0 /8, release: 0, amp: 0.75
##| sleep 2.0 / 4
##| end
##| sleep 2
live_loop :drums do
with_fx :tanh, mix: rrand(0,0.2) do
with_fx :slicer, phase: 0.5/[1,2,4,8,2,4,8].choose do
with_fx :lpf, cutoff: rrand(100,120) do
sample :bd_haus, amp: 1.4
end
if one_in(6)
sleep 1.0/3
else
sleep 1.0/6
end
sample :bd_fat, amp: 3
if one_in(4)
sleep 1.0/3
else
sleep 1.0/6
end
end
end
end
with_fx :compressor, threshold: 0.6, relax_time: 0.2,
slope_below: 3.2, mix: 0.7 do
with_fx :reverb, mix: 0.5 do
live_loop :thunder do
sample thunder, attack: 3, release: 6, start: 0.004, finish: 0.1, amp: 8
sleep (sample_duration thunder) / 10.0
sample thunder, attack: 4, release: 4, start: (1.0/3.0)*2, amp: 2
sleep ((sample_duration thunder)/3)*2
end
sleep 3
live_loop :thunderLoop1 do
if one_in(2)
with_fx :lpf, cutoff: rrand(1,130), cutoff_slide: [1,2,3,4].choose, mix: 0.8 do
with_fx :hpf, cutoff: rrand(1,126), cutoff_slide: [1,2,3,4,8].choose, mix: 0.8 do
with_fx :slicer, phase: [0.25,0.5].choose do
sample thunder, attack: 0.1, release: 0.2, start: 0.004, finish: 0.014,
rate: rrand(0.7,1.0), amp: 8, pan: rrand(-0.2,-0.1), pan_slide: rrand(0.1,0.3),
amp: rrand(0.6,0.9)
end #fx
end #fx
end #fx
sleep 4
else
with_fx :hpf, cutoff: rrand(1,126), cutoff_slide: [1,2,3,4,8].choose, mix: 0.8 do
with_fx :lpf, cutoff: rrand(1,130), cutoff_slide: [1,2,3,4].choose, mix: 0.8 do
with_fx :slicer, phase: [0.25,0.5].choose do
sample thunder, attack: 0.1, release: 0.2, start: 0.004, finish: 0.014,
rate: rrand(0.5,1.0), amp: 8, pan: rrand(0.1,0.2), pan_slide: rrand(0.1,0.3),
amp: rrand(0.6,0.9)
end #fx
end #fx
end #fx
sleep 4
end #if
end #loop
with_fx :reverb, mix: 0.3 do
live_loop :rocks1 do
if rand(100) > 30
use_synth :pnoise
with_fx :hpf, cutoff: rrand(1,130), cutoff_slide: [1,2,3,4,8].choose do
y = rrand(50,70);
puts note_info(y)
play y,
attack: rrand([0.333,1].choose,2), release: rrand(6,8) * rrand(1,2),
pan: rrand(-0.9,-0.3), pan_slide: rrand(1,3), amp: rrand(0.3,1.222) * 1.333
end #fx
end #fx
sleep 6.0 *rrand(1,4)
end #loop
end #if
with_fx :reverb, mix: 0.7 do
live_loop :rocks2 do
sleep rrand(3,6)
if rand(100) > 31
use_synth :pnoise
with_fx :lpf, cutoff: rrand(1,130), cutoff_slide: [1,2,3,4,8].choose do
z = rrand(50,70)-30
puts note_info(z)
play z,
attack: rrand([0.5,1].choose,2), release: rrand(6,8)*2 * rrand(1,2),
pan: rrand(0.3,0.9), pan_slide: rrand(1,3), amp: rrand(0.2,0.9) * 1.333
end #fx
end #fx
sleep 9.0 * rrand(1,4)
end #loop
end #if
with_fx :compressor, threshold: 0.7, relax_time: 0.05,
slope_below: 1.222, slope_above: 0.7, mix: 0.8 do
with_fx :reverb, mix: 0.5 do
live_loop :fish do
use_synth [:chipbass,:chipbass,:chiplead,:beep,:beep,:fm].choose
12.times do
with_bpm 46/[0.5,1,2,4,8].choose do
with_fx :hpf, cutoff: rrand(1,128), cutoff_slide: [0.25,0.5,1,2].choose do
with_fx :lpf, cutoff: rrand(1,127), cutoff_slide: [0.25,0.5,1,2,3].choose do
with_fx :panslicer, phase: [0.1,0.2,0.25,0.5,1].choose,
pulse_width: rrand(0.01,0.09), mix: rrand([0,0.5].choose,1) do
with_fx :echo, phase: [2,3,4,6].choose, decay: [3,6].choose do
with_fx :gverb, mix: rrand(0.01,0.25) do
with_fx :echo, phase: [0.25,0.25,0.5,1].choose do
x = scale([[:g3,:g4].choose,:a3].choose,[:zhi].choose).choose
puts note_info(x)
play x, attack: 0.01, release: rrand(0.001,[0.05,0.1].choose),
amp: rrand(0.777,1.4444) * rrand(1.0,1.4),
pan: rrand(-0.333,0.333), pan_slide: [0.1,0.2,0.5,1].choose,
divisor: [1,2,1,2,4,8,rand(16)].choose,
depth: [2,4,2,4,2,4,8,rand(16)].choose
end #fx
end #fx
end #fx
end #fx
end #fx
end #fx
end #bpm
sleep [0.1,0.25,0.25,0.5,1,1,2].choose
end #times
sleep [4,8,12,16].choose
end #loop
end #fx
end #fx
end #reverb
end #compressor
sleep 4
live_loop :hat do
use_synth :pnoise
myRes = rrand(0,0.9)
mySleep = [3,6,12].choose
64.times do
play 60, attack: 0.01, release: 0.01, amp: 0.4, res: myRes
sleep 1.0/mySleep
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment