Slew Limiter
Tier: Core | ComponentType: 38 | Params: 2
Linear rate limiter with independent rise and fall times for portamento, parameter smoothing, and envelope shaping.
Overview
SlewLimiter restricts the maximum rate of change of a signal. It has two independent time constants — Rise Rate controls how quickly the output can increase, and Fall Rate controls how quickly it can decrease. The rate limiting is linear (constant slew rate), not exponential, which gives a distinctive ramp-like character to transitions.
Common applications include:
- Portamento/glissando: Smooth pitch transitions between notes
- Parameter smoothing: Remove zipper noise from stepped control changes
- Envelope shaping: Convert a square gate into a trapezoid with controlled attack and decay ramps
- Anti-aliasing for control signals: Bandwidth-limit modulation sources before they reach audio-rate parameters
When the rise and fall rates are equal, the limiter is symmetric. When they differ, the component produces asymmetric slewing — for example, fast attack with slow release, or slow attack with fast release.
File Locations
| Path | |
|---|---|
| Header | Sources/FolioDSP/include/FolioDSP/Core/SlewLimiter.h |
| Implementation | Sources/FolioDSP/src/Core/SlewLimiter.cpp |
| Tests | Tests/FolioDSPTests/SlewLimiterTests.swift |
| Bridge | Sources/FolioDSPBridge/src/FolioDSPBridge.mm (SlewLimiterBridge) |
Parameters
| Index | Name | Description | Min | Max | Default Min | Default Max | Default | Unit |
|---|---|---|---|---|---|---|---|---|
| 0 | Rise Rate | Maximum upward slew rate | 0.1 | 5000.0 | 1.0 | 500.0 | 10.0 | ms |
| 1 | Fall Rate | Maximum downward slew rate | 0.1 | 5000.0 | 1.0 | 500.0 | 10.0 | ms |
Processing Algorithm
The process() function executes once per sample, limiting how fast the output can track the input.
1. Rate Conversion
The rise and fall times in milliseconds are converted to per-sample rate limits. The rate represents the maximum change in output value per sample, assuming a full-scale (0 to 1) transition over the specified time:
For example, a rise rate of 10 ms at 44100 Hz gives \(r_{\text{rise}} = 1 / (0.01 \times 44100) \approx 0.00227\) per sample.
2. Delta Computation
The difference between the input and the current output determines the direction of slewing:
3. Rate-Limited Update
The output moves toward the input, but no faster than the applicable rate limit:
When the delta is smaller than the rate limit, the output reaches the input exactly (no overshoot). When the delta exceeds the rate limit, the output ramps at the maximum allowed rate.
4. Slewing Detection
A boolean flag indicates whether the output is still catching up to the input:
This flag is emitted in the snapshot for UI indication of active slewing.
Core Equations
Snapshot Fields
| Field | Type | Range | Unit | Description |
|---|---|---|---|---|
| Input Value | Float | -1–1 | Current input sample value | |
| Output Value | Float | -1–1 | Current slew-limited output value | |
| Rise Rate | Float | 0.1–5000 | ms | Current rise rate setting |
| Fall Rate | Float | 0.1–5000 | ms | Current fall rate setting |
| Slewing | Bool | 0–1 | Whether the output is actively slewing toward the input |
Implementation Notes
- Linear slewing produces straight-line ramps, unlike exponential smoothers (one-pole filters) which produce curved approach. This is musically useful for portamento where the pitch glide should sound constant-speed rather than decelerating.
- Per-sample rate is recomputed every sample from the atomic parameter values. This means the slew rate can be modulated in real-time without artifacts.
- No overshoot: the
min/maxclamping ensures the output never exceeds the input value. When the remaining delta is smaller than the rate, the output snaps exactly to the input. - Slewing threshold of \(10^{-6}\) avoids the flag flickering due to floating-point rounding when the output has effectively reached the input.
- Reset sets the internal state (
current_) to 0.0. After reset, the first input sample will trigger immediate slewing from zero. - Parameters are not smoothed (smoothed = false in ParamInfo) because the rate conversion already provides continuous behavior — abrupt rate changes simply change the slope of the current ramp.
- All parameters use
std::atomic<float>for lock-free thread safety. - Snapshot emission is decimated to ~60 fps (every 735 samples at 44.1 kHz).
Equation Summary
y += clamp(x-y, -fall, +rise)