TempoClick
Creates an impulse click track on the server. The advantage of this over a Synth running an Impulse is that the server's sample rate may not match the language-side clock exactly. That Synth could drift out of sync with the language after several minutes. TempoClick uses one Impulse synth per beat, keeping together with its language-side clock.
*new(server, clock, bus, subdiv = 1)
server: The server on which the click will be placed.
clock: The TempoClock to which the click track will be synchronized. It must be a TempoClock.
bus: The control-rate bus that will receive the impulses. You should typically not specify this, so the click will grab its own bus.
subdiv: The tempo resolution, in 1/nths of the beat. If you want a click track to have four clicks per beat, use subdiv:4.
The click will be played automatically. It consumes very little processor power.
free
Stop the click track and free server resources.
Example:
b = Buffer.read(s, "sounds/a11wlk01.wav");
c = TempoClick(s, TempoClock.default, subdiv: 8);
(
a = {
var click = In.kr(c.bus, 1), // you can also map the kr bus to a SynthDef argument
tProb = TRand.kr(0.0, 1.0, click) < 0.6, // like 0.6.coin
trig = click * tProb,
bufFr = BufFrames.ir(b),
start = TRand.kr(0, bufFr - (0.125 * BufSampleRate.ir(b)), trig),
pos = Phasor.ar(trig, 1, start, 1e26, start),
sig = BufRd.ar(1, b, pos, loop: 0),
decay = Decay2.kr(trig, 0.01, 0.1);
(sig * decay) ! 2
}.play;
)
// TempoClick uses server.latency, just like patterns by default
// so this Pbind will stay in sync with the synth
(
p = Pbind(
\degree, Pstutter(Pwhite(1, 4, inf), Pwhite(-2, 9, inf)) - #[0, 2, 4],
\dur, Pwrand([Pseq(#[0.125, 0.375], 1), 0.25, 0.5, 0.75], #[1, 4, 3, 1].normalizeSum, inf),
\sustain, max(0.12, Pkey(\dur) * Pwrand(#[0.2, 0.4, 0.8], #[0.6, 0.3, 0.1], inf)),
\amp, Pexprand(0.02, 0.1, inf)
).play;
)
p.stop;
a.free;
c.free;