there are very few limitations as to what you can do in a CroneEngine. you can use Patterns or any other sclang feature, whether it’s a good idea or not.
we have not yet published the repo containing the base classes, but of course they are in the filesystem on your norns and you can examine them in the usual ways.
in advance of more proper documentation / tutorials, here is a sort of template:
Engine_Foo : CroneEngine {
var <baz_poll;
var <baz_seq;
// this is your constructor. the 'context' arg is a CroneAudioContext.
// it provides input and output busses and groups.
// see its implementation for details.
*new { arg context, doneCallback;
^super.new(context, doneCallback);
}
// this is called when the engine is actually loaded by a script.
// you can assume it will be called in a Routine,
// and you can use .sync and .wait methods.
alloc {
// this is how you add "commands",
// which is how the lua interpreter controls the engine.
// the format string is analogous to an OSC message format string,
// and the 'msg' argument contains data.
this.addCommand("foo", "f", { arg msg; postln( msg[1]); });
/// this is how you add a "poll", which is how to send data back to lua,
// triggering a callback.
// by default, a poll is periodically evaluated with a given function.
// this function just returns a random number.
this.addPoll("bar", { 1.0.rand });
/// here is a non-periodic poll, which we can arbitrarily trigger.
// notice that it has no function argument.
baz_poll = this.addPoll("baz", periodic:false);
// this Routine triggers the "baz" poll with another random number,
// at a random interval.
// (i would have used Pseq here for demonstration, but i've forgotten how!)
baz_seq = Routine { inf.do {
baz_poll.update(1.0.rand);
(0.1 + 1.0.rand).wait;
} }.play;
free {
// here you should free resources (e.g. Synths, Buffers &c)
// and stop processes (e.g. Routines, Tasks &c)
baz_seq.stop;
}
}