Engines basically encapsulate arbitrary sclang code. you can use as many Synths, Busses, Groups, Patterns, Events, <blahblah> as you want. the only rules are:
- you can’t use graphics stuff
- you must free all server resources that you allocate in the
free {} method (synths, buffers &c)
- it’s probably a good idea to allocate all resources in your engine’s
init {} method
and you can use the superclass addCommand() and addPoll() methods to define your engine’s interface to norns lua.
Does SC have access to the systems MIDI io if available?
yes, though it is entirely independent of the norns UI so it may be confusing to use or customize.
Can a Lua script communicate with an engine via an internal MIDI bus?
not without some pretty lightweight hacking of linux stuff.
update [december 2020]: a virtual MIDI device is now included out of the box.
Can you pass data back from the engine to a Lua script (for example to update onscreen parameter values on preset change?
yes, we call an sc->lua channel a “poll”, and a lua->sc channel a “command.” polls are less flexible, basically callback for a single float or a byte array. commands are more flexible, like remote procedure calls with different parameter types. see e.g. Glut engine for example of polls (it’s how grain positions are conveyed to lua.)