paging @mlogger from this thread
as a demonstration i added an engine that compiles and executes arbitrary .scd code at runtime.
putting this in ‘development’ because, well, basically have been holding off on pushing this kind of thing until the 3.0 update, which is approaching.
3.0 update will overhaul, streamline and extend the supercollider interface for norns.
engine classes and environments are simpler (easier to develop off-norns),
lifecycle management is simpler (e.g. Main.stop in sclang will not mess anything up),
there are convenience methods for exposing Classes to lua (less boilerplate,)
and proxy/factory methods to connect interpreted code to lua (if you don’t want to use classes.)
and finally i am thinking about ways to make the OSC connections more flexible (for arbitrary RPC-like action.) though it would be nice if someone who enjoys that kind of thing would take it over. i don’t think the hardcoded lua <-> SC OSC system is quite powerful enough to be a general solution right now for talking to other OSC-enabled environments. but with a little TLC i think we could make a fine standard that could be easily ported to PD or whatever.
anyways, here is simple thing that works with current systems:
this engine just takes three commands:
-
script(file) runs a .scd file
-
chunk(text) compiles and executes a chunk of sclang code (or tries to)
-
clear() executes ~cleanup function and cleans the current Environment
it’s important that each script contains ~cleanup function which frees any persistent resources!
this lua script itself is very dumb and does nothing but re-run a couple different .scd files, with no interaction.
if you wanted to get values to and from the script (e.g. control stuff with encoders / param system), probably easiest to set up explicit matching OSC connections in lua osc.event and in the sclang code. (and then before you know it you’re adding more stuff to the wrapper engine and then we are reinventing the 3.0 stuff presently in the pipeline, so maybe hold off a bit.)
scripts should be able to use MIDI and HID devices but i haven’t tried it. (maybe norns will steal the MIDI ports, i dunno.)
graphics and window-driven UI stuff in sclang, will not work.
it would be a simple exercise to use the keycode libraries from one of the text-driven norns scripts, and make a little sclang repl here, with an OSC connection for feedback.
i think i want to put this here because it feels worthwhile to mention that norns lua environment is pretty fully featured with not a lot of restrictions. one can create shell processes, use thread-backed coroutines for asynchronous stuff, do file I/O, pipes, sockets, and OSC. and it’s very performant compared to, say, python or node.js.
so… norns lua can act as a poweful launch configuration manager for other arbitrary processes, including audio process. (and can manage JACK connections through a shell.) i actually use it this way pretty frequently in my day job as an audiology research scientist. (where, unfortunately, the apps and settings themselves are proprietary stuff.)
just throwing that out there. if someone wants run csound or automatism patches on norns, we can work together a little bit and make that a more integrated experience, if that’s attractive.