Skip to content

Instantly share code, notes, and snippets.

@mbutz
Last active November 2, 2017 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbutz/17f325110904efdb8f42151e6c6ed1ca to your computer and use it in GitHub Desktop.
Save mbutz/17f325110904efdb8f42151e6c6ed1ca to your computer and use it in GitHub Desktop.
My first Live Coding with Sonic Pi
# Live Coding with Sonic Pi
# Martin Butz, mb@mkblog.org, 2016-09-16
# You will find the complete video session here: https://youtu.be/80Sw7G-4nno
# Live Loops for timing
set_volume! 1
use_bpm 120
live_loop :bar do
sleep 4
end
live_loop :ptn do
sync :bar
sleep 4 * 4
end
run = 1
live_loop :noise_to_music do
sync :bar
use_synth :noise
use_synth_defaults attack: 12, sustain: 12, release: 12
4.times do
with_fx :rbpf, centre: (scale(:c4, :minor_pentatonic, num_octaves: 2).choose), res: 0.97 do
with_fx :slicer, phase: [0.35, 0.65, 0.85].choose do
with_fx :slicer, phase: 0.25, pulse_width: 0.8, smooth: 0.1, invert_wave: 1 do
play :c1, amp: 0.5
end
end
end
sleep 2
end
end
live_loop :hihat do
stop if run == 0
sync :bar
8.times do
if spread(4,8).reverse.tick
sample :drum_cymbal_closed, amp: 0.25
end
sleep 0.5
end
end
live_loop :kick1 do
stop if run == 0
sync :bar
4.times do
if spread(2,4).tick
sample :bd_fat, lpf: 50, amp: 0.5
end
sleep 1
end
end
live_loop :kick2 do
stop if run == 0
sync :bar
16.times do
if spread([5].choose,16).tick
sample :bd_808, lpf: 50, amp: 0.5
end
sleep 0.25
end
end
live_loop :shaker do
stop if run == 0
sync :bar
use_synth :noise
use_synth_defaults release: 0.075
16.times do
with_fx :hpf, cutoff: 115 do
play :c1, amp: 0.25
end
sleep 0.25
with_fx :hpf, cutoff: 100 do
play :c1, amp: 0.15
end
sleep 0.25
end
end
live_loop :bass1 do
use_synth :fm
use_synth_defaults divisor: 2, depth: 1, release: 0.25, cutoff: 50, amp: 0.25
sync :bar
bass_line1 = (ring :c2,:g2,:c3,:bb2)
16.times do
if spread(3,16).tick
play bass_line1.look
end
sleep 0.25
end
end
live_loop :bass2 do
use_synth :fm
use_synth_defaults divisor: 2, depth: 1, release: 0.25, cutoff: 40, amp: 0.25
sync :bar
bass_line2 = (ring :c2,:f1,:bb1,:c3,:eb3,:g2,:c3,:eb3)
16.times do
if spread([3,7,9,11].choose,16).tick
play bass_line2.look
end
sleep 0.25
end
end
live_loop :snare do
stop if run == 0
sync :bar
8.times do
sleep 1
if one_in 3
with_fx :echo, phase: 0.75, decay: 1, mix: 0.5 do
sample :elec_snare, finish: 0.15, hpf: 100, amp: 0.35
end
else
sample :elec_snare, finish: 0.15, hpf: 100, amp: 0.35
end
sleep 1
end
end
live_loop :sare_support do
stop if run == 0
sync :ptn
sleep 30
if one_in 2
with_fx :echo, phase: 0.75, decay: 4, mix: 0.5 do
sample :elec_snare, finish: 0.15, hpf: 100, amp: 0.35
end
sleep 2
end
end
live_loop :chords do
sync :ptn
use_synth :fm
use_synth_defaults divisor: 1, depth: 0.1, release: 0.5, amp: 0.15
with_fx :reverb, room: 1, mix: 0.5 do
64.times do
if spread(3,64).tick
play chord([:c5,:f5,:eb5,:d5,:a5].choose, '7sus4')
end
sleep 0.25
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment