sc has a bunch of scaffolding code called crone to nicely interface with the lua engine.
here’s how to make the an incredibly simple sc engine:
// CroneEngine_TestSine
// dumbest possible test: a single, mono sinewave
Engine_TestSine : CroneEngine {
var <synth;
*new { arg context, doneCallback;
^super.new(context, doneCallback);
}
alloc {
synth = {
arg out, hz=220, amp=0.5, amplag=0.02, hzlag=0.01;
var amp_, hz_;
amp_ = Lag.ar(K2A.ar(amp), amplag);
hz_ = Lag.ar(K2A.ar(hz), hzlag);
Out.ar(out, (SinOsc.ar(hz_) * amp_).dup);
}.play(args: [\out, context.out_b], target: context.xg);
this.addCommand("hz", "f", { arg msg;
synth.set(\hz, msg[1]);
});
this.addCommand("amp", "f", { arg msg;
synth.set(\amp, msg[1]);
});
}
free {
synth.free;
super.free;
}
}
crone automatically reports available commands when the engine is loaded. so lua will be able to call
engine.hz(400)
engine.amp(0.3)
for example. this isn’t a thorough explanation. it’s a starter— throwing something to the sc people until the docs and code is ready. but this give you an idea of what it means to wrap some sc code in a way that lua can see it and play easily.