Skip to content

Instantly share code, notes, and snippets.

@nischalshrestha
Last active October 4, 2023 03:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nischalshrestha/74380718a256ec7d4a4460b676bdb987 to your computer and use it in GitHub Desktop.
Save nischalshrestha/74380718a256ec7d4a4460b676bdb987 to your computer and use it in GitHub Desktop.
Sonic Pi Jams
##| Recreating a Colin Bender arppegio pattern from lockdown day 40
##| Cm, Abmaj, Ebmaj, Bdim
##| intervals for readability
root = 0
second = 1
third = 2
fourth = 3
fifth = 4
eighth = 7
tenth = 9
##| the 4 arpeggios
cm = scale(:c5, :minor, num_octaves: 2)
abM = scale(:ab4, :major, num_octaves: 2)
ebM = scale(:eb5, :major, num_octaves: 2)
bdim = chord(:b4, 'm+5', num_octaves: 2).reverse.drop(1).reverse
##| interval pattern for the first 3 arps
indices = [root, third, fifth, third, eighth, fifth, tenth, eighth]
##| the bdim has a slightly different interval pattern
dim_indices = [root, second, third, second, fourth, third, fifth, fourth]
##| setup the scales and intervals list to iterate
scales = [cm, abM, ebM, bdim]
intervals = [indices, indices, indices, dim_indices]
##| constant for the time (0.1 ish is nice but can be too fast for some PCs so change as needed)
note_duration = 0.105
##| loop through the arps!
live_loop :main_arp do
amp = 0.5
s = scales.tick
i = intervals.look
with_fx :reverb, room: 0.8, mix: 0.5 do
with_fx :lpf, cutoff: 0 do
16.times do
note = s[i.tick(:note)]
##| with_synth :saw do
##| play note, amp: amp, attack: 0.025, sustain: 0.01, release: 0.05
##| end
##| with_synth :saw do
##| play note - 12, amp: amp, attack: 0.05, sustain: 0.01, release: 0.05
##| end
##| with_synth :saw do
##| play note - 12 * 2, amp: amp, attack: 0.01, sustain: 0.01, release: 0.08
##| end
with_synth :saw do
play note - 12 * 3, amp: amp, attack: 0.025, sustain: 0.01, release: 0.08
end
##| with_synth :saw do
##| play note - 12 * 4, amp: amp + 0.25, attack: 0.05, sustain: 0.01, release: 0.08
##| end
with_synth :beep do
play note, amp: 0, attack: 0.05, sustain: 0.05, release: 0.01, pan: rrand_i(-1, 1)
end
sleep note_duration
end
end
end
end
live_loop :bass_drum do
with_fx :lpf, cutoff: 90 do
sample :bd_haus, rate: 1, amp: 0
sleep note_duration * 16
end
end
##| chord swells
roots_low = [chord(:c2, :minor), chord(:ab2, :major), chord(:eb2, :major), chord(:b2, 'm+5')]
roots_high = [chord(:c5, :minor), chord(:ab4, :major), chord(:eb5, :major), chord(:b4, 'm+5')]
live_loop :swells do
r1 = roots_low.tick
r2 = roots_high.look
amp = 0.5
with_fx :reverb, room: 0.9, mix: 0.8 do
with_fx :lpf, cutoff: 0 do
with_synth :saw do
play r1, amp: amp, attack: 0.2, sustain: 0.5, release: 1, pan: -0.5
end
with_synth :saw do
play r1, amp: amp, attack: 0.4, sustain: 0.5, release: 1, pan: 0.5
end
with_synth :saw do
play r2, amp: amp + 0.5, attack: 0.5, sustain: 0.1, release: 1, pan: 0
end
end
sleep note_duration * 16
end
end
@sinewalker
Copy link

I especially like these techniques in your code!

  • additive synthesis in the :main_arp live loop, by toggling voices with comments
  • the way that the code is laid out so that you can see the parameters, much like a modular synth patch board
  • use of cutoff: to fade in/out parts is a nice change from using amp: for that effect
  • in the demonstration video (which brought me here), the kick drum is ever so slightly faster (rather than note_duration), making it phase across the beat with the chord swells, and I thought that was really cool.

@nischalshrestha
Copy link
Author

Thanks for your kind words @sinewalker!

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