Van der Pol Tube Distortion — Cubic Waveshaping

A parameterized cubic fold waveshaper inspired by the Liénard form associated with the Van der Pol oscillator, with an optional monotonic peak-hold character, oversampling, and a final hard ceiling.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.5.1 (2026) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

Van der Pol Tube Distortion is a memoryless cubic waveshaper. It does not numerically solve a Van der Pol oscillator and it is not a complete physical tube model. The historical connection is narrower: Van der Pol used a local polynomial description of a triode characteristic in the development of nonlinear oscillator theory. This script turns related linear-plus-cubic shapes into audio transfer functions.

Two independent choices define the curve: Characteristic chooses the polynomial coefficients; Character chooses what happens when the cubic reaches its turning point. The default Characteristic is the legacy AudioTools cubic z − amount·z³/3. The alternative amount·(z − z³/3) is the correctly scaled form corresponding to the negative Liénard characteristic of the standard Van der Pol equation.

The audio path is: input → optional oversampling → Drive → selected cubic characteristic → selected Character behavior → Output_Gain → shaping hard clamp at ±0.999 → anti-alias downsampling (when enabled) → final safety clamp at ±0.999.

Quick start

  1. Select exactly one Sound object in Praat.
  2. Run VanDerPol_Tube_Distortion.praat.
  3. Choose Manual or one of the five named presets. Named presets overwrite Drive, Cubic_amount, and Output_Gain only.
  4. Choose Character: authentic cubic fold or monotonic peak-hold.
  5. Choose Characteristic: the legacy cubic or the Van der Pol-scaled form.
  6. Normally leave Limiter at hard clamp only (default). The legacy tanh option is retained only for compatibility with v0.2/v0.3 behavior.
  7. Click OK. The result is named source_VdP_Preset_Fold or source_VdP_Preset_Monotonic.
Preset scope: presets do not choose Character, Characteristic, Oversample, or Limiter. Therefore the same preset can produce substantially different curves depending on those global choices.

Five named presets

PresetDriveCubic_amountOutput_GainNotes in authentic-fold mode
Subtle Coloration1.050.200.98No fold for |input| ≤ 1.
Gentle Cubic Warmth1.200.500.95No fold for |input| ≤ 1.
Classic Cubic Drive2.501.000.85Folds within the normal ±1 input range and can invert.
Aggressive Drive5.001.500.60Strong fold-back; the hard clamp becomes a major shaping stage.
Fold-back Extreme9.003.000.40Deep fold-back with extensive hard-clamp shaping.
Do not read the preset name as a complete model description. In particular, Classic Cubic Drive with the default authentic-fold Character is a wavefolder, whereas the same numeric preset with monotonic peak-hold behaves as a saturating cubic plateau.

Characteristics and curve geometry

1. Cubic characteristic — default / legacy

z = input × Drive
ycubic = z − amount·z³/3

Here Cubic_amount changes the ratio between the linear and cubic terms. It therefore changes the fold and inversion positions. This parameter is not the μ parameter of the standard Van der Pol differential equation.

2. Van der Pol scaled characteristic

z = input × Drive
ycubic = amount·(z − z³/3)

For the standard equation x'' − μ(1 − x²)x' + x = 0, the associated Liénard integral is F(x)=μ(x³/3−x). This script's second characteristic implements its negative, −F(x)=μ(x−x³/3), using Cubic_amount as the scale factor.

Fold and inversion

The script uses the ratio cubicEff = cubic coefficient / linear coefficient. When that ratio is positive:

Thresholds in input units

Fold onset: |input| = 1 / (Drive·√cubicEff)

Zero crossing / inversion onset: |input| = √(3/cubicEff) / Drive

In authentic cubic fold, the polynomial is allowed to turn back and later change sign. In monotonic peak-hold, values past the turning point are held at the cubic peak:

peak = curveLin × (2/3) / √cubicEff

