home/ atoms/ sc-lag-portamento

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.

“lag time" (duration of the ramp), in this case, is 2 seconds. This is what causes the glissando effect you hear after running the last line of the example.”
corpus · a-gentle-introduction-to-supercollider-ruviaro-archive-org-c · chunk 15