I’m trying to make a sample play every time I tap my foot. It actually works, but there’s an issue. If the trigger isn’t long enough, the sample stops before it’s complete. And if I trigger is long enough that I tap my foot twice it won’t play the sample the second time.
To add to the complexity, I also want to have a loop mode, where it plays the sample continuously, but restarts the sample if I tap my foot. But perhaps one step at a time
Here’s a small sample that demonstrates the problem.
SynthDef("simpleTrig", {
arg buf;
var trigger = Trig.ar(Impulse.ar(1), 1.6);
var snd=PlayBuf.ar(2, buf, BufRateScale.kr(buf), trigger: trigger);
Out.ar(0, snd);
}).send(s);
So, with this example I want the sample to play once a second, but since the trigger is 1.6s long, it only plays every two seconds. If the sample is 1.2 secs long, and I set the trigger to .9s, it will play every second, but the sample gets cut off.
Maybe there’s another method I should focus on, but PlayBuf seemed like the right direction. Any advice?
Thanks,
Paul