That’s a simple typo !
You didn’t specify the startPos
flag argument, so, currently, your startPos variable is passed as trigger
:
This should be:
sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf) * rate, startPos: startPos, loop: 0);
or
sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf) * rate, 0, startPos, loop: 0);
As a side note, even if it does not impact your algorithm, I’d advocate using z[\buffer]
and z[\bufferPlayer]
instead of z.buffer
and z.bufferplayer
(see this post about this syntax distinction).