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/b604bef3469bb724078560833b8a3265 to your computer and use it in GitHub Desktop.
Save AlexandreRangel/b604bef3469bb724078560833b8a3265 to your computer and use it in GitHub Desktop.
Sonic Pi music code
# Alexandre rANGEL
# www.quasecinema.org
# my mothers were angels with fire veils and feather wings v14
# Sonic Pi 2.10
# 16-Apr-2016
use_bpm 140
set_volume! 0.777
t = Time.new
x = (t.year / t.month / t.day * t.hour * t.min * t.sec)
use_random_seed x
puts x
#http://www.freesound.org/people/firnwald/sounds/84162/ (dungeon drum)
#http://www.freesound.org/people/qubodup/sounds/183994/ (light switch)
# download samples, rename and put it in your path, defined here:
sample_kick = '/Users/rangel/pisamples/kick_mpc.wav'
sample_switch = '/Users/rangel/pisamples/switch.wav'
what_sound = 1
live_loop :metro do
clock = tick(:metro)
bar = clock / 4
puts "bar : #{bar}"
puts (ring "1 |","2 | |","3 | | |","4 | | | |")[clock]
what_sound = rrand_i(1,5) if one_in(rrand_i(1,2))
sleep 1
end #metro
lfo_start = 60
c = 0
lfo = 0
live_loop :bass do
lfo = lfo + (ring +0.5,-0.5)[c/120] #lfo from 60 to 120
c = c + 1
with_fx :slicer, smooth: 0.5, phase: 4 do
with_fx :hpf, cutoff: (lfo_start+lfo) do
sample :bass_trance_c, attack: 0.1,
rate: rrand(0.85,1.05)/[1,2].choose, amp: rrand(2.5,2.7) *[1.6,1.8].choose
end
end
sleep 2
end
############################################################
s1 = 1
live_loop :switch do
if what_sound = 1 or what_sound = 4
if one_in(2)
with_fx :compressor, slope_above: 0.48 do
#with_fx :echo, phase: (ring 0.5,0.5,1,2,2,2,4,4)[s1/2], mix: [0.66,0.75].choose do
with_fx :gverb, room: [1,1,1,1,1,2,2,4,8].choose, mix: rrand(0.22,0.5) do
s1=s1+2
with_fx :slicer, phase: [0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,1].choose do
with_fx :pitch_shift, pitch: rrand(-2,2),
window_size: rrand(0.0001,0.01) do
#sample :mySamples__switch, start: 0.5, finish: 0.6,
# amp: rrand(2,3.333),
# pan: rrand(-1,0.8) if one_in(6)
sample sample_switch, start: 0.966, finish: 0.968,
amp: rrand(2.5,3.333) *0.666,
pan: rrand(-1,1) #if one_in(3)
end
end
#end
end
end
end
end
sleep 2 #[0.5,0.5,0.5,1].choose
end
############################################################
sleep 24
with_fx :compressor, slope_below: 1.3, slope_above: 0.7, mix: 0.7 do
############################################################
k2 = 0
live_loop :kick2 do
with_fx :ixi_techno, res: rrand(0.1,0.9), phase: rrand(0.02,0.24),
cutoff_min: rrand(1,99), mix: 0.5 do
with_fx :distortion, distort: rrand(0.2,0.7), mix: 0.4 do
sample :drum_tom_lo_hard, start: rrand(0,0.99), rate: rrand(0.96,0.97),
amp: (ring 0.9,1.0)[k2] *2.5
sample :drum_heavy_kick, rate: 0.9, amp: (ring 0,0.4,0,0.6)[k2/3] *[1.3,1.5].choose
end
end
sleep 1.0 / 2
sleep 4 if one_in(24)
sleep 8 if one_in(36)
k2=k2+1
end # kick2
############################################################
sleep 15
k1 = 0
live_loop :kick do
with_fx :ixi_techno, res: rrand(0.2,0.5), phase: 0.1, cutoff_min: 30, mix: 0.5 do
with_fx :distortion, distort: rrand(0.2,0.7), mix: 0.7 do
sample sample_kick, start: 0.97, rate: rrand(0.94,0.96),
amp: (ring 0.9,0.7)[k1] * 0.8
sample :bd_haus, rate: 0.9, amp: (ring 0,0.4,0,0.6)[k1/3] * 0.8
end
end
sleep (ring 2,2,2,1)[k1] / 2.0
sleep 4 if one_in(32)
sleep 8 if one_in(48)
k1=k1+1
end # kick
#############################################################
sleep 8
b1 = 0
live_loop :beep1 do
if what_sound = 2 or what_sound = 4 or what_sound = 5
if one_in(2)
with_fx :slicer do
with_fx :level, amp: (ring 0.8,0,0.8,0.4)[b1/4] do
b1=b1+1
with_fx :flanger, phase: (ring 1,0.1,2,0.2,0.3,0.4,0.5,1,2)[b1/24] do
4.times do
sample :elec_blip,
amp: rrand(1.4,1.6)
sleep (ring 0.2,0.2,0.4,0.2,0.4,0.4,0.2,0.2) [x] * 2
x = x + 1
end
2.times do
sample [:elec_blip,:elec_blip2].choose,
amp: rrand(1.3,1.6)
sleep (ring 0.2,0.2,0.4,0.2,0.4,0.4,0.2,0.2) [x] * 2
x = x + 1
end
end
end
end
end
end
sleep 2
end
live_loop :beep2 do
if what_sound = 3 or what_sound = 5
if one_in(2)
puts 'go'
with_fx :octaver, mix: [0,1].choose do
with_fx :wobble, phase: [0.5,1,2].choose do
with_fx :vowel, vowel_sound: rrand_i(1,5), voice: 2 do
my_scale = scale([:f,:c].choose, :melodic_minor_asc)
permutations = my_scale.permutation(5)
use_synth [:chiplead,:chipbass].choose
permutations.each do |notes|
play_pattern_timed(notes,1.0/2)
play_pattern_timed(notes,1.0/1)
end
end
end
end
end
end
sleep 2
end
end #compressor
############################################################
sleep 8
live_loop :hat do
sample :drum_cymbal_pedal, finish: rrand(0.2,0.6), amp: 0.7
sleep 0.5
sleep 4 if one_in(36)
end
############################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment