-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmidithru.lua
More file actions
63 lines (49 loc) · 1.33 KB
/
midithru.lua
File metadata and controls
63 lines (49 loc) · 1.33 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
-- midithru
--
--
-- ENC2 - Select MIDI IN device
-- ENC3 - Select MIDI OUT device
--
--
--
--
--
local midi_in_device = midi.connect(1)
local midi_out_device = midi.connect(2)
function init()
-- Add params
params:add{type = "number", id = "midi_in_device", name = "MIDI IN Device", min = 1, max = 4, default = 1, action = function(value)
midi_in_device.event = nil
midi_in_device = midi.connect(value)
midi_in_device.event = function(data)
midi_out_device:send(data)
end
end}
params:add{type = "number", id = "midi_out_device", name = "MIDI Out Device", min = 1, max = 4, default = 2, action = function(value)
midi_out_device = midi.connect(value)
midi_out_device.event = nil
end}
params:bang()
end
function enc(n,d)
if n == 2 then
if params:get("midi_in_device") + d ~= params:get("midi_out_device") then
params:delta("midi_in_device",d)
end
elseif n == 3 then
if params:get("midi_out_device") + d ~= params:get("midi_in_device") then
params:delta("midi_out_device",d)
end
end
redraw()
end
function redraw()
screen.clear()
screen.move(10,20)
screen.text("Midi thru")
screen.move(10,40)
screen.text(string.format("IN device: %d", params:string("midi_in_device")))
screen.move(70,40)
screen.text(string.format("OUT device: %d", params:string("midi_out_device")))
screen.update()
end