Lags and controlnames

Ndef(\node1, {SinOsc.ar(\freq.ar.lag(1), 0, 0.1)}).play;
Ndef(\node1).set(\freq, [1000.rand+100]);

Here’s a pretty straightforward example - there’s a Node that’s being set with a new frequency value.There’s a lag on it. Is there a convenient way to change the lag time externally? I can imagine adding an additional ControlName for all of the potential lags that I would want to change - but I’m curious if there is a better way.

Thanks!

There’s no “automatic” way to control lags. For more complex synths, I sometimes do something like this:

(
{
	var lagMult = \lagMult.kr(1, spec:[0, 10]);
	var lagAdd = \lagAdd.kr(0, spec:[-10, 10]);
	var ctrl = {
		|name, spec, defaultLag=0|
		var lagName = "%Lag".format(name).asSymbol;
		var lagAmount = lagName.kr(defaultLag, spec:[0, 10]);
		
		name.kr(spec:spec).lag(lagMult * lagAmount + lagAdd);
	};
	
	var lpfFreq = ctrl.(\lpfFreq, \freq.asSpec, 0);
}	
)

This is nice because I can do things like set ALL lags to the same value:

synth.set(\lagMult, 0, \lagAdd, 3.4);

scale all lags…

synth.set(\lagMult, 1.2);

or set individual parameter lags:

synth.set(\lpfFreq, 440 \lpfFreqLag, 1.1);
4 Likes

Hi Scztt-

Thanks for the insight…
I think I understand that you’re making a lag “factory” (is that the correct terminology?) - but just to clarify, you would be making all-new control names for every parameter of every synth you wanted to lag? What would normally be “\freq” in the LPF, for instance, is now being named lpfFreq?

I’m still a little unclear where the LPF synth would be defined in this, also…

Yes, factory is the right term here :slight_smile:
But no, I wouldn’t make new control names - lpfFreq was only an example. If I wanted my \freq to be laggable, I would just do freq = ctrl.(\freq, \freq.asSpec, 0); - this would construct a regular \freq control AND a \freqLag control.

2 Likes