Wave Digital Filters and Virtual Analog

Lecture 6 · From the circuit to the digital filter

Dr.-Ing. Maximilian Schäfer · Prof. Dr.-Ing. Sebastian J. Schlecht

Where we are

One question, asked of every method

Block Representation Generator
Filters and effects LTI and time-varying systems hand-designed
Classical synthesis samples, partials, modes, physical state hand-designed
DDSP the same structured models parameters learned
Reverberation a recursive dynamical system hand-designed, fittable
Diffusion a learned representation learned

 

The four questions

  1. How is the sound represented?
  2. What are the controllable parameters?
  3. What structure is built in?
  4. What is fixed by design, and what is learned?

Filters and effects, part 5 of 5. Last time: delay lines and Karplus–Strong. Today: wave digital filters: from the schematic of a circuit to a digital filter, linear and nonlinear.

Wave Digital Filters

Wave Digital Filters (WDF) Idea and applications

  • Originally developed by Alfred Fettweis (1970s) for the design of digital filters from analog prototypes (Fettweis, 1986)
  • Idea: Transition from the Kirchhoff domain (voltage and current) into a wave domain (incident and reflected wave)

Application in Sound synthesis:

  • Convert lumped acoustic models into digital ones using the bilinear transform
  • Modeling of nonlinear excitation mechanisms (Piano hammer, reed in wind instruments)
  • Linear resonator models (woodwind bore)

Application in Virtual Analog Modeling

  • WDFs are currently used for the modeling of musical electronic circuits
  • Modeling of guitar effects pedals (Big Muff, Tube screamer, etc.)
  • Modeling of amplifiers (Mesa Boogie Mk2, Fender Bassman, etc.)
  • …

 

Kirchhoff port: current i(t) into the port and voltage u(t) across it.

Wave port: incident wave a(t) and reflected wave b(t).

Wave Digital Filters (WDF) From Kirchhoff variables to waves

  • Transition from voltage and current to incident and reflected wave by the mapping rule: \[a(t) = u(t) + R\,i(t), \qquad b(t) = u(t) - R\,i(t)\]
  • Individual components (resistors, capacitors, etc.) and connection structures (serial/parallel) are transformed into the WD domain separately:

Table of components and their wave digital counterparts: source, resistor, capacitor as a unit delay, and the two-port adaptor with port resistances.

  • Transition from Kirchhoff to WD domain also possible for complex non-linear components (see references on WDF)

WDF and the bilinear transformation: the RC low-pass

RC lowpass circuit: source u_in, resistor R, capacitor C, output u_C.

The simplest passive RC low-pass, a treble-cut tone control: \[\frac{U_\mathrm{C}(s)}{U_\mathrm{in}(s)} = \frac{1}{1 + sRC}, \qquad \omega_\mathrm{c} = \frac{1}{RC}\]

 

So far we transformed the transfer function. A circuit has component values, possibly nonlinear components, and then no transfer function at all.

Idea

Apply the bilinear transform to each component and keep the circuit’s structure: that is the wave digital filter.

A capacitor becomes a unit delay

Capacitor, \(U = \frac{1}{sC} I\), in waves:

\[\frac{B}{A} = \frac{U - RI}{U + RI} = \frac{1 - sRC}{1 + sRC}\]

Bilinear transform with \(R = \frac{T}{2C}\) gives \(sRC = \frac{z - 1}{z + 1}\):

\[\frac{B}{A} = \frac{(z+1) - (z-1)}{(z+1) + (z-1)} = z^{-1}\]

 

Component Kirchhoff Port \(R\) Wave digital
resistor \(u = R_\mathrm{r}\, i\) \(R_\mathrm{r}\) \(b = 0\)
capacitor \(U = \frac{1}{sC} I\) \(\frac{T}{2C}\) \(b[k] = a[k-1]\)
inductor \(U = sL\, I\) \(\frac{2L}{T}\) \(b[k] = -a[k-1]\)
source \(u = u_\mathrm{Q} + R_\mathrm{i}\, i\) \(R_\mathrm{i}\) \(b = u_\mathrm{Q}\)
open circuit \(i = 0\) any \(b = a\)

