Thanks @zebra, I’m still not getting it to work. I’ve tried to make a simpler example. See below. What is wrong with my code? Is it the engine or the lua code?
SuperCollider CroneEngine
Engine_SimplePassThru : CroneEngine {
var amp=0;
var <synth;
// 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 {
//Add SynthDefs
SynthDef(\passThru, {|in, out, amp=0|
var sound = SoundIn.ar(in);
Out.ar(out, sound*amp);
}).add;
context.server.sync;
synth = Synth.new(\passThru, [\in, context.in_b, \out, context.out_b, \amp, 0], context.xg);
// 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("test", "ifs", {|msg|
msg.postln;
});
this.addCommand("amp", "f", {|msg|
synth.set(\amp, msg[1]);
});
}
free {
// here you should free resources (e.g. Synths, Buffers &c)
// and stop processes (e.g. Routines, Tasks &c)
synth.free;
}
}
LUA Code
-- PassThru Test
engine.name = 'SimplePassThru'
function init()
print("Simple Pass Thru Test")
end
function key(n,z)
if n == 2 then
if z == 1 then
screen.text("Listen")
screen.update()
engine.amp(1.0)
elseif z == 0 then
screen.clear()
screen.update()
engine.amp(0.0)
end
end
end