-
Notifications
You must be signed in to change notification settings - Fork 0
/
workspace_five.spi
58 lines (47 loc) · 1.73 KB
/
workspace_five.spi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Welcome to Sonic Pi
use_bpm :link
set_link_bpm! 90
# Step 1: Choose Chords with Variation
chords = [(chord :D, :minor),
(chord :A, :minor),
(chord :E, :minor7).take(3), # Added variation - minor 7th chord
(chord :F, :maj9).take(3)] # Added variation - major 9th chord
# Step 2: Create and Rearrange Matrix
notes_matrix = chords.map { |chord| chord.to_a }
min_distance_matrix = notes_matrix.transpose.map { |column| column.permutation.to_a.min_by { |perm| perm.each_cons(2).sum { |a, b| (a - b).abs } } }
rearranged_matrix = min_distance_matrix.transpose
# Step 3: Live Loop Rendering with Variation
live_loop :chord_sequence do
with_fx :reverb, mix: 0.5 do
rearranged_matrix.each do |row|
#Apply Note Inversions for Variation
#notes_with_variation = row.shuffle
notes_with_variation = row.ring.mirror
# Apply Rhythmic Variations for Variation
rhythm_variation = [0.75, 0.5, 0.8, 0.5].choose
notes_with_variation.each do |note|
use_octave -2
synth :piano, note: note, release: 1.5, attack: 0.2
sleep rhythm_variation
end
end
end
end
live_loop :spatial_effects do
stop
with_fx :pan, pan: calculate_pan(tick), amp: 0.8 do
rearranged_matrix.each do |row|
lfo_value = Math.sin(2 * Math::PI * 0.25 * tick)
volume = 0.8 + (lfo_value * 0.2)
synth :pluck, note: row.first, release: 0.8, amp: volume
sleep 0.5
end
end
end
define :calculate_pan do |tick_value|
pan_range = -1..1
lfo_value = Math.sin(2 * Math::PI * 0.15 * tick_value)
normalized_lfo = lfo_value / 60.0
pan_value = normalized_lfo * (pan_range.max - pan_range.min) + pan_range.min
[pan_range.min, [pan_value, pan_range.max].min].max
end