Journal

100 live-loops

Cet article n’existe qu’en anglais.

A challenge to practice Sonic Pi by publishing 100 live-loops in 30 days, with the first fifteen loops.

Part of the Sonic Pi notebook, 2016–2018.

100 Live-Loops is a challenge I made for myself in order to practice Sonic Pi and to discover new sounds and coding structures. The goal is to publish 100 live-loops in 30 days. Feel free of course to use, modify, copy.

Be warned that some loops might be written in odd or inefficient ways and most loops are merely sound design experiments  Some live-loops require external samples, the samples are provided if the license allow me to share them.

1. Random percs

This snippet is based a lot on randomized patterns, you can change the global seed by changing the value of the a variable. This will change the sample selection and the played patterns.It required external samples, basically each sample line, looks into a directory and selects a random selection of samples. for this second example I’m afraid I can’t share the samples as they come from a pack I bought a long time ago from https://www.zenhiser.com/.
Feel free to share any fork you make of those loops !

There is some fx control to bring more chaos into the loop.

live_loop :breakbeatgenerator do
with_fx :level, amp: 1 do
#stop
tick
a = 925
b = a/2
c = b/2
d = c/2
verb = 0.5
verb = rrand(0.6, 0.8) if look == 4 or look == rrand_i(4, 12) or look == 9
crushed = 0
crushed = 1 if look == 3 or look == 5 or look == 9
with_fx :slicer, phase: 0.125, mix: 0.9, amp_min: 0.5 do
use_random_seed (stretch [a], 4, [b], 4, [a], 2, [c], 6, [b], 2, [d], 8, [a], 2, [c], 4).look
with_fx :bitcrusher, sample_rate: 44100, sample_rate_slide: 0.125, mix: crushed do |fx|
with_fx :reverb, room: 1, room_slide: 1, mix: crushed do |fx2|
8.times do
control fx, sample_rate: rrand_i(2000, 5000)
control fx2, room: 0.5
sample sd,dice(7) + 21, lpf: rrand_i(50, 120) if one_in(3)
sample sd2,dice(5), pitch: rrand(5, 12) if one_in(3)
sample cy,dice(20), rate: [-1, 1].choose if one_in(8)
sample bd,dice(6)+ 4, amp: 01 if one_in(7)
sample perc,dice(20), hpf: 90 if one_in(6)
sample hh,dice(20), amp: rrand(0.4, 0.8) if one_in(5)
sample sd2,dice(5), pitch: rrand(5, 12) if one_in(12)
sample cy,dice(20), rate: [-1, 1].choose if one_in(15)
sample bd,dice(6)+ 4, amp: 01 if one_in(7)
sample perc,dice(20), hpf: 90 if one_in(21)
sample hh,dice(20), amp: rrand(0.4, 0.8) if one_in(2)
time_warp 0.0 do
sample bd, dice(20), lpf: rrand_i(40, 120) if one_in(4)
end
sleep 0.125
end
end
end
end
end
end

2. Calm

An eerie melody with a lot of transpositions, pitchshift allows for live frequency modulation with a single control.
Does not require external samples.

live_loop :calm do
#stop
tick
with_fx :pitch_shift, pitch: 0 do
with_transpose (stretch [0, 3, 7, 9, -12, -9, -5, -3], 1).look do
with_fx :echo, phase: 1 do
density 2 do
with_fx :hpf, cutoff: 70 do
with_fx :reverb, mix: 1, room: 1, damp: 0.9 do
use_synth :mod_fm
use_synth_defaults mod_phase: 2, divisor: (stretch [0.5, 1, 4], 16).look
play_pattern_timed [:c4, :f4, :ab5, :c5, :ab5, :f4, :ab6, :c4],
[0.25, 0.5, 0.25, 0.75, 0.25], amp: 0.05
sleep 0.25
end
end
end
end
end
end
end

3. Daniellea

Playing with loop_ samples and making them change overtime.
Does not require external samples.

