forked from monome/bowery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvdelay.lua
More file actions
33 lines (30 loc) · 789 Bytes
/
Copy pathcvdelay.lua
File metadata and controls
33 lines (30 loc) · 789 Bytes
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
--- control voltage delay
-- input1: CV to delay
-- input2: 0v = capture, 5v = loop
-- output1-4: delay equaly spaced delay taps
LENGTH = 100 -- sets loop time
-- closer to LENGTH is shorter, closer to 0 is longer
taps = { 1
, 26
, 51
, 76
}
--private vars
bucket = {}
write = 1
function init()
input[1].mode( 'stream', 0.01 ) -- 100Hz fastest stable
for n=1,4 do output[n].slew = 0.01 end
for n=1,LENGTH do bucket[n] = 0 end
end
input[1].stream = function(v)
c = input[2].volts / 4.5
c = (c < 0) and 0 or c
c = (c > 1) and 1 or c
bucket[write] = v + c*(bucket[write] - v)
write = (write % LENGTH) + 1
for n=1,4 do
taps[n] = (taps[n] % LENGTH) + 1
output[n].volts = bucket[math.floor(taps[n])]
end
end