Last active
November 2, 2017 19:19
-
-
Save mbutz/324f11fa3f395427a72298a62d755ef6 to your computer and use it in GitHub Desktop.
Live Coding with Sonic Pi, 2016-10-15, Ambient Tune
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some Live Coding with Sonic Pi | |
# Using Emacs, sonic-pi.el (thanks to Joseph Wilk) and some home-baked Guitar Samples | |
# I also use snippets to speed things up ... | |
# Video of the session: https://www.youtube.com/watch?v=3zGt-1JSfgA | |
use_bpm 120 | |
# Download samples at: http://www.mkblog.org/download/samples-sonicpi-lc-2016-10-15.zip | |
path = "/PATH/TO/SAMPLES/" | |
# Some home-baked Guitar Samples | |
wave = "guit-a-g-01.wav" | |
robin = "guit-chord-am4.wav" | |
merl = "guit-echo-03.wav" | |
bordun = "guit-quarten.wav" | |
# Timing | |
live_loop :metro do | |
sleep 0.5 | |
end | |
live_loop :bar do | |
sleep 4 | |
end | |
# A wave-like sound | |
live_loop :wave do | |
stop | |
sync :bar | |
sample "#{path}#{wave}", amp: 0.05, rate: 1.026 | |
#sample "#{path}#{wave}", amp: 1.25, pitch_stretch: 16, rate: 1.026*2, pitch_dis: 0.001, time_dis: 0.001 | |
#sample "#{path}#{wave}", amp: 1.75, pitch_stretch: 16, rate: 1.026*4, pitch_dis: 0.001, time_dis: 0.001 | |
sleep 4 | |
end | |
# Sporadic Insertions | |
live_loop :bird do | |
stop | |
sync :bar | |
sleep 8 | |
with_fx :reverb, room: 1, mix: 1 do | |
with_fx :band_eq, freq: hz_to_midi(1200), res: 0.1, db: 12 do | |
with_fx :bpf, centre: hz_to_midi(1200), res: 0.1 do | |
sample "#{path}#{merl}", amp: 1.5, rate: 2.0125, pitch_stretch: 16, pitch: [-7,-5,0].choose, attack: 1.5 | |
end | |
end | |
end | |
sleep [8,16,32].choose | |
end | |
# The Bordun Sample sound like Bells | |
live_loop :bells do | |
stop | |
sync :bar | |
with_fx :hpf, cutoff: 90 do | |
sample "#{path}#{bordun}", amp: 0.5, rate: 1.425, pitch_stretch: [8,12,16].choose, pitch: [0, 0,-0,-2,-7].choose | |
end | |
sleep 4 | |
end | |
# Spheric Melody | |
live_loop :hassel do | |
stop | |
sync :bar | |
vol = 0.25 # transpose 12 > 0.1 | |
vol = 0.15 | |
# divisor 4: vol 0.075, transpose 24 | |
# divisor 2: vol 0.075, transpose 0 | |
# divisor 1: vol 0.075, transpose 0 | |
use_synth :fm | |
use_synth_defaults divisor: 1, depth: 1, attack: 2, release: 4, amp: vol | |
#use_synth :dsaw | |
#use_synth_defaults detune: 0.005, cutoff: 90 | |
with_fx :echo, phase: 16, decay: 1, mix: 0.75 do | |
with_fx :reverb, room: 0.5, mix: 0.5 do | |
with_fx :vowel, vowel_sound: 2, voice: 4 do # voice: 1, 2, 4, 5; vowel: 1, 2, 3, 4 | |
with_transpose 0 do | |
# play :e5, attack: 4, sustain: 5, release: 5, amp: vol | |
# sleep 8 | |
# play :d5, attack: 4, sustain: 5, release: 5, amp: vol | |
# sleep 8 | |
play :g4, attack: 4, release: 4, amp: vol - vol*0.25 | |
sleep 6 | |
play :fs4, attack: 8, release: 4, amp: vol - vol*0.25 | |
sleep 6 | |
play :e4, attack: 8, release: 4, amp: vol - vol*0.25 | |
sleep 8 | |
play :d4, attack: 8, release: 4, amp: vol - vol*0.25 | |
sleep 8 | |
play :a3, attack: 8, release: 4, amp: vol - vol*0.25 | |
sleep 8 | |
play :b3, attack: 8, release: 10, amp: vol + vol*0.25 | |
sleep 4 | |
# play :fs4, attack: 8, sustain: 0, release: 14, amp: vol + vol*0.25 | |
# sleep 4 | |
# play :g4, attack: 8, sustain: 0, release: 14, amp: vol + vol*0.25 | |
end | |
end | |
end | |
end | |
sleep 16 | |
end | |
# The basic Bass | |
live_loop :bass1 do | |
stop | |
sync :bar | |
use_synth :fm | |
use_synth_defaults divisor: 1, depth: 1, attack: 0, release: 0.5, amp: 1 | |
with_fx :band_eq, freq: hz_to_midi(200), res: 0.25, db: -10 do | |
vol = 1.5 | |
if one_in(4) | |
play :g1, amp: vol | |
sleep 0.25 | |
play :g1, amp: vol - vol*0.33 | |
sleep 0.75 | |
sleep 0.75 | |
play :g1, amp: vol | |
sleep 2.25 | |
elsif | |
play :e1, amp: vol | |
sleep 0.25 | |
play :e1, amp: vol - vol*0.33 | |
sleep 0.75 | |
sleep 0.75 | |
play :e1, amp: vol | |
sleep 2.25 | |
end | |
play :a1, amp: vol | |
sleep 0.25 | |
play :a1, amp: vol - vol*0.33 | |
sleep 0.75 | |
sleep 0.75 | |
play :a1, amp: vol | |
sleep 2.25 | |
end | |
end | |
# A second accentuating Bass Line | |
bass2_line = (ring :r, :c2, :r, :c2, :a2, :a2, :r, :c2) | |
live_loop :bass2 do | |
stop | |
sync :bar | |
use_synth :fm | |
use_synth_defaults divisor: 1, depth: 0.75, attack: 0, release: 0.15, amp: 0.5, cutoff: 100 | |
with_fx :band_eq, freq: hz_to_midi(400), res: 0.25, db: -10 do | |
16.times do | |
if spread([5,7,9,9,11].choose,16).tick | |
play bass2_line.look | |
end | |
sleep 0.25 | |
end | |
end | |
end | |
# My standard noisy Hihat | |
live_loop :hihat_base do | |
stop | |
sync :bar | |
16.times do | |
with_synth :cnoise do | |
with_synth_defaults release: 0.075, amp: 0.35, pan: 0.25 do | |
with_fx :hpf, cutoff: 120 do | |
play :c | |
end | |
end | |
end | |
sleep 0.25 | |
end | |
end | |
# My standard accentuating noisy Hihat | |
live_loop :hihat do | |
stop | |
sync :bar | |
16.times do | |
if spread([15, 9, 5].choose, 16).reverse.tick | |
with_synth :cnoise do | |
with_synth_defaults release: 0.075, amp: 0.5, pan: -0.25 do | |
with_fx :hpf, cutoff: 120 do | |
play :c | |
end | |
end | |
end | |
end | |
sleep 0.25 | |
end | |
end | |
# A noisy Snare, Sound controlled by cutoff | |
live_loop :snare do | |
stop | |
sync :bar | |
with_synth :cnoise do | |
with_synth_defaults release: 0.05, amp: 0.5, pan: 0 do | |
with_fx :hpf, cutoff: 110 do | |
sleep 1 | |
with_fx :echo, phase: 0.75, decay: 1, mix: [0,0,0.5].choose do | |
play :c | |
end | |
sleep 2 | |
with_fx :echo, phase: [0.25,0.75].choose, decay: 2, mix: [0,0,0.25].choose do | |
play :c | |
end | |
sleep 1 | |
end | |
end | |
end | |
end | |
# A simple Bass Drum, acctually only supporting the percussive Bass Line 2 | |
live_loop :bass_drum do | |
stop | |
sync :bar | |
4.times do | |
sample :bd_ada, amp: 0.4, rate: 0.75 | |
sleep 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment