Skip to content

Instantly share code, notes, and snippets.

@jindrichmynarz
Created December 14, 2021 20:59
Show Gist options
  • Save jindrichmynarz/e9f29dbc5f894802dd0be71df140cbf3 to your computer and use it in GitHub Desktop.
Save jindrichmynarz/e9f29dbc5f894802dd0be71df140cbf3 to your computer and use it in GitHub Desktop.
Live-coding in Sonic Pi at Tech4Good online meet-up
### Sonic Pi
### The Live Coding Music Synth for Everyone
### https://sonic-pi.net
use_debug false
use_bpm 80
drum_mix = 1
bass_mix = 1
synth_mix = 1
# play 50
# play :d3
# synth :sine, note: 50
define :kick do |amp = 1|
k = synth :sine, note: 50, amp: amp, attack: 0.01,
decay: 0.2, release: 0.1, note_slide: 0.05
control k, note: 33
end
live_loop :bar do
sleep 4
end
live_loop :kick, sync: :bar do
if bools(1, 0, 1, 0, 1, 0, 1, 1).tick then
kick 0.8 * drum_mix
end
sleep 0.5
end
define :hat do |amp = 1|
with_fx :rhpf, cutoff: 120 do
synth :pnoise, amp: amp, attack: 0.02, release: 0.1
end
end
live_loop :hats, sync: :bar do
sleep 0.5
hat drum_mix
sleep 0.5
end
live_loop :more_hats, sync: :bar do
if (spread(9, 24) + spread(5, 8)).tick then
hat 0.4 * drum_mix
end
sleep 0.25
end
live_loop :ohat, sync: :bar do
sleep 0.5
with_fx :rhpf, cutoff: 126 do
synth :noise, attack: 0.02, sustain: 0.1, release: 0.2,
amp: 0.5 * drum_mix, pan: [-0.5, 0.5].tick
end
sleep 0.5
end
live_loop :snare, sync: :bar do
sleep 1
with_fx :reverb, mix: [0, 0, 0, 0, 0, 0, 0, 0.7].tick, room: 0.99 do
sample :sn_dolf, start: 0.1, finish: 0.5, amp: [0.5, 0.7].look * drum_mix
end
sleep 1
end
bass_notes = [:f1, :a1, :d1, :d1]
live_loop :bass, sync: :bar do
if (spread(3, 24).rotate(10) + spread(5, 8).rotate(2)).tick then
synth :fm, note: bass_notes.look, amp: bass_mix, decay: 0.3, release: 0.3, divisor: 1, depth: 2
end
sleep 0.25
end
live_loop :synth, sync: :bar do
sleep 0.5
synth :saw, note: chord(:d2, :minor, num_octaves: 2),
decay: 0.2, release: 0.1, amp: 0.5 * synth_mix, pan: [-0.5, 0.5].tick
sleep 1.5
end
pad_cutoffs = range(80, 120, 0.5).reflect
pad_chords = stretch([:minor, :minor7], 4)
live_loop :pads, sync: :bar do
synth :dark_ambience, note: chord(:d3, pad_chords.look), amp: synth_mix,
attack: 2, decay: 4, release: 4, room: 90, res: 0.9,
noise: 1, cutoff: pad_cutoffs.tick, detune1: 0.1
sleep 8
end
live_loop :beeps, sync: :bar do
with_fx :krush do
synth :beep, note: :d2, decay: 0.1, release: 0.1, amp: 0.3 * synth_mix
end
sleep 1.5
end
ping_melody = [[:d4, 1.5],
[:d4, 1],
[:d4, 0.25],
[:c4, 0.5],
[:d4, 0.5],
[:c4, 0.5],
[:d4, 2.75]]
live_loop :ping, sync: :bar do
with_fx :reverb, room: 0.9 do
with_fx :whammy, grainsize: [0.001, 0.01, 0.1].tick do
with_synth :chiplead do # :sine
with_synth_defaults decay: 0.1, release: 0.1, amp: 0.3 * synth_mix, width: rand_i(2), pan: -0.5 do
ping_melody.each do |n, s|
play n
sleep s
end
n = play :d2, decay: 2, note_slide: 2
control n, note: :d1
sleep 1
end
end
end
end
end
# Echo of ping
pong_melody = [[:d3, 0.25],
[:d3, 0.75],
[:c4, 0.75],
[:d3, 1.75]]
live_loop :pong, sync: :ping do
sleep 4.5
with_fx :reverb, room: 0.9 do
with_fx :bitcrusher, bits: 4, amp: 0.3 * synth_mix do
pong_melody.each do |n, s|
synth :dsaw, note: n, decay: 0.1, release: 0.1, pan: 0.5
sleep s
end
end
end
end
##| set_mixer_control! amp: 0, amp_slide: 64
##| set_mixer_control! lpf: 30, lpf_slide: 32
@ekid
Copy link

ekid commented Jan 31, 2022

nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment