Hard Clip (Variable Knee) — User Guide

Static symmetric clipping with an exact hard-clip option, a quadratic soft knee, optional oversampling, output-level control, and diagnostic visualization.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.4.1 (2026) License: MIT License Repo: Praat AudioTools
Contents:

What this does

Hard Clip (Variable Knee) is a memoryless symmetric waveshaper. It multiplies the input by Drive, applies either an exact hard clamp or a three-region clipping curve with a quadratic knee around Threshold, restores the original polarity, and then multiplies by Output_Gain. The same formula is applied independently to every input channel, so mono, stereo, and higher-channel-count Sounds retain their channel structure.

Important distinction: this is a static clipper, not a look-ahead or envelope-controlled limiter. Its response depends on the instantaneous sample value. The optional output stage can attenuate or normalize the completed file by peak measurement, but that stage is global peak scaling rather than dynamic limiting.

Quick start

  1. Select exactly one Sound object in Praat.
  2. Run Hard_Clip.praat.
  3. Choose a preset or leave Manual.
  4. Set Drive, Threshold, Knee_half_width, and Output_Gain.
  5. Choose an Oversample factor from the supported range 1–8. The default is 4×.
  6. Choose the Output_level. The default is Preserve shaped level.
  7. Optionally draw the visualization and play the result.
Preset scope: presets override only Drive, Threshold, Knee_half_width, and Output_Gain. They do not change Oversample, Output_level, Peak_target, Spectrum_reference, Draw_visualization, or Play_result.

Signal path

Processing order

Input → optional resample up by Oversample → x = input × Drive → symmetric hard/soft-knee waveshaper → × Output_Gain → if oversampled: band-limited resample back to original sample rate → optional global output-level stage → Result

If Oversample = 1, the waveshaper runs directly at the source sample rate. If it is greater than 1, Praat resamples the working copy upward, applies the nonlinearity there, then resamples back with precision 50.

Transfer function

Let x = input × Drive, T = Threshold, and K = Knee_half_width. The script works with |x|, then restores sign and applies Output_Gain.

When K > 0

Linear region: |x| ≤ T − K y_abs = |x| Quadratic knee: T − K < |x| < T + K y_abs = T − (T + K − |x|)² / (4K) Plateau: |x| ≥ T + K y_abs = T Final sample: y = y_abs × sign(x) × Output_Gain

When K = 0

y_abs = min(|x|, T) y = y_abs × sign(x) × Output_Gain

This is an exact symmetric hard clip with no knee. The script handles this as a separate formula so there is no division by zero.

The legal soft-knee range is 0 ≤ K ≤ T. A knee wider than the threshold would make the quadratic expression negative around zero and can invert quiet samples, so the script rejects that case instead of silently changing it.

The low-level source-to-output slope is Drive × Output_Gain, not necessarily 1:1. In the hard plateau, the waveshaper ceiling before any output-level scaling is approximately Threshold × |Output_Gain|.

Harmonic symmetry: with positive Drive and Output_Gain, the transfer function is odd-symmetric. For an ideal centered sine wave this symmetry produces predominantly odd harmonics. A wider knee changes how quickly the transfer bends and generally reduces the strength of very high-order components; it does not turn the symmetric clipper into an even-harmonic generator.

Parameters & presets

Form parameters

ParameterDefaultActual behavior
PresetManualManual plus five named parameter sets.
Drive1.0Input multiplier before threshold/knee evaluation. Zero makes the result silent; negative values invert the sign before an additional sign restoration, so experimental sign behavior is possible.
Threshold0.5Center/ceiling parameter of the clipper. Values below 0.01 are raised to 0.01 with a report. Values above 1 are allowed because Drive can still push samples into the knee or plateau.
Knee_half_width0.2Half-width of the knee. Total knee width is 2K. Zero means exact hard clipping. Negative values or K > Threshold are rejected.
Output_Gain0.9Constant multiplier after the waveshaper. Negative values invert the whole shaped output; zero silences it.
Oversample4Requested integer factor. Values below 1 run as 1; values above 8 run as 8, with a note in the Info window.
Output_levelPreserve shaped levelPreserve, conditional attenuation, or normalization.
Peak_target0.95Used only by attenuation or normalization. Must be >0 and ≤1 in those modes; it is ignored in Preserve.
Spectrum_referenceMatched peakMatched peak isolates spectral-shape change; Absolute rendered levels retains the actual output/source level difference.
Draw_visualizationYesDraws waveforms, transfer curve, LTAS comparison, and summary.
Play_resultYesPlays the processed Sound when finished.

Built-in presets

PresetDriveThresholdKnee half-widthOutput gain
Near-Hard Clip1.20.80.050.95
Soft Clipper2.00.60.40.8
Hard Distortion5.00.40.010.6
Subtle Glue1.00.70.51.0
Low-Threshold Fuzz8.00.10.10.5
The preset names describe the parameter behavior; they are not circuit models. In particular, Low-Threshold Fuzz is a symmetric static clipper setting, not an emulation of a particular fuzz pedal.

Oversampling and aliasing

Clipping is nonlinear and generates new spectral components. If those components exceed Nyquist at the working sample rate, they fold back as aliases. With Oversample > 1, the script raises the working sample rate before the nonlinear stage and uses Praat's band-limited resampling when returning to the original rate. This reduces aliasing compared with running the same clipper directly at the source rate.

Not alias-free: oversampling is a mitigation, not a guarantee of perfect removal. The chosen factor is limited to 8×, and extremely nonlinear or high-frequency material can still produce audible residual artifacts.

Output level

ModeBehavior
Preserve shaped level (v0.2)Leaves the post-clipping/post-resampling magnitude unchanged. Peak_target is ignored.
Attenuate to target only if peak > targetMeasures the result peak. If it exceeds Peak_target, the whole Sound is scaled down so that its peak equals the target. If it is already at or below target, nothing changes.
Normalize to targetIf the output peak is non-zero, globally scales the whole Sound so its peak equals Peak_target. Silent output is left unchanged.

The attenuation mode is not a sample-by-sample limiter; it is one global gain operation after processing.

Visualization

The v0.4.1 visualization uses the suite layout and reports the actual current settings:

All input channels are processed and preserved. The waveform and LTAS commands operate on the multi-channel Sound according to Praat's standard object behavior; the script does not downmix the result to mono.

Limitations & practical interpretation

Applications

Useful contexts include transient clipping, drum and percussion distortion, controlled static saturation, intentionally hard digital clipping, and experimental nonlinear sound transformation. For reproducible work, record the preset plus Oversample, Output_level, Peak_target (when active), and Spectrum_reference because those secondary choices are not locked by the preset.