Send each Trigger of Playbuf to another Speaker

I have the following synth which basically plays a buffer, with some modulations in rate etc.
In the Pan2 part I would like to send each new trigger of the PlayBuf to a random loudspeaker, so each time the playbuf jumps back to the start position. How could I achieve this?

(
SynthDef(\play, {
	arg buf=0;
	var snd;
	var trig = LFNoise0.ar(10);
	snd = PlayBuf.ar(
		buf.numChannels,
		2,
		trigger: trig,
		rate: BufRateScale.kr(buf) * LFNoise0.kr(10).range(-4, 4.0),
	);
	snd = BPF.ar(snd, LFNoise0.kr(10).range(100, 2000), rq: 0.1);
	snd = FreeVerb.ar(snd, mix: LFNoise0.kr(10).range(0, 0.7), room: LFNoise0.kr(1).range(0, 0.9));
	Out.ar(0, Pan2.ar(snd, pos: trig))
}).add
)

See the other thread for why your use of buf is wrong.

Since you are already using a trigger, Demand rate ugen are ideal here!

SynthDef(\play, { 
	var trig = LFNoise0.ar(10);
	var snd = PlayBuf.ar(1, \buf.kr,
		trigger: trig,
		rate: BufRateScale.kr(\buf.kr) * LFNoise0.kr(10).range(-4, 4.0),
	);
	var panPos = Demand.ar(trig, 0, Dwhite(-1.0, 1.0));
	Out.ar(0, Pan2.ar(snd, pos: panPos))
}).add
1 Like