Skip to content

diodeladder

Zero-delay feedback implementation of a 4 pole (24 dB/oct) diode low-pass filter.

⚠ Deprecated alias

diode_ladder is a deprecated alias of diodeladder in Csound 7. Use diodeladder in new code. The old name still works for compatibility.

This filter design was originally used in the EMS VCS3 and was the resonant filter in the Roland TB-303.

Syntax

asig = diodeladder(ain, xcf, xk [, inlp, isaturation, istor])
asig diode_ladder ain, xcf, xk [, inlp, isaturation, istor]

Initialization

istor --initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

Performance

asig -- low-pass output signal.

ain -- input signal.

xcf -- filter cutoff frequency (i-, k-, or a-rate).

xk -- filter feedback value k (i-, k-, or a-rate) that controls resonance. Range 0.0-17.0 . Self-oscillation occurs at 17.0.

knlp (optional, default=0) -- Non-linear processing method. 0 = no processing, 1 = higher-quality NLP, 2 = lower-quality NLP (faster). Method 1 uses (1.0 / tanh(ksaturation)) * tanh(ksaturation * input). Method 2 uses tanh(ksaturation * input). Enabling NLP may increase the overall output of filter above unity and should be compensated for outside of the filter.

ksaturation (optional, default=1) -- saturation amount to use for non-linear processing. Values > 1 increase the steepness of the NLP curve.

Examples

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

Example of the diodeladder opcode.
<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>

sr  = 44100
ksmps  = 16
nchnls  = 2
0dbfs   = 1


sine@global:i = ftgen(0, 0, 65537, 10, 1)
cutfq@global:k = init(6000)

instr modulation 
  cutfq = lfo(4000, 0.1) + 6000 
endin

instr bass       
  amp:i = ampdbfs(-12) 
  pch:i = cps2pch(p4, 12)

  sig:a = vco2(0.5, pch, 0)

  cut:a = expon(i(cutfq), p3, 200) 
  Out:a = diodeladder(sig, cut, 8, 1, 4)

  Out *= expseg(1.0, p3 - 0.05, 1.0, 0.05, 0.001) 
  Out = limit(Out, -1.0, 1.0)
  out(Out, Out)
endin

pat@global:i[] = init(8)
pat[0] = 6.00
pat[1] = 7.00
pat[2] = 6.00
pat[3] = 7.00
pat[4] = 5.07
pat[5] = 6.07
pat[6] = 5.08
pat[7] = 6.08

instr player
  ndx:i = p4

  ;; play instrument
  if pat[ndx] > 0 then
    schedule("bass", 0, 0.2, pat[ndx])
  endif

  ;; temporal recursion
  schedule("player", 0.2, 0.1, (ndx + 1) % lenarray(pat))
endin

schedule("modulation", 0, -1)
schedule("player", 0, 0.1, 0)
eventi("e", 0, 0.1 * 128)

</CsInstruments>

<CsScore>  
</CsScore>

</CsoundSynthesizer>

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

Example of the diode_ladder opcode.
<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>
sr=44100
ksmps=16
nchnls=2
0dbfs=1


gi_sine ftgen 0, 0, 65537, 10, 1

gkcut init 6000


instr modulation 
  gkcut = lfo(4000, 0.1) + 6000 
endin

instr bass       

  iamp = ampdbfs(-12) 
  ipch = cps2pch(p4, 12)

  asig = vco2(0.5, ipch, 0)

  acut = expon:a(i(gkcut), p3, 200) 
  aout = diode_ladder(asig, acut, 8, 1, 4)

  aout *= expseg:a(1.0, p3 - 0.05, 1.0, 0.05, 0.001) 

  aout = limit(aout, -1.0, 1.0)

  outc(aout, aout)

endin


gipat[] init 8
gipat[0] = 6.00
gipat[1] = 7.00
gipat[2] = 6.00
gipat[3] = 7.00
gipat[4] = 5.07
gipat[5] = 6.07
gipat[6] = 5.08
gipat[7] = 6.08


instr player
  indx = p4

  ;; play instrument
  if(gipat[indx] > 0) then
    schedule("bass", 0, 0.2, gipat[indx])
  endif

  ;; temporal recursion
  schedule("player", 0.2, 0.1, (indx + 1) % lenarray(gipat))

endin

schedule("modulation", 0, -1)
schedule("player", 0, 0.1, 0)
event_i("e", 0, 0.1 * 128)

</CsInstruments>

<CsScore>  
</CsScore>

</CsoundSynthesizer>

References

This filter is based on the work of Will Pirkle that employs Vadim Zavalishin's work with bilinear tranforms to create topology-preserving transform (TPT) implementations of analog filters.

  1. Pirkle, Will. Designing Software Synthesizer Plug-ins in C++: For RackAFX, VST3, and Audio Units. CRC Press, 2014.
  2. Pirkle, Will. AN-6: Virtual Analog (VA) DiodeLadder Filter. 2013.
  3. Zavalishin, Vadim. "The Art of VA filter design." Native Instruments, 2012.

See also

Standard filters: Zero-delay Feedback Filters (Virtual Analog)

Credits

Author: Steven Yi
April 2017

New in Csound 6.09.0