-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.lua
50 lines (44 loc) · 1.04 KB
/
clock.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
position = 0
playing = false
function start()
playing = true
position = 0
print('play')
end
function stop()
playing = false
print('stop')
end
function advanceClock(offset)
offset = offset or 1
position = position + offset
-- print("advanceClock() sees position == ", position, " and when == ", when)
if when ~= nil and position >= when then
print('sending grid based on clock')
sendGrid()
end
if position >= 96 then
position = position % 96
when = nil
end
if pushGrid ~= nil then
sendGrid()
end
end
function resetClock()
position = 0
end
-- 768 clocks in 8 progressions
-- 96 in 1 progression
function onReceiveMIDI(message, connections)
if message[1] == MIDIMessageType.START then
start()
elseif message[1] == MIDIMessageType.STOP then
stop()
elseif message[1] == MIDIMessageType.CLOCK and playing then
advanceClock()
elseif stash_control_changes and isControlChange(message) and not messageIsNRPN(message) then
stashControlChange(message)
debugControlChangeStash()
end
end