The Lag UGen smooths abrupt parameter changes by creating a linear ramp over a specified duration
When a synth parameter (like frequency) is changed with .set, the change is instantaneous. Wrapping the parameter in Lag.kr(freq, lagTime) causes SC to interpolate smoothly over lagTime seconds, producing portamento/glissando effects. In the SynthDef, the argument is enclosed: Lag.kr(freq, 2) means changes to freq ramp over 2 seconds. SystemClock.sched can automate periodic parameter changes that then glide via Lag.
Examples
SynthDef(‘glide’,{arg freq=440; Out.ar(0, SinOsc.ar(Lag.kr(freq,2),mul:0.1))}).add; x = Synth(‘glide’); x.set(\freq, 880); // glides to 880 over 2 seconds
Assessment
Explain the audible difference between setting \freq directly and wrapping it in Lag.kr(freq, 1). Write both versions.