Hi James
Thanks for your suggestion. One of those rare periods without a computer nearby meant i couldn't try this out sooner. Here's my stab at implementing what you described. Your description makes sense to me, but I'm going wrong somewhere.
With the following code, the metronome ticks away, but when i run the line to generate a quantizedbleep synth, no beep is heard. I guess the gate isn't being opened properly (?). I'm using a SetResetFF toggle here with the idea of quantizing gate=0 messages too, as the next step.
Can you see where i'm going wrong?
(
var metronome_bus;
s = Server.local;
s.reboot;
s.waitForBoot({
// A metronomic pulse
SynthDef("metronome", { arg hz,metronome_bus;
var im=Impulse.ar(hz, 0.0, 1);
OffsetOut.ar(metronome_bus,im);
Out.ar(0,im);
}).send(s);
// Beeps should be quantized to be synchronised with the metronome pulse
SynthDef("quantisedbeep", { arg gate=1,metronome_bus;
var quantizedgate=SetResetFF.ar(
Trig.ar(gate,0.9)*(In.ar(metronome_bus)),
0
);
var env=Env.asr(0.005, 0.5, 0.005, 1, 'linear');
var env_gen=EnvGen.kr(env, gate: quantizedgate, doneAction: 2);
var sine = SinOsc.ar(900,0,0.5);
var note = (sine)*(env_gen);
Out.ar(0,note);
}).send(s);
SystemClock.sched(0.5,
{
m=Bus.audio(s);
t=Synth(\metronome,[\hz,1,\metronome_bus,m]);}
);
})
)
(
// Run this manually in between clicks. The note should begin on the following click.
s=Synth("quantisedbeep",[\metronome_bus,m]);
)