Skip to content

Instantly share code, notes, and snippets.

@WindowDump
Created January 30, 2023 23:55
Show Gist options
  • Save WindowDump/62bd1618b16f7f0a0a58f832f8c1cb2f to your computer and use it in GitHub Desktop.
Save WindowDump/62bd1618b16f7f0a0a58f832f8c1cb2f to your computer and use it in GitHub Desktop.
demo of a sonic pi song
live_loop :root_setter do
#chords = ring(:e3, :e3, :ab2, :ab2, :db3, :db3, :b2, :ab2, :e3, :e2, :gb3, :gb3, :ab2, :db3, :b2)
#chords = ring(:e3, :e3, :ab3, :ab2, :db3, :db3, :b2, :ab2, :gb3, :gb3, :ab3, :b2, :gb3, :ab2, :db3, :b2)
chords = ring(:e3, :e3, :db3, :b2, :gb3, :gb3, :e3, :db3, :e3, :e3, :gb3, :gb3, :ab3, :ab3, :gb3, :b2)
#chords = ring(:e3, :e3, :gb3, :gb3, :ab3, :ab3, :gb3, :b2)
set :root, chords.tick
sleep 3.9
sync :kick
end
live_loop :kick do
kick_vol = 0.5
sample :bd_haus, amp: kick_vol
sleep 0.25
#if one_in(18)
#sample :bd_haus, amp: 0.4
#end
#sleep 0.10
force_triple = false
if one_in(6)
sample :bd_haus, amp: kick_vol
if one_in(12)
force_triple = true
end
end
sleep 0.15
if one_in(12) or force_triple
sample :bd_haus, amp: kick_vol
end
sleep 0.10
end
with_fx :reverb, room: 1, damp: 0.8 do
with_fx :echo, mix: 0.5, pre_mix: 0.5, phase: 0.25, decay: 1.5, max_phase: 4 do
live_loop :snare do
sync :kick
sleep 0.5
sample :sn_dolf, amp: 0.3
sample :drum_snare_hard, amp: 0.1
if knit(false, 1, true, 1).tick(:snare_no_tap) and one_in(4)
sleep 1.0
else
if knit(true, 1, false, 1).tick(:snare_third_tap)
sleep 0.40
else
sleep 0.25
sample :drum_snare_soft, amp: 0.5
sleep 0.15
end
sample :drum_snare_soft, amp: 0.5
sleep 0.35
sample :drum_snare_soft, amp: 0.5
sleep 0.25
end
sample :sn_dolf, amp: 0.3
sample :drum_snare_hard, amp: 0.1
sleep 0.4
end
end
end
with_fx :reverb, amp: 0.8, room: 1, damp: 0.5 do
ride = :drum_cymbal_soft
closed = :drum_cymbal_closed
open = :drum_cymbal_open
pedal = :drum_cymbal_pedal
with_fx :echo, mix: 0.5, pre_mix: 0.5, phase: 0.25, decay: 0.5, max_phase: 4 do
live_loop :splash, delay: 0.5 do
sample :drum_splash_hard, amp: 0.5
sleep 7.9
sync :kick
end
live_loop :ride do
sync :kick
sample ride, amp: 0.3
if knit(true, 3, false, 4).tick
sleep 1.9
else
sleep 0.4
end
end
live_loop :hats do
sync :kick
sample closed, amp: rrand(0.28, 0.32)
sleep 0.15
if one_in(2)
sample closed, amp: rrand(0.28, 0.32)
end
sleep 0.10
sample closed, amp: rrand(0.28, 0.32)
# don't dampen open for random interest
if one_in(4)
sample open, amp: 0.2
if one_in(2)
sleep 0.15
sample closed, amp: rrand(0.28, 0.32)
sleep 0.09
else
sleep 0.24
# randomly stop for added funkyness
if one_in(2)
sync :kick
sleep 0.49
end
end
else
sample open, amp: rrand(0.18, 0.24), sustain: 0.11, release: 0.05
sleep 0.15
sample closed, amp: rrand(0.28, 0.32)
sample pedal, amp: 0.3
sleep 0.09
end
end
end
end
use_synth :chiplead
live_loop :lead_lick do
#sync :splash
with_fx :reverb, amp: 0.6, mix: 0.1, room: 1.0, damp: 0.5 do |reverb|
use_synth_defaults amp: 0.6, width: 1, decay: 0.05, sustain_level: 0.9, release: 0.04
root = get[:root] + 24
sync :kick
# bar 1
swing_factor = rrand(0.0, 0.01)
if knit(true, 3, false, 1).tick(:first_slide)
if knit(true, 1, false, 1, true, 1).tick(:higher)
note = root
play note, sustain: 0.15
sleep 0.25
else
if ring(false, false, false, true).tick(:first_spike)
note = root + 7
else
note = root + 5
end
play note, amp: 0.3, sustain: 0.05
sleep 0.15 + swing_factor
note = root + 3
play note, amp: 0.4, sustain: 0.01
sleep 0.1 - swing_factor
end
else
note = root
s = play note + 5, note_resolution: 1.0, sustain: 0.2, note_slide: 0.15, note_slide_curve: -10
sleep 0.1
control s, note: note - 2
sleep 0.15
end
note = root - 2
play note, sustain: 0.05
sleep 0.15 + swing_factor
note = root - 2
play note, sustain: 0.01
sleep 0.1 - swing_factor
# bar 2
swing_factor = rrand(0.0, 0.01)
note = root - 5
play note, sustain: 0.1
sleep 0.15 + swing_factor
note = root - 7
play note, sustain: 0.15
sleep 0.25
note = root + 2
play note, amp: 0.4, sustain: 0.15
sleep 0.1 - swing_factor
# bar 3
swing_factor = rrand(0.0, 0.01)
sleep 0.15 + swing_factor
note = root - 2
play note, sustain: 0.01
sleep 0.1 - swing_factor
note = root - 7
play note, sustain: 0.05
sleep 0.15 + swing_factor
note = root - 12
play note, sustain: 0.01
sleep 0.1 - swing_factor
# bar 4
swing_factor = rrand(0.0, 0.01)
if knit(true, 1, false, 1).tick(:stinger)
note = root + 5
play note, amp: 0.3, sustain: 0.05
sleep 0.25
note = root + 2
play note, amp: 0.4, sustain: 0.05
sleep 0.15 + swing_factor
note = root + 3
play note, amp: 0.4, sustain: 0.05
sleep 0.05
else
note = root + 5
play note, amp: 0.3, sustain: 0.15
sleep 0.45
end
end
end
use_synth :chiplead
live_loop :mid_riff do
root = get[:root] + 12
with_fx :reverb, reps: 1, amp: 0.30, mix: 0.1, room: 1.0, damp: 0.5 do
with_fx :rlpf, reps: 4, amp: 1.0, cutoff: root + 12, res: 0.5 do
sync :kick
use_synth_defaults amp: 1.0, decay: 0.05, sustain_level: 0.8, release: 0.025, width: 0
note = root
if knit(true, 4, false, 4).tick(:mrroot)
mrc = ring(root)
else
if knit(true, 4, false, 4).tick(:mrtype)
mrc = chord(root, 'dom7')
else
mrc = chord(root, '7-5').shuffle
end
end
beep = play mrc.tick(:mrc), sustain: 0.15
sleep 0.25
comment do
# weird sounding euroarps
beep = play note, sustain: 0.15, note_slide: 0.10, note_resolution: 2.0, note_slide_curve: 0
control beep, note: note + 7
sleep 0.10
control beep, note: note, note_slide: 0
control beep, note: note + 7, note_slide: 0.10
sleep 0.10
control beep, note: note, note_slide: 0
control beep, note: note + 7, note_slide: 0.10
sleep 0.05
end
kill beep
note = root - 5
play note, amp: 0.5, decay: 0, sustain: 0.05
sleep rrand(0.15, 0.16)
note = root - 5
play note, amp: 0.5, decay: 0, sustain: 0.05
#sleep 0.09
end
end
end
use_synth :organ_tonewheel
live_loop :pad_organ do
#stop
root = get[:root] + 36
use_synth_defaults amp: 1.0, attack: 0.05, decay: 0.1, sustain: 3.6, sustain_level: 0.9, release: 0.1, rs_freq_var: 0.5, hard: 0.9, vel: 0.1
with_fx :reverb, amp: 0.04, mix: 0.5, room: 1.0, damp: 0.5 do
with_fx :distortion, amp: 0.6, pre_amp: 2.0, distort: 0.95 do
#with_fx :krush, amp: 0.4, gain: 5, cutoff: root + 12, res: 0.7 do
sync :kick
#play chord(root, 'major', invert: 0)/
play root, nazard: 4, blockflute: 2, tierce: 1, larigot: 1, sifflute: 1
sleep 3.9
end
end
end
use_synth :chipbass
use_synth_defaults amp: 1.0, decay: 0.05, sustain_level: 0.8, release: 0.025
set :bass_counter, 0
set :bass_hit, false
define :bass_next do |notes, nrlpf, duration|
n = notes[get[:bass_counter]]
set :bass_counter, inc(get[:bass_counter])
control nrlpf, amp: get[:bass_amp], cutoff: n+get[:bass_cutoff], res: 0.1
set :bass_hit, false
play n, sustain: duration
end
define :bass_slap do |notes, nrlpf, duration|
# slap that bass! ouuuuu
n = get[:root]
control nrlpf, amp: get[:bass_amp] * 0.70, cutoff: n+get[:bass_cutoff]+12, res: 0.4
set :bass_hit, true
play n, sustain: duration
end
define :bass_peek do |notes, nrlpf, duration|
n = notes[get[:bass_counter]]
control nrlpf, amp: get[:bass_amp], cutoff: n+get[:bass_cutoff], res: 0.2
set :bass_hit, false
play n, sustain: duration
end
define :tri_quarter do |notes, nrlpf, first|
if first or not one_in(4)
if not first and one_in(4) and not get[:bass_hit]
bass_slap notes, nrlpf, 0.15
else
bass_next notes, nrlpf, 0.15
end
end
sleep 0.25
# play 8th note
if one_in(2)
if one_in(4) and not get[:bass_hit]
bass_slap notes, nrlpf, 0.15
else
bass_next notes, nrlpf, 0.15
end
set :bass_hit, true
else
# two 16ths
if one_in(3)
bass_next notes, nrlpf, 0.05
else
if one_in(4)
set :bass_hit, true
else
set :bass_hit, false
end
end
end
sleep knit(0.15, 2, rrand(0.15, 0.16), 1).choose
#sleep rrand(0.15, 0.16)
# play 16th
if not get[:bass_hit]
bass_next notes, nrlpf, 0.04
end
end
define :tri_triple do |notes, nrlpf|
# do triplets i guess, remember to swing
swing_factor = rrand(0.005, 0.015)
sleep_amount = 0.5/3 + swing_factor
bass_next notes, nrlpf, 0.1
sleep sleep_amount
if one_in(4) and not get[:bass_hit]
bass_slap notes, nrlpf, 0.1
set :bass_counter, inc(get[:bass_counter])
else
bass_next notes, nrlpf, 0.1
end
sleep sleep_amount
if one_in(5) and not get[:bass_hit]
bass_slap notes, nrlpf, 0.045
set :bass_counter, inc(get[:bass_counter])
else
bass_next notes, nrlpf, 0.045
end
end
define :tri_variation do |notes, nrlpf|
if one_in(24) and false
tri_triple notes, nrlpf
else
if one_in(6)
tri_straight notes, nrlpf
else
tri_quarter notes, nrlpf, false
end
end
end
define :tri_slap do |notes, nrlpf|
bass_next notes, nrlpf, 0.15
sleep 0.25
bass_slap notes, nrlpf, 0.15
end
define :tri_straight do |notes, nrlpf|
bass_next notes, nrlpf, 0.15
sleep 0.25
bass_next notes, nrlpf, 0.15
end
with_fx :distortion, amp: 0.6, distort: 0.6 do
live_loop :tri_groove do
set :bass_cutoff, 24
set :bass_amp, 0.35
use_synth_defaults amp: 1.0, decay: 0.05, sustain_level: 0.8, release: 0.025
with_fx :nrlpf, reps: 4, amp: get[:bass_amp] do |nrlpf|
arp_ct = ['7', 'dom7', 'm7', 'm7', '7', 'dom7', '7sus4', '7sus2'].ring
if knit(true, 1, false, 7).tick(:c_changed)
arp_ct.tick(:arp_ct)
chord_changed = true
else
chord_changed = false
end
if knit(true, 12, false, 2, true, 2, true, 12, false, 4).tick(:note_invert)
notes = chord(get[:root]-24, arp_ct.look(:arp_ct), invert: 1).take_last(3)
else
notes = chord(get[:root]-24, arp_ct.look(:arp_ct), invert: 1).take_last(3).reverse
end
sync :kick
if knit(true, 4, false, 4).tick(:bass_freestyle)
# rhythm mode
bass_next notes, nrlpf, 0.15
sleep 0.25
if one_in(4)
bass_slap notes, nrlpf, 0.10
else
bass_next notes, nrlpf, 0.10
end
sleep knit(0.15, 2, rrand(0.15, 0.16), 1).choose
if knit(false, 7, true, 1).tick(:reset_bass)
if one_in(2) and not get[:bass_hit]
bass_slap notes, nrlpf, 0.045
end
set :bass_counter, 0
end
else
# freestyle mode
if knit(true, 1, false, 3).tick(:force_quarter)
tri_quarter notes, nrlpf, true
else
if knit(true, 10, false, 2).tick(:variation)
if one_in(4)
tri_straight notes, nrlpf
else
tri_variation notes, nrlpf
end
else
tri_slap notes, nrlpf
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment