Last active
April 17, 2021 16:49
-
-
Save ryrun/0649eb5fbcef9cc21053ea5e2a1cf994 to your computer and use it in GitHub Desktop.
Midi script for VST protoplug for "drone" notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "include/protoplug" | |
noteOn = 0 | |
function plugin.processBlock(samples, smax, midiBuf) | |
blockEvents = {} | |
-- drone note, 72 = C | |
local rootNote = 69 | |
for ev in midiBuf:eachEvent() do | |
if ev:isNoteOn() and ev:getNote() ~= rootNote then | |
if noteOn > 0 then | |
local newEv = midi.Event.noteOff( | |
ev:getChannel(), | |
rootNote, | |
ev:getVel()) | |
table.insert(blockEvents, newEv) | |
end | |
local newEv = midi.Event.noteOn( | |
ev:getChannel(), | |
rootNote, | |
ev:getVel()) | |
table.insert(blockEvents, newEv) | |
noteOn = noteOn + 1 | |
elseif ev:isNoteOff() and ev:getNote() ~= rootNote then | |
local newEv = midi.Event.noteOff( | |
ev:getChannel(), | |
rootNote, | |
ev:getVel()) | |
if noteOn==1 then | |
table.insert(blockEvents, newEv) | |
end | |
noteOn = noteOn - 1 | |
end | |
end | |
--midiBuf:clear() --uncomment for just drone note | |
if #blockEvents>0 then | |
for _,e in ipairs(blockEvents) do | |
midiBuf:addEvent(e) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment