Skip to content

Commit 8850530

Browse files
committed
Examples - further work on examples prior to v2.7
* Mainly tweaking to deal with the new rand gen
1 parent 03583c5 commit 8850530

File tree

9 files changed

+92
-78
lines changed

9 files changed

+92
-78
lines changed

app/server/sonicpi/lib/sonicpi/spiderapi.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,22 +1447,28 @@ def rand_back(amount=1)
14471447
doc: "Roll the random generator back essentially 'undoing' the last call to `rand`. You may specify an amount to roll back allowing you to skip back n calls to `rand`.",
14481448
examples: ["
14491449
# Basic rand stream rollback
1450+
14501451
puts rand # prints 0.75006103515625
1452+
14511453
rand_back # roll random stream back one
14521454
# the result of the next call to rand will be
14531455
# exactly the same as the previous call
1456+
14541457
puts rand # prints 0.75006103515625 again!
14551458
puts rand # prints 0.733917236328125",
14561459
"
14571460
# Jumping back multiple places in the rand stream
1461+
14581462
puts rand # prints 0.75006103515625
14591463
puts rand # prints 0.733917236328125
14601464
puts rand # prints 0.464202880859375
14611465
puts rand # prints 0.24249267578125
1466+
14621467
rand_back(3) # roll random stream back three places
14631468
# the result of the next call to rand will be
14641469
# exactly the same as the result 3 calls to
1465-
# `rand` ago.
1470+
# rand ago.
1471+
14661472
puts rand # prints 0.733917236328125 again!
14671473
puts rand # prints 0.464202880859375"]
14681474

@@ -1482,22 +1488,30 @@ def rand_skip(amount=1)
14821488
doc: "Jump the random generator forward essentially skipping the next call to `rand`. You may specify an amount to jump allowing you to skip n calls to `rand`.",
14831489
examples: ["
14841490
# Basic rand stream skip
1491+
14851492
puts rand # prints 0.75006103515625
1493+
14861494
rand_skip # jump random stream forward one
14871495
# typically the next rand is 0.733917236328125
1496+
14881497
puts rand # prints 0.464202880859375",
14891498
"
14901499
# Jumping forward multiple places in the rand stream
1500+
14911501
puts rand # prints 0.75006103515625
14921502
puts rand # prints 0.733917236328125
14931503
puts rand # prints 0.464202880859375
14941504
puts rand # prints 0.24249267578125
1505+
14951506
rand_reset # reset the random stream
1507+
14961508
puts rand # prints 0.75006103515625
1509+
14971510
rand_skip(2) # jump random stream forward three places
14981511
# the result of the next call to rand will be
14991512
# exactly the same as if rand had been called
15001513
# three times
1514+
15011515
puts rand 0.24249267578125"]
15021516

15031517

etc/examples/algomancer/sonic_dreams.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# rand-seed-ver 31
2-
# Meta-eX
1+
# rand-seed-ver 32
32
#
43
# Coded by Sam Aaron
54
#
@@ -10,29 +9,29 @@
109

1110
define :ocean do |num, amp_mul=1|
1211
num.times do
13-
s = synth [:bnoise, :cnoise, :gnoise].choose, amp: rrand(0.5, 1.5) * amp_mul, attack: rrand(0, 4), sustain: rrand(0, 2), release: rrand(0, 5) + 0.5, cutoff_slide: rrand(0, 5), cutoff: rrand(60, 100), pan: rrand(-1, 1), pan_slide: 1, amp: rrand(0.5, 1)
12+
s = synth [:bnoise, :cnoise, :gnoise].choose, amp: rrand(0.5, 1.5) * amp_mul, attack: rrand(0, 1), sustain: rrand(0, 2), release: rrand(0, 5) + 0.5, cutoff_slide: rrand(0, 5), cutoff: rrand(60, 100), pan: rrand(-1, 1), pan_slide: 1
1413
control s, pan: rrand(-1, 1), cutoff: rrand(60, 110)
15-
sleep rrand(2, 4)
14+
sleep rrand(0.5, 4)
1615
end
1716
end
1817

19-
define :echoes do |num, tonics, co=80, res=0.9, amp=1|
18+
define :echoes do |num, tonics, co=100, res=0.9, amp=1|
2019
num.times do
21-
play chord(tonics.choose, :minor).choose, res: res, cutoff: rrand(co - 40, co + 20), amp: 0.5 * amp, attack: 0, release: rrand(0.5, 1.5), pan: rrand(-0.7, 0.7)
20+
play chord(tonics.choose, :minor).choose, res: res, cutoff: rrand(co - 20, co + 20), amp: 0.5 * amp, attack: 0, release: rrand(0.5, 1.5), pan: rrand(-0.7, 0.7)
2221
sleep [0.25, 0.5, 0.5, 0.5, 1, 1].choose
2322
end
2423
end
2524

2625
define :bd do
2726
cue :in_relentless_cycles
2827
16.times do
29-
sample :bd_haus, amp: 3
28+
sample :bd_haus, amp: 4, cutoff: 120
3029
sleep 0.5
3130
end
3231
cue :winding_everywhichway
3332
2.times do
3433
2.times do
35-
sample :bd_haus, amp: 3
34+
sample :bd_haus, amp: 4, cutoff: 120
3635
sleep 0.25
3736
end
3837
sample :ambi_lunar_land
@@ -41,7 +40,7 @@
4140
end
4241

4342
define :drums do |level, b_level=1, rand_cf=false|
44-
synth :fm, note: :e2, release: 0.1, amp: b_level * 2.5
43+
synth :fm, note: :e2, release: 0.1, amp: b_level * 3, cutoff: 130
4544
co = rand_cf ? rrand(110, 130) : 130
4645
a = rand_cf ? rrand(0.3, 0.5) : 0.6
4746
n = rand_cf ? :bnoise : :noise
@@ -106,8 +105,9 @@
106105
at [7, 12], [:crash, :within_oceans] do |m|
107106
cue m
108107
end
108+
109109
uncomment do
110-
use_random_seed 0
110+
use_random_seed 1000
111111
with_bpm 45 do
112112
with_fx :reverb do
113113
with_fx(:echo, delay: 0.5, decay: 4) do
@@ -118,6 +118,7 @@
118118
ocean 1, 0.25
119119
end
120120
sleep 10
121+
use_random_seed 1200
121122
echoes(5, [:b1, :b2, :e1, :e2, :b3, :e3])
122123
cue :a_distant_object
123124
echoes(5, [:b1, :e1, :e2, :e3])
@@ -149,14 +150,12 @@
149150
in_thread(name: :bassdrums) do
150151
use_random_seed 0
151152
sleep 22
152-
loop do
153-
3.times do
154-
bd
155-
end
156-
sleep 28
157-
loop do
158-
bd
159-
end
153+
3.times do
154+
bd
155+
end
156+
sleep 28
157+
live_loop :bd do
158+
bd
160159
end
161160
end
162161

@@ -200,7 +199,7 @@
200199
drums 2
201200
end
202201

203-
loop do
202+
live_loop :drums do
204203
8.times do |i|
205204
drums 1
206205
end
@@ -230,6 +229,7 @@
230229
puts "Reality A"
231230
sleep 12
232231
use_synth_defaults phase: 0.5, res: 0.5, cutoff: 80, release: 3.3, wave: 1
232+
233233
2.times do
234234
[80, 90, 100, 110].each do |cf|
235235
use_merged_synth_defaults cutoff: cf
@@ -240,7 +240,7 @@
240240
end
241241
4.times do |t|
242242
binary_celebration(6, 0.5)
243-
synth :zawa, note: :e2, phase: 0.25, res: rrand(0.9, 0.99), cutoff: [100, 105, 110, 115][t]
243+
synth :zawa, note: :e2, phase: 0.25, res: rrand(0.8, 0.9), cutoff: [100, 105, 110, 115][t]
244244
sleep 3
245245
end
246246
end

etc/examples/magician/idm_breakbeat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
live_loop :idm_bb do
44
n = [1,2,4,8,16].choose
5-
sample :drum_heavy_kick
5+
sample :drum_heavy_kick, amp: 2
66
sample :ambi_drone, rate: [0.25, 0.5, 0.125, 1].choose, amp: 0.25 if one_in(8)
77
sample :ambi_lunar_land, rate: [0.5, 0.125, 1, -1, -0.5].choose, amp: 0.25 if one_in(8)
88
sample :loop_amen, attack: 0, release: 0.05, start: 1 - (1.0 / n), rate: [1,1,1,1,1,1,-1].choose

etc/examples/sorcerer/monday_blues.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
live_loop :synths, delay: 6 do
2222
puts "how does it feel?"
2323
use_synth :mod_saw
24-
use_synth_defaults amp: 0.5, attack: 0, sustain: 1, release: 0.25, cutoff: 90, mod_range: 12, mod_phase: 0.5, mod_invert_wave: 1
24+
use_synth_defaults amp: 0.5, attack: 0, sustain: 1, release: 0.25, mod_range: 12, mod_phase: 0.5, mod_invert_wave: 1
2525
notes = (ring :F, :C, :D, :D, :G, :C, :D, :D)
2626
notes.each do |n|
27-
play note(n, octave: 1)
28-
play note(n, octave: 2)
27+
tick
28+
play note(n, octave: 1), cutoff: (line 90, 130, steps: 16).look
29+
play note(n, octave: 2), cutoff: (line 90, 130, steps: 32).look
2930
sleep 1
3031
end
3132
end

etc/examples/wizard/blimp_zones.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
live_loop :foo do
99
with_fx :reverb, kill_delay: 0.2, room: 0.3 do
1010
4.times do
11-
use_random_seed 6667
11+
use_random_seed 4000
1212
8.times do
1313
sleep 0.25
14-
play chord(:e3, :m7).choose, release: 0.1, pan: rrand(-1, 1, res: 0.9), amp: 0.8
14+
play chord(:e3, :m7).choose, release: 0.1, pan: rrand(-1, 1, res: 0.9), amp: 1
1515
end
1616
end
1717
end

etc/examples/wizard/blip_rhythm.rb

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,40 @@
22

33
load_samples [:drum_heavy_kick, :elec_plip, :elec_blip]
44
use_bpm 100
5+
use_random_seed 100
56

67
with_fx :reverb, mix: 0.6, room: 0.8 do
7-
in_thread do
8-
with_fx :echo, room: 0.8, decay: 8, phase: 1, mix: 0.4 do
9-
loop do
10-
11-
n = [:e2, :e2, :a3].choose
12-
13-
with_synth :dsaw do
14-
with_transpose -12 do
15-
in_thread do
16-
2.times do
17-
play n, attack: 0.6, release: 0.8, detune: rrand(0, 0.1), cutoff: rrand(80, 120)
18-
sleep 3
19-
end
8+
with_fx :echo, room: 0.8, decay: 8, phase: 1, mix: 0.4 do
9+
live_loop :blip do
10+
n = [:e2, :e2, :a3].choose
11+
12+
with_synth :dsaw do
13+
with_transpose -12 do
14+
in_thread do
15+
2.times do
16+
play n, attack: 0.6, release: 0.8, detune: rrand(0, 0.1), cutoff: rrand(80, 120)
17+
sleep 3
2018
end
2119
end
2220
end
21+
end
2322

24-
sleep 4
25-
26-
with_synth :tri do
27-
play chord(n, :m7), amp: 0.6, release: 0.8
28-
end
23+
sleep 4
2924

30-
sleep 2
25+
with_synth :tri do
26+
play chord(n, :m7), amp: 5, release: 0.8
3127
end
28+
29+
sleep 2
3230
end
3331
end
32+
end
3433

3534

36-
with_fx :echo, room: 0.8, decay: 8, phase: 0.25, mix: 0.4 do
37-
loop do
38-
sample :drum_heavy_kick, amp: 0.5
39-
sample :elec_plip, rate: [0.5, 2, 1, 4].choose * [1, 2, 3, 10].choose, amp: 0.6
40-
sleep 2
41-
end
35+
with_fx :echo, room: 0.8, decay: 8, phase: 0.25, mix: 0.4 do
36+
live_loop :rhythm do
37+
sample :drum_heavy_kick, amp: 0.5
38+
sample :elec_plip, rate: [0.5, 2, 1, 4].choose * [1, 2, 3, 10].choose, amp: 0.6
39+
sleep 2
4240
end
4341
end

etc/examples/wizard/shufflit.rb

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
sleep 1
77

88
live_loop :travelling do
9-
with_fx :echo, phase: 0.125, mix: 0.4 do
10-
use_synth :beep
11-
notes = scale(:e3, :minor_pentatonic, num_octaves: 1)
12-
4.times do
13-
use_random_seed 67
14-
16.times do |idx|
15-
sleep 0.25
16-
play notes.choose, pulse_width: 0.2, attack: 0, release: 0.1, pan: (range -1, 1, step: 0.125)[idx], amp: rrand(0.7, 1.3)
17-
end
18-
end
9+
use_synth :beep
10+
notes = scale(:e3, :minor_pentatonic, num_octaves: 1)
11+
use_random_seed 679
12+
tick_reset_all
13+
with_fx :echo, phase: 0.125, mix: 0.4, reps: 16 do
14+
sleep 0.25
15+
play notes.choose, attack: 0, release: 0.1, pan: (range -1, 1, step: 0.125).tick, amp: rrand(2, 2.5)
1916
end
2017
end
2118

@@ -28,16 +25,14 @@
2825
end
2926

3027
live_loop :shuff, auto_cue: false do
31-
with_fx :hpf, cutoff: 10 do
32-
8.times do
33-
tick
34-
sleep 0.25
35-
sample :bd_tek, amp: factor?(look, 8) ? 6 : 4
36-
sleep 0.25
37-
use_synth :tb303
38-
use_synth_defaults cutoff_attack: 1, cutoff_release: 0, env_curve: 2
39-
play (knit :e2, 24, :c2, 8).look, release: 1.5, cutoff: (range 70, 90).look, depth: 10 , amp: 2 if factor?(look, 2)
40-
sample :sn_dub, rate: -1, sustain: 0, release: (knit 0.05, 3, 0.5, 1).look
41-
end
28+
with_fx :hpf, cutoff: 10, reps: 8 do
29+
tick
30+
sleep 0.25
31+
sample :bd_tek, amp: factor?(look, 8) ? 6 : 4
32+
sleep 0.25
33+
use_synth :tb303
34+
use_synth_defaults cutoff_attack: 1, cutoff_release: 0, env_curve: 2
35+
play (knit :e2, 24, :c2, 8).look, release: 1.5, cutoff: (range 70, 90).look, depth: 10 , amp: 2 if factor?(look, 2)
36+
sample :sn_dub, rate: -1, sustain: 0, release: (knit 0.05, 3, 0.5, 1).look
4237
end
4338
end
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
live_loop :lands, auto_cue: false do
1313
with_fx :reverb, room: 1, reps: 4 do
1414
use_synth :dsaw
15-
use_random_seed 66679
16-
ns = (scale :e2, :minor_pentatonic, num_octaves: 3)
15+
use_random_seed 310003
16+
ns = (scale :e2, :minor_pentatonic, num_octaves: 4).take(4)
1717
16.times do
18-
play ns.choose, detune: 12, release: 0.1, amp: 2, amp: rand + 0.5, cutoff: rrand(70, 120)
18+
play ns.choose, detune: 12, release: 0.1, amp: 2, amp: rand + 0.5, cutoff: rrand(70, 120), amp: 2
1919
sleep 0.125
2020
end
2121
end
@@ -27,7 +27,13 @@
2727
sleep 7.75
2828
end
2929

30-
live_loop :tijd, auto_cue: false do
31-
sample :bd_haus, amp: 2.5
30+
live_loop :tijd, auto_cue: true do
31+
sample :bd_haus, amp: 2.5, cutoff: 100
3232
sleep 0.5
3333
end
34+
35+
live_loop :ind do
36+
# sync :tijd
37+
sample :loop_industrial, beat_stretch: 1
38+
sleep 1
39+
end

0 commit comments

Comments
 (0)