Skip to content

Instantly share code, notes, and snippets.

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/0cb1add3c751a3f5edbe to your computer and use it in GitHub Desktop.
Save AlexandreRangel/0cb1add3c751a3f5edbe to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# 'polaris untamed ritual - still intact and comfortably outside the event horizon' (v18)
# https://www.youtube.com/watch?v=fzb5sf2Dcyo
# www.quasecinema.org
# 21-Feb-2016 / Sonic Pi 2.12
arrangement = true
mybpmbase = 30
mybpm = mybpmbase # * 2 #6, 8, 12, 16, 4, 2
use_bpm mybpm
startClock = 0 # 0 to start song at beginning
clock = startClock # global var
bar = 0 # global var
set_sched_ahead_time! 2
set_volume! 0.75
t = Time.new
x = ((t.year - t.month - t.day - t.hour - t.min - t.sec) * 1).to_int
puts "x = #{x}"
use_random_seed = x #1970 1962 1964 1918
# http://www.freesound.org/people/modularsamples/sounds/291042/
# download sample, rename to polaris.aiff
# and put it in your path, defined here:
samplePolaris = '/Users/rangel/Documents/SamplesPi/polaris.wav'
load_sample samplePolaris
load_sample :bass_drop_c
load_sample :bd_klub
load_sample :bd_haus
load_sample :bd_pure
live_loop :metro do
#ramdom bpms:
mybpm = mybpmbase * [2,2,2,2,2,2,2,2,2,2,2,2,2,0.5,1,4,4,4].choose
mybpm = 15.0 / 2.0 if bar == 1
mybpm = 15 if bar == 2
mybpm = 30 if bar == 3
mybpm = 60 if bar == 4
mybpm = 60 if bar == 5
with_bpm mybpm do
cue :metro
sleep 0.5
clock = startClock + tick
bar = (clock / 4) + 1
puts "let's go!" if clock < 1
puts "bar : #{bar}, bpm: #{mybpm}"
puts ring( "1 !","2 ! !","3 ! ! !","4 ! ! ! !")[clock]
#output click sound
end #mybpm
end #metro
#############################################################
#with_fx :compressor, slope_below: 1.0, slope_above: 0.85,
#threshold: 0.75, relax_time: 0.1, mix: 0.25 do
#############################################################
with_fx :compressor, slope_below: 2.0, slope_above: 1.15,
relax_time: 0.1, mix: 0.5 do
live_loop :polaris1 do
with_bpm mybpm do
sample samplePolaris, beat_stretch: (ring 128,64,32)[tick],
amp: 2.3
sleep 2
with_fx :flanger, delay: ring( 2,4).tick do
sample samplePolaris, beat_stretch: 128,
pitch: 16, amp: rrand(1.55,1.75), pan: -1,
rate: (ring 1,-1,1,-1,1,-1)[tick]
end #:flanger
sleep 64 / 2
with_fx :slicer, phase: 0.25 do
sample samplePolaris, beat_stretch: [32,64].choose,
window_size: rrand(0.001,0.006),
amp: rrand(1.6,1.9), pan: -1,
rate: (ring 1,-1,1,-1,1,-1)[tick+1]
end #:slicer
with_fx :slicer, phase: 0.5,
smooth_up: 0.1, smooth_down: 0.1 do
sample samplePolaris, beat_stretch: [64,32,64,32].choose,
window_size: rrand(0.001,0.01),
rate: -1, pitch: -16,
amp: 1.75, pan: -1
end #:slicer
sleep 64 / 2
end #bpm
end #:polaris1
with_fx :compressor, slope_below: 2.73, slope_above: 1.8,
relax_time: 0.1, mix: 0.5 do
with_fx :pitch_shift, pitch: -8,
window_size: rrand(0.001,0.004) do
with_fx :ixi_techno, phase: [2,4,8,16,24].choose,
res: rrand(0.5,0.9), mix: rrand(0.5,0.75) do
live_loop :polaris2 do
with_bpm mybpm do
sample samplePolaris,
beat_stretch: [1,2,4,8].choose,
pitch: [-3,-5,-7].choose,
window_size: 0.001,
amp: rrand(0.3,0.55) * 2.25,
pan: 1
sleep 2
sample samplePolaris,
beat_stretch: [1,2,4,8].choose,
pitch: [-3,-5,-7].choose-8,
window_size: rrand(0.001,0.005),
amp: rrand(0.3,0.4) * 2.34,
pan: 1
sleep [2,4,8,16,24].choose / 2
end #mybpm
end #:polaris2
end
end
end
end #:compressor1
#######################################################
sleep 16 if arrangement == true # delay start
#######################################################
live_loop :beat1 do
with_fx :krush, cutoff: 80, mix: rrand(0.3,0.6) do
with_fx :pitch_shift, pitch: [-72,-64,-64,-48,-36].choose,
window_size: rrand([0.004,0.007].choose,0.008) do
with_fx :distortion, distort: rrand(0.8,1.0), mix: rrand(0.8,0.9) do
with_fx :lpf, cutoff: rrand(70,90) do
sample samplePolaris,
start: 0.35, finish: 0.4, beat_stretch: 4, amp: rrand(1.0,1.4) * 1.65,
rate: rrand(0.9,1.0),
pan: rrand(0.5,1.0), pan_slide: [0.25,0.5,1].choose
end
end
with_fx :distortion, distort: rrand(0.75,1.0), mix: rrand(0.8,0.9) do
with_fx :lpf, cutoff: rrand(80,100) do
sample samplePolaris,
start: 0.4, finish: 0.42, beat_stretch: 2, amp: rrand(1.0,1.4) * 1.85,
rate: -1,
pan: rrand(0.5,1.0), pan_slide: [0.25,0.5,1].choose
end
end
end
sleep 0.25 * [0.5,1,1,1,1,2,4].choose
sleep 0.25 if one_in(4)
sleep 0.50 if one_in(16)
end
end
#######################################################
sleep 4 if arrangement == true # delay start
#######################################################
live_loop :beat2 do
with_bpm (mybpm * 1.0) do
with_fx :echo, phase: [0.25].choose, decay: 1,
mix: (ring 0.0,0.333,0.4,0.5,0.6,0.8)[tick/4], reps: 2 do
with_fx :reverb, room: 0.7, mix: 0.3 do
with_fx :bitcrusher, sample_rate: rrand(17000,28000),
mix: rrand(0.2,0.4), bits: [11,12,13,14,15,16].choose,
pitch: [-24,-16,-8].choose, mix: 0.5,
window_size: [0.001,0.002,0.003,0.004].choose do
sample :bd_haus, rate: [0.9,0.94,0.96,0.98,1.0].choose,
pan: rrand(-0.3,0.3), rate: [0.5,0.75,1,1,1,1,1,1,1,1,1].choose,
amp: rrand(1.3,1.5) * 1.1 * ring( 0.33,0.5,0.33,0.7)[tick] * 1.4
end #:bitcrusher
sample [:bd_klub,:bd_pure,:bd_klub].choose, rate: [0.9,1.0].choose,
pan: rrand(-0.12,0.12),
amp: rrand(1.4,1.7) * ring( 0.7,0.2,0.5,0.1)[tick] * 3.48,
rate: [-1,1].choose
sleep 1.0 * 0.5
end #mybpm
end #:reverb
end #echo
end #:beat2
#######################################################
sleep 0.25 / 2.0 # offset
#######################################################
live_loop :tss1 do
with_bpm (mybpm/4.0) do
with_fx :reverb, room: rrand(0.06,0.8), mix: rrand(0.3,0.6) do
sample :drum_snare_hard, amp: rrand(0.6,0.9) *0.6
sample :drum_snare_soft, amp: rrand(1.3,1.5) *0.8
end #:reverb
sleep 0.25
end #mybpm
end #:tss1
#######################################################
sleep 0.2 # offset
#######################################################
live_loop :bass do
with_fx :slicer, phase: ring( 0.25,1,2,4,8,0.5)[tick/4],
slope_up: (ring( 0.25,1,2,4,8,0.5)[tick/4])/2,
slope_down: ring( 0.25,1,2,4,8,0.5)[tick/4] do
with_fx :slicer, phase: ring( 0.5,0.75,1,0.25)[tick/[4,6].choose] do
sample :bass_drop_c, rate: -[0.9,1.0].choose,
pitch: [-36,-24,-16,-8].choose,
amp: rrand(1.2,1.35) * 0.75,
pan: rrand(-0.52,0.52),
pan_slide: [0.2,0.25].choose,
beat_stretch: [4,6,8].choose,
window_size: rrand(0.0001,0.01),
start: rrand(0,0.3),
finish: rrand(0.4,0.8)
end #:slicer
end #:slicer
sleep ring( 4,1,1,1, 2,1,2,1, 2,1,2,1, 2,1,2,1)[tick/8] * 1 #[0.5,1,1,1,1,2].choose
end
#######################################################
sleep 127 if arrangement == true # delay start
sleep 0.6 # offset
#######################################################
with_fx :compressor, slope_below: 2.6, slope_above: 1.66 do
live_loop :tss2 do #crazy hatter
with_bpm (mybpm/2.0) do
use_synth [:pnoise].choose
with_fx :pitch_shift, pitch: 16, window_size: [rrand(0.0001,0.001),rrand(0.0001,0.1)].choose do
play :C3, amp: ring(0.3,0.2,0.3,0.33)[tick] * rrand(0.44,1.2) * 0.5,
release: [0.2,0.4,2].choose, rate: 0.5
end
with_fx :pitch_shift, window_size: [rrand(0.0001,0.001),rrand(0.0001,0.1)].choose do
play [:A3,:C3,:G3].choose, amp: ring(0.3,0.2,0.3,0.33)[tick] * 1.2 * 0.5,
release: [0.1,0.2,1].choose, rate: 0.5
end
sleep 1.5 / [2,4].choose
sleep 1.5 * 2 if one_in(24)
sleep 1.5 * 4 if one_in(128)
end
end #mybpm
end #:compressor
#######################################################
#end #:compressor
#######################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment