You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a MIDI effect that, after a while, errors out with the message
error calling plugin_processBlock() : not enough memory
and stops doing anything.
My code is the following:
require "include/protoplug"
-- Use CC 4 to interfere with dynamics on CC 1.
CC = {}
CC.dynamic = 1
CC.interferic = 4
outEvents = {}
Channel = {}
function Channel:new(channelNumber)
self.__index = self
local o = {dynamic = 64, interferic = 64, channel = channelNumber}
setmetatable(o, self)
return o
end
function Channel:dynamicEvent(pos)
local value = math.min(127, math.max(0, self.dynamic + (self.interferic - 64)))
-- print(self.dynamic, self.interferic, value)
return midi.Event.control(self.channel, CC.dynamic, value, pos)
end
chan = {}
for i=1, 16 do
chan[i] = Channel:new(i)
end
function plugin.processBlock(samples, buffer_size, midiBuf)
for i=0, #outEvents do outEvents[i] = nil end -- Clear the list
for ev in midiBuf:eachEvent() do
if ev:isControl() then
if CC.dynamic == ev:getControlNumber() then
chan[ev:getChannel()].dynamic = ev:getControlValue()
table.insert(outEvents, chan[ev:getChannel()]:dynamicEvent(ev.time))
elseif CC.interferic == ev:getControlNumber() then
chan[ev:getChannel()].interferic = ev:getControlValue()
table.insert(outEvents, chan[ev:getChannel()]:dynamicEvent(ev.time))
else
table.insert(outEvents, midi.Event(ev))
end
else
--print(ev)
table.insert(outEvents, midi.Event(ev))
end
end
refillMIDIBuffer(midiBuf)
end
function refillMIDIBuffer(midiBuf)
midiBuf:clear()
for _, e in ipairs(outEvents) do
midiBuf:addEvent(e)
end
end
I really don't see why this would complain about memory. Any help appreciated.
The text was updated successfully, but these errors were encountered:
I can't reproduce it. I'm sending it LFOs on CC1 and CC4, and I tried stress-testing it by wrapping the midiBuf:eachEvent loop in another loop that repeats it 1000 times. Haven't tried in Reaper yet. It probably won't help, but you could try
running "collectgarbage"
I have a MIDI effect that, after a while, errors out with the message
and stops doing anything.
My code is the following:
I really don't see why this would complain about memory. Any help appreciated.
The text was updated successfully, but these errors were encountered: