Sound Effects


Topics in Digital Heritage:
Numerical Methods for Digital Reconstruction

Jin Woo Lee

KAIST

Fall 2026

Recap

Tools from Classes 12–18 We Reuse Today

  • Shared variable: exciter and resonator exchange one force; one scalar equation per step, Newton if nonlinear (16)
  • Modes: linear parts as exact oscillators, no numerical dispersion (17)
  • Hopf: oscillation starts when input beats loss (18)
  • Stiffness: explicit needs \(k|\lambda|\) small (12)
  • Today: put a magnet under the string.

Show code
s = ModalString(110.0, OPEN["A2"], B_open=1.5e-4)        # class 15 stiff string, as exact modes
(F_b,), _ = s.response(s.pluck(0.12), 2.0, [s.bridge_weights()])
save_wav("recap_string", F_b)
fig, ax = plt.subplots(figsize=(5.0, 2.3))
show_spec(ax, F_b, f"A2 string, {len(s.p)} exact modes: the force on the bridge")
ax.set_xlabel("time (s)"); ax.set_ylabel("kHz")
plt.tight_layout()
plt.show()

an acoustic string: the bridge force (classes 15 to 17)

Component Model of an Electric Instrument and Its Effects

part today physics numerical method (first seen)
exciter pick, Rhodes hammer, E-bow driver coil (fed by the E-bow’s own sensor coil) contact, magnetic force lumped ODE, explicit (13, 16)
resonator guitar string, Rhodes tine + tonebar stiff string, cantilever bar modes + exact recursion (15, 17)
pickup single coil, Rhodes pickup Faraday’s law, nonlinear flux interpolation + a memoryless nonlinearity (8, 16)
circuits pickup RLC, wah filter, diode clipper, triode Kirchhoff, Shockley, Child–Langmuir trapezoid (time varying for the wah) + Newton per sample, tables, wave digital filters (5, 12)
mechanics spring and plate reverb dispersive helical spring, plate modes (15, 17)

Today’s ILO

  • Model an electromagnetic pickup by Faraday’s law (position as a comb filter, large motion as a nonlinearity) and couple it to the string and bar models to build an electric guitar and a Rhodes piano.
  • Predict when the E-bow feedback loop starts to oscillate from the loop gain per mode, and explain why saturation keeps it bounded with an energy argument.
  • Write analog circuits as (stiff, nonlinear) ODEs, solve them with the trapezoidal rule + Newton per sample, and compare explicit steps, tables, and wave digital filters in accuracy, stability, and cost; explain what a tube amp is, how it is modelled, and how it sounds; model a wah-wah pedal as a time-varying filter.
  • Explain aliasing from nonlinearities and reduce it by oversampling and antiderivative antialiasing.
  • Model spring reverb as a dispersive PDE, implement it modally, and contrast it with plate reverb.
  • Assemble a full signal chain, and map the numerical methods of the whole course onto digital reconstruction problems for the final project.

Electromagnetic Pickups

A Short History of the Electromagnetic Pickup

  • 1931: Beauchamp and Rickenbacker, the “Frying Pan” lap steel: the first commercial electromagnetic pickup
  • 1936: Gibson ES-150; Charlie Christian makes the electric guitar a solo voice
  • 1950–52: solid bodies (Fender Telecaster, Gibson Les Paul): the sound comes from string + pickup, not the body
  • mid 1950s: Seth Lover’s humbucker: two coils in opposite polarity cancel the 60 Hz hum
  • Today: almost every electric guitar and bass, the same Faraday’s law

Faraday’s Law Makes the Pickup a Velocity Sensor

Steel string moves, flux through the coil changes: \[ e=-N\frac{d\Phi}{dt},\qquad \Phi(u)=\frac{a^3}{\bigl(a^2+(d-u)^2\bigr)^{3/2}} \]

  • \(\Phi\): magnetic flux through the coil, the field lines of the magnetized string (a dipole at height \(d-u\)) that cross the coil’s disk; closer string, more lines
  • \(a\): coil radius; \(d\): rest gap; \(u\): displacement toward the pole; \(N\): turns

\[ e=-N\,\Phi'(u)\,u_t\ \approx\ -N\,\Phi'(0)\,u_t \]

  • Small motion: a velocity sensor (the bridge reads \(u_x\))
  • Large motion: \(\Phi'(u)\) varies, a nonlinearity
  • \(u_t\) exact from the modes

Show code
u = np.linspace(-1e-3, 1e-3, 400); d = 3e-3
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(5.0, 2.5))
ax1.plot(1e3 * u, flux(u, d) / flux(0.0, d), color=COL["pickup"], lw=1.8, label="$\\Phi$")
ax1.plot(1e3 * u, 1 + dflux(0.0, d) * u / flux(0.0, d), "k--", lw=1, label="tangent")
ax2.plot(1e3 * u, dflux(u, d) / dflux(0.0, d), color=COL["pickup"], lw=1.8); ax2.axhline(1, color="k", ls="--", lw=1)
ax1.set_title("flux $\\Phi(u)/\\Phi(0)$, $d=3$ mm", fontsize=9); ax2.set_title("sensitivity $\\Phi'(u)/\\Phi'(0)$", fontsize=9)
for ax in (ax1, ax2):
    ax.set_xlabel("$u$ (mm), toward the pole")
ax1.legend(fontsize=7, loc="upper left")
plt.tight_layout()
plt.show()

Pickup Position Acts as a Comb Filter on the Modes

