Loop with RecordBuf

Hello,

i should ‘translate’ this script into a version with SynthDef and while analyzing it i realized that the loop doesn’t work.
Also, i didn’t understand how to set the loop duration.
Anyone can help me please? Thank you!

s.options.inDevice_("Mic");
s.options.outDevice_("Headphones");

s.boot;
Buffer.freeAll;
b = Buffer.alloc(s, s.sampleRate * 2);

(
x = {
	var sig;
    sig = SoundIn.ar(0);
	RecordBuf.ar(sig,b,\offset.kr(0),\reclev.kr(1),\prelev.kr(0),\run.kr(1),\loop.kr(1));
	PlayBuf.ar(1!2,b,loop:1);
}.play;
)

I had a look at the synth (x.trace) and it looks like everything is in order… so I don’t know what “doesn’t work” means. Could you clarify?

hjh