-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4seq.lua
More file actions
112 lines (95 loc) · 1.91 KB
/
Copy path4seq.lua
File metadata and controls
112 lines (95 loc) · 1.91 KB
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
-- 4seq
-- arc based 4x prolly sequencer
--
-- by 256k
engine.name = 'PolyPerc'
MusicUtil = require("musicutil")
local arc4 = arc.connect()
local mididev = midi.connect()
local rootNote = 64
-- CONSTANTS
local PROB_THRESHOLD_LIMIT = 101
-- ---------
local problist = {}
local thold = {}
local playhead = {}
function refresh()
redraw()
end
function tholdInit(tholdVal)
for t=1,4 do
thold[t] = tholdVal
end
end
function playheadInit()
for p=1,4 do
playhead[p] = 1
end
end
function playheadInc(playheadNum, seqLength)
local ph = playhead[playheadNum]
if ph >= seqLength then
playhead[playheadNum] = 1
return
end
playhead[playheadNum] = ph + 1
end
function problistInit(thld_limit)
for a=1,4 do
problist[a] = {}
for i=1,64 do
problist[a][i] = math.random(thld_limit)
end
end
end
function init()
problistInit(PROB_THRESHOLD_LIMIT)
tholdInit(PROB_THRESHOLD_LIMIT)
playheadInit()
for i=1,4 do
drawRingProbSeq(i)
end
clock.run(function()
while true do
clock.sync(1/4)
for i=1,4 do
playheadInc(i, 64)
drawRingProbSeq(i)
-- print(problist[i][playhead[i]])
if problist[i][playhead[i]] > thold[i] then
engine.hz(MusicUtil.note_num_to_freq(rootNote) * i)
end
end
end
end)
end
mididev.event = function(data)
local d = midi.to_msg(data)
if d.type == "note_on" then
rootNote = d.note
end
end
function arc4.delta(n,d)
print("THOLD: ", thold[n])
thold[n] = util.clamp((thold[n] + d / 16 ), 0, PROB_THRESHOLD_LIMIT )
drawRingProbSeq(n)
end
function drawRingProbSeq(ring)
for i=1,64 do
local ledVal
if problist[ring][i] > thold[ring] then
ledVal = 10
else ledVal = 0
end
if i == playhead[ring] then ledVal = 15 end
arc4:led(ring, i, ledVal )
end
arc4:refresh()
end
function redraw()
screen.clear()
screen.font_size(24)
screen.move(10,10)
screen.text("hello")
screen.update()
end