Connecting components: adaptors

Parallel adaptor, ports \(0 \dots n\) share one voltage \(v\):

\[v = \frac{\sum_i G_i\, a_i}{\sum_i G_i}, \qquad b_i = 2v - a_i, \qquad G_i = \frac1{R_i}\]

Choose one port reflection-free (\(G_0 = \sum_{i \ge 1} G_i\)): its output wave \(b_0 = \sum_{i \ge 1} \frac{G_i}{G_0}\, a_i\) does not depend on its own input \(a_0\). For series/parallel circuits this breaks every delay-free loop: the circuit becomes a tree, computed leaves → root → leaves, once per sample.

 

WDF tree of the RC lowpass: source and capacitor connected by a parallel adaptor to the root, an open circuit or a diode pair.

Same filter, two routes

Route 1: transfer function → bilinear transformation → \(H_\mathrm{d}(z) = \frac{1 - z_\infty}{2}\frac{z+1}{z - z_\infty}\)

Route 2: circuit → wave digital filter (source, capacitor, parallel adaptor, open-circuit root)

Identical

With \(R\) = 2.2 kΩ, \(C\) = 10 nF (\(f_\mathrm{c}\) = 7.2 kHz) the two outputs on the riff differ by about \(10^{-16}\) (machine precision). A linear WDF is the bilinear transform of its circuit.

 

  • the WDF uses the component values directly: no prewarping (\(\omega_\mathrm{c} T/2\) instead of \(\tan(\pi f'_\mathrm{c}/f_\mathrm{s})\))
  • every component keeps its own state and parameter: a potentiometer is a single number
  • passivity of the circuit carries over (Fettweis’ motivation): robust, e.g. against coefficient quantization

Zero-delay feedback: the TPT state-variable filter

Magnitude responses of the TPT state-variable filter (lowpass, bandpass, highpass) against the analog filter, and a bandpass at 8 kHz where the classic SVF detunes.

TPT low-pass, \(Q = 4\), \(f_\mathrm{c}\) = 200 Hz → 8 kHz

 

  • the analog state-variable filter: two integrators in a feedback loop
  • replace each integrator by the trapezoidal rule (the bilinear transformation) and solve the loop for the current sample, no unit delay in the loop
  • \(g = \tan(\pi f_\mathrm{c}/f_\mathrm{s})\): prewarping built in, identical to the bilinear transform of the analog filter
  • the classic SVF with a unit delay in the loop detunes: its 8 kHz band-pass peaks at 10–11 kHz
  • the same idea as the WDF: keep the topology, discretize each element

V. Zavalishin, The Art of VA Filter Design, 2020 (topology-preserving transform).

Beyond the transfer function: a diode clipper

Circuit: source u_in, series resistor R, capacitor C in parallel with two antiparallel diodes, output u_C.

Replace the open circuit at the root by two antiparallel diodes, \(i = 2I_\mathrm{s}\sinh(v/V_\mathrm{T})\). At the root, per sample, solve \[\frac{a - v}{R_0} = 2 I_\mathrm{s} \sinh\frac{v}{V_\mathrm{T}}, \qquad b = 2v - a\] with \(R_0 = 1/G_0\) (Newton iterations, warm-started from the last sample).

 

input
0.2 V
2 V
20 V

Voltage across the capacitor of the diode clipper for input peaks of 0.2 V, 2 V and 20 V: the larger the input, the flatter the clipped tops. Run at 4 × 44.1 kHz; output peaks 0.20 V, 0.56 V, 0.68 V.

Nonlinear means new frequencies: aliasing

Four spectra of a 2.5 kHz sine through tanh(10x): naive, 4x oversampled, ADAA, ADAA with 2x oversampling; harmonics in blue, aliased components in red.

 

A clipper creates harmonics above \(f_\mathrm{s}/2\); they fold back as inharmonic components.

  • oversampling (4×): interpolate to \(4f_\mathrm{s}\), clip, low-pass, decimate
  • antiderivative antialiasing (ADAA): \(y[n] = \dfrac{F(x[n]) - F(x[n-1])}{x[n] - x[n-1]}\) with \(F' = f\): one evaluation of \(F\) instead of \(f\) plus a division per sample; suppression strongest below 10 kHz, usually combined with moderate (2×) oversampling

S. Bilbao, F. Esqueda, J. D. Parker, V. Välimäki, “Antiderivative antialiasing for memoryless nonlinearities,” IEEE SPL, 2017.

Listen: aliasing

2.5 kHz sine through \(\tanh(10x)\), naive
sine, 4× oversampled
sine, ADAA
riff, naive
riff, ADAA

 

Listen

The naive sine has tones that are not harmonics of 2.5 kHz. Can you hear them? Which version removes them, and at what cost?

Wave Digital Filters (WDF) - Examples WDF model of the clipping stage of a BIG MUFF PI

Schematic of the Big Muff Pi clipping stage: transistor stage with diode pair D3, D4 in the feedback path.

WDF adaptor structure of the Big Muff clipping stage: an R-type adaptor at the root connecting diodes, transistor and the linear components.

Photo of an Electro-Harmonix Big Muff Pi pedal. Big Muff Pi · Skimel, CC BY-SA 4.0

🔊 input and WDF model: played in the lecture

Figures reproduced from Fig. 2(a) (clipping stage) and Fig. 2(e) (WDF adaptor structure) of K. J. Werner, V. Nangia, J. O. Smith III, and J. S. Abel, “Resolving Wave Digital Filters with Multiple/Multiport Nonlinearities,” in Proc. 18th Int. Conf. Digital Audio Effects (DAFx-15), Trondheim, Norway, Nov. 30 – Dec. 3, 2015 · paper

Wave Digital Filters (WDF) - Examples WDF model of a MesaBoogie MK2: circuit, lead mode

Analog circuit for “lead” mode:

Schematic of the Mesa/Boogie Mark II-B preamplifier in lead mode, stages 1 to 6 with tubes and tone stack.

Figure reproduced from Fig. 5(a) of J. Zhang and J. O. Smith III, “Real-Time Wave Digital Simulation of Cascaded Vacuum Tube Amplifiers using Modified Blockwise Method,” in Proc. 21st Int. Conf. Digital Audio Effects (DAFx-18), Aveiro, Portugal, Sept. 4–8, 2018 · paper

Wave Digital Filters (WDF) - Examples WDF model of a MesaBoogie MK2: circuit, clean mode

Analog circuit for “clean” mode:

Schematic of the Mesa/Boogie Mark II-B preamplifier in clean mode, stages 1 to 6 with tubes and tone stack.

Figure reproduced from Fig. 5(b) of J. Zhang and J. O. Smith III, “Real-Time Wave Digital Simulation of Cascaded Vacuum Tube Amplifiers using Modified Blockwise Method,” in Proc. 21st Int. Conf. Digital Audio Effects (DAFx-18), Aveiro, Portugal, Sept. 4–8, 2018 · paper

Wave Digital Filters (WDF) - Examples WDF model of a MesaBoogie MK2: WDF structure

Realization by WDF structure:

Blockwise WDF model of the Mesa/Boogie preamplifier: one WDF tree per stage, connected for the lead and the clean branch.

 

dry

WDF model

Audio demo by Jingjie Zhang, played from his project page.

Figure reproduced from Fig. 6 of J. Zhang and J. O. Smith III, “Real-Time Wave Digital Simulation of Cascaded Vacuum Tube Amplifiers using Modified Blockwise Method,” in Proc. 21st Int. Conf. Digital Audio Effects (DAFx-18), Aveiro, Portugal, Sept. 4–8, 2018 · paper

Wave Digital Filters (WDF) - Examples WDF model of a Hammond Chorus/Vibrato Unit: circuit

Analog circuit:

Schematic of the Hammond vibrato/chorus: an LC ladder with 18 sections and taps feeding a rotating scanner.

Photo of a Hammond B3 organ with a Leslie 122 speaker. Hammond B3 with Leslie 122 · it:user:Salli, CC BY-SA 3.0

 

Figure reproduced from Fig. 1 of K. J. Werner, W. R. Dunkel, and F. G. Germain, “A Computational Model of the Hammond Organ Vibrato/Chorus using Wave Digital Filters,” in Proc. 19th Int. Conf. Digital Audio Effects (DAFx-16), Brno, Czech Republic, Sept. 5–9, 2016 · paper

Wave Digital Filters (WDF) - Examples WDF model of a Hammond Chorus/Vibrato Unit: WDF structure

Realization by WDF structure:

WDF structure of the Hammond LC ladder: root adaptor with source and switch, then repeated series and parallel adaptor sections.

🔊 WDF model: played in the lecture

 

Figure reproduced from Fig. 5(a) of K. J. Werner, W. R. Dunkel, and F. G. Germain, “A Computational Model of the Hammond Organ Vibrato/Chorus using Wave Digital Filters,” in Proc. 19th Int. Conf. Digital Audio Effects (DAFx-16), Brno, Czech Republic, Sept. 5–9, 2016 · paper

Wrap-up

Check yourself

The capacitor

In the wave domain a capacitor becomes \(b[k] = a[k-1]\) with port resistance \(R_\mathrm{C} = \frac{T}{2C}\). Where did the bilinear transformation of lecture 2 go?

The four questions, for filters and effects

Prototype + bilinear / allpass transformation Wave digital filter
Representation rational transfer function \(H_\mathrm{d}(z)\), difference equation waves at the ports of a circuit tree
Controls gain \(G\), cutoff/center frequency, bandwidth or \(Q\) (and \(f_\mathrm{s}\)) component values \(R\), \(C\), \(L\), potentiometers
Built-in structure analog prototype, order and stability preserved, frequency warped circuit topology, passivity, nonlinear elements
Fixed vs. learned designed, closed form for every knob designed from the schematic (white box); grey-box fitting of amp models in lecture 10

Take away

Waves instead of \(u\) and \(i\)

\(a = u + R\,i\), \(b = u - R\,i\): every component becomes a simple digital element, every connection an adaptor.

 

Linear circuits

A linear WDF is the bilinear transform of the circuit, computed component by component and stable by construction (passivity).

 

Nonlinear circuits

Diodes, transistors and tubes sit at the root of the tree: the route to virtual analog models of pedals, amplifiers and organs.

This closes the filters block. Lecture 7 starts the synthesis block: oscillators and spectra.

Further reading

  • A. Fettweis, “Wave digital filters: theory and practice,” Proc. IEEE 74(2), 1986
  • K. J. Werner, Virtual analog modeling of audio circuitry using wave digital filters, PhD thesis, Stanford University, 2016
  • V. Zavalishin, The Art of VA Filter Design, rev. 2.1.2, 2020 (freely distributed PDF)
  • S. Bilbao, F. Esqueda, J. D. Parker, V. Välimäki, “Antiderivative antialiasing for memoryless nonlinearities,” IEEE Signal Processing Letters 24(7), 2017
  • J. O. Smith III, Physical Audio Signal Processing, online book
  • K. J. Werner, V. Nangia, J. O. Smith III, J. S. Abel, “Resolving Wave Digital Filters with Multiple/Multiport Nonlinearities,” Proc. DAFx-15, Trondheim, 2015
  • K. J. Werner, W. R. Dunkel, F. G. Germain, “A Computational Model of the Hammond Organ Vibrato/Chorus using Wave Digital Filters,” Proc. DAFx-16, Brno, 2016
  • J. Zhang, J. O. Smith III, “Real-Time Wave Digital Simulation of Cascaded Vacuum Tube Amplifiers using Modified Blockwise Method,” Proc. DAFx-18, Aveiro, 2018

WDF slides from the WS 25/26 lecture slides (M. Schäfer); figures redrawn in TikZ (slides/filters_tikz/), example figures from the cited DAFx papers, added examples by the slides/make_filters_*.py scripts in the course repository.