I'm having a bit of trouble getting the behaviour i'd like.
My aim is to create a synth that includes a phasor uGen. I wanted to code it so that when the synth is instantiated, the phasor can be set to begin from a given frame, but then loop as normal (from 0 to 1000) thereafter.
I couldn't think of a way to get the phasor to start at the correct position at the moment the synth was instantiated, so i tried to send 'set' commands to it shortly after. The idea was that i would set the phasor's resetPos to the frame it should begin from, at the moment of instantiation. And shortly afterwards use a set message to tip the phasor's reset trigger. Thereby forcing the phasor to jump to the desired start position.
But i think that timing issues are preventing this approach from working. If i send the set commands one at a time, the phasor jumps to the correct position. But if i try to run them 'all at once', to get the effect that the phasor begins at the offset position, then the trigger doesn't fire (because of latency between the client and surver somehow?).
(
s = Server.local;
s.reboot;
s.waitForBoot({
b = Bus.audio(s);
SynthDef("PlayBuf", { arg bus, reset_trigger;
var ph = Phasor.kr(reset_trigger, 0.1, 0, 1000, 500);
Out.kr(bus,ph);
}).send(s);
SystemClock.sched(0.0,{
b.get({arg val; val.postln;});
0.2;
});
});
)
(
x=Synth("PlayBuf",[\bus,b]);
x.set(\reset_trigger,0);
x.set(\reset_trigger,1); // The phasor should jump to 500 at this point
)
Does anyone know of a way that i can ask the phasor to begin at a specified frame when i instantiate the synth that contains it?