-
Notifications
You must be signed in to change notification settings - Fork 0
/
polyat2noteon.lua
32 lines (26 loc) · 961 Bytes
/
polyat2noteon.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
-- Convert MIDI Poly Pressure (aka Poly Aftertouch) to Note On events
-- 0..15 or set to -1 to apply to events on all channels
local filter_chan = -1
-- whether to pass non-polyAT events
local pass_other = true
-- lowest note of affected note range
local note_low = 0
-- highest note of affected note range
local note_high = 127
-- NO NEED TO CHANGE ANYTHING BELOW
function polyat2noteon(self, frames, forge, chan, note, vel)
if (filter_chan == -1 or chan == filter_chan) and (note >= note_low and note <= note_high) then
forge:time(frames):midi(MIDI.NoteOn | chan, note, vel)
end
end
-- define a MIDIResponder object to handle note-on and note-off events
local midiR = MIDIResponder({
[MIDI.NotePressure] = polyat2noteon,
}, pass_other)
function run(n, control, notify, seq, forge)
-- iterate over incoming events
for frames, atom in seq:foreach() do
-- call responder for event
local handled = midiR(frames, forge, atom)
end
end