I am playing around with the sampler class and trying to implement a scripting engine that processes MIDI events (basically like KONTAKT does with KSP). I checked out both Angelscript and Lua, and I hacked it together, but stumbled upon performance issues: Whenever I call the respective Lua function that handles the processing of the midi message from within the audio callback, it starts glitching if I do more than "x = 2 + 4" :) I know there is the law to do nothing stupid in the audio callback (and I think the Lua GC falls under that category), but the only other solution I figured was to use a second MidiBuffer and process all messages in a separate thread, but that at least doubles the latency (since the processes MidiMessages are only available in the next processBuffer() callback. That can't be the solution.
Has anyone tried messing with the Lua internals (eg. replacing the allocator with the more realtime suitable TLSF and using LuaJIT), or is this unnecessary for the rather simple task of processing some midi messages (eg. storing the last note and changing the velocity based on the tempo of the last notes)?