Skip to content

lagud

Exponential Lag.

Plugin opcode in scugens.

Exponential lag with different smoothing time for up- and downgoing signals. Port of Supercollider's LagUD.

This is essentially the same as the opcode lag except that you can supply a different 60 dB time for ascending and descending signals. This is useful for smoothing out control signals, where "fade in" should be different from "fade out", or to model the attack/release of a gate, etc.

For a constant input, each lag time specifies how long it takes to reduce the difference from the target to 0.1% of its starting value.

Syntax

aout = lagud(ain, klagup, klagdown [, initialvalue])
kout = lagud(kin, klagup, klagdown [, initialvalue])
aout lagud ain, klagup, klagdown [, initialvalue]
kout lagud kin, klagup, klagdown [, initialvalue]

Initialization

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

Performance

ain, kin -- input signal

klagup -- 60 dB lag time in seconds for the upgoing signal. Use zero for no smoothing in this direction.

klagdown -- 60 dB lag time in seconds for the downgoing signal. Use zero for no smoothing in this direction.

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

Examples

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

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

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

instr 1
  kx = randh(2, 1)
  kx2 = lagud(kx, 1.0, 0.1, 1)
  printks "x %f  x2 %f\n", 0.1, kx, kx2
endin

instr 2
  kmidis[] fillarray 60, 65, 60, 65, 60
  ilen = lenarray(kmidis)
  kidx = int(linseg(0, ilen*2, ilen-0.00000001))
  kmidi = mtof(kmidis[kidx])
  afreq = lagud(a(kmidi), 1, 0.1)
  a0 = oscili(0.7, afreq)
  kfreq = lagud(kmidi, 1, 0.1)
  a1 = oscili(0.7, kfreq)
  outch 1, a0
  outch 2, a1
endin

</CsInstruments>
<CsScore>
; i 1 0 10
i 2 0 12

</CsScore>
</CsoundSynthesizer>

See also

Standard Filters: Control signal filters

Credits

By: Eduardo Moguillansky 2017