This peak-hold is a constructed monotonic waveshaper. It should not be interpreted as a physical tube-transfer model.

Harmonics: the transfer functions are odd-symmetric. For a centered periodic input this suppresses even harmonics and generates odd harmonics. A DC offset or other input asymmetry breaks that condition, so even harmonics can appear.

Controls

ControlDefaultBehavior
PresetManualFive named presets set Drive, Cubic_amount and Output_Gain. They do not set Character, Characteristic, Oversample or Limiter.
Characterauthentic cubic foldAuthentic preserves cubic fold/inversion; monotonic peak-hold replaces the post-peak fold with a constant plateau.
CharacteristicCubic: z − amount·z³/3Selects the polynomial coefficient relationship.
Drive3.0Positive pre-waveshaper input multiplier.
Cubic_amount1.0Must be > 0. Controls cubic strength, or scales the full characteristic in Van der Pol-scaled mode.
Output_Gain1.0Post-waveshaper gain applied before the hard clamp. It is a real value; negative settings invert polarity before clamping.
Oversample4Effective range 1–8. Values outside the range are clamped and reported. 2× is deliberately refused because of the documented resampling phase issue; use 1 or 3–8.
Limiterhard clamp onlyApplies only to authentic cubic fold. Option 1 restores the legacy v0.2/v0.3 tanh fallback above |cubic|=3 before the hard clamp.
Draw_visualizationYesDraws the waveshaper transfer, parameter report, output waveform and summary.
Play_resultYesPlays the processed Sound after completion.
Legacy tanh fallback: the compatibility branch switches from the cubic to 3·tanh(cubic) when |cubic| exceeds 3. It is slightly discontinuous at the switching boundary and is masked by the hard clamp for all five named presets. For new work, the default hard clamp only is the cleaner choice.

Processing pipeline

1. Copy the selected Sound; original remains untouched.
2. If Oversample > 1, resample to source_rate × Oversample.
3. Compute z = sample × Drive.
4. Apply the selected Characteristic.
5. Apply Character: authentic cubic fold or monotonic peak-hold.
6. In authentic mode only, optionally apply the legacy tanh fallback.
7. Multiply by Output_Gain.
8. Measure the fraction of processing-rate samples beyond ±0.999.
9. Apply the shaping hard clamp to ±0.999.
10. If oversampled, resample back to the source rate and restore the source time domain/length.
11. Measure any downsampling overshoot, then apply a final safety clamp to ±0.999.
12. Report final statistics, visualize if requested, and optionally play the result.
Why there are two hard clamps: the first is part of the shaping path at the elevated processing rate. Downsampling can ring slightly around a clipped waveform and re-create peaks above the ceiling, so the second clamp is applied after the return to the source rate to enforce the final ±0.999 bound.

Visualization

The suite-standard 8-inch Picture page contains four functional regions:

The transfer panel also shows y=x as a reference and the ±0.999 ceiling. It is the most direct diagnostic for deciding whether the chosen settings remain monotonic, fold back, invert, or spend substantial time on the hard ceiling.

Limits and interpretation

Aliasing is reduced, not eliminated. Cubic folding, the peak-hold corner and hard clipping generate high harmonics. Oversampling creates headroom and the downsampling filter removes much of the out-of-band energy, but the process is not alias-free; the final safety clamp can itself reintroduce a small amount of high-frequency energy.

Strong presets are partly hard-clipping effects. At aggressive settings many processing-rate samples exceed ±0.999 before the shaping clamp. The Info window reports this fraction; when it is large, the hard clamp is a primary timbral element rather than merely a safety device.

Extreme Manual settings can overflow numerically. The script probes the final Sound for undefined samples and reports their fraction if they occur. Reduce Drive or Cubic_amount if that warning appears.

Historical scope: the Van der Pol reference motivates the cubic family and the alternative scaled characteristic. The script does not model tube bias, plate voltage, dynamic impedance, frequency-dependent circuitry, hysteresis, or other properties of an actual tube stage.