Wave Shaper Distortion — User Guide
A Praat AudioTools waveshaping processor with 12 nonlinear transfer functions, five processing modes, optional wet-path oversampling, dry/wet mixing, normalization, and visualization.
What this does
The script processes exactly one selected Sound object. It first creates a wet copy, optionally resamples that wet path to a higher sample rate, applies one of 12 memoryless nonlinear transfer functions through one of five routing modes, returns the wet path to the source sample rate, mixes it with the original dry signal, and optionally peak-normalizes the final result.
Drive is applied before the selected transfer function. Some processing modes alter that routing: Frequency Split uses a stronger drive on the high band, Multi-Stage distributes the requested drive across three cascaded stages, and Stereo Wide applies different drive amounts to Mid and Side.
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
Wave Shaper Distortion.praat. - Choose a waveshaping Shape, set Drive, Mix_percent, Oversample, and a processing Mode.
- Choose whether to normalize, draw the visualization, and play the result, then click OK.
Parameters (form fields)
| Name (GUI) | Type | Default | Implemented behavior |
|---|---|---|---|
| Shape | choice | 1. Hyperbolic Tangent (soft) | Selects one of the 12 transfer functions listed below. |
| Drive | positive | 2.0 | Must be greater than zero. It multiplies the signal before waveshaping, with mode-specific variations described below. |
| Mix_percent | real | 80 | Wet percentage. Values below 0 or above 100 are rejected. Dry level is 1 - Mix/100. |
| Oversample | integer | 4 | 1 = off. Values below 1 are clamped to 1; values above 8 are clamped to 8. 2 is explicitly rejected. Values 3–8 are supported. |
| Mode | optionmenu | Standard | Selects Standard, Frequency Split (800 Hz), Asymmetric, Multi-Stage, or Stereo Wide (M/S). |
| Normalize | boolean | on | After dry/wet mixing, scales a non-silent result to peak 0.95. Near-silent output (peak ≤ 1e-9) is left unchanged. |
| Draw_visualization | boolean | on | Draws the diagnostic/transfer visualization in the Picture window. |
| Play_result | boolean | on | Plays the final Sound after processing. |
Waveshaping algorithms
For the nominal Standard-mode transfer, let u = Drive × x. The script applies the following functions sample by sample:
| # | GUI name | Implemented transfer function |
|---|---|---|
| 1 | Hyperbolic Tangent (soft) | tanh(1.5u) / 1.5 |
| 2 | Sine Fold (warm) | 0.85 × sin(2.5u) |
| 3 | Arc Tangent (smooth) | 2 × atan(1.8u) / π |
| 4 | Polynomial (aggressive) | u - 0.33u³ |
| 5 | Absolute Value (digital) | |u| (full-wave rectification) |
| 6 | Square Law (fuzzy) | 0.8 × u × |u| |
| 7 | Chebyshev (harmonic) | 0.7u + 0.2(2u² - 1) + 0.1(4u³ - 3u) + 0.2. The final offset makes f(0)=0. |
| 8 | Sigmoid (tube-like) | 2 / (1 + exp(-2u)) - 1 |
| 9 | Exponential Saturator | For u ≥ 0: (1-exp(-2u)) / (1+exp(-2u)+0.1exp(-u)); for u < 0, the sign-reversed counterpart using positive exponents. |
| 10 | Bitcrush (lo-fi) | floor(16u + 0.5) / 16. This is amplitude quantization in 1/16 steps; it does not reduce the sample rate. |
| 11 | Single Wave Wrap | u while |u| ≤ 1; otherwise -sign(u) × (2 - |u|). This is the script's single-fold mapping, not a periodic modulo wrap. |
| 12 | Diode Ladder (analog) | Positive samples: 0.5 × (1-exp(-2u)); negative samples: 0.3 × (exp(2u)-1). |
Processing modes
| Mode | Implemented processing |
|---|---|
| Standard | Multiplies the wet signal by Drive, then applies the selected transfer function. |
| Frequency Split (800 Hz) | Creates a low band with Filter (pass Hann band): 20, 800, 100 and a high band with Filter (pass Hann band): 800, source Nyquist, 100. The low band is shaped at Drive; the high band at 1.5 × Drive; the two shaped bands are then summed. |
| Asymmetric (+/- different) | Runs the Standard waveshaper, then multiplies positive output samples by 1.3 and negative output samples by 0.8. |
| Multi-Stage (3x cascade) | Sets stageDrive = Drive^(1/3), then performs three consecutive stages of multiply by stageDrive → waveshape. |
| Stereo Wide (M/S) | For stereo input, forms M=(L+R)/2 and S=(L-R)/2. Mid is shaped at Drive; Side at 1.5 × Drive; output is reconstructed as L=M+S, R=M-S. Mono input falls back to Standard. Input with more than two channels is rejected in this mode. |
Signal flow & channel handling
Wet path: source copy → optional oversampling → selected mode / waveshaper → return to source sample rate → dry/wet mix → optional peak normalization.
Oversampling
If Oversample is greater than 1, only the wet copy is resampled to source sample rate × Oversample before nonlinear processing. After shaping it is resampled back to the original sample rate with Praat's Resample command (precision 50), then extracted to the source start/end time so the original time domain is restored before mixing. The dry source itself is never oversampled.
Oversample = 2 is deliberately disabled by the script because its documented Praat 6.1.38 round trip produced frequency-dependent phase shifts. The default is 4×.
Dry/wet mix and normalization
When Mix_percent is below 100, the final pre-normalization signal is wet × Mix/100 + original × (1-Mix/100). At 100%, no dry signal is added.
Normalization occurs after this mix. Therefore, with Normalize enabled, even Mix_percent = 0 can change the source level: the all-dry result is still scaled to peak 0.95 unless it is near-silent.
Channels
Standard, Frequency Split, Asymmetric, and Multi-Stage operate on the selected Sound without reducing its channel count. Stereo Wide accepts mono or stereo only: mono uses the Standard fallback, stereo uses the M/S path, and input with more than two channels stops with an error.
Visualization
When Draw_visualization is on, the Picture window shows:
- the original and processed full-duration waveforms using one shared amplitude scale;
- a source/result zoom over the first up-to-20 ms, again using a shared scale;
- the nominal memoryless transfer curve
y=f(Drive×x)for the selected shape; - the 12-algorithm list with the active shape highlighted;
- current Drive, Mix, Mode, oversampling, normalization state, and a final summary including output peak.
The transfer-curve panel intentionally shows only the nominal waveshaper. It does not fold Frequency Split or M/S routing, asymmetric post-gain, Multi-Stage cascading, oversampling/downsampling, dry/wet mixing, or final normalization into the curve.
Outputs
- Object name:
<original>_<shape token>_<mode token>. Shape tokens includeTanh,SineFold,Arctan,Polynomial,Abs,SquareLaw,Chebyshev,Sigmoid,ExpSaturator,Bitcrush,SingleWaveWrap, andDiodeLadder. Mode tokens areStandard,FreqSplit,Asymmetric,MultiStage, andStereoWide. - Sample rate: the final result is returned to the source sample rate.
- Duration / time domain: restored to the source start and end times after an oversampled round trip.
- Normalization: if enabled and the result is not near-silent, final peak is scaled to 0.95. If disabled, no peak ceiling is applied; the script reports a warning when the final peak exceeds 1.0.
- Playback: if Play_result is on, the result is played after processing and remains selected.