Skip to content

Instantly share code, notes, and snippets.

@AlexandreRangel
Last active June 10, 2017 04:01
Show Gist options
  • Save AlexandreRangel/adfa1620ac6243fba420 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/adfa1620ac6243fba420 to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# "sunday morning worship code" (v13)
# www.quasecinema.org
# 06-Feb-2016
# Sonic Pi 2.12
mybpm = 144
use_bpm mybpm
startClock = 0 # 0 to start song at beginning
clock = 0 # global var
bar = 0 # global var
set_volume! 0.6
t = Time.new
x = (t.year - t.month - t.day - t.hour - t.min - t.sec)
puts "x = #{x}" #1931
use_random_seed = x
# download sample, rename to harley.wav and machinery.wav and put in your samples folder
# http://www.freesound.org/people/garysanford/sounds/178111/
# http://www.freesound.org/people/ERH/sounds/163465/
sampleHarley = '/Users/rangel/Documents/SamplesPi/harley.wav' # your path here
load_sample sampleHarley
sampleMachinery = '/Users/rangel/Documents/SamplesPi/machinery.wav' # your path here
load_sample sampleMachinery
#############################################################
# 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
mybpm = 144 / 2 if bar < 24
mybpm = 144 if bar == 0
mybpm = 144 if bar > 24
#ramdom bpms:
mybpm = 144 / 4 if one_in(36*1.1)
mybpm = 144 / 2 if one_in(72*1.1)
mybpm = 144 / 8 if one_in(48*1.1)
mybpm = 144 * 2 if one_in(24*1.1)
puts "let's go!" if clock < 1
puts "bar : #{bar}, bpm: #{mybpm}"
puts (ring "1 !","2 ! !","3 ! ! !","4 ! ! ! !")[clock]
end #metro
#############################################################
sleep 0.5 #offset metro2
#############################################################
live_loop :metro2 do
sync :metro
sleep 0.5
cue :metro2
sleep 0.5
end #metro2
#############################################################
with_fx :compressor, slope_above: 0.75,
pre_amp: 0.8, mix: 0.8 do
#############################################################
#comment do
live_loop :harley do
with_bpm mybpm do
with_fx :slicer, phase: [0.1,0.2,0.25,0.5,1].choose,
mix: [0.01,1,1,1,1,1,1].choose do
with_fx :compressor do
sample sampleHarley, beat_stretch: 128, amp: 4
end #:compressor
end #:slicer
sleep 128
end #with_bpm
end #harley
#end #comment
#############################################################
sleep 8 #delay start
#comment do
live_loop :bass1 do
sync :metro
use_synth :pulse
with_bpm mybpm do
with_fx :pitch_shift, pitch: [0,2,4,8].choose,
window_size: 0.05 do
with_fx :slicer,
phase: (ring 0.5,0.25,0.5,0.95,0.1)[tick/16] do
with_fx :distortion, distort: 0.5, mix: 0.5 do
play chord(:c0, :minor).choose,
attack: 0.01, sustain: 2, release: 2,
pan: -0.2, amp: 0.66
end #krush
end #slicer
end #pitch
sleep (ring 2,1,4)[clock/16]
end #mybpm
end #bass
#end #comment
#############################################################
sleep 32 # delay start
#comment do
live_loop :bass2 do
sync :metro
use_synth [:tb303,:prophet].choose
with_bpm mybpm do
with_fx :compressor do
with_fx :flanger, decay: [0.25,0.5,1,2,4,8,12].choose,
mix: 0.5 do
with_fx :slicer, phase: [0.25,0.5,0.75,1.0].choose,
mix: (ring 0.25,0.5,0.75,1.0)[tick] do
if one_in(2)
play chord(:c0, :maj11).choose,
attack: 2.0, sustain: 1, release: 6,
pan: 0.2, amp: rrand(5,7) * 0.4
else
play chord(:c1, :dom7).choose,
attack: 4.0, sustain: 2, release: 4,
pan: 0.2, amp: rrand(5,7) * 0.4
end #if
end #slicer
end #flanger
end #compressor
sleep [1,2,3,4,4,6,6,8].choose
end #mybpm
end #bass
#end #comment
#############################################################
sleep 24 # delay start
#comment do
live_loop :kick do
sync :metro
with_bpm mybpm do
with_fx :echo, phase: (ring 0.25,0.5,0.2,0.25,0.5,3)[tick/32],
mix: (ring 0.4,0.8)[tick/2] do
sample :bd_haus, amp: rrand(3.3,3.5) *1.1 *0.66
use_synth :pulse
play (ring 40,40,40,32)[tick/1], amp: 0.7 *0.66
end #echo
sleep (ring 4,2,1,1,1,1,1,1, 4,1,1,1,1,1,1,1)[tick/16]
end #mybpm
end #kick
#end #comment
#############################################################
sleep 16.5 # delay start
#comment do
live_loop :hat do
sync :metro2
use_synth :cnoise
with_bpm mybpm do
with_fx :echo, phase: 1.0/3, mix: [0,0,0,0.9][tick/12] do
with_fx :echo, phase: 0.25, mix: [1,1,1,0][tick/12] do
with_fx :pitch_shift, pitch: (ring 8,8,12,12)[tick],
window_size: (ring 0.040,0.08)[tick/8] do
play 48, attack: 0.1, release: 0.1,
amp: (ring 2.25,2.6,4.0,2.5)[tick] + 3.0 *0.6
play rrand_i(42,54), attack: 0.1, release: 0.1,
amp: (ring 4.25,2.6,2.6,2.5)[tick] + 3.0 *0.6
end #pitch
end #echo2
end #echo1
sleep 1
end #mybpm
end #hat
#end #comment
#############################################################
sleep 16 #delay start
#comment do
live_loop :ride do
sync :metro2
use_synth (ring :noise,:cnoise)[tick/2]
with_bpm mybpm do
play 60, attack: (ring 0.02,0.03,0.04)[tick/32],
release: (ring 0.5,0.8,0.3,0.75,0.1)[tick/8],
amp: rrand(0.14,0.16) + (ring 0.4,0.45)[tick/2] * 1.333
sleep (ring 1,1,1,1,4,1,1,1, 4,1,1,1,2,1,1,1)[tick/64]
end #mybpm
end ##ride
#end #comment
#############################################################
#comment do
live_loop :beep do
sync :metro
with_bpm mybpm do
if one_in(2)
use_synth [:sine,:saw,:beep,:pulse].choose
with_fx :pan, pan: [-0.8,-0.5,0,0.5,0.8].choose,
pan_slide: [0.25,0.5,1,2,4,8].choose do
with_fx :normaliser, mix: [0.2,0.4,0.6,0.7,0.8].choose do
with_fx :pitch_shift, pitch: [-2,-4,-8,-12,-16,-24].choose,
window_size: [0.01,0.02,0.04,0.1,0.2].choose do
with_fx :ixi_techno, phase: [1,2,3,4].choose,
mix: rrand(0.5,0.75) do
with_fx :flanger, phase: [0.25,0.5,1,2,4].choose,
res: rrand(0.0,0.5), res_slide: 1,
mix: [0.05,0.5,1].choose do
with_fx :echo, phase: [0.25,0.5,1.5,3].choose,
mix:(ring 0.4,0.7,0.4,0.9)[clock/4] do
play [60,60,64,90].choose, amp: 1.0 *1.1,
attack: 0.1, release: 2
play [60,60,64,90].choose, amp: 1.2 *1.1,
attack: 0.1, release: 4
play [60,62,64,90].choose, amp: 1.4 *1.1,
attack: 0.5, release: 8
end #echo
end #flanger
end #ixi
end #pitch
end #normalizer
end #pan
end #if
sleep 4
end #mybpm
end #beep
#end #comment
#############################################################
#comment do
live_loop :machinery do
with_bpm mybpm do
with_fx :compressor, pre_amp: 1.3, slope_below: 2.4, mix: 0.8 do
with_fx :pitch_shift, pitch: [-2,-4,-8,-12,-16,-24].choose,
window_size: [0.001,0.002,0.004,0.01,0.02].choose do
sample sampleMachinery, beat_stretch: [16,32,64].choose,
amp: rrand(3,7) * 1.5, rate: [-1,1,1].choose
end #:pitch_shift
end #:compressor
sleep [2,4,8,8,16,16,16,32].choose
end #mybpm
end #machinery
#end #comment
#############################################################
end #:compressor
#############################################################
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment