-
Notifications
You must be signed in to change notification settings - Fork 0
/
pools.lua
323 lines (284 loc) · 9.39 KB
/
pools.lua
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
-- pools
--
-- a pitch shifting reverb
--
--
-- @justmat
engine.name = "Pools"
local lfo = include "lib/hnds_pools"
local FilterGraph = require "filtergraph"
local page = 2
local alt = false
local dry_lvl = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
local lfo_targets = {
"none",
"dry",
"verb",
"shimmer",
"freq",
"res",
"time",
"damp",
"size",
"diff",
"lowx",
"midx",
"highx",
"pitchDisp",
"timeDisp"
}
local function update_fg()
-- keeps the filter graph current
local ftype = params:get("type") == 0 and "lowpass" or "highpass"
filter:edit(ftype, 12, params:get("freq"), params:get("res"))
end
function lfo.process()
-- for lib hnds
for i = 1, 4 do
local target = params:get(i .. "lfo_target")
if params:get(i .. "lfo") == 2 then
if lfo_targets[target] == "freq" then
-- pre verb filter freq
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 2.0, 0, 20000))
elseif lfo_targets[target] == "time" then
-- reverb time/ t60
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 2.0, 0, 60))
elseif lfo_targets[target] == "size" then
-- reverb size
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 2.0, 0.50, 5.00))
elseif lfo_targets[target] == "timeDisp" then
-- pitch shift time dispertion
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 2.0, 0.00, 0.50))
else
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 2.0, 0.00, 1.00))
end
end
end
end
function init()
-- mix params
-- dry volume
params:add_control("dry", "dry", controlspec.new(0.00, 1.00, "lin", 0.01, .80))
params:set_action("dry", function(v) engine.amp(v) end)
-- wet volume
params:add_control("verb", "verb", controlspec.new(0.00, 1.00, "lin", 0.01, 0.5))
params:set_action("verb", function(v) engine.verb(v) end)
-- sparkle volume
params:add_control("shimmer", "shimmer", controlspec.new(0.00, 1.00, "lin", 0.01, 0.2))
params:set_action("shimmer", function(v) engine.shimmer(v) end)
params:add_separator()
-- filter params
-- freq
params:add_control("freq", "freq", controlspec.new(0.01, 20000, "exp", 0, 20000))
params:set_action("freq", function(v) engine.freq(v) end)
-- resonance/q
params:add_control("res", "res", controlspec.UNIPOLAR)
params:set_action("res", function(v) engine.res(v) end)
-- input gain
params:add_control("gain", "gain", controlspec.new(0.00, 5.00, "lin", 0.01, 1.00))
params:set_action("gain", function(v) engine.gain(v) end)
-- filter type lp/hp
params:add_number("type", "type", 0, 1, 0)
params:set_action("type", function(v) engine.type(v) end)
params:add_separator()
-- reverb params
-- t60: approximate reverberation time in seconds (assuming damp == 0)
params:add_control("time", "time", controlspec.new(0, 60, "lin", 1, 5))
params:set_action("time", function(v) engine.t60(v) end)
-- dampening: controls damping of high-frequencies as the reverb decays
params:add_control("damp", "damp", controlspec.new(0.00, 1.00, "lin", 0.01, 0.13))
params:set_action("damp", function(v) engine.damp(v) end)
-- size: scales size of delay-lines within the reverberator, producing the impression of a larger or smaller space
params:add_control("size", "size", controlspec.new(0.5, 5.0, "lin", 0.1, 1.5))
params:set_action("size", function(v) engine.size(v) end)
-- early diffusion: controls shape of early reflections
params:add_control("diff", "diff", controlspec.new(0.00, 1.00, "lin", 0.01, 0.70))
params:set_action("diff", function(v) engine.diff(v) end)
-- modulation depth
params:add_control("modDepth", "mod depth", controlspec.new(0, 50, "lin", 0, 1))
params:set_action("modDepth", function(v) engine.modDepth(v) end)
-- modulation frequency
params:add_control("modFreq", "mod freq", controlspec.new(0.0, 10.00, "lin", 0.01, 0.1, "hz"))
params:set_action("modFreq", function(v) engine.modFreq(v) end)
params:add_separator()
-- reverb eq/filtering
-- low: multiplier (0..1) for the reverberation time within the low band
params:add_control("lowx", "low x", controlspec.new(0.00, 1.00, "lin", 0.01, 1.00))
params:set_action("lowx", function(v) engine.low(v) end)
-- mid: multiplier (0..1) for the reverberation time within the mid band
params:add_control("midx", "mid x", controlspec.new(0.00, 1.00, "lin", 0.01, 1.00))
params:set_action("midx", function(v) engine.mid(v) end)
-- high: multiplier (0..1) for the reverberation time within the high band
params:add_control("highx", "high x", controlspec.new(0.00, 1.00, "lin", 0.01, 1.00))
params:set_action("highx", function(v) engine.high(v) end)
-- lowband: the crossover point between low and mid bands
params:add_control("lowband", "lowband", controlspec.new(100, 6000, "lin", 0, 6000, "hz"))
params:set_action("lowband", function(v) engine.lowcut(v) end)
-- highband: the crossover point between high and mid bands
params:add_control("highband", "highband", controlspec.new(1000, 10000, "lin", 0, 1000, "hz"))
params:set_action("highband", function(v) engine.highcut(v) end)
params:add_separator()
-- pitch shift controls
-- pitch dispersion: random variation of pitch
params:add_control("pitchDisp", "pitchDisp", controlspec.new(0.00, 1.00, "lin", 0.01, 0.13))
params:set_action("pitchDisp", function(v) engine.pitchDispersion(v * .25) end)
-- time dispersion: delay between playing a note and hearing the shifted note
params:add_control("timeDisp", "timeDisp", controlspec.new(0.00, 0.50, "lin", 0.01, 0.12))
params:set_action("timeDisp", function(v) engine.timeDispersion(v) end)
-- pitch ratio: amount to pitchshift by
params:add_control("pitchRatio", "pitchRatio", controlspec.new(0.0, 4.0, "lin", 0, 2.0))
params:set_action("pitchRatio", function(v) engine.pitchRatio(v) end)
for i = 1, 4 do
lfo[i].lfo_targets = lfo_targets
end
lfo.init()
params:bang()
filter = FilterGraph.new()
filter:set_position_and_size(0, 0, 127, 64)
norns.enc.sens(0, 3)
-- screen metro
screen_timer = metro.init()
screen_timer.time = 1/15
screen_timer.stage = 1
screen_timer.event = function() redraw() end
screen_timer:start()
end
function key(n, z)
if n == 1 then alt = z == 1 and true or false end
if z == 1 then
if n == 2 then
page = util.clamp(page - 1, 1, 3)
elseif n == 3 then
page = util.clamp(page + 1, 1, 3)
end
end
end
function enc(n, d)
if page == 1 then
if n == 1 then
params:delta("type", d)
elseif n == 2 then
params:delta("freq", d)
elseif n == 3 then
params:delta("res", d)
end
elseif page == 2 then
if n == 1 then
params:delta("dry", d)
elseif n == 2 then
params:delta("verb", d)
elseif n == 3 then
params:delta("shimmer", d)
end
else
if alt then
if n == 1 then
params:delta("lowx", d)
elseif n == 2 then
params:delta("midx", d)
elseif n == 3 then
params:delta("highx", d)
end
else
if n == 1 then
params:delta("time", d)
elseif n == 2 then
params:delta("damp", d)
elseif n == 3 then
params:delta("diff", d)
end
end
end
end
local function draw_mix()
local dry = math.floor(lfo.scale(params:get("dry"), 0, 1, 0, 15))
local verb = math.floor(lfo.scale(params:get("verb"), 0, 1, 0, 15))
local shimmer = math.floor(lfo.scale(params:get("shimmer"), 0, 1, 0, 15))
screen.clear()
screen.aa(1)
screen.font_face(13)
-- dry
screen.font_size(24)
screen.level(15)
screen.rect(4, 4, 42, 27)
screen.fill()
screen.move(8, 24)
screen.level(dry_lvl[dry + 1])
screen.text("dry")
-- verb!
screen.font_size(24)
for i=1, verb do
screen.move(82 + i, 26 + i)
screen.font_size(32)
screen.level(i)
screen.text_center("wet!")
end
-- shimmer
if verb > 0 then
for i = 1, shimmer do
screen.level(math.random(15))
local x = math.random(0, 127)
local y = math.random(32, 64)
screen.move(x, y)
screen.circle(x, y, math.random(1))
screen.stroke()
end
end
screen.move(64, 58)
screen.font_face(23)
screen.font_size(24)
screen.level(shimmer)
screen.text_center("shimmer")
screen.update()
end
local function draw_filter()
update_fg()
screen.clear()
filter:redraw()
screen.update()
end
local function draw_edit()
screen.clear()
screen.font_face(7)
screen.font_size(16)
screen.level(alt and 2 or 8)
-- time
screen.move(1, 60)
screen.text("tm")
screen.rect(7, 46, 6, -lfo.scale(params:get("time"), 0, 60, 0, 40))
-- dampening
screen.move(25, 60)
screen.text("dp")
screen.rect(31, 46, 6, -lfo.scale(params:get("damp"), 0, 1, 0, 40))
-- diffusion
screen.move(49, 60)
screen.text("df")
screen.rect(55, 46, 6, -lfo.scale(params:get("diff"), 0, 1, 0, 40))
screen.fill()
screen.stroke()
screen.level(alt and 8 or 2)
-- pitch dispertion
screen.move(75, 60)
screen.text("L")
screen.rect(77, 46, 6, -lfo.scale(params:get("lowx"), 0, 1, 0, 40))
-- time dispertion
screen.move(93, 60)
screen.text("M")
screen.rect(97, 46, 6, -lfo.scale(params:get("midx"), 0, 1, 0, 40))
-- pitch ratio
screen.move(114, 60)
screen.text("H")
screen.rect(117, 46, 6, -lfo.scale(params:get("highx"), 0, 1, 0, 40))
screen.fill()
screen.stroke()
screen.update()
end
function redraw()
if page == 1 then
draw_filter()
elseif page == 2 then
draw_mix()
else
draw_edit()
end
end