-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmidilooper.lua
More file actions
51 lines (44 loc) · 880 Bytes
/
midilooper.lua
File metadata and controls
51 lines (44 loc) · 880 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pattern = require 'lib/pattern_time'
p = pattern.new()
message = "..."
brute = midi.connect(1)
function playback(d)
brute:send(midi.to_data(d))
end
function init()
p.process = playback
end
brute.event = function(d)
data = midi.to_msg(d)
if data.type then
p:watch(data)
end
end
function key(n,z)
if n==3 and z==1 then
if p.rec == 0 and p.play == 0 then -- empty, start recording
p:rec_start()
message="rec"
elseif p.rec == 1 then --recording
p:rec_stop()
print (p.count)
if p.count > 0 then
p:start()
message = "loop"
else
message = "..."
end
elseif p.play == 1 then -- playing
p:stop()
p:clear()
message = "..."
end
redraw()
end
end
function redraw()
screen.clear()
screen.move(64,40)
screen.text_center(message)
screen.update()
end