Trigger a buffer with PlayBuf for a certain number of times

How could I trigger a playbuf instance to trigger only a certain number of times? Using trigger ugens like Impulse can’t be stopped . Is there a ugen which would be like an Impulse with a definable number of triggers?

You can check PulseCount…

b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");

(
{ |n = 5|
  var trig = Impulse.ar(1);
  var allowTrig = PulseCount.ar(trig) < n;
  PlayBuf.ar(1, b, BufRateScale.kr(b), trig * allowTrig, doneAction: 2 - (2 * allowTrig));
}.play;
)
1 Like

have a look here:

3 Likes