live_loop :daniellea do
with_fx :level, amp: 1 do
beatlenght = (ring 16, 8, 4, 1).tick
echophase = (stretch [1, 0.125], 32 ).look
tick
#stop
with_fx :echo, phase: echophase do
with_fx :panslicer, phase: 4, mix: 0.75 do
cutoff = (line 60, 120, steps: 16).look
sample :loop_tabla, onset = pick, beat_stretch: beatlenght, lpf: cutoff
sleep 1
if echophase == 0.125 then
sample :bd_tek, rate: -1, lpf: 90
sample :bd_gas, rate: -0.5, lpf: 80
end
end
end
end
end

4. Hesitating

Does not require external samples.

live_loop :hesitating do
#stop
with_fx :level,amp: 0.1 do
with_fx :reverb , room: 0.99, mix: 0.99, damp: 1 do
with_fx :ixi_techno, phase: 1, cutoff_max: 100, cutoff_min: 20, res: 0.75, mix: 0.4 do
use_synth [:blade, :pretty_bell].choose
use_synth_defaults
with_transpose (stretch [-12, 12, 0, 12], 16).tick do
play choose([69,72,76,77]) ,amp: 0.3, attack: 0.0, sustain: 0.1, release: 0.1
play choose([69,72,76,77]) + 24 ,amp: 0.3, attack: 0.0, sustain: 0.1, release: 0.1
play choose([69,72,76,77]) + 36,amp: 0.3, attack: 0.0, sustain: 0.1, release: 0.1
sleep choose([0.0625,0.25,0.375,0.125,0.125])
end
end
end
end
end

5. Buzz

A slowly evolving buzz with an overuse of fxs.
Does not require external samples.

live_loop :buzz do
tick
#stop
with_fx :pitch_shift, pitch: 12 do
with_fx :ring_mod, freq: [0.125, 0.5, 1, 2].choose do
with_fx :level, amp: 0.1 do
with_fx :slicer, phase: 8, mix: 0.25 do
with_fx :band_eq, db: 40, freq: 80 do
with_fx :reverb do
with_fx :octaver, super_amp: 2, sub_amp: 0.5, subsub_amp: 0.25, mix: 0.25 do
s = synth :dsaw, note: chord((stretch [:e1, :fb2], 32).look, :minor).look, release: 8, attack: 4, detune_slide: 8
control s, detune: 1.05
sleep 4
end
end
end
end
end
end
end
end

6. Benoix XVI

A slow moving organ type sound with some added noise. Additive synthesis & resonant low pass filter
Does not require external samples.

live_loop :benoixXVI do
tick
with_fx :lpf, cutoff: 90 do
notelist = (ring 69,72,76,77).look + 12
a = chord(notelist, :minor, num_octaves: 2)
pw = 0.17
with_fx :rlpf, res: 0.33 do
with_fx :reverb, mix: 0.9 do
with_fx :tanh, mix: 0.2 do
use_synth :pulse
use_synth_defaults pulse_width: pw, release: 4, attack: 4
play a
play a-12
play a+24
play a+0.1
synth :mod_tri, note: a-12, release: 8, mod_wave: 1, amp: 0.2
synth :tri, note: a-12, release: 2, attack: 4
synth :noise, cutoff: 90, amp: 0.1
sleep 8
end
end
end
end
end

7. Crushed !

A bitcrusher destroyed pattern, lpf & sample_rate controls are fun to play with in live conditions.
Does not require external samples, but used some defines (not present in the code) to load sonic-pi samples with custom attributes.

live_loop :pattern2 do
#stop
with_fx :bitcrusher, sample_rate: 100, mix: 0 do
with_fx :lpf, cutoff: 120 do
with_fx :compressor, pre_amp: 400, slope_above: 4, slope_below: 1.25 do
with_fx :wobble, phase: 1, cutoff_max: 125, res: (line 0.95, 0.98, steps: 16).look do
tick_reset if look >= 7
tick
closed
ride
kick if look % 8 == 0 or look % 8 == 5
snare if look % 8 == 2 or look % 8 == 6
time_warp 0.15 do
closed_silent if look % 8 == 5 or look % 8 == 6
end
sleep 0.25
end
end
end
end
end

8. Moo