\[ e\propto\sum_p\phi_p(x_p)\,q_p'(t),\qquad \phi_p(x_p)=\sin\frac{p\pi x_p}{L} \]

  • The pickup = interpolation \(I_{x_p}\) (class 16)
  • Pickup on a node of mode \(p\): silent (\(L/4\): \(p=4\); \(L/3\): \(p=3\)). Notches at \(p\approx m\,L/d_p\)
  • Neck (16 cm): notches \(p\approx4,8,12\), warm
  • Bridge (4 cm): first notch \(p\approx16\), thin and bright
  • Aperture 2 cm: average over a window, trapezoid quadrature (class 9), a lowpass

Show code
s = ModalString(110.0, OPEN["A2"], B_open=1.5e-4)
a = s.pluck(0.12); P = 36
fig, axs = plt.subplots(2, 1, figsize=(5.0, 2.6), sharex=True)
for ax, (name, dp, col) in zip(axs, [("neck", 0.16, COL["string"]), ("bridge", 0.04, COL["pickup"])]):
    w_pt = s.pickup_weights(dp)                        # point: sin(p pi x_p / L)
    w_ap = s.pickup_weights(dp, width=0.02)            # 2 cm aperture, trapezoid quadrature
    ref = np.abs(a * s.om)[:P]; db = lambda v: 20 * np.log10(v / ref.max() + 1e-9)
    ax.plot(s.p[:P], db(ref), color="0.6", lw=1.2)
    ax.bar(s.p[:P], db(np.abs(a * s.om * w_ap)[:P]) + 70, bottom=-70, width=0.7, color=col)
    for m in range(1, 3):
        ax.axvline(m * s.L / dp, color=col, ls=":", lw=1)
    ax.set_ylim(-70, 3); ax.set_ylabel("dB"); ax.set_xlim(0.3, P + 0.7)
    ax.set_title(f"{name} pickup, {100 * dp:.0f} cm (gray: no pickup)", fontsize=8.5)
axs[1].set_xlabel("partial $p$")
plt.tight_layout()
plt.show()
for name, dp in [("neck", 0.16), ("bridge", 0.04)]:
    (u_,), (ut_,) = s.response(a, 2.0, [s.pickup_weights(dp, width=0.02)])
    save_wav(f"pos_{name}", pickup_filter(pickup_emf(u_, ut_, linear=True)))

neck pickup (16 cm)

bridge pickup (4 cm)

Nonlinear Flux Adds a 2nd Harmonic to Hard Plucks

String is linear: \(u=A\sin\omega t\) stays a pure \(\omega\) at any \(A\) (class 17). Pickup is not: \(\Phi'(u)\approx\Phi'(0)+\Phi''(0)\,u\), so \[ e\approx-N\Phi'(0)A\omega\cos\omega t-\tfrac12N\Phi''(0)A^2\omega\,{\color{#c0392b}\sin2\omega t} \]

  • \({\color{#c0392b}2\omega}\) is new, not in the string: \(H_2/H_1=\Phi''(0)A/2\Phi'(0)\), with \(\Phi''(0)/\Phi'(0)=0.27\)/mm (\(d=3\) mm)
  • \(A=0.1\) mm: \(1.3\%\) (\(-38\) dB); \(A=1.2\) mm: \(16\%\) (\(-16\) dB). Hard plucks are brighter, not only louder
  • Two partials: also \(\omega_1\pm\omega_2\)

Show code
t = np.arange(int(0.5 * fs)) * k; w0 = 2 * np.pi * 110.0; A = np.geomspace(0.03e-3, 1.2e-3, 14)
dd = 1e-7; c2 = (dflux(dd) - dflux(-dd)) / (2 * dd) / dflux(0.0)          # Phi''(0) / Phi'(0), centered difference
fig, ax = plt.subplots(figsize=(5.0, 2.5))
for lin, col, lab in [(False, COL["pickup"], "flux model"), (True, "0.5", "linear pickup")]:
    h2 = [harmonics_db(pickup_emf(A_ * np.sin(w0 * t), A_ * w0 * np.cos(w0 * t), linear=lin), 110.0, 2)[1] for A_ in A]
    ax.semilogx(1e3 * A, np.maximum(h2, -120), "o", color=col, ms=5, label=lab)
ax.semilogx(1e3 * A, 20 * np.log10(np.abs(c2) * A / 2), "k--", lw=1.2, label="$\\Phi''(0)A/2\\Phi'(0)$")
ax.set_xlabel("amplitude at the pickup $A$ (mm)"); ax.set_ylabel("$H_2/H_1$ (dB)"); ax.set_ylim(-125, 0)
ax.set_title("2nd harmonic of a pure 110 Hz motion, $d=3$ mm", fontsize=9); ax.legend(fontsize=7, loc="center right")
plt.tight_layout()
plt.show()
s = ModalString(110.0, OPEN["A2"], B_open=1.5e-4); W = [s.pickup_weights(0.16, width=0.02)]
for tag, amp, lin in [("soft", 0.1e-3, False), ("hard", 1.2e-3, False), ("hard_linear", 1.2e-3, True)]:
    (u_,), (ut_,) = s.response(s.pluck(0.12, amp), 2.0, W)
    save_wav(f"pluck_{tag}", pickup_filter(pickup_emf(u_, ut_, linear=lin)))

soft (0.1 mm)

hard (1.2 mm)

hard, linear

Electric Guitar Model: Modal Strings Read by a Pickup

s = ModalString(f, f_open)    # fret: shorter L
a = s.pluck(d_pluck)          # triangle -> modes
W = [s.pickup_weights(d_pickup), s.bridge_weights()]
(u, F), (ut, _) = s.response(a, dur, W)
emf += pickup_emf(u, ut, gap) # a pole per string
  • Riff: A5, D5, E5, A5 power chords, strummed (4 ms per string); a new chord mutes the last
  • Acoustic vs electric: what is read, not the string

Show code
fig, axs = plt.subplots(3, 1, figsize=(5.4, 2.7), sharex=True)
for ax, (y, title) in zip(axs, [(F_riff, "bridge force (acoustic)"), (clean, "neck pickup, with its circuit"), (clean_bridge, "bridge pickup")]):
    show_spec(ax, y, title, fmax=5); ax.set_ylabel("kHz", fontsize=7); ax.tick_params(labelsize=7)
axs[-1].set_xlabel("time (s)")
plt.tight_layout(h_pad=0.2)
plt.show()

acoustic: bridge force

electric: neck pickup

electric: bridge pickup

Rhodes Piano

A Short History of the Rhodes Piano

  • 1940s: Harold Rhodes builds small pianos from aircraft parts to teach piano to wounded soldiers for their rehabilitation
  • 1959: the Rhodes Piano Bass, with Leo Fender
  • 1965–70: CBS buys Fender; the Fender Rhodes electric piano, the Stage piano (1970)
  • 1970s: the sound of jazz fusion, soul, and pop (Herbie Hancock, Chick Corea, Stevie Wonder, Billy Joel)
  • 1983 on: Yamaha DX7 FM e-piano, then samples and physical models (what we build today); new Rhodes pianos built again since the 2000s

Rhodes Tine and Tonebar as Two Coupled Oscillators

  • Tine: cantilever bar (class 15), modes \(f_1\times(1,\,6.27,\,17.55)\): a bell-like attack
  • Tonebar: heavy, tuned to \(f_1\), joined at the clamp \[ \mathbf{y}''=-\omega_1^2\begin{pmatrix}1+c&-c\\-c&1+c\end{pmatrix}\mathbf{y} \]
  • Eigenvectors (class 17): in phase shakes the mount, dies fast
  • Antiphase: forces on the mount cancel, rings for seconds (a tuning fork)
  • Hammer: \(F=K_H[u_H-J^\top\mathbf{q}]_+^{\alpha}\), explicit (class 13)

Show code
fig, ax = plt.subplots(figsize=(5.0, 2.5))
for (e, tip, F), col, lab in [(rh_nob, "0.55", "tine alone"), (rh_bar, COL["rhodes"], "tine + tonebar")]:
    tt, db = frame_db(tip)
    ax.plot(tt, db, color=col, lw=1.8, label=lab)
ax.set_ylim(-60, 2); ax.set_xlabel("time (s)"); ax.set_ylabel("tip (dB)"); ax.legend(fontsize=7.5)
ax.set_title("tine tip amplitude: the antiphase mode keeps ringing", fontsize=9)
plt.tight_layout()
plt.show()

tine alone

tine + tonebar

Rhodes Pickup Offset Controls the Harmonics

Tip swings across the pole axis: flux is a bell of the tip position \[ \Phi(s)=\bigl(1+s^2\bigr)^{-3/2},\quad s=\tfrac{\text{tip}}{w}+x_0,\quad e=-\Phi'(s)\,s_t \]

  • \(x_0=0\) (on the axis): flux drops on both sides, twice per period: only the octave
  • \(x_0=0.5\) (inflection, \(\Phi''=0\)): soft \(\approx\) sine; hard: \(H_2\approx H_1\), the bark
  • \(x_0=1.5\) (far): weaker, and a 2nd harmonic even when soft

Show code
th = np.linspace(0, 4 * np.pi, 801)[:-1]
RH_X0 = [(0.0, "0.45"), (0.5, COL["rhodes"]), (1.5, COL["pickup"])]
fig, axs = plt.subplots(3, 2, figsize=(5.0, 2.8), sharex=True)
for j, (A, lab) in enumerate([(0.3, "soft: swing $\\pm0.3w$"), (1.1, "hard: swing $\\pm1.1w$")]):
    for i, (x0, col) in enumerate(RH_X0):
        ax = axs[i, j]; s_ = A * np.sin(th) + x0
        e = 3 * s_ / (1 + s_**2)**2.5 * A * np.cos(th)          # e = -Phi'(s) s_t for a sinusoidal tip
        E = np.abs(np.fft.rfft(e))                               # two periods: harmonic h is bin 2h
        ax.plot(th / (2 * np.pi), np.sin(th), color="0.65", lw=0.9, ls="--")
        ax.plot(th / (2 * np.pi), e / np.abs(e).max(), color=col, lw=1.5)
        ax.set_yticks([]); ax.set_ylim(-1.2, 1.2); ax.set_xlim(0, 2)
        r = "octave only" if E[2] < 1e-6 * E[4] else f"$H_2/H_1$ {20 * np.log10(E[4] / E[2]):.0f} dB"
        ax.text(0.98, 0.04, r, transform=ax.transAxes, fontsize=6.5, ha="right", va="bottom", color=col,
                bbox=dict(fc="white", ec="none", alpha=0.8, pad=0.5))
        if j == 0:
            ax.set_ylabel(f"$x_0={x0:g}$", fontsize=8, color=col, rotation=0, ha="right", va="center")
    axs[0, j].set_title(lab, fontsize=8.5)
    axs[-1, j].set_xlabel("time (tip periods)", fontsize=8, labelpad=0)
fig.text(0.5, 0.995, "dashed: tip motion; solid: pickup output $e(t)$", ha="center", va="top", fontsize=7.5, color="0.35")
plt.tight_layout(h_pad=0.15, w_pad=0.6, rect=(0, 0, 1, 0.96))
plt.show()

Rhodes Spectra vs Hammer Velocity and Pickup Offset

  • Same instrument, same model: velocity changes timbre (through the pickup)
  • Listen for: octave at \(x_0=0\), clean vs bark at \(x_0=0.5\)
  • Per sample: 4 modes, 1 contact, 1 flux slope: 88 keys in real time
Fc = KH * max(uH - ws @ q, 0)**al       # contact
q, qp = c1*q - c2*qp + k**2/mt*ws*Fc, q # exact modes
s = wt @ q / w + x0                     # tip, offset
e = 3*s / (1 + s**2)**2.5 * s_t         # -Phi'(s) s_t
Show code
fig, axs = plt.subplots(1, 3, figsize=(9.0, 2.3), sharey=True)
names = {0.0: "centered on the pole", 0.5: "at the inflection", 1.5: "far from the pole"}
for ax, (x0, col) in zip(axs, [(0.0, "0.45"), (0.5, COL["rhodes"]), (1.5, COL["pickup"])]):
    for j, (tag, lab, a_) in enumerate([("soft", "soft (0.4 m/s)", 0.35), ("hard", "hard (3 m/s)", 1.0)]):
        h = harmonics_db(rh_cases[(tag, x0)][int(0.15 * fs):int(0.65 * fs)], 220.0, 6)
        hh = np.maximum(h, -80)
        ax.bar(np.arange(1, 7) + 0.2 * (2 * j - 1), hh + 80, bottom=-80, width=0.4, color=col, alpha=a_, ec=col, label=lab)
    ax.set_xticks(range(1, 7)); ax.set_ylim(-80, 4); ax.set_xlabel("harmonic $h$ of $f_1=220$ Hz", labelpad=1)
    ax.set_title(f"$x_0={x0:g}$: {names[x0]}", fontsize=9, color=col); ax.legend(fontsize=7, loc="upper right")
axs[0].set_ylabel("level (dB re strongest)")
plt.tight_layout(w_pad=0.6)
plt.show()

soft, \(x_0=0\)

soft, \(x_0=0.5\)

soft, \(x_0=1.5\)

hard, \(x_0=0\)

hard, \(x_0=0.5\)

hard, \(x_0=1.5\)

E-bow
(Electromagnetic Feedback)

A Short History of the E-bow

  • Invented by Gregory Heet; sold from 1976 (Heet Sound Products), US patent 1978
  • The first hand-held device that keeps a guitar string ringing without touching it
  • Later Plus EBow: a harmonic mode switch (we will see why it works: a reversed polarity)
  • Built-in versions: sustainer pickups (Fernandes Sustainer, Sustainiac)
  • Rock and ambient guitar: violin- or cello-like endless notes

E-bow Model: Sensor Coil, Amplifier, Driver Coil

  • Sensor coil (inside the E-bow, not the guitar pickup): \(v_s=I_{x_s}\mathbf{u}_t\)
  • Amplifier: gain \(G\), coil lowpass \(H\), supply limit \(F=F_{\max}\tanh(z/F_{\max})\)
  • Driver coil: force \(+J_{x_d}F\); mode \(p\) gets \(\phi_p(x_d)F/m\)
vs = ps @ (q - qp) / k                    # sensor: one sample delay
z = al * z + (1 - al) * G * vs            # coil lowpass
F = Fmax * np.tanh(z / Fmax)              # supply limit
q, qp = c1*q - c2*qp + k**2 * pd/m * F, q # exact modes + driver

Show code
fig, axs = plt.subplots(1, 2, figsize=(5.0, 2.5), width_ratios=[1, 2.2])
z = np.linspace(-3, 3, 200)
axs[0].plot(z, np.tanh(z), color=COL["ebow"], lw=2); axs[0].plot(z, z, "k--", lw=0.8)
axs[0].set_ylim(-1.6, 1.6); axs[0].set_title("driver force $F/F_{\\max}$", fontsize=8.5)
v = eb_runs["above"][0]; tt = np.arange(len(v)) * k
axs[1].plot(tt, v / np.abs(v).max(), color=COL["ebow"], lw=0.3)
axs[1].annotate("exponential\ngrowth", (0.25, 0.3), (0.45, -0.85), fontsize=7, arrowprops=dict(arrowstyle="->", lw=0.7))
axs[1].text(2.0, 1.08, "limited: constant amplitude", fontsize=7, ha="center")
axs[1].set_ylim(-1.2, 1.3); axs[1].set_xlabel("time (s)"); axs[1].set_ylabel("$v_s$ (normalized)", labelpad=1); axs[1].set_yticks([])
axs[1].set_title("sensor velocity at $G=20\\,G_c$", fontsize=8.5)
axs[0].set_xlabel("$z/F_{\\max}$ (amp input)", labelpad=1)
plt.tight_layout()
plt.show()

E-bow Onset Gain per Mode and Bounded Energy

Small amplitude, per mode: \[ \sigma_p^{\text{eff}}=\sigma_p-\frac{G\,\phi_p(x_s)\,\phi_p(x_d)\,\mathrm{Re}H(\omega_p)}{2m} \] \(\sigma_p^{\text{eff}}<0\): grows (Hopf, class 18). Lowest \(G_{c,p}\) wins.

Energy (class 16): \[ \frac{dH}{dt}=-2\sum_p\sigma_p\,m\,(q_p')^2+F\,u_t(x_d),\quad |F|\le F_{\max} \]

  • Loss \(\sim v^2\), input \(\sim|v|\): bounded for any \(G\)
  • No limit: input \(\sim v^2\) too, it blows up
Show code
fig, ax = plt.subplots(figsize=(5.0, 2.6))
P8 = EB.p[:8]
for pol, col, off, lab in [(1, COL["ebow"], -0.2, "normal polarity"), (-1, "0.55", 0.2, "reversed (harmonic switch)")]:
    r = ebow_thresholds(EB, XS, XD, pol=pol)[:8] / GC
    ok = np.isfinite(r)
    ax.bar(P8[ok] + off, r[ok], width=0.4, color=col, label=lab)
    ax.plot(P8[~ok] + off, np.full((~ok).sum(), 1.4), "x", color=col, ms=5, mew=1.4)
    j = np.argmin(np.where(ok, r, np.inf))
    ax.text(P8[j] + off, r[j] * 1.3, "starts\nfirst", fontsize=7, color=col, ha="center", va="bottom", linespacing=0.9)
ax.plot([], [], "x", color="0.3", label="$\\times$: never grows ($\\phi_p(x_s)\\phi_p(x_d)$ wrong sign)")
ax.set_yscale("log"); ax.set_ylim(0.7, 5000); ax.set_xticks(range(1, 9)); ax.set_xlabel("mode $p$")
ax.set_ylabel("onset gain $G_{c,p}\\ /\\ G_{c,1}$")
ax.set_title("gain at which mode $p$ starts to grow", fontsize=9); ax.legend(fontsize=6.5, loc="upper left")
plt.tight_layout(); plt.show()

Show code
fig, ax = plt.subplots(figsize=(5.0, 2.6))
for name, col, lab in [("below", "0.55", "$G=0.8\\,G_c$: loss wins, decays"), ("above", COL["ebow"], "$G=20\\,G_c$ with $\\tanh$ limit: grows, then levels off"),
                       ("nosat", COL["pickup"], "$G=20\\,G_c$, no limit: grows forever")]:
    E = eb_runs[name][1]; tE = np.arange(len(E)) * 64 * k
    ax.plot(tE, 10 * np.log10(E / E[1]), color=col, lw=1.8, label=lab)
En = eb_runs["nosat"][1]; Efin = 10 * np.log10(En[-2] / En[1])
ax.annotate(f"reaches {Efin:.0f} dB at 3 s", (0.4, 58), (0.55, 36), fontsize=7, color=COL["pickup"],
            arrowprops=dict(arrowstyle="->", color=COL["pickup"], lw=0.8))
ax.set_ylim(-50, 60); ax.set_xlim(0, 3); ax.axhline(0, color="0.8", lw=0.8)
ax.set_xlabel("time (s)"); ax.set_ylabel("string energy (dB re start)")
ax.set_title("energy $H(t)$: the limit keeps it bounded", fontsize=9); ax.legend(fontsize=6.5, loc="lower right")
plt.tight_layout(); plt.show()

E-bow Simulations Below and Above the Onset Gain

  • G3 string, sensor \(0.30L\), driver \(0.36L\) from the bridge
  • \(f_c=250\) Hz lowpass, \(F_{\max}=0.5\) mN
  • The note swells: exponential start, then a limit cycle
  • Harmonic mode: the fundamental dies, the 3rd partial grows
Show code
fig, axs = plt.subplots(1, 4, figsize=(9.6, 2.3), sharey=True)
for ax, (name, title) in zip(axs, [("pluck", "pluck only ($G=0$)"), ("below", "$G=0.8\\,G_c$: decays"),
                                   ("above", "$G=20\\,G_c$: sustain"), ("harmonic", "reversed: 3rd partial")]):
    show_spec(ax, eb_runs[name][0], title, fmax=2.5); ax.set_xlabel("time (s)")
axs[0].set_ylabel("kHz")
plt.tight_layout()
plt.show()

pluck only

\(G=0.8\,G_c\)

\(G=20\,G_c\)

harmonic mode

E-bow vs Friction Bow on the Same String

Bow (class 16): friction of the relative velocity \[ F=-F_B\,\phi(v_{\text{rel}}) \]

  • Stick-slip: one slip per period (Helmholtz)
  • Implicit at one point: Newton per step

E-bow: a magnetic force from the sensed velocity \[ F=F_{\max}\tanh\bigl(G\,(H*v_s)/F_{\max}\bigr) \]

  • Smooth, lowpassed: no sudden slip
  • Explicit loop, swells in slowly

Show code
fig, axs = plt.subplots(2, 1, figsize=(5.0, 2.7))
T0 = int(round(fs / 196.0)); n0 = int(2.5 * fs); sl = slice(n0, n0 + 3 * T0)
for (y, col, lab), off in zip([(bow_v, "#a0522d", "bow, $F_B=0.2$ N"), (eb_runs["above"][0], COL["ebow"], "E-bow, $20\\,G_c$")], [-0.2, 0.2]):
    axs[0].plot(1e3 * np.arange(3 * T0) * k, y[sl] / np.abs(y[sl]).max(), color=col, lw=1.3, label=lab)
    axs[1].bar(np.arange(1, 11) + off, harmonics_db(y[n0:], 196.0, 10) + 70, bottom=-70, width=0.4, color=col)
axs[0].set_xlabel("ms", labelpad=0); axs[0].set_yticks([]); axs[0].legend(fontsize=7, loc="lower center", ncol=2, bbox_to_anchor=(0.5, 0.98), frameon=False)
axs[0].set_title("velocity at the sensor point, 3 periods", fontsize=8.5, pad=16)
axs[1].set_ylim(-70, 3); axs[1].set_xlabel("harmonic", labelpad=0); axs[1].set_ylabel("dB")
plt.tight_layout(h_pad=0.3)
plt.show()

bow, 0.2 N

E-bow, \(20\,G_c\)

bow, pressed (1 N)

Analog Circuits as ODEs

A Short History of Distortion Circuits and Virtual Analog

Analog effects

  • 1962: Maestro Fuzz-Tone (Gibson), the first commercial fuzz; famous from “Satisfaction” (1965)
  • 1978–79: diode clipping pedals: Boss DS-1 (diodes to ground), Ibanez Tube Screamer (diodes in the feedback)

Virtual analog (the circuit, simulated)

  • 1971: Fettweis, wave digital filters
  • 1995–98: virtual analog synths (Nord Lead), amp modelers (Line 6 POD)
  • 2007–16: circuit ODEs + implicit solvers (Yeh, Abel, Smith), ADAA (Parker et al.); today’s modelers (Kemper, Fractal, Neural DSP)

Four Steps from a Circuit Diagram to Audio Samples

element law role in the ODE mechanical analog
resistor \(R\) \(v=R\,i\) algebraic damper: \(F=c\,\dot x\)
capacitor \(C\) \(i=C\,v'\) a state (its voltage) spring: \(F=\kappa x\), \(C\leftrightarrow1/\kappa\)
inductor \(L\) \(v=L\,i'\) a state (its current) mass: \(F=m\,\ddot x\)
diode \(i=I_s\bigl(e^{v/V_t}-1\bigr)\) nonlinear, algebraic one-way damper (check valve)
triode \(I_p(v_{gk},v_{pk})\) (Koren) nonlinear, algebraic valve: a small \(v_{gk}\) throttles a large flow \(I_p\)

\(v\): voltage across the element (V) \(\leftrightarrow\) force \(F\);
\(i\): current through it (A) \(\leftrightarrow\) velocity \(\dot x\); \('=d/dt\).
\(I_s\): diode saturation current; \(V_t\approx26\) mV: thermal voltage.
\(I_p\): plate current; \(v_{gk}\), \(v_{pk}\): grid–cathode and plate–cathode voltages.

  • Kirchhoff: currents into a node sum to 0; voltages around a loop sum to 0 (\(\leftrightarrow\) forces on a mass balance)
  • Element laws + Kirchhoff \(\Rightarrow\ \mathbf{x}'=f(\mathbf{x},u)\), always (a mass–spring–damper is a series \(RLC\))
  • Today: pickup + cable (linear, 2 states), diode clipper (nonlinear, 1 state), triode (nonlinear, 2 unknowns), wah (linear, time varying, 2 states)

On a Linear Circuit: Pickup Coil + Cable

Kirchhoff, state \(\mathbf{x}=(i,v)\): \[ L\,i'=e-R\,i-v,\quad C\,v'=i-v/R_L\ \Rightarrow\ \mathbf{x}'=A\mathbf{x}+B\,e \] Trapezoid (class 12) \(=\) bilinear \(s\to\frac2k\frac{1-z^{-1}}{1+z^{-1}}\)

  • Forward Euler: \(|1+k\lambda|=\) 1.075: unstable
  • Trapezoid: always stable, but warps \(\omega\to\frac2k\arctan\frac{\omega k}{2}\)
  • Prewarp \(k\) to pin one frequency

Show code
b_, a_ = pickup_tf(**PU)
f = np.logspace(np.log10(300), np.log10(20000), 2000)
Ha = freqs(b_, a_, 2 * np.pi * f)[1]                                  # analog
Hb = freqz(*bilinear(b_, a_, fs), f, fs=fs)[1]                       # trapezoid = bilinear
fpk = f[np.argmax(np.abs(Ha))]
kw = 2 * np.tan(np.pi * fpk / fs) / (2 * np.pi * fpk)                # prewarped step for the peak
Hw = freqz(*bilinear(b_, a_, 1 / kw), f, fs=fs)[1]
e_test = np.random.default_rng(1).standard_normal(2000)
gap_ss = np.abs(trapezoid_ss(*pickup_ss(**PU), e_test) - pickup_filter(e_test)).max()
fig, ax = plt.subplots(figsize=(5.0, 2.6))
ax.semilogx(f, 20 * np.log10(np.abs(Ha)), color="k", lw=2.4, label=f"analog: peak {fpk:.0f} Hz")
ax.semilogx(f, 20 * np.log10(np.abs(Hb)), color=COL["circuit"], lw=1.6, label=f"trapezoid: peak {f[np.argmax(np.abs(Hb))]:.0f} Hz")
ax.semilogx(f, 20 * np.log10(np.abs(Hw)), "--", color=COL["pickup"], lw=1.4, label="trapezoid, prewarped")
ax.set_xlabel("frequency (Hz)"); ax.set_ylabel("dB"); ax.set_ylim(-40, 12); ax.legend(fontsize=7, loc="lower left")
ax.set_title(f"pickup + cable (state space loop = scipy bilinear to {gap_ss:.0e})", fontsize=8.5)
plt.tight_layout()
plt.show()
s = ModalString(110.0, OPEN["A2"], B_open=1.5e-4)
(u_,), (ut_,) = s.response(s.pluck(0.12), 2.0, [s.pickup_weights(0.16, width=0.02)])
e_raw = pickup_emf(u_, ut_)
save_wav("circuit_raw", e_raw); save_wav("circuit_rlc", pickup_filter(e_raw))

EMF only (velocity)

through the RLC circuit

On a Nonlinear Circuit (step 1)

The Diode Clipper ODE Is Stiff

Kirchhoff at the node, Shockley for the pair: \[ C\,V'=\frac{u-V}{R}-2I_s\sinh\frac{V}{V_t}=C\,f(V,u) \]

  • Small \(V\): an RC lowpass
  • \(V\approx\pm0.6\) V: a soft wall (clipping)

\[ J(V)=-\frac{1}{RC}-\frac{2I_s}{CV_t}\cosh\frac{V}{V_t} \]

  • \(k|J|\) grows exponentially: stiff (class 12)
  • Forward Euler needs \(k|J|<2\): about \(\times30\) oversampling

Show code
V = np.linspace(0, 0.72, 400)
kJ = k * (1 / (R_D * C_D) + 2 * IS_D / (C_D * VT_D) * np.cosh(V / VT_D))
fig, ax = plt.subplots(figsize=(5.0, 2.8))
ax.semilogy(V, kJ, color=COL["circuit"], lw=2.2, label="$k|J(V)|$ at 44.1 kHz")
for L_, ls in [(1, "-"), (8, "--"), (32, ":")]:
    ax.axhline(2 * L_, color=COL["pickup"], ls=ls, lw=1.2)
    Vb = V[np.argmax(kJ > 2 * L_)]
    ax.text(0.01, 2 * L_ * 1.25, f"forward Euler, {L_}x: stable for $V<{Vb:.2f}$ V", fontsize=7.5, color=COL["pickup"])
ax.axvspan(0.55, 0.72, color="0.92", zorder=0); ax.text(0.635, 0.3, "clipping\nregion", ha="center", fontsize=8, color="0.4")
ax.set_xlabel("capacitor voltage $V$ (V)"); ax.set_ylabel("$k\\,|J(V)|$"); ax.set_ylim(0.2, 3e3); ax.legend(fontsize=7.5, loc="upper left")
ax.set_title(f"$R={R_D / 1e3:.1f}$ k$\\Omega$, $C={C_D * 1e9:.0f}$ nF, $I_s={IS_D * 1e9:.2f}$ nA, $V_t={1e3 * VT_D:.1f}$ mV", fontsize=8.5)
plt.tight_layout()
plt.show()

On a Nonlinear Circuit (step 2+3)

Explicit Euler vs Trapezoid + Newton vs Table

Trapezoid: solve \(F(V^{n+1})=p\) each sample, \[ \begin{aligned} F(V)&=\Bigl(1+\tfrac{k}{2RC}\Bigr)V+\tfrac{kI_s}{C}\sinh\tfrac{V}{V_t}\\ p&=V^n+\tfrac k2\Bigl(f^n+\tfrac{u^{n+1}}{RC}\Bigr) \end{aligned} \] \(F\) monotone: one root. Newton (5) or a table of \(F^{-1}\) (8).

step (5 V, 220 Hz) RMS error (V) \(f\) evals / sample
forward Euler, 1x blows up 1
forward Euler, 32x 5.5e-02 32
trapezoid + Newton 4.8e-04 3.7
trapezoid by table 4.8e-04 1 lookup
memoryless table (\(C=0\)) 3.0e-02 1 lookup

Show code
t3 = 1e3 * np.arange(len(u3)) * k; sl = slice(0, int(1.6 * fs / 220))
fig, ax = plt.subplots(figsize=(5.0, 2.5))
ax.plot(t3[sl], ref3[sl], color="k", lw=3, alpha=0.35, label="reference (32x)")
ax.plot(t3[sl], y_fe32[sl], color=COL["pickup"], lw=1, ls="--", label="Euler, 32x")
ax.plot(t3[sl], y_tr[sl], color=COL["circuit"], lw=1.4, label="trapezoid + Newton, 1x")
ax.plot(t3[sl], y_st[sl], color=COL["tube"], lw=1, ls=":", label="memoryless")
ax.plot(t3[blow], 0, "x", color=COL["pickup"], ms=10, mew=2.5)
ax.annotate(f"Euler 1x: overflow at sample {blow}", (t3[blow], 0), (2.5, 0.08), fontsize=7.5,
            color=COL["pickup"], arrowprops=dict(arrowstyle="->", color=COL["pickup"], lw=0.8))
ax.set_xlabel("time (ms)"); ax.set_ylabel("$V$ (V)"); ax.set_ylim(-0.85, 0.85)
ax.legend(fontsize=6.5, ncol=4, loc="lower center", bbox_to_anchor=(0.5, 1.0), frameon=False, handlelength=1.5)
plt.tight_layout()
plt.show()

On a Nonlinear Circuit (step 3 in practice)

Bounding the Newton Iterations per Sample

v = V                                # warm start: last sample
for it in range(MAXIT):              # bounded: real time
    g  = a1 * v + b1 * sinh(v / Vt) - p
    dv = g / (a1 + b1 / Vt * cosh(v / Vt))
    v -= clip(dv, -0.1, 0.1)         # step limit
    if abs(dv) < 1e-9: break
else: v = bisect(F, p)               # monotone: always bracketed
  • Warm start: \(V\) moves little per sample, quadratic convergence at once
  • Step limit (SPICE): bounded worst case
  • Bisection fallback (class 5): \(F\) monotone, always works
  • Real time: a fixed maximum count
Show code
a1, b1 = 1 + k / (2 * R_D * C_D), k * IS_D / C_D
Vs = 0.55; p = a1 * Vs + b1 * np.sinh(Vs / VT_D)               # a sample whose root is 0.55 V
Fv = lambda v: a1 * v + b1 * np.sinh(v / VT_D) - p
path = [0.0]
for _ in range(25):                                           # Newton from a cold start
    v = path[-1]; path.append(v - Fv(v) / (a1 + b1 / VT_D * np.cosh(v / VT_D)))
    if abs(path[-1] - path[-2]) < 1e-9: break
vv = np.linspace(-0.1, 1.15, 600)
fig, ax = plt.subplots(figsize=(5.0, 2.6))
ax.plot(vv, np.arcsinh(Fv(vv)), "k", lw=1.8, label="$\\mathrm{asinh}\\,(F(V)-p)$")
ax.plot(path, np.arcsinh(Fv(np.array(path))), "o-", color=COL["pickup"], ms=4, lw=0.8, label=f"cold start: {len(path) - 1} iterations")
ax.axhline(0, color="0.7", lw=0.8); ax.axvline(Vs, color=COL["circuit"], ls=":", lw=1.2)
ax.set_xlabel("$V$ (V)"); ax.set_ylabel("residual (asinh)"); ax.legend(fontsize=7.5, loc="upper left")
ax.set_title("the first tangent overshoots; then about $V_t$ per step", fontsize=9)
plt.tight_layout()
plt.show()

Show code
fig, ax = plt.subplots(figsize=(5.0, 2.6))
bins = np.arange(0.5, 40.5)
for (lab, its), col in zip(nt_runs.items(), [COL["circuit"], COL["pickup"], COL["tube"]]):
    ax.hist(np.minimum(its, 39), bins, color=col, alpha=0.55, label=f"{lab}: mean {its.mean():.1f}, max {its.max()}")
ax.set_yscale("log"); ax.set_xlabel("Newton iterations per sample"); ax.legend(fontsize=7)
ax.set_title("guitar riff, gain 20, 44.1 kHz", fontsize=9)
plt.tight_layout()
plt.show()

On a Nonlinear Circuit (step 4)

Harmonics above Nyquist Fold Back (Aliasing)

  • A clipper turns \(\sin\omega_0t\) into harmonics \(hf_0\), all of them
  • Sampling keeps \(|f|<f_s/2\); harmonic \(h\) lands at \[ f_{\text{alias}}=\bigl|\,hf_0-mf_s\,\bigr|,\quad m=\mathrm{round}(hf_0/f_s) \]
  • Not a multiple of \(f_0\): inharmonic, metallic
  • Input goes up, aliases go down
  • Not a solver error: an exact solution, sampled, still aliases

Show code
fig, axs = plt.subplots(2, 1, figsize=(5.0, 2.5), sharex=True)
for ax, (y, title) in zip(axs, [(y_naive, "memoryless clipper, 44.1 kHz"), (y_os8, "8x oversampled")]):
    f, S = spectrum_db(y)
    ax.plot(f / 1e3, S, color="k", lw=0.6)
    for h in range(1, 18):
        ax.axvline(h * 1.2445, color=COL["circuit"], ls=":", lw=0.8)
    ax.set_ylim(-120, 3); ax.set_ylabel("dB"); ax.set_title(title + f": aliases {alias_db(y, 1244.5):.0f} dB", fontsize=8.5)
axs[1].set_xlabel("kHz (dotted: harmonics of 1244.5 Hz)"); axs[1].set_xlim(0, 22.05)
plt.tight_layout(h_pad=0.3)
plt.show()

sweep 300 Hz to 5 kHz, naive: listen for tones going down

On a Nonlinear Circuit (step 4)

Reducing Aliasing by Oversampling or ADAA

Oversample by \(L\): \(\uparrow L\), \(g\) at \(Lf_s\), lowpass, \(\downarrow L\)

  • Any system (also the ODE clipper); cost \(\times L\)

ADAA: average \(g\) along the input path \[ y_n=\frac{G(u_n)-G(u_{n-1})}{u_n-u_{n-1}},\quad G'=g \]

  • \(G\): cumulative trapezoid (9); \(u_n\approx u_{n-1}\): \(0/0\) (2), use \(g\) at the midpoint

Show code
fig, ax = plt.subplots(figsize=(5.0, 2.3))
for (lab, r), col, mk in zip(al_res.items(), ["k", COL["tube"], COL["circuit"], COL["string"]], ["o", "s", "^", "D"]):
    ax.semilogx(f_list, r, mk + "-", color=col, lw=1.5, ms=4, label=lab)
ax.set_xlabel("input frequency (Hz), 5 V sine"); ax.set_ylabel("aliased energy (dB)")
ax.set_title("energy between the harmonics, re the harmonics", fontsize=9); ax.legend(fontsize=7.5)
ax.set_xticks(f_list); ax.set_xticklabels([str(v) for v in f_list], fontsize=7); ax.minorticks_off()
plt.tight_layout()
plt.show()

naive, 1x

ADAA, 1x

oversampled 8x

Wave Digital Filters

Steps 1 to 3 in Wave Variables

At each port: incident \(a=v+R\,i\), reflected \(b=v-R\,i\) (\(R\): port resistance, our choice)

element port \(R\) with the trapezoidal rule
capacitor \(C\) \(k/(2C)\) \(b^{n}=a^{n-1}\): a unit delay
inductor \(L\) \(2L/k\) \(b^{n}=-a^{n-1}\)
source \(u\) with \(R\) \(R\) \(b=u\)

One sample, in the order of the circled numbers:

  1. Source and capacitor send their waves to the adaptor (a scattering junction, class 18)
  2. The adaptor sends one wave up to the root
  3. Root: the diode pair, one scalar Newton
  4. Reflected waves go back down; \(C\) stores its wave for the next sample

Show code
y_wdf = clip_wdf(u3); y_ref, _ = clip_trap(u3, tol=1e-13)
sl = slice(0, int(1.3 * fs / 220))
fig, ax = plt.subplots(figsize=(5.0, 2.2))
ax.plot(t3[sl], u3[sl] / 5 * 0.8, color="0.75", lw=1, label="input $u$ (scaled)")
ax.plot(t3[sl], y_ref[sl], color=C_SRC if "C_SRC" in dir() else COL["circuit"], lw=2.4, alpha=0.6, label="trapezoid + Newton")
ax.plot(t3[sl][::6], y_wdf[sl][::6], "o", color=COL["pickup"], ms=3, label="wave digital filter (every 6th sample)")
ax.set_xlabel("time (ms)"); ax.set_ylabel("$V$ (V)"); ax.legend(fontsize=7, loc="lower left")
ax.set_title(f"same output: max $|v_{{\\mathrm{{WDF}}}}-v_{{\\mathrm{{trap}}}}|$ = {np.abs(y_wdf - y_ref).max():.0e} V (rounding)", fontsize=8.5)
plt.tight_layout()
plt.show()

Pros: modular, passive by construction. Limit: one nonlinearity (the root).

Tube Amplifiers

A Short History of Tube Amplifiers, from Radio to Hi-Fi

  • 1904–06: Fleming’s diode, de Forest’s Audion triode: the first electronic amplifier (radio, telephone, sound film)
  • late 1940s: the 12AX7 / ECC83 double triode (today’s model), still the standard guitar preamp tube
  • 1950s–60s: guitar amps (Fender Bassman, Vox AC30, Marshall JTM45): overdriven tubes become the rock sound
  • 1950s: the hi-fi golden age (McIntosh, Marantz); from the late 1960s transistors win: cheaper, cooler, cleaner
  • Hi-fi today: a small but lasting luxury niche: 300B single-ended triode amps (a Japanese revival of the 1980s–90s), the McIntosh MC275 still in production. Bought for soft clipping, even harmonics, and the glow, not for low distortion; tubes now made mainly in Russia, China, and Slovakia

What a Tube Amplifier Is

  • A triode is a valve for electrons: the heated cathode emits them, the plate collects them, and the grid between them sets how many pass
  • Amplifier: a 1 V change on the grid becomes a change of tens of volts on the plate (gain \(\approx 60\) per stage)
  • Distortion: pushed hard, the current cannot go below zero, and the grid starts to conduct; the output saturates smoothly
  • Today we model one preamp triode and the cabinet filter

How a Tube Stage Is Modelled

The same recipe as the diode clipper (Steps 1 to 4):

  1. Tube law: plate current from the grid and plate voltages, \(I_p\propto(v_{pk}/\mu+v_{gk})^{3/2}\) (Child–Langmuir), smoothed and fitted to a measured 12AX7 (the Koren model)
  2. Circuit around it: Kirchhoff’s current law at the plate and the cathode; one capacitor, so one ODE
  3. Per sample: trapezoid + Newton on 2 unknowns \((v_p, v_k)\), about 3 iterations; 2\(\times\) oversampling
  4. Transformer and cabinet: nearly linear, so filters
Show code
vp0, vk0, Ip0, it0 = triode_bias()
t_c = np.arange(int(0.2 * fs)) * k; per = slice(len(t_c) - int(fs / 50), len(t_c))
fig, ax = plt.subplots(figsize=(4.6, 2.8))
for A, col in [(0.5, "0.55"), (8.0, COL["tube"])]:
    u_ = A * np.sin(2 * np.pi * 50 * t_c); y_ = triode(u_)
    ax.plot(u_[per], y_[per] - vp0, color=col, lw=2 if A > 1 else 1.4, label=f"input amplitude {A:g} V")
ax.axhline(0, color="0.85", lw=0.8); ax.axvline(0, color="0.85", lw=0.8)
ax.annotate("cutoff: the current\ncannot go below 0", xy=(-6.5, 70), xytext=(-7.8, 20), fontsize=8, arrowprops=dict(arrowstyle="->", color="0.3"))
ax.annotate("grid conducts:\nthe output stops falling", xy=(5.5, -95), xytext=(2.6, -45), fontsize=8, arrowprops=dict(arrowstyle="->", color="0.3"))
ax.annotate("small input: a straight line,\nslope $\\approx -60$ (the gain)", xy=(0.2, -10), xytext=(-7.8, -75), fontsize=8, color="0.3", arrowprops=dict(arrowstyle="->", color="0.5"))
ax.set_xlabel("grid input $u$ (V)"); ax.set_ylabel("plate output $\\Delta v_p$ (V)"); ax.legend(fontsize=7, loc="upper right")
ax.set_title("one triode stage: input vs output", fontsize=9)
plt.tight_layout(); plt.show()

How a Tube Amp Sounds: Asymmetric Clipping and the Cabinet

  • Diode pair: clips top and bottom alike, so odd harmonics only (3rd, 5th: harsher)
  • Triode: clips the two sides differently, so a strong 2nd harmonic (an octave up: “warm”)
  • Cabinet: a guitar speaker cuts above \(\approx 5\) kHz
  • Without it, the clipping harmonics sound like fizz

Show code
fig, axs = plt.subplots(1, 2, figsize=(5.5, 2.4), width_ratios=[1.2, 1])
axs[0].bar(np.arange(1, 9) - 0.2, h_diode + 110, bottom=-110, width=0.4, color=COL["circuit"], label="diode")
axs[0].bar(np.arange(1, 9) + 0.2, h_tri + 110, bottom=-110, width=0.4, color=COL["tube"], label="triode")
axs[0].set_ylim(-110, 3); axs[0].set_xlabel("harmonic of 110 Hz"); axs[0].set_ylabel("dB"); axs[0].legend(fontsize=7)
f = np.logspace(np.log10(40), np.log10(20000), 1500); H = np.ones(len(f), complex)
for sec in CAB:
    H *= freqz(*biquad(*sec), f, fs=fs)[1]
axs[1].semilogx(f, 20 * np.log10(np.abs(H)), color="0.3", lw=1.8)
axs[1].set_ylim(-50, 10); axs[1].set_xlabel("Hz"); axs[1].set_title("cabinet response", fontsize=9)
plt.tight_layout()
plt.show()

overdrive (diode, 4x) + cabinet

triode (2x) + cabinet

triode, no cabinet: fizz

Wah-wah Pedal

A Short History of the Wah-wah Pedal

  • 1920s–30s: jazz trumpeters open and close a plunger mute for a voice-like “wah-wah” (Clyde McCoy, Sugar Blues)
  • 1966–67: Brad Plunkett at Warwick Electronics (Thomas Organ, the US distributor of Vox) puts an amp’s midrange filter under a foot pedal: the Vox Clyde McCoy wah and the Cry Baby
  • 1967–71: Jimi Hendrix, Eric Clapton (Cream), the funk guitar of Isaac Hayes’s Theme from Shaft
  • 1972: the auto-wah (Musitron Mu-Tron III): the playing’s loudness, not the foot, moves the filter
  • Today: the Dunlop Cry Baby; the circuit is nearly unchanged: one inductor, a few capacitors, one transistor, a potentiometer under the rocker

Wah Pedal as a Moving Bandpass Filter

  • The rocker turns a potentiometer; the circuit is a resonant bandpass: centre \(f_c\approx\) 350 Hz (heel) to 2.2 kHz (toe), \(Q\approx 5\)–\(8\); it sounds like a vowel going from “oo” to “ah”
  • Model: one RLC-type ODE whose \(\omega_c(t)\) the pedal sets: \[\ddot v+\frac{\omega_c(t)}{Q}\dot v+\omega_c(t)^2v=\frac{\omega_c(t)}{Q}\dot u\]
  • Linear but time varying: Steps 1 to 3 of a linear circuit (trapezoid = bilinear, prewarped), with the coefficients recomputed every sample
Show code
fig, ax = plt.subplots(figsize=(4.6, 2.3))
f = np.logspace(np.log10(60), np.log10(10000), 800)
for p in [0, 0.25, 0.5, 0.75, 1.0]:
    fc_ = wah_fc(p); w0 = 2 * np.pi * fc_ / fs; al = np.sin(w0) / 12
    H = freqz([al, 0, -al], [1 + al, -2 * np.cos(w0), 1 - al], f, fs=fs)[1]
    ax.semilogx(f, 20 * np.log10(np.abs(H)), color=plt.cm.RdPu(0.35 + 0.6 * p), lw=1.8)
    ax.text(fc_, 1.0, "heel" if p == 0 else ("toe" if p == 1 else ""), ha="center", fontsize=8, color=plt.cm.RdPu(0.35 + 0.6 * p))
ax.annotate("", xy=(2200, -26), xytext=(350, -26), arrowprops=dict(arrowstyle="-|>", color="0.3", lw=1.2))
ax.text(880, -24.5, "pedal moves $f_c$", ha="center", fontsize=8, color="0.3")
ax.set_ylim(-30, 5); ax.set_xlabel("frequency (Hz)"); ax.set_ylabel("dB"); ax.set_title("bandpass for 5 pedal positions ($Q=6$)", fontsize=9)
plt.tight_layout(); plt.show()

clean riff (no wah)

wah, foot rocking

auto-wah

wah → overdrive → tube + cabinet

Fast Pedal Moves Need Physical Filter States

Same \(H(z)\) at every instant, different states:

  • Direct form II biquad stores \(w[n]\), a mix of past inputs and outputs with no physical meaning: after a jump in the coefficients it is wrong for the new filter, so the output bursts
  • State-variable filter, integrators by the trapezoidal rule (class 12): its states are the two capacitor voltages, which cannot jump when the pot moves
g = tan(pi*fc[n]/fs); R = 1/(2*Q)       # fc[n]: the pedal now
hp = (x - (2*R + g)*s1 - s2) / (1 + 2*R*g + g*g)
bp = g*hp + s1;  s1 = bp + g*hp         # capacitor 1
s2 = s2 + 2*g*bp                        # capacitor 2
y  = 2*R*bp                             # unit gain at fc

Rule: when parameters move, use a structure whose states are physical (state-variable, ladder, wave digital filter).

Show code
t_s = np.arange(int(0.08 * fs)) * k; x_s = np.sin(2 * np.pi * 400 * t_s)
snap = lambda tr: np.clip((t_s - 0.04) / max(tr, 1e-9), 0, 1)
fig, axs = plt.subplots(1, 2, figsize=(5.4, 2.5), width_ratios=[1.5, 1])
y_svf, y_df = wah_svf(x_s, snap(0.002)), wah_df2(x_s, snap(0.002))
axs[0].plot(1e3 * t_s, y_df, color="0.55", lw=1.1, label="direct form II")
axs[0].plot(1e3 * t_s, y_svf, color=COL["wah"], lw=1.5, label="state-variable (trapezoid)")
axs[0].axvspan(40, 42, color="0.85"); axs[0].text(41, 3.0, "heel $\\to$ toe\nin 2 ms", fontsize=7.5, ha="left", va="top")
axs[0].set_xlim(20, 70); axs[0].set_xlabel("time (ms)"); axs[0].set_ylabel("output"); axs[0].legend(fontsize=7, loc="lower left"); axs[0].set_title("400 Hz sine, pedal snapped", fontsize=9)
trs = np.array([0.1, 0.3, 1, 3, 10, 30]) * 1e-3
for fn, col, lab in [(wah_df2, "0.55", "direct form II"), (wah_svf, COL["wah"], "state-variable")]:
    pk = [(lambda y: np.abs(y[int(0.04 * fs):]).max() / np.abs(y[int(0.02 * fs):int(0.04 * fs)]).max())(fn(x_s, snap(tr))) for tr in trs]
    axs[1].semilogx(1e3 * trs, pk, "o-", color=col, ms=4, lw=1.4, label=lab)
axs[1].axhline(1, color="0.7", lw=0.8, ls=":"); axs[1].set_xlabel("snap time (ms)"); axs[1].set_ylabel("peak after / before"); axs[1].set_yscale("log"); axs[1].legend(fontsize=7)
axs[1].set_title("burst size", fontsize=9)
plt.tight_layout(); plt.show()

Mechanical Effects

A Short History of Spring and Plate Reverb

  • late 1930s–40s: Hammond organ company: a spring with a magnetic transducer at each end makes a living-room organ sound like a church
  • 1957: EMT 140 plate reverb (Germany): a 1 × 2 m steel plate, the studio standard (our plate of classes 15 and 17)
  • 1961: Fender’s stand-alone reverb unit; springs soon built into amps (Twin Reverb): the “drip” of surf guitar
  • Today: real springs are still in guitar amps (cheap, characteristic); digital springs solved as PDEs since the late 2000s (Bilbao, Parker): what we do today

Spring Reverb as a Helical Spring PDE

\[ \begin{aligned} u_{tt}&=-\kappa^2\bigl(u_{xxxx}+2q^2u_{xx}+q^4u\bigr)+\gamma^2q^2(\zeta_x-u)\\ \zeta_{tt}&=\gamma^2(\zeta_{xx}-u_x) \end{aligned} \] \(q\): coil curvature. \(q\to0\): a bar (15) + a 1D wave (14).

  • Modes \(u\propto\sin\beta x\), \(\zeta\propto\cos\beta x\): a \(2\times2\) eigenproblem per \(\beta\)
  • Lower branch: a hump, cutoff \(f_c=\frac{3\kappa q^2}{8\pi\sqrt5}\)
  • Upper branch \(\approx\) 400 kHz: explicit FD hopeless; modes: just drop it

Show code
b = np.linspace(1, 1900, 800); lo, hi = [], []
for bb in b:                                                  # 2 x 2 generalized eigenproblem per wavenumber
    Kb = np.array([[KAP**2 * (bb**2 - QQ**2)**2 + 2511.0**2 * QQ**2, 2511.0**2 * QQ**2 * bb],
                   [2511.0**2 * QQ**2 * bb, 2511.0**2 * QQ**2 * bb**2]])
    lam = np.linalg.eigvalsh(np.diag([1, 1 / QQ]) @ Kb @ np.diag([1, 1 / QQ]))
    lo.append(np.sqrt(max(lam[0], 0)) / (2 * np.pi)); hi.append(np.sqrt(lam[1]) / (2 * np.pi))
fig, axs = plt.subplots(1, 2, figsize=(5.0, 2.7), width_ratios=[2.2, 1])
axs[0].plot(b, np.array(lo) / 1e3, color=COL["spring"], lw=2)
axs[0].plot(SP[:, 0], SP[:, 1] / (2 * np.pi * 1e3), ".", color="k", ms=1.5, label=f"modes $\\beta=m\\pi$: {len(SP)}")
axs[0].axhline(fc_formula / 1e3, color=COL["pickup"], ls="--", lw=1)
axs[0].text(30, 6.0, f"$f_c$: formula {fc_formula:.0f} Hz,\ncomputed {SP[SP[:, 0] < QQ, 1].max() / (2 * np.pi):.0f} Hz",
            fontsize=7, color=COL["pickup"])
axs[0].axvline(QQ, color="0.6", ls=":"); axs[0].text(QQ - 40, 15, "$\\beta=q$", fontsize=8, ha="right")
axs[0].set_ylim(0, 20); axs[0].set_xlabel("$\\beta$"); axs[0].set_ylabel("kHz"); axs[0].legend(fontsize=7, loc="upper left")
axs[0].set_title("lower branch: what we hear", fontsize=9)
axs[1].plot(b, np.array(hi) / 1e3, color="0.5", lw=2); axs[1].set_xlabel("$\\beta$")
axs[1].set_title("upper branch", fontsize=9); axs[1].set_ylim(390, 420)
plt.tight_layout()
plt.show()

Plate Reverb vs Spring Reverb: Dispersion Relations

Plate (15, 17): \(\omega=\kappa\beta^2\), 2D, dense constant mode density: a smooth tail

Spring: 1D, sparse modes, a hump: distinct chirps, dark cutoff. Same method: the character is in \(\omega(\beta)\)

Show code
fig, axs = plt.subplots(1, 2, figsize=(5.8, 2.6), sharey=True)
show_spec(axs[0], h_plate[:int(1.0 * fs)], f"plate, {n_plate} modes: smooth", fmax=8, win=1024, vmin=-70)
show_spec(axs[1], h_spring[:int(1.0 * fs)], f"spring, {n_spring} modes: chirps", fmax=8, win=1024, vmin=-70)
axs[0].set_ylabel("kHz")
for ax in axs:
    ax.set_xlabel("time (s)")
plt.tight_layout()
plt.show()

riff + plate

riff + spring

The Signal Chain

Signal Chain Built One Stage at a Time

1 string

2 + pickup

3 + wah

4 + overdrive

5 + tube + cabinet

6 + spring reverb

stage method Python time for 3.6 s of audio real-time factor
string + pickup 12 notes, exact free vibration + flux 1.44 s 0.40
pickup circuit bilinear biquad 0.00 s 0.00
wah (state-variable, foot rocking) trapezoid, coefficients per sample 0.09 s 0.02
overdrive (4x, Newton) trapezoid + Newton per sample 0.76 s 0.21
triode (2x, 2x2 Newton) + cabinet Newton per sample + 5 biquads 2.60 s 0.72
spring (FFT convolution) one FFT convolution 0.01 s 0.00

Interactive Web Demo of the Guitar Rig

Choosing a Method

Choosing a Solver for a Virtual Analog Circuit

explicit (Euler, RK) trapezoid + Newton table wave digital filter modal
where today E-bow loop, contacts pickup RLC, wah (no Newton: linear), diode clipper, triode inverse of \(F\), memoryless clipper diode clipper string, tine, spring, plate
accuracy 1st order (Euler); warps less 2nd order; frequency warping (prewarp) trapezoid + interpolation error; memoryless loses \(C\) identical to trapezoid exact frequencies
stability \(k\lvert\lambda\rvert\) bound: needs \(\times30\) for diodes linear part: unconditional; Newton must converge as the scheme it tabulates passive by construction always (linear)
cost per sample \(\times\) oversampling iterations (watch the worst case) one lookup one scalar Newton at the root \(O(\text{modes})\)
breaks down stiff circuits many unknowns: an \(n\times n\) solve per iteration more than 1 or 2 inputs (curse of dimension) several nonlinearities nonlinear or time-varying parts

Checklist

  1. Linear: modes or a bilinear filter (prewarped); if a pedal or knob moves it, a structure with physical states (state-variable).
  2. Stiff nonlinear circuit: trapezoid + Newton, warm started, bounded iterations.
  3. One or two inputs to the implicit step: precompute a table.
  1. Built from a schematic, one nonlinearity: wave digital filter.
  2. Any nonlinearity: budget for aliasing (oversampling, ADAA).
  3. Feedback: check loop gain and energy before you listen.

Course Wrap-up

Course Summary: Numerical Methods and Where We Used Them

Checklist for Evaluating Your Project’s Simulation

question how to show it where we did it
Consistent? order of accuracy halve \(h\) or \(k\); the error drops by \(2^{p}\) (log-log slope) 9, 10, 12
Stable? CFL or eigenvalues (linear); a conserved or bounded energy (nonlinear); Newton iterations: mean and worst 14, 13, today (E-bow, clipper)
Converged? a reference at a finer resolution; the error against it 15, today (32x clipper reference)
Matches reality? partial frequencies, \(T_{60}\), spectral envelope, impulse response vs a recording or the built object 16, 17
Matches theory? overlay an analytic prediction (dispersion, group delay, threshold) today (chirps, E-bow thresholds), 16
Cost? real-time factor; cost against accuracy 17, today (chain)
Why this method? what another method would gain or lose, in one paragraph 18, today

Looking Ahead

Final Project Presentation (12/03)

Before 12/03: 11/26 no class (admission interviews); 12/01 open office hour day: bring your project questions.

Suggested outline (mapped to the course ILO):

  1. What you reconstruct and which path: analysis & simulation or design & verification.
  2. Model: the equations and a component diagram like today’s.
  3. Method and why (ILO 1): FD, modal, waveguide, FEM, virtual analog; what an alternative would gain or lose.
  4. Implementation and demo (ILO 2): play it, before and after each ingredient.
  5. Evaluation (ILO 3): accuracy, stability, comparison to a recording or the built object.
  6. Limits and next steps.

The report is due after the presentation.

Recap

Recap on Today’s ILO

  • Pickups: \(e=-N\Phi'(u)\,u_t\); position = a comb filter (interpolation at \(x_p\)), aperture = quadrature lowpass, large motion = a memoryless nonlinearity (even harmonics). Electric guitar = string modes + pickup; Rhodes = hammer + tine/tonebar tuning fork + an offset pickup (the bark).
  • E-bow: a feedback loop; a mode grows when its loop gain beats its loss (Hopf); saturation makes the input grow like \(|v|\) and the loss like \(v^2\): bounded energy.
  • Circuits: state space ODEs. Linear: trapezoid = bilinear (prewarp). Diodes and tubes: stiff and nonlinear, so trapezoid + Newton per sample (warm start, safeguards); a table when the step depends on one input; WDF = the same trapezoid. Tubes: asymmetric soft clipping (2nd harmonic) + a cabinet filter. Wah: a moving bandpass; a state-variable filter keeps its states physical when the pedal moves.
  • Aliasing: harmonics fold back; oversampling and ADAA.
  • Spring reverb: a coupled PDE with a hump in \(\omega(\beta)\); exact modes, chirps predicted by the group velocity. Plate: \(\omega=\kappa\beta^2\), smooth.
  • The course: one signal chain uses modes, recursions, interpolation, quadrature, Newton, trapezoid, and dispersion. See you on 12/03.