I realise this question is something of a meme, but I have, I think, a specific angle on it.
Here’s my code.
(SynthDef(\LFOexample, {|out|
var sig = SinOsc.ar(440);
var lfo = SinOsc.ar(Rand(0.1,10));
var impulse = Impulse.ar(5);
var env = EnvGen.kr(Env.perc(0.02, 4), impulse, doneAction:0);
sig = sig * lfo *env;
Out.ar(out, sig);
}).add;
)
Synth(\LFOexample);
What I would like to happen is that each time there is a new Impulse the LFO generates a new random value. I realise that will not happen because Rand…
generates this when the SynthDef first starts playing, and remains fixed for the duration of the synth’s existence.
I realise on the language side I could solve this problem easily by sending a new random value, but for long and boring reasons - that include wanting the ‘clock’ to be in the SynthDef - I don’t want to do this.
I want the SynthDef to generate a new random value each time there is a new Impulse. I’ve tried using LFNoise.ar to generate random values, but no luck, as it keeps generating new values out of sync with the Impulse.
Is there a way to do this, or am I barking up the wrong tree?
Thanks, Dom