Skip to content

SoftClipper

Tier: Primitives | ComponentType: 5 | Params: 2

Threshold-and-knee-based tanh saturation for gentle gain limiting in feedback paths.

Overview

SoftClipper provides smooth amplitude limiting using a threshold/knee topology. Below the knee start point, the signal passes through unchanged. Above it, tanh saturation progressively compresses the signal toward the threshold. The knee parameter controls the width of the transition zone — a wider knee gives a more gradual onset of compression.

Designed as a building block for feedback paths where controlled saturation prevents runaway without hard clipping artifacts. The tanh curve provides musically pleasant soft limiting that can be pushed into audible coloring at low thresholds.

File Locations

Path
Header Sources/FolioDSP/include/FolioDSP/Primitives/SoftClipper.h
Implementation Sources/FolioDSP/src/Primitives/SoftClipper.cpp
Tests Tests/FolioDSPTests/SoftClipperTests.swift
Bridge Sources/FolioDSPBridge/src/FolioDSPBridge.mm (SoftClipperBridge)

Parameters

Index Name Description Min Max Default Min Default Max Default Unit
0 Threshold Level above which soft clipping engages -60.0 0.0 -12.0 0.0 -6.0 dB
1 Knee Width of the transition zone between linear and clipped regions 0.0 24.0 0.0 12.0 6.0 dB

Processing Algorithm

1. Convert Threshold to Linear

\[T = 10^{T_{\text{dB}} / 20}\]

2. Calculate Knee Start

\[K_{\text{lin}} = 10^{K_{\text{dB}} / 20} - 1\]
\[K_{\text{start}} = \frac{T}{1 + K_{\text{lin}}}\]

3. Apply Soft Clipping

For \(|x| \leq K_{\text{start}}\): pass through unchanged.

For \(|x| > K_{\text{start}}\):

\[\text{excess} = |x| - K_{\text{start}}\]
\[\text{range} = T - K_{\text{start}}\]
\[y = \text{sign}(x) \cdot \left(K_{\text{start}} + \text{range} \cdot \tanh\!\left(\frac{\text{excess}}{\text{range}}\right)\right)\]

4. Gain Reduction Tracking

\[\text{GR} = |x| - |y|\]

Snapshot Fields

Field Type Range Unit Description
Threshold Float -60–0 dB Current threshold
Knee Float 0–24 dB Current knee width
Gain Reduction Float 0–24 dB Amount of gain being reduced
Input Level Float 0–1 Input amplitude

Implementation Notes

  • Symmetric clipping — positive and negative peaks treated identically via sign multiplication
  • The tanh curve provides smooth asymptotic approach to the threshold ceiling
  • Both parameters are smoothed for click-free real-time adjustment
  • Division by range is protected against zero (minimum 1e-6)

Equation Summary

y = t + range·tanh((x-t)/range)