home/ atoms/ sc-buffer-playbuf

PlayBuf plays a Buffer at a controllable rate, with optional looping and a trigger to jump to startPos

PlayBuf reads through a Buffer automatically according to a playback rate argument. The rate is a ratio: 1 = normal speed, 2 = double speed, -1 = reverse. The numChannels argument must match the buffer’s channel count — a mismatch silently produces wrong output. Use BufRateScale.kr(buf) to compensate for differing buffer and server sample rates. Loop=1 makes PlayBuf loop and ignore doneAction. A t_trig argument allows jumping back to startPos. PlayBuf’s doneAction defaults to 0, which leaves finished Synths consuming CPU — specify doneAction:2 for one-shot sounds.

Examples

sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf) * rate, t_trig, start, loop, doneAction:da); Transpose by semitones: \rate, 7.midiratio (a perfect fifth up).

Assessment

A student loads a stereo buffer and uses PlayBuf.ar(1, buf). The sound plays in mono only and sounds pitched down. Identify both bugs and fix them.

“The main difference between these two is that PlayBuf will read through a buffer automatically according a given playback rate, whereas BufRd doesn't have a rate argument”
corpus · supercollider-tutorials-full-transcripts-and-code-eli-fields · chunk 20