Lua Support by guysv · Pull Request #312 · schismtracker/schismtracker
Quick update i guess
lua multi-tasking
I pretty much put all my money on abusing the lua-instruction-counter-debug-hook to preemptively multitask lua code with the schism event loop. Had couple of nasty lua-stack-balance bugs on the way there, still wonder if threads are not the way to go, anyway it's technically cooler this way so what the hell ;)
pattern editing API
Added some basic functions to retrieve pattern position, and note/param setters
lua callbacks, MIDI control message handling
Added a lua task queue that is unloaded when the lua console is idle. Now schism C code can post lua execution requests, that eventually invoke a lua global function the user can overwrite in the console.
For MIDI, that's _on_midi(value, param) (Only MIDI control messages for now)
A Humble Demo
Ok so now that I got all that running, I wanted to see if all that lua scripting stuff is actually practical.
Like I mentioned earlier I have some MPK mini lying around. Inspecting the keyboard with a MIDI monitor shows that the knobs emit MIDI control messages with value and param (mapped to knob position).
I then tried this midi callback:
cp = current_pattern
cc = current_channel
cr = current_row
_on_midi = function(v,p) pattern.set_param(cp(), cc(), (cr()+1)%64, v*2) end
(looks like clipboard paste into the lua console is broken, WIP...)
Anyway, combine this with schism MIDI pattern trigger. I can now sweep the channel effect param value with the knob! I was even able to quickly compose a tune that was actually listenable. Check out the track 😎 !
You might be wondering about the (cr()+1)%64. The point was to make the param modification happen ahead of the cursor, so I could immediately listen to the track while i'm jamming. This also means this hack sacrifices some hit accuracy for usability I guess this is an inherent issue with the matrix model of the tracker.