Designing a Nonlinear Compressor/Limiter/Expander for Modern AudioA nonlinear compressor/limiter/expander is a dynamic range processor whose gain response, attack/release behavior, and sidechain detection are shaped by nonlinear functions rather than pure linear time-invariant filters. These devices are prized in modern audio for musicality, transparent control, and creative character. This article explains goals and use cases, core building blocks, nonlinear design choices, implementation details, testing and tuning, and practical tips for mixing and mastering.
Why nonlinear dynamics processors?
Nonlinear behavior lets a dynamics processor react in ways that sound more natural or more musically useful than an LTI (linear time-invariant) design:
- Musical compression: Saturating or smoothly rounded transfer functions avoid harsh “pumping” and preserve transient perception.
- Adaptive response: Level-dependent time constants (attack/release) can be short for transients and long for sustained material, improving transparency.
- Combined functions: A single nonlinear architecture can act as compressor, hard/soft limiter, or expander by changing parameters or the detection path.
- Character and coloration: Nonlinearities such as soft clipping or wave-shaping provide pleasing harmonic content useful in modern pop, electronic, and instrumental production.
Core building blocks
1) Input stage and preconditioning
- High-quality anti-aliasing and optional analog-model pre-emphasis.
- Input gain staging to place signal in the optimal range for detection and nonlinear elements.
2) Level detection (sidechain)
- Common detectors: RMS, peak (true peak/rectified), or hybrid.
- Nonlinear detectors apply compressive or expansive functions to the detected level, e.g., logarithmic detector followed by power-law smoothing.
- Lookahead buffering (latency) for peak limiting.
3) Nonlinear gain computer (transfer function)
- The core mapping from detected level to gain reduction; implemented as a nonlinear function G(L).
- Transfer shapes:
- Soft-knee compression using smooth functions (e.g., sigmoid, cubic spline).
- Power-law expansion/expander gates: gain ∝ L^α where α < 1 or > 1.
- Limiting via steep sigmoid or hard clamp with smoothing.
- Parameterization: threshold, ratio (generalized), knee width, makeup gain, range (max reduction), and transition curvature.
4) Time constants (attack/release)
- Level-dependent (adaptive) time constants: τ_attack(L), τ_release(L).
- Common approach: make attack decrease (faster) for higher overshoots and release increase (slower) for lower levels to avoid pumping.
- Use exponential smoothing: g[n] = α(L) * g[n-1] + (1-α(L)) * targetGain
5) Gain application
- Apply computed gain to audio path with sample-accurate smoothing to prevent zipper noise.
- Consider per-sample interpolation or oversampling to avoid inter-sample distortion (especially for limiters).
6) Nonlinear output stages and coloration
- Soft clipping, tube/transformer modeling, or gentle harmonic generation can be added post-gain for musicality.
- Optional makeup gain and level compensation.
Nonlinear design choices and trade-offs
Detection metric: RMS vs Peak vs Hybrid
- RMS smooths energy and is perceived as level; good for program-dependent compression.
- Peak reacts to transients; necessary for true limiting.
- Hybrid blends short-term peak sensitivity with longer RMS for musical control.
Transfer function shapes
- Sigmoids and smoothed piecewise polynomials give continuous derivatives (no audible clicks).
- Power functions (L^k) can craft expanders or log-like behavior.
- Hard clamps are simple but require filtering and lookahead to avoid distortion.
Adaptive time constants
- Pros: reduce pumping, preserve transients.
- Cons: complexity, possible unpredictable behavior in extreme signals.
Oversampling and anti-aliasing
- Nonlinearities generate harmonics; oversampling reduces aliasing but increases CPU.
- Use polyphase or bandlimited interpolation when implementing soft-clipping or waveshaping.
Practical implementations
Example signal flow (digital)
- Anti-alias input / upsample (optional).
- Detect envelope: choose detector → rectify → smooth with adaptive τ.
- Compute gain G(L) via nonlinear transfer function.
- Smooth gain per-sample; apply to audio.
- Post-process: makeup gain, optional analog-model nonlinearity.
- Downsample / dither and output.
Basic pseudocode (conceptual)
// Inputs: x[n] audio, params (threshold, ratio, knee, attackCurve, releaseCurve) env = 0 for each sample n: d = detectMetric(x[n]) // peak/RMS/hybrid targetGain = computeGain(d) // nonlinear transfer function alpha = smoothingCoeff(d) // adaptive attack/release coefficient env = alpha*env + (1-alpha)*targetGain y[n] = env * x[n] y[n] = postColor(y[n]) // optional soft clip / saturation
Testing, measurement, and UI considerations
- Provide real-time meters for input level, detector level, gain reduction, and output.
- Implement true-peak measurement for limiting accuracy.
- Test with standardized test signals: sine sweeps, pink noise, impulsive transients, mix stems.
- Offer presets for common tasks: vocal compression, bus glue, transparent limiter, aggressive brickwall.
- Expose advanced controls in an “expert” panel: knee curvature, detector weighting, oversampling, lookahead.
Tuning guidelines and use cases
- Vocal: use an RMS/hybrid detector, medium attack (5–20 ms), medium release (50–300 ms), soft knee; add subtle tube saturation for presence.
- Drums (punch): faster attack (0.1–2 ms) for transient control, faster release (20–120 ms), peak detection with lookahead for limiting.
- Bus glue: gentle ratio (:1), slowish attack (10–30 ms) to let transients through, program-dependent release for musical pumping.
- Master limiter: hybrid detector, lookahead, aggressive transfer near 0 dBFS with oversampling and inter-sample peak handling.
Common pitfalls and how to avoid them
- Aliasing from nonlinearities — use oversampling and bandlimited waveshaping.
- Zipper noise from coarse parameter smoothing — perform per-sample smoothing.
- Undesired pumping — tune release/adaptive curves, use sidechain filtering (high-pass) to ignore low-frequency energy.
- False comfort from meters — include true-peak and inter-sample indicators for mastering.
Advanced topics (brief)
- Multiband nonlinear dynamics: split bands before nonlinear detection to control frequency-dependent dynamics.
- Sidechain filtering: low-frequency rumble removal (HPF) to prevent overreaction to bass.
- Machine-learning assisted parameter suggestion: ML models recommend attack/release/threshold from audio analysis.
- Nonlinear state-variable detectors: use perceptually motivated loudness models (ITU-R BS.1770) for detection.
Conclusion
Designing a nonlinear compressor/limiter/expander requires decisions across detection, transfer function shape, adaptive timing, and implementation quality (oversampling, smoothing). When done well, nonlinear designs offer musical control, transparent limiting, and useful coloration for modern production tasks. The key is thoughtful trade-offs: preserve transients, avoid aliasing and pumping, and provide controls that let engineers dial in behavior predictably.
Leave a Reply