EDIT - sorry for the continual edits, just lots to think about — Is the ElectraOne OS single threaded? In other words, if I am sitting in a while loop spinning and waiting, does any other processing take place in the LUA code while I spin? What about processing external inputs (MIDI, knobs, screen)?
Summary - I’m trying to request and process a bank of patches from a synth one at a time with no success so far.
pseudo code for how I have it now:
-- synchronization variable processed = 0 function getOne(patchNum) processed = 0 -- send sysex to request the patch end function getAll() for i = 1, 127 do getOne(i) while (processed == 0) do print("Waiting ...") end end end function patch.onResponse() -- read sysex message -- do lots of stuff with the data processed = 1 end
What happens is usually I see the “Waiting …” message in the log file a lot and then nothing else ever happens. It definitely never cycles through multiple sends/responses. Not sure how LUA handles variables in a loop like that. Since it’s not a local, I would have thought the global was checked each time through, but that doesn’t appear to be the case.
My second thought (this morning on the drive in - currently untested) would be to change it up slightly.
My fear with this version though is that I might blow the stack out since patch.onResponse() is invoked before it finishes.
numPatches = 128 function getOne(patchNum) -- send sysex to request the patch end function getAll() getOne(1) end function patch.onResponse() -- read sysex message -- do lots of stuff with the data i = i + 1 if (i < numPatches) then getOne(i) end end