Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active June 10, 2017 13:36
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/9893ba3a35915eab4cac to your computer and use it in GitHub Desktop.
Save AlexandreRangel/9893ba3a35915eab4cac to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# "void running" (v25)
# www.quasecinema.org
# 06-Mar-2016
# Sonic Pi 2.12
arrangement = true
mybpmbase = 116
mybpm = mybpmbase * 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.9 #1.1 #0.75
t = Time.new
x = ((t.year - t.month - t.day - t.hour - t.min - t.sec) / 30).to_int
puts "x = #{x}"
use_random_seed = x
# http://www.freesound.org/people/modularsamples/sounds/284669/
# download sample above, rename to g5fm.wav
# and put it in your path, defined here:
sampleG5fm = '/Users/rangel/Documents/SamplesPi/g5fm.wav' # your path
load_samples [sampleG5fm,:bd_haus,:bd_klub,:bd_zum]
################################################################
live_loop :metro do
mybpm = mybpmbase * (ring 2,2,2,2,2,2,4,2)[tick/128]
mybpm = mybpmbase * 4 if 1 == (ring 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0)[tick/16]
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]
end #mybpm
end #metro
live_loop :metro2 do
with_bpm mybpm do
cue :metro2
sleep 0.5
end
end #metro2
################################################################
with_fx :compressor, slope_below: 10.0, slope_above: 0.333, relax_time: 0.1,
pre_amp: 6.0, mix: 0.5 do
with_fx :echo, phase: 4, reps: 2, mix: 1.0/3.0 do
with_fx :reverb do
#############################################################
live_loop :note1 do
with_bpm mybpm * [1,0.5].choose do
sample sampleG5fm,
pitch: rrand(-16,0),
windows_size: rrand(0.003,0.005),
beat_stretch: 6*rrand(1,2),
attack: rrand(0,6)/2.0, release: rrand(0,6),
pan: rrand(0,1), pan_slide: 6*rrand(1,2),
amp: rrand(0,3) *4
sleep 8
end
end
live_loop :note2 do
with_bpm mybpm * [1,0.5].choose do
sample sampleG5fm,
pitch: rrand(-24,0),
windows_size: rrand(0.002,0.004), beat_stretch: 4*rrand(1,3),
attack: rrand(0,4)/2.0, release: rrand(0,5),
pan: rrand(-1,0), pan_slide: rand(4),
amp: rrand(0,3) *4
sleep 10
end
end
sleep 2 #delay start
live_loop :note3 do
with_bpm mybpm * [1,2].choose do
sample sampleG5fm,
pitch: rrand(-36,0),
windows_size: rrand(0.001,0.003),
beat_stretch: 8*rrand(1,2),
attack: rrand(0,5)/2.0, release: rrand(0,5),
pan: rrand(-1,1), pan_slide: 8*rrand(1,2),
amp: rrand(0,3) *5
sleep 12
end
end
live_loop :note4 do
with_bpm mybpm * [2,1].choose do
sample sampleG5fm,
pitch: rrand(-48,0),
windows_size: rrand(0.03,0.05), beat_stretch: 6*rrand(1,4),
attack: rrand(0,4), release: rrand(2,6),
pan: rrand(-0.8,0.8), pan_slide: 6*rrand(1,4),
amp: rrand(0,3) *5
sleep 8*2
end
end
sleep 2
live_loop :note5 do
with_bpm mybpm * [1,0.5].choose do
sample sampleG5fm,
pitch: rrand(-64,0),
windows_size: rrand(0.02,0.04), beat_stretch: 2*rrand(4,8),
attack: rrand(0,2), release: rrand(2,5),
pan: rrand(-0.5,0.5), pan_slide: 2*rrand(4,8),
amp: rrand(0,3) *6
sleep 12*2
end
end
sleep 2
live_loop :note6 do
with_bpm (mybpm * [1,0.5].choose) do
with_fx :reverb, room: 1, mix: 0.97 do
sample sampleG5fm,
pitch: rrand(-72,0),
windows_size: rrand(0.01,0.03), beat_stretch: 8*rrand(1,6),
attack: rrand(0,2), release: rrand(2,5),
amp: rrand(0,3) *6
sleep 12*2
end
end
end
end #reverb
end #echooo
end #compressor
################################################################
sleep 8
################################################################
live_loop :bass1 do
with_bpm mybpm * 0.5 do
16.times do
use_synth ring(:blade,:prophet)[tick/16]
play [36,32,30].choose, attack: 0.1, release: 3,
amp: ring( 4.0,4.2)[tick/2] * rrand(0.25,0.3) * ring(0.7,0.8)[tick/16]
if one_in(8)
sleep ring( 2,2,2,8)[tick]
else
sleep ring( 2,1,2,1)[tick]
end #if
end
sleep 4
with_fx :slicer, phase: 0.25 * 0.5 do
18.times do
use_synth :fm
with_fx :reverb, mix: 0.75 do
play_chord chord(:e2, :m13), attack: 0.1, release: [1,3,6].choose,
amp: ring( 3.5,3.8)[tick/2] * rrand(0.25,0.3) * ring(0.9,1.1)[tick/16]
if one_in(8)
sleep ring( 2,2,2,8)[tick]
else
sleep ring( 2,1,2,1)[tick]
end #if
end
end
end
sleep 4
48.times do
use_synth :dsaw
with_fx :slicer, phase: (ring 0.25,0.5,0.5,1,1)[tick/6] do
with_fx :reverb, mix: rrand(0.3,0.99) do
play_chord chord(:g3, :maj11), attack: 0.1, release: [1,3,6].choose,
amp: (ring 3.3,3.5)[tick/2] * rrand(0.25,0.3) * ring(0.9,1.2)[tick/16]
if one_in(8)
sleep (ring 2,2,2,8)[tick]
else
sleep (ring 2,1,2,1)[tick]
end #if
end
end
end
sleep 2
end #bpm
end #bass
################################################################
sleep 24 #delay start
################################################################
live_loop :kick do
# sync :metro
with_bpm mybpm do
sample :bd_klub,
amp: rrand(1.7,1.8) * (ring 0.2,0.9,1.1,0.9)[tick] * 1.4
sample :bd_haus,
amp: rrand(0.5,0.6) * (ring 0.7,1.1,0.9,0.2)[tick]
sleep 1
sample :bd_zum, amp: rrand(0.37,0.45), rate: rrand(-1.0,-0.8), start: 0.2
sample :bd_zum, amp: rrand(0.37,0.44), rate: rrand(0.8,1.0)
sleep 1
end #bpm
end #kick
################################################################
live_loop :ride do
# sync :metro
with_bpm mybpm do
use_synth :cnoise
with_fx :echo, phase: 1.0/(ring 2,6)[tick/6],
mix: rrand(0.5,0.66), reps: 2 do
play 60, release: [1,2].choose,
amp: rrand(1.5,1.58) * (ring 0.0444,0.024,0.04,0.022)[tick]
end #echo
sleep (ring 3,4,3,4,3)[tick/3] * 1
end
end #ride
################################################################
sleep 8 #delay start
################################################################
live_loop :synth1 do
with_bpm mybpm do
if bar % [3,4].choose == 0 then
with_fx :slicer,
phase: (ring 0.1,0.1,0.2,0.3,0.5,0.15,0.75,1)[tick/2],
slope_up: (ring 0.05,0.11,0.2,1)[tick],
slope_down: (ring 0.5,1)[tick] do
with_fx :flanger, phase: [0.5,1,2].choose do
with_fx :nrbpf, centre: rrand(30,70),
centre_slide: [0.5,1,2].choose,
res: rrand(0.1,0.333), mix: rrand(0.2,0.5) do
with_fx :echo,
phase: [0.25,0.5,0.5,1,2,3,4,3,8,10,12,16].choose,
reps: 3, mix: 0.4444 do
use_synth :pulse
play_chord chord(:g5, :sus2),
pan: rrand(-1,1), pan_slide: (ring 0.5,1)[tick/2],
amp: (ring 0.5,0.1,0.5,0.1)[tick/4] * rrand(0.0,0.002) if one_in(3)
play (ring 70,76,74,92)[tick/2] - rrand(8,16),
pan: rrand(-1,1), pan_slide: (ring 0.5,1)[tick/2],
amp: (ring 0.5,0.1,0.5,0.1)[tick/4] * rrand(0.0,0.001) if one_in(3)
end #echo
end #flanger
end #nrbpf
end #slicer
end #bar
sleep (ring 1,1,1,2,1,1,2,36, 1,1,1,1,1,1,1,48)[clock/2] * [2,4].choose
end #bpm
end #synth1
################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment