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.
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.
Quick start
- Select exactly one Sound object in Praat.
- Run
Hard_Clip.praat. - Choose a preset or leave Manual.
- Set Drive, Threshold, Knee_half_width, and Output_Gain.
- Choose an Oversample factor from the supported range 1–8. The default is 4×.
- Choose the Output_level. The default is Preserve shaped level.
- Optionally draw the visualization and play the result.
Signal path
Processing order
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
When K = 0
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|.
Parameters & presets
Form parameters
| Parameter | Default | Actual behavior |
|---|---|---|
| Preset | Manual | Manual plus five named parameter sets. |
| Drive | 1.0 | Input 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. |
| Threshold | 0.5 | Center/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_width | 0.2 | Half-width of the knee. Total knee width is 2K. Zero means exact hard clipping. Negative values or K > Threshold are rejected. |
| Output_Gain | 0.9 | Constant multiplier after the waveshaper. Negative values invert the whole shaped output; zero silences it. |
| Oversample | 4 | Requested integer factor. Values below 1 run as 1; values above 8 run as 8, with a note in the Info window. |
| Output_level | Preserve shaped level | Preserve, conditional attenuation, or normalization. |
| Peak_target | 0.95 | Used only by attenuation or normalization. Must be >0 and ≤1 in those modes; it is ignored in Preserve. |
| Spectrum_reference | Matched peak | Matched peak isolates spectral-shape change; Absolute rendered levels retains the actual output/source level difference. |
| Draw_visualization | Yes | Draws waveforms, transfer curve, LTAS comparison, and summary. |
| Play_result | Yes | Plays the processed Sound when finished. |
Built-in presets
| Preset | Drive | Threshold | Knee half-width | Output gain |
|---|---|---|---|---|
| Near-Hard Clip | 1.2 | 0.8 | 0.05 | 0.95 |
| Soft Clipper | 2.0 | 0.6 | 0.4 | 0.8 |
| Hard Distortion | 5.0 | 0.4 | 0.01 | 0.6 |
| Subtle Glue | 1.0 | 0.7 | 0.5 | 1.0 |
| Low-Threshold Fuzz | 8.0 | 0.1 | 0.1 | 0.5 |
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.
Output level
| Mode | Behavior |
|---|---|
| Preserve shaped level (v0.2) | Leaves the post-clipping/post-resampling magnitude unchanged. Peak_target is ignored. |
| Attenuate to target only if peak > target | Measures 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 target | If 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:
- Original waveform — the source Sound.
- Clipped waveform — the finished result after output-level processing.
- Static clipping curve — the waveshaper mapping, including Drive, Output_Gain, and any global level scaling. If oversampling is active, the title explicitly states that this curve is the waveshaper before anti-alias filtering, because a resampling filter cannot be represented by a single memoryless x→y curve.
- Spectrum — LTAS of source and result up to min(Nyquist, 12 kHz). Matched peak scales copies of both signals to the same peak before LTAS so the comparison emphasizes spectral shape; Absolute rendered levels preserves level differences.
- Summary strip — source, channel count, preset, shaping parameters, oversampling, output mode, measured peak, and spectrum reference. The target is shown only when the output mode actually uses it.
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
- This is a static memoryless waveshaper, not a compressor, look-ahead limiter, amplifier circuit model, or pedal model.
- The knee is symmetric around zero. It does not intentionally create asymmetric/even-harmonic coloration.
Thresholdis evaluated after Drive. A threshold above 1.0 can still engage if Drive raises the working samples enough.Knee_half_widthcannot exceed Threshold because the implemented quadratic would otherwise become negative around zero.- Oversampling reduces nonlinear aliasing but does not mathematically eliminate every alias component.
- Normalize and conditional attenuation are file-wide peak scaling operations and can change the overall gain relationship established by Output_Gain.
- There is no wet/dry mix in this script. For parallel clipping, create/mix a separate processed copy externally.
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.