Skip to content

lag

Exponential Lag.

Plugin opcode in scugens.

lag smooths a signal with a 60 dB lag time. For a constant input, this is the time needed to reduce the difference from the target to 0.1% of its starting value. It is a port of SuperCollider's Lag.

Syntax

aout = lag(ain, klagtime [, initialvalue])
kout = lag(kin, klagtime [, initialvalue])
aout lag ain, klagtime [, initialvalue]
kout lag kin, klagtime [, initialvalue]

Initialization

initialvalue -- optional starting value for the filter. If omitted, the filter starts at the first input value.

Performance

ain, kin -- input signal

klagtime -- 60 dB lag time in seconds. Use zero for no smoothing.

At audio rate, changes to the lag time take effect smoothly over one control block.

Examples

Here is an example of the lag opcode. It uses the file lag.csd.

Example of the lag opcode.
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0

instr 1
  ; smooth a krate signal  
  kx = floor(line(0, p3, 10))
  kx2 = lag(kx, 0.1)
  printk2 kx2
endin

instr 2
  ; smooth an audio signal
  kmidi = floor(line(60, p3, 72)/2)*2
  afreq = upsamp(mtof(kmidi))
  afreqsmooth = lag(afreq, 1)
  a1 = oscili(1, afreq)
  a2 = oscili(1, afreqsmooth)
  outch 1, a1
  outch 2, a2 
endin

</CsInstruments>
<CsScore>
i 1 0 5
i 2 0 10

</CsScore>
</CsoundSynthesizer>

See also

Standard Filters: Control signal filters

Credits

By: Eduardo Moguillansky 2017