Asymmetric Soft Clipping — User Guide
Static asymmetric tanh waveshaping with independent positive/negative shaping, bias handling, output-level control, and a transfer-function visualization that follows the rendered settings.
What this does
Asymmetric Soft Clipping applies one static nonlinear transfer function to every sample of the selected Sound. The input is first scaled by Drive and shifted by Bias. The sign of that driven-and-biased value chooses either Pos_Shape or Neg_Shape, and the selected branch is passed through tanh(). Output_Gain then scales the shaped signal.
Because the positive and negative branches can use different slopes, the transfer curve can be asymmetric. Bias provides a second source of asymmetry by shifting the operating point before the branch decision. The result can range from mild saturation to strongly one-sided distortion.
The processing is channel-preserving: mono stays mono, stereo stays stereo, and a multichannel Sound keeps all of its channels. The same transfer parameters are applied independently to every sample in every channel.
Quick start
- Select exactly one Sound in Praat.
- Run
Asymmetric_Soft_Clipping.praat. - Choose a preset, or leave Manual (Use settings below) to use the five shaping fields directly.
- Choose a Bias_mode: keep the raw DC offset, compensate the zero-input offset, or remove the final file mean.
- Choose an Output_level mode.
- Optionally enable Draw_visualization and Play_result.
The result is a copy named <source>_Tube_<preset>, for example voice_Tube_WarmTube. The original Sound is not modified.
The transfer function
1. Drive
Drive multiplies the input before the nonlinear stage. With ordinary positive values, increasing Drive moves more samples into the flatter regions of tanh(), increasing saturation and reducing the local slope at larger amplitudes.
2. Bias and the branch switch
Bias is added before the sign test. Therefore the positive/negative shape is selected from the sign of x·Drive + Bias, not from the sign of the original sample. When Drive is nonzero, the branch boundary occurs at:
The visualization marks this point as the sign flip when it lies inside the displayed input range.
3. Positive and negative shape
Pos_Shape and Neg_Shape scale the argument of tanh() on their respective branches. Larger positive values make that branch reach saturation more quickly. Unequal branch values make the static curve asymmetric and can alter the balance of even- and odd-order harmonic components for periodic material.
4. Output gain
Output_Gain is a constant scalar after tanh(). In the raw mode, the asymptotic shaped bounds are therefore approximately ±|Output_Gain|. Later DC or peak-level stages can shift or rescale those bounds.
tanh() is smooth, but it is still nonlinear and generates new harmonics. Harmonics above Nyquist can alias back into the audible band. This script does not oversample internally.
Bias and DC handling
Bias changes both the shape of the transfer curve and its resting output. The script explicitly computes the raw zero-input value:
where shape(Bias) is Pos_Shape for non-negative Bias and Neg_Shape for negative Bias.
| Bias mode | What the script does | Consequence |
|---|---|---|
| Raw DC-biased (v0.1/v0.2) | Uses the raw waveshaper output with no DC correction. | Zero input produces f(0), which may be nonzero. Large bias can therefore create a substantial constant offset during silence. |
| DC-compensated (zero in → zero out) | Subtracts the calculated raw f(0) from every output sample. | A digital-zero input maps to zero while the curve remains asymmetric. The upper and lower asymptotic bounds are shifted by the same offset. |
| Remove final mean | Applies the waveshaper first, then Praat's Subtract mean to the rendered Sound. | The correction depends on the actual source file. It cannot be represented completely by a single static input→output curve. |
Parameters & presets
Form parameters
| Parameter | Default | Meaning |
|---|---|---|
| Preset | Manual | Manual settings or one of five fixed presets. A preset overrides the five shaping fields below. |
| Drive | 2.0 | Pre-shaper input multiplier. |
| Bias | 0.1 | Offset added before branch selection and tanh(). |
| Pos_Shape | 1.0 | Shape coefficient when x·Drive + Bias ≥ 0. |
| Neg_Shape | 3.0 | Shape coefficient when x·Drive + Bias < 0. |
| Output_Gain | 0.8 | Constant scalar applied after tanh(), before the selected Bias/output-level stages. |
| Bias_mode | Raw DC-biased | Selects raw, zero-input-compensated, or final-mean-removed output. |
| Output_level | Preserve shaped level | Preserve, conditionally attenuate, or normalize the rendered peak. |
| Draw_visualization | Yes | Draw the transfer-function diagnostic, parameter report, output waveform, and summary. |
| Play_result | Yes | Play the processed Sound after rendering. |
Built-in presets
| Preset | Drive | Bias | Pos | Neg | Output gain |
|---|---|---|---|---|---|
| Warm Tube Saturation | 1.5 | 0.05 | 0.8 | 1.2 | 0.9 |
| Hard Overdrive | 5.0 | 0.0 | 2.0 | 2.0 | 0.5 |
| Asymmetric Fuzz | 3.5 | 0.3 | 5.0 | 0.5 | 0.6 |
| Extreme Biased Saturation | 4.0 | 0.8 | 4.0 | 0.5 | 0.6 |
| Subtle Warmer | 1.1 | 0.02 | 0.5 | 0.6 | 0.95 |
Experimental Manual values
The five shaping controls are real fields with no enforced numeric bounds. The script permits unusual values and reports several important cases:
- Drive = 0: the input itself is discarded; the output is determined by Bias and the selected branch.
- Pos_Shape = 0 or Neg_Shape = 0: that branch becomes flat.
- Negative shape: that branch reverses polarity; the script labels this experimental rather than tube-like.
- Negative Output_Gain: the complete shaped output is polarity-inverted before later level scaling.
Output-level modes
| Mode | Behavior |
|---|---|
| Preserve shaped level | No peak scaling is applied. If the pre-level peak exceeds 1.0, the Info window reports a warning. This mode preserves the magnitude of Output_Gain. |
| Attenuate to 0.95 only if peak > 0.95 | If the rendered peak is above 0.95, Praat Scale peak attenuates it to 0.95. If it is already at or below 0.95, nothing changes. This is conditional whole-file scaling, not a dynamic limiter. |
| Normalize peak to 0.95 | For a non-silent result, the whole Sound is scaled so its peak becomes 0.95. A zero-peak result is left silent and normalization is skipped safely. |
Visualization
The v0.4.1 visualization uses the Praat AudioTools 8-inch page layout and is organized as a diagnostic view of the transformation rather than a generic waveform display.
Transfer function
Plots input from −1.5 to +1.5. The vertical range is measured from the actual curve instead of being clipped to a fixed display limit. The dotted y=x line is the undistorted reference.
Digital full scale
Lines at +1 and −1 are labelled as digital full scale. They are references, not the waveshaper's mathematical ceiling.
Mode-dependent bounds
Raw mode shows symmetric tanh bounds based on |Output_Gain|. DC-compensated mode shows the shifted upper/lower bounds. Final-mean removal intentionally shows no static bound because the offset is source-dependent.
Zero-input / DC report
Raw mode reports raw y(0); DC compensation shows raw y(0) → effective 0; final-mean removal states that the final value depends on the source.
Output waveform
Mono is drawn directly. For two channels, Ch 1 and Ch 2 are overlaid. For more than two channels, only Ch 1/2 are drawn and the panel explicitly states that all output channels are preserved.
Render-aware level scaling
If conditional attenuation or normalization actually scales this render, the transfer curve includes that scalar. Final mean removal is not drawn into the curve because it cannot be described from input amplitude alone.
Processing pipeline
Select exactly one Sound
↓
Apply preset values (if chosen)
↓
Compute raw zero-input output f(0)
↓
Copy source → <source>_Tube_<preset>
↓
u = x·Drive + Bias
choose Pos_Shape / Neg_Shape from sign(u)
raw y = tanh(u·shape)·Output_Gain
↓
Bias mode:
Raw → no correction
DC-compensated → subtract f(0)
Remove final mean→ Subtract mean after shaping
↓
Measure pre-level peak
↓
Output-level mode:
Preserve / conditional attenuation / peak normalization
↓
Optional visualization → optional playbackNotes & limitations
- Static process: Drive, Bias, shape coefficients, and Output_Gain do not change over time.
- No oversampling: strong nonlinear settings can generate audible aliasing.
- No wet/dry control: the produced Sound is fully processed. Parallel blending must be done elsewhere.
- No automatic loudness matching: Preserve keeps the shaped level; the two other modes operate on peak, not perceived loudness.
- Bias can create DC: Raw mode deliberately preserves it. Use DC-compensated or Remove final mean when a zero-centered result is required.
- Mean removal is source-dependent: it changes the completed render according to the file's measured mean, so it is not equivalent to subtracting the static zero-input value.
- Visualization input range: the transfer curve is shown for input amplitudes −1.5…+1.5 even if the source contains samples outside that range.