live_loop :moo do
with_fx :reverb do
#stop
tick
density (stretch [1, 2], 2).look do
with_fx :slicer, mix: (ring 0.9,0.25).look, phase: (stretch [1, 0.75, 0.5], 16).look do
with_transpose (ring 0,3).look do
keya = (stretch [1, 2, 4], 4).look
keyd = (stretch [4, 5, 6], 16).look
degreelist = (ring keya, 2, 6, keyd).look
octaves = (stretch [:g4, :g3, :g5, :g6], 16).look
synth :fm, note: degree(degreelist, octaves, :blues_minor), release: (ring 0.5,0.125).look, amp: 1
synth :fm, note: (ring :g4, :bb4).look, amp: 1, release: 2 if look % 8 == 0
synth :fm, note: degree(degreelist, :g2, :blues_minor), release: (ring 1,0.125).look, amp: 0.5
sleep (ring 0.25, 0.375, 0.125, 0.5).look
end
end
end
end
end

9. Distorted kicks

live_loop :distorted_kicks do
#stop
tick
with_fx :level, amp: 4 do
with_fx :krush, mix: 0.1 do
with_fx :flanger, delay: 0.25, wave: 4, depth: rrand(80, 120), phase: 0.125, mix: 0.25 do
sample :bd_klub, lpf: 120
with_fx :rlpf, res: 0.0 do
sample :bass_hit_c, release: 4, lpf: 100 ## lpf
with_fx :flanger, wave: 4, depth: rrand(80, 120), phase: 0.125, mix: 0.25 do
sample :bd_klub, release: 4, lpf: 120
with_fx :rlpf, res: 0.99 do
sample :bd_pure, release: 4, lpf: 100#, amp: 32
end
end
end
sleep 0.375
end
end
end
end

10. osc control via vvvv

This one is a bit different as it’s my first attempt to control Sonic-Pi using osc controls. I made a little patch with my favorite prototyping software aka vvvv. The code nor the sound itself is impressive on it’s own and probably could be rewritten in a more optimised way. My Ruby knowledge is limited so bare with me.
I’m sending a spread of 8 values from vvvv : 1 note value (nt), 1 control value (va), 1 cutoff value (co), 1 sample rate value (sr) and a list of 4 notes (ch).
Those are unpacked in sonic-pi using osc_in[0] to get the first value or osc_in.last(4) to get the chord notes values. osc_in = sync “/vvvv” is the main clock, updated each time I send a value from vvvv.
You can download the vvvv patch here, it’s undocumented but should be quite easy to understand. Remember that sonic-pi receives messages on the 4559 port.

live_loop :osc_control do
tick_reset if look >= 8
tick
use_synth :pretty_bell
osc_in = sync "/vvvv"
#puts osc_in
nt = osc_in[0]
va = osc_in[1]
co = osc_in[2]
sr = osc_in[3]
ch = osc_in.last(4)
puts ch
with_fx :lpf, cutoff: co do
play nt
end
sample :drum_cymbal_closed, amp: 0.25
sample :bd_tek if look == 2 or look == 5
use_synth :pluck
use_synth_defaults depth: 0.1, divisor: 2.5
with_fx :bitcrusher, mix: va, sample_rate: sr do
play_chord ch, release: 1.0/8.0
sleep 1.0/8.0
end
end

11. Drum’n’bass pattern

A simplified d&b drum pattern made with tick + look and equality tests. It also uses some defines for sound definition.
It does require external samples (but you can easily replace them in the code).

define :bd do
sample :mydrum_bd808
synth :saw, note: :c7, release: 0.03
end
define :sn do
with_fx :krush, gain: 0.3, mix: 0.7 do
sample :mydrum_snare_short, amp: 1
sample :sn_dub, hpf: 120, amp: 0.5
end
end
define :hh do
with_fx :gverb, dry: (line 0, 1, steps: 128).mirror.tick do
sample :mydrum_hihat_muffled, hpf: 110, amp: rand(0.7) + 0.6
end
end
live_loop :pattern do
#stop
tick_reset if look >= 15
tick
bd if look == 0 or look == 10
sn if look == 4 or look == 12
hh
sleep 0.25
end

12. Add

It’s made of two parts, an “add” function which uses three synths and a note list as an input and the live_loop itself.
Doesn’t require any external samples.

define :add do |s1,s2,s3,n, atk: 0.1, rel: 2, amp: 0.1|
with_fx :level, amp: amp do
synth s1, note: n - 12, release: atk
synth s1, note: n + 0.1, release: atk
synth s1, note: n, release: atk * 2
synth s2, note: n + 24, release: rel
synth s2, note: n + 24.1, release: rel
synth s2, note: n + 11.8, release: rel
synth s2, note: n, release: rel
synth s3, note: n - 11.8, release: rel
synth s3, note: n - 12, release: rel
end
end
live_loop :addlip do
#stop
with_fx :level, amp: 1 do
density 1 do
tick
with_fx :reverb do
transpose_list = (stretch [-12, 0, 12, 0, -24, 0, 24], 70).look
with_transpose transpose_list do
notes1 = (ring :a4, :gb4, :db4, :gb3, :a3).look
notes2 = (ring :a4, :gb4, :db4, :ab3, :a3).look
notes3 = (ring :a4, :gb4, :eb4, :ab3, :a3).look
notes4 = (ring :a5, :gb5, :eb5, :ab4, :a4).look
notes5 = (ring :a4, :db4, :ab4, :db3, :a3).look
notes6 = (ring :a4, :gb4, :db5, :ab5, :ab4).look
notes7 = (ring :a3, :db4, :ab3, :gb5, :eb4).look
noteslist = (stretch [notes1], 10, [notes2], 10, [notes3], 10, [notes7], 10,
[notes4], 10, [notes2], 10, [notes2], 10, [notes5], 10, [notes6], 10, [notes7], 10)
add(:dsaw, :pretty_bell, :sine, noteslist.look, rel: (ring 1.0/2.0, 1.0/4.0).look)
sleep (ring 1.0/4.0, 1.0/8.0).look
end
end
end
end
end

13. Acid

live_loop :acidbassline do
with_fx :level, amp: 0.4 do
#stop
tick
notelist = (stretch [:e3, :e4], 32).look
phasevar = (line 0.125, 1, steps: 256).look
freqvar = (line 40, 65, steps: 64).mirror.look
with_fx :reverb do
use_synth :tb303
play chord((stretch [:e4, :c4], 32).look, :minor).look, release: 0.125, cutoff: freqvar*2, pan: (line -0.5, 0.5, steps: 32).mirror.look, amp: 0.2
play chord((stretch [notelist, :c3], 32).look, :minor).look, release: 0.125, cutoff: freqvar*2, pan: (line -0.5, 0.5, steps: 32).mirror.look, amp: 0.2
sleep 0.125
end
end
end

14. random seed w/t piano

live_loop :melodie do
tick
use_random_seed stretch([1, 4, 8, 16], 16).look
16.times do
with_transpose (ring -7, 12, -5).look do
notes = (scale :c3, :aeolian, num_octaves: 2)
chords = (chord notes.choose, :minor).look
synth :piano, note: chords
time_warp 0.125 do
synth :piano, note: chords + 12
end
sleep 0.25
end
end
end

15. simple rythm

define :somekindofsnare do
with_fx :lpf do
with_fx :hpf do
synth :noise, attack: 0.001, decay: 0.01, sustain: 0.001, release: 0
end
end
with_fx :tanh, mix: 0.9 do
s = synth :sine, note: :c1, note_slide: 0.5, attack: 0.04, release: 0.2, sustain: 0
control s, note: :a0
end
time_warp 0.1 do
with_fx :hpf, cutoff: 120, cutoff_slide: 0.25 do |fx|
with_fx :band_eq, db: 10, freq: 120 do
synth :bnoise, attack: 0.05, release: 0.1
control fx, cutoff: 80
end
end
end
end
use_bpm 80
live_loop :r4 do
sample :bd_pure
sample :sn_zome
sleep 4.0/4.0
end
live_loop :r3 do
sample :drum_cymbal_pedal
sample :bd_klub
sleep 2.0/4.0
sample :bd_klub if tick % 16 == 0
sleep 1.0/4.0
end
live_loop :r2 do
sample :bd_klub
sleep 1.0/4.0
sample :bd_klub if tick % 16 == 0
sleep 1.0/4.0
end
live_loop :r1 do
somekindofsnare
sample :drum_cymbal_closed, amp: (ring 0.25, 1, 0.5, 1).tick
sample :drum_heavy_kick, amp: (ring 0.25, 1, 0.5, 1).look if spread(3, 16).look
sleep 1.0/4.0
end

Originally published on svdk.fr in 2018.

Esc