Hi everyone.
I came across Sonic Pi at the weekend and I’ve been having great fun so far. Wanting to make something musical without actually specifying the notes to play, I thought repetitions and patterns were the way to go. This picks random notes in a key and repeats the random length phrases a random number of times.
I thought I’d share, I hope you like it:
use_bpm 102
use_random_seed Time.now.to_i
base = ':es1'
type = [:minor, :m, :m6]
key = scale(base, :minor, num_octaves: 5)
$note=32
live_loop :ageis do
$sleepmax = dice(4)
$intervalmax = dice(7)
use_synth :tri
with_fx :reverb, room: 0.99999 do
with_fx :distortion, distort: 0.99 do
##| what's a tidier way of writing this?
$sleeps = [rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25,
rrand_i(1,$sleepmax)*0.25].ring
$interval = [rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax),
rrand_i(-$intervalmax,$intervalmax)].ring
##| arp = chord_degree(rrand_i(1,7), base, :minor, rrand_i(3,8))
arp = chord(:es4, :m, num_octaves: 2)
n = dice(2)*dice(8)
n.times do
play (arp.tick)+12,release: 0.1,amp: 0.3
sleep 0.25
end
n = dice(4)*dice(8)
n.times do
play key[$note+$interval.tick(:one)], amp: 0.1, release: 0.15
sleep $sleeps.tick(:two)
end
$note = $note+$interval[8]
##| tick_reset_all
end
end
end
##| rhythm section from:
##| https://github.com/soundslikedata/open_source_music
live_loop :bass, sync: :ageis do
use_sample_defaults amp: 7
3.times {sample :bd_boom; sleep 0.75}
sleep 0.25; sample :bd_boom; sleep 1.5
end
live_loop :hats, sync: :bass do
10.times {sample :drum_cymbal_closed, rate: 1.75, amp: 2; sleep 0.25}
sample :drum_cymbal_open, sustain: 0.15, rate: 1.88, amp: 2
6.times {sample :drum_cymbal_closed, rate: 1.75, amp: 2; sleep 0.25}
end
live_loop :snare, sync: :bass do
sleep 1
sample :drum_snare_hard, amp: 0.8, rate: 1.05, sustain: 0.1
sleep 1
end
live_loop :pads, sync: :bass do
use_synth :tb303
use_synth_defaults sustain: 5, release: 2.5, amp: 0.5, cutoff: 70
play chord(:es5, :m); play chord(:es4, :m)
sleep 8
play chord(:es4, :m6); play chord(:es3, :m6)
sleep 8
end
##| simpler slow melody
live_loop :polis, sync: :bass do
use_synth :beep
$sleep2 = rrand_i(5,8)*0.25
$interval2 = rrand_i(-7,7)
play key[$note+$interval2], sustain: $sleep2 - 0.2, amp: 2
sleep $sleep2
end
\aR/