[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] Synth call not working within task



Hi all,

I have this synth call that only plays for half a second or so when I put it inside this task:

sample1_playtask = Task({
1.do({
sample1_length.wait;
sample1_play = Synth("sample1_play", [\sample_length, 4, \ratearray, 1, \loop, 1], s, \addToHead);
})
});

But it plays just fine if I call it from sclang without the gui and the task that it's in, like this;

~sample1_play = Synth("sample1_play", [\sample_length, 4, \ratearray, 1, \loop, 1], s, \addToTail);

This is the SynthDef:
SynthDef("sample1_play", { arg rate, sample_length, ratearray, loop;
var trig, src, out;
trig = Impulse.kr(sample_length.reciprocal);
src = "">PlayBuf.ar(1, 0, ratearray, trig, 0, loop);
out = Out.ar(0, src);
}).load(s);

There must be something obvious here, but I can't figure out what. I can post my whole code if there's nonthing here that could be what's wrong.

Thanks in advance,
-Kyrre.