v1.6.4 release: LookAheadLimiter releaseTime decoupled from lookAheadTime

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 18:10:54 -07:00
parent 5e6534a615
commit d6875da2cb
5 changed files with 89 additions and 23 deletions
+5 -3
View File
@@ -105,7 +105,7 @@ File: `Sources/Lyrebird/Generators/Dynamics/LookAheadLimiter.swift`
Delays the output by `lookAheadTime` seconds and uses the look-ahead window to detect peaks before they arrive, guaranteeing the output never exceeds `±maxAmplitude`. No overshoot.
```swift
LookAheadLimiter(in:maxAmplitude:lookAheadTime:sampleRate:)
LookAheadLimiter(in:maxAmplitude:lookAheadTime:releaseTime:sampleRate:)
```
| Parameter | Type | Default | Description |
@@ -113,6 +113,7 @@ LookAheadLimiter(in:maxAmplitude:lookAheadTime:sampleRate:)
| `in` | `ValidGeneratorInput` | — | Signal to limit |
| `maxAmplitude` | `ValidGeneratorInput` | `1.0` | Peak ceiling (absolute value) |
| `lookAheadTime` | `Double` | `0.005` | Delay in seconds. Set at init. |
| `releaseTime` | `ValidGeneratorInput` | `0.050` | Gain-release time constant (seconds), read per block; decoupled from `lookAheadTime`. Clamped to ≥ 0. Keep it above the period of the lowest expected frequency to avoid low-frequency distortion. |
| `sampleRate` | `Double` | `44100.0` | Used to size ring buffers at init. |
**Output:** single channel, delayed by `lookAheadSamples = Int(lookAheadTime × sampleRate)`.
@@ -122,7 +123,7 @@ LookAheadLimiter(in:maxAmplitude:lookAheadTime:sampleRate:)
2. Scan the look-ahead window (`lookAheadSamples`) for peak.
3. Required gain = `min(1, maxAmplitude / peak)`.
4. Attack is **instantaneous** (gain can always be reduced within the window).
5. Release smoothed: `releaseCoeff = exp(−1 / (sr × lookAheadTime))`.
5. Release smoothed: `releaseCoeff = exp(−1 / (sr × releaseTime))`, recomputed per block (so `releaseTime` may track a live parameter) rather than fixed at init.
6. Output = delayed sample × current gain.
**Pre-allocated buffers:**
@@ -134,7 +135,8 @@ LookAheadLimiter(in:maxAmplitude:lookAheadTime:sampleRate:)
**Usage:**
```swift
let mastered = LookAheadLimiter(in: mix, maxAmplitude: 0.99, lookAheadTime: 0.005)
let mastered = LookAheadLimiter(in: mix, maxAmplitude: 0.99, lookAheadTime: 0.005,
releaseTime: 0.050, sampleRate: engine.sampleRate)
```
---