forked from mrbombmusic/sonic-pi-drum-rnn-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sonic-Pi-receiver.rb
125 lines (113 loc) · 2.3 KB
/
Sonic-Pi-receiver.rb
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use_osc "localhost", 12004
samples = [
[
:bd_haus,
:drum_snare_hard,
:drum_cymbal_closed,
:drum_cymbal_open,
:drum_tom_hi_hard,
:drum_tom_mid_hard,
:drum_tom_lo_hard,
:drum_splash_hard,
:drum_cymbal_soft
], [
:perc_bell,
:perc_bell2,
:perc_snap,
:perc_snap2,
:perc_swash,
:perc_till,
:perc_door,
:perc_impact2,
:perc_swoosh
], [
:elec_twang,
:elec_wood,
:elec_pop,
:elec_beep,
:elec_blip,
:elec_blip2,
:elec_ping,
:elec_bell,
:elec_twip
],
[
#insert samples here
], [
#insert samples here
], [
#insert samples here
]
]
step = []
midiNotes = []
live_loop :receivedNewDrums do
use_real_time
a = sync "/osc*/wek/outputs"
b = sync "/osc*/wek2/outputs"
set :notes, a
set :steps, b
puts a
end
live_loop :receivedGenDrums do
use_real_time
c = sync "/osc*/wek3/outputs"
d = sync "/osc*/wek4/outputs"
set :genNotes, c
set :genSteps, d
end
live_loop :playGenPatternOrNot do
use_real_time
e = sync "/osc*/wek5/outputs"
set :playGenOrNot, e
end
live_loop :selectKit do
use_real_time
f = sync "/osc*/wek6/outputs"
set :kit, f
end
a = 1.4
live_loop :playDrumPatterns, sync: :selectKit do
midiNotes = get[:notes] || []
step = get[:steps] || []
genNote = get[:genNotes] || []
genStep = get[:genSteps] || []
playGen = get[:playGenOrNot]
i = get[:kit][0].to_i
dr = { samples[i][0] => 36,
samples[i][1] => 46,
samples[i][2] => 38,
samples[i][3] => 42,
samples[i][4] => 51,
samples[i][5] => 48,
samples[i][6] => 50,
samples[i][7] => 49,
samples[i][8] => 45
}
if playGen
if playGen[0] == 1 || playGen[0] == 2
16.times do |i|
for x in 0..midiNotes.length do
if step[x] == i
sample dr.select{|k,v| v == midiNotes[x]}.keys.first, amp: a
end
end
osc "/druminfo", i, 0
sleep 0.25
end
end
if playGen[0] == 0 || playGen[0] == 2
16.times do |i|
for x in 0..genNote.length do
if genStep[x] == i
sample dr.select{|k,v| v == genNote[x]}.keys.first, amp: a
end
end
osc "/druminfo", i, 1
sleep 0.25
end
end
else
sleep 0.25
end
end