feat(cabinet): mic voicing (14a) + cabinet output soft-limit

Phase 14a of cabinet mic modeling.

- MicVoice (No Mic / Dynamic / Ribbon / Condenser): broad-strokes synthesized
  mic curves (our own MIT content, not captures) as CabIRStage biquad specs
  (presence bump, low/high shelving) that CabinetIRFactory appends to the cab
  cascade before baking — folded into the SAME single convolution IR, so mic
  choice costs nothing at render time. MicVoice.off appends nothing → the IR
  is byte-identical to the raw cab voice (backward compatible).
- CabinetIRFactory.makeIR gains a `mic:` param (default .off) + RBJ low/high
  shelf offline biquads.
- CabinetPedal: Mic selector (rebuildsOnChange, append-only 2nd selector so
  old presets still load with mic defaulting to off) + a tanh soft-limit →
  Clip(±1) output stage, so a decoupled amp → cabinet chain can't clip the
  DAC (a speaker cab is analog; clean signals pass at ~unit gain).
- Help acknowledgment notes the mic voicings are synthesized, not captures.

Tests: No-Mic IR byte-identical to raw cab; dynamic lifts presence, ribbon
darkens top, condenser adds air (peak-normalization-invariant tilt ratios);
mic changes output, round-trips; output stays within ±1 across cab×mic. 659
tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 08:55:11 -07:00
parent a2fcd59e1b
commit 7f1856e8e5
7 changed files with 333 additions and 17 deletions
@@ -0,0 +1,43 @@
// CabIRStage.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
/// One filter stage in an off-RT cabinet-IR cascade, as a kind plus parameters.
///
/// Consumed by ``CabinetIRFactory`` when it bakes an impulse response: the cab voice contributes a
/// fixed cascade, and a ``MicVoice`` contributes extra stages (presence bump, top-end/low-end
/// shelving) appended to it. `q` is used by high-pass / low-pass / peaking stages; `gainDb` by
/// peaking and the shelves; shelves use a fixed slope set by the factory.
struct CabIRStage {
/// The biquad kind this stage bakes into.
enum Kind {
case highPass
case lowPass
case peaking
case lowShelf
case highShelf
}
let kind: Kind
let freq: Double
let q: Double
let gainDb: Double
/// A resonant peak/dip at `freq`.
static func peaking(_ freq: Double, q: Double, gainDb: Double) -> CabIRStage {
CabIRStage(kind: .peaking, freq: freq, q: q, gainDb: gainDb)
}
/// A low-frequency shelf at `freq` (slope fixed by the factory).
static func lowShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
CabIRStage(kind: .lowShelf, freq: freq, q: 0.0, gainDb: gainDb)
}
/// A high-frequency shelf at `freq` (slope fixed by the factory).
static func highShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
CabIRStage(kind: .highShelf, freq: freq, q: 0.0, gainDb: gainDb)
}
}
@@ -12,6 +12,8 @@ import Darwin
private let cabinetBiquadNyquistFraction: Double = 0.49
/// RBJ-cookbook divisor converting a peaking-filter gain in dB to its `A` amplitude term.
private let cabinetPeakingGainDivisor: Double = 40.0
/// RBJ-cookbook divisor converting a shelf-filter gain in dB to its `A` amplitude term (same `/40`).
private let cabinetShelfGainDivisor: Double = 40.0
/// Synthesizes a short cabinet impulse response for a ``CabinetVoice`` by running a unit
/// impulse through a cascade of RBJ biquads (high-pass → two-stage low-pass → low-mid body
@@ -37,16 +39,24 @@ public enum CabinetIRFactory {
private static let breakupQ: Double = 2.0
/// Q for the mid interference notch (narrow, so it dips without gutting the midrange).
private static let notchQ: Double = 2.5
/// Fixed shelf slope for the ``MicVoice`` low-/high-shelf stages (gentle, like the amp shelves).
private static let micShelfSlope: Double = 0.7
/// Builds the impulse response for `voice` at `sampleRate`.
/// Builds the impulse response for `voice` (optionally mic'd by `mic`) at `sampleRate`.
///
/// The cab voice's fixed cascade is baked first; any ``MicVoice`` stages are appended before the
/// impulse is run, so the mic colour is folded into the same single IR (no extra render-time
/// cost). ``MicVoice/off`` appends nothing, so the result is byte-for-byte the raw cab voice.
///
/// - Parameters:
/// - voice: The cabinet voicing to synthesize.
/// - mic: The microphone voicing layered on top. Defaults to ``MicVoice/off`` (no mic).
/// - sampleRate: Engine sample rate in Hz.
/// - frames: IR length in frames. Defaults to ``defaultFrames``.
/// - Returns: A mono `LyrebirdBuffer` holding the normalized IR, tagged with `sampleRate`.
public static func makeIR(
voice: CabinetVoice,
mic: MicVoice = .off,
sampleRate: Double,
frames: Int = CabinetIRFactory.defaultFrames
) -> LyrebirdBuffer {
@@ -60,6 +70,25 @@ public enum CabinetIRFactory {
OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate),
]
// Append the mic voicing's stages (none for `.off`) so its colour bakes into the same IR.
for stage: CabIRStage in mic.stages {
switch stage.kind {
case .highPass:
chain.append(OfflineBiquad.highPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
case .lowPass:
chain.append(OfflineBiquad.lowPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
case .peaking:
chain.append(OfflineBiquad.peaking(
freq: stage.freq, q: stage.q, gainDb: stage.gainDb, sampleRate: sampleRate))
case .lowShelf:
chain.append(OfflineBiquad.lowShelf(
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
case .highShelf:
chain.append(OfflineBiquad.highShelf(
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
}
}
var ir: [Double] = [Double](repeating: 0.0, count: frames)
for n: Int in 0..<frames {
var sample: Double = n == 0 ? 1.0 : 0.0
@@ -161,4 +190,44 @@ private struct OfflineBiquad {
let a2: Double = 1.0 - alpha / amplitude
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
}
/// RBJ low-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
static func lowShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
let amplitude: Double = pow(10.0, gainDb / cabinetShelfGainDivisor)
let w0: Double = 2.0 * Double.pi * f / sampleRate
let cosW0: Double = cos(w0)
let sinW0: Double = sin(w0)
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
let ap1: Double = amplitude + 1.0
let am1: Double = amplitude - 1.0
let b0: Double = amplitude * (ap1 - am1 * cosW0 + twoSqrtAAlpha)
let b1: Double = 2.0 * amplitude * (am1 - ap1 * cosW0)
let b2: Double = amplitude * (ap1 - am1 * cosW0 - twoSqrtAAlpha)
let a0: Double = ap1 + am1 * cosW0 + twoSqrtAAlpha
let a1: Double = -2.0 * (am1 + ap1 * cosW0)
let a2: Double = ap1 + am1 * cosW0 - twoSqrtAAlpha
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
}
/// RBJ high-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
static func highShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
let amplitude: Double = pow(10.0, gainDb / cabinetShelfGainDivisor)
let w0: Double = 2.0 * Double.pi * f / sampleRate
let cosW0: Double = cos(w0)
let sinW0: Double = sin(w0)
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
let ap1: Double = amplitude + 1.0
let am1: Double = amplitude - 1.0
let b0: Double = amplitude * (ap1 + am1 * cosW0 + twoSqrtAAlpha)
let b1: Double = -2.0 * amplitude * (am1 + ap1 * cosW0)
let b2: Double = amplitude * (ap1 + am1 * cosW0 - twoSqrtAAlpha)
let a0: Double = ap1 - am1 * cosW0 + twoSqrtAAlpha
let a1: Double = 2.0 * (am1 - ap1 * cosW0)
let a2: Double = ap1 - am1 * cosW0 - twoSqrtAAlpha
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
}
}
@@ -0,0 +1,76 @@
// MicVoice.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
/// A microphone voicing baked into the cabinet impulse response — the frequency signature of the
/// mic in front of the speaker, layered on top of the ``CabinetVoice`` cab curve.
///
/// Each voice is a compact set of ``CabIRStage`` filter stages (a presence bump, low-end and
/// top-end shelving) that ``CabinetIRFactory`` appends to the cab cascade before baking, so mic
/// choice costs nothing extra at render time — it is folded into the single convolution IR. These
/// are **broad-strokes synthesized curves** (our own MIT content, not captures of any specific
/// microphone), analogous to ``CabinetVoice``.
///
/// ``off`` contributes no stages, so a cab with no mic bakes exactly the raw cab voice — the
/// original, mic-less behaviour.
public enum MicVoice: String, CaseIterable, Sendable {
case off
case dynamic
case ribbon
case condenser
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
/// range. Mirrors ``CabinetVoice/voice(atSelectorValue:)`` so a huge / NaN selector never traps.
///
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
/// - Returns: The corresponding voice, clamped to `allCases`.
public static func voice(atSelectorValue selectorValue: Double) -> MicVoice {
let all: [MicVoice] = allCases
guard selectorValue.isFinite else { return all[0] }
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
let index: Int = Int(bounded.rounded())
return all[index]
}
/// Human-readable name for pickers.
public var displayName: String {
switch self {
case .off: return "No Mic"
case .dynamic: return "Dynamic"
case .ribbon: return "Ribbon"
case .condenser: return "Condenser"
}
}
/// The mic's filter stages, appended to the cab cascade before baking. Empty for ``off``.
///
/// Broad-strokes voicings: the **dynamic** (moving-coil, close-mic staple) adds an upper-mid
/// presence bump with a tightened low end and rolled-off extreme top; the **ribbon** is dark and
/// smooth (warm low-mid, steep top rolloff, no presence spike); the **condenser** is the most
/// extended and airy (gentle top-end lift, light presence sheen).
var stages: [CabIRStage] {
switch self {
case .off:
return []
case .dynamic:
return [
CabIRStage.lowShelf(120.0, gainDb: -2.0),
CabIRStage.peaking(5500.0, q: 1.0, gainDb: 4.0),
CabIRStage.highShelf(9000.0, gainDb: -3.0),
]
case .ribbon:
return [
CabIRStage.lowShelf(200.0, gainDb: 2.5),
CabIRStage.peaking(2500.0, q: 0.8, gainDb: -1.5),
CabIRStage.highShelf(6500.0, gainDb: -7.0),
]
case .condenser:
return [
CabIRStage.peaking(8000.0, q: 1.0, gainDb: 1.5),
CabIRStage.highShelf(11000.0, gainDb: 3.0),
]
}
}
}
@@ -45,6 +45,9 @@ public final class CabinetPedal: Pedal {
/// stops via the ``cabinet`` selector; read at board-build time by `effect(_:)`, which
/// instantiates only that voice's convolver (the selector is `rebuildsOnChange`).
@UIParam public var cabinet: Double = 0.0
/// Selected microphone voicing as an index into ``MicVoice/allCases`` (`0` = No Mic). Baked into
/// the same IR as the cab voice, so it costs nothing extra at render time. `rebuildsOnChange`.
@UIParam public var mic: Double = 0.0
// MARK: - Constants
@@ -54,6 +57,18 @@ public final class CabinetPedal: Pedal {
/// Convolution is taken fully wet here; the `Pedal` base class provides the user wet/dry mix.
private let convolutionMix: Double = 1.0
/// Output soft-limit drive. `1.0` gives unit small-signal gain (clean signals pass untouched)
/// with a `tanh` asymptote at ±1 — a speaker cab is analog and does not digital-clip, so peaks
/// (convolution can overshoot ±1) soft-compress rather than hard-clip.
private let softLimitDrive: Double = 1.0
/// Symmetric output stage — a pure `tanh` limiter, no even-harmonic colour.
private let softLimitBias: Double = 0.0
/// 2× is enough: the cab low-pass already band-limits the signal feeding this stage.
private let softLimitOversample: Int = 2
/// Absolute digital ceiling for the hard safety clamp catching the sub-percent overshoot the
/// `tanh`'s DC-blocker / halfband filters can leave just above ±1.
private let outputCeiling: Double = 1.0
/// Selector stops, one per ``CabinetVoice`` in `allCases` order (value == index).
private static let voiceStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
.enumerated()
@@ -61,6 +76,13 @@ public final class CabinetPedal: Pedal {
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
}
/// Selector stops, one per ``MicVoice`` in `allCases` order (value == index).
private static let micStops: [PedalSelectorKnob.Stop] = MicVoice.allCases
.enumerated()
.map { (index: Int, mic: MicVoice) in
PedalSelectorKnob.Stop(title: mic.displayName, value: Double(index))
}
// MARK: - Init
/// Creates a cabinet pedal.
@@ -86,28 +108,42 @@ public final class CabinetPedal: Pedal {
[
PedalSelectorKnob(
label: "Cab", node: $cabinet, stops: CabinetPedal.voiceStops, rebuildsOnChange: true),
PedalSelectorKnob(
label: "Mic", node: $mic, stops: CabinetPedal.micStops, rebuildsOnChange: true),
]
}
// MARK: - Effect
/// Convolves the dry signal against the single selected cabinet IR.
/// Convolves the dry signal against the single selected cabinet + mic IR, then soft-limits.
///
/// Only the voice named by the live `cabinet` selector is instantiated, so exactly one
/// partitioned-FFT convolver runs. Changing the selector triggers a board rebuild (the selector
/// is `rebuildsOnChange`), which re-enters `effect(_:)` with the new voice — so switching cabs
/// costs a brief rebuild rather than running every voice at once. Synthesizing the short IR
/// happens off the RT thread in `build()`.
/// Only the voice/mic named by the live selectors is baked, so exactly one partitioned-FFT
/// convolver runs; the mic colour is folded into that same IR at no extra render cost. Changing
/// either selector triggers a board rebuild (both are `rebuildsOnChange`). Synthesizing the short
/// IR happens off the RT thread in `build()`.
///
/// The closing `TriodeStage(bias: 0)` → `Clip(±1)` is a symmetric `tanh` soft-limit + hard
/// ceiling: a speaker cab is analog and can't digital-clip, and the convolution can push peaks
/// past ±1, so peaks soft-compress toward ±1 while clean signals (well below ±1) pass at ~unit
/// gain. This keeps a decoupled amp → cabinet chain from clipping the DAC.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: The cabinet-convolved mono output.
/// - Returns: The cabinet-convolved, mic-voiced, soft-limited mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let sr: Double = sampleRate
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cabinet)
return ConvolutionReverb.Audio(
let micVoice: MicVoice = MicVoice.voice(atSelectorValue: mic)
let convolved: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
input: dry,
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
ir: CabinetIRFactory.makeIR(voice: voice, mic: micVoice, sampleRate: sr),
mix: convolutionMix
)
let softLimited: TriodeStage = TriodeStage(
input: convolved,
drive: softLimitDrive,
bias: softLimitBias,
oversample: softLimitOversample
)
return Clip.Audio(softLimited, lo: -outputCeiling, hi: outputCeiling)
}
}
+3 -2
View File
@@ -176,8 +176,9 @@ public struct HelpView: View {
"Filter design follows the RBJ Audio EQ Cookbook by Robert Bristow-Johnson — the "
+ "standard biquad coefficient formulas, used to synthesize the Cabinet pedal's "
+ "built-in speaker impulse responses.",
"The Cabinet pedal's built-in cab voicings are original impulse responses generated in "
+ "code — not captures of any third-party hardware or IR pack.",
"The Cabinet pedal's built-in cab and microphone voicings are original impulse "
+ "responses generated in code — not captures of any third-party speaker, "
+ "microphone, or IR pack.",
"The tube-amp voice pedals' tone stacks "
+ "follow the Yeh & Smith analysis of the classic passive tone-stack circuit (\"Discretization "
+ "of the '59 Fender Bassman Tone Stack\", DAFx-06); their models are original code, not "
@@ -110,4 +110,57 @@ struct CabinetIRFactoryTests {
let names: [String] = CabinetVoice.allCases.map { $0.displayName }
#expect(Set(names).count == names.count, "duplicate cabinet display names")
}
// MARK: - Mic voicing
/// Ratio of the IR's magnitude at `hz` to a mid-band reference (800 Hz). Peak-normalization
/// scales the whole IR, so it cancels in this ratio — letting a mic's *relative* boost/cut at a
/// frequency be compared across IRs regardless of their independent normalization.
private func tiltRatio(_ ir: LyrebirdBuffer, hz: Double) -> Double {
let reference: Double = responseMagnitude(ir, hz: 800.0)
guard reference > 0.0 else { return 0.0 }
return responseMagnitude(ir, hz: hz) / reference
}
@Test func noMicMatchesRawCabIR() {
// MicVoice.off must append no stages, so the IR is byte-identical to the mic-less default —
// the backward-compatible path for cabs saved before mic voicing existed.
for voice: CabinetVoice in CabinetVoice.allCases {
let raw: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate)
let offMic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, mic: .off, sampleRate: sampleRate)
#expect(raw.count == offMic.count)
var identical: Bool = true
for i: Int in 0..<raw.count where raw[i, 0] != offMic[i, 0] { identical = false; break }
#expect(identical, "\(voice) No-Mic IR differs from the raw cab IR")
}
}
@Test func dynamicMicLiftsPresence() {
// The dynamic mic adds a presence bump at ~5.5 kHz → a higher 5.5 kHz-to-mid tilt than no mic.
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .off, sampleRate: sampleRate)
let dynamic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .dynamic, sampleRate: sampleRate)
#expect(tiltRatio(dynamic, hz: 5500.0) > tiltRatio(off, hz: 5500.0),
"dynamic mic did not lift the presence region")
}
@Test func ribbonMicDarkensTop() {
// The ribbon mic rolls the top off (−7 dB shelf @ 6.5 kHz) → a lower 8 kHz-to-mid tilt.
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
let ribbon: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .ribbon, sampleRate: sampleRate)
#expect(tiltRatio(ribbon, hz: 8000.0) < tiltRatio(off, hz: 8000.0),
"ribbon mic did not darken the top end")
}
@Test func condenserMicAddsAir() {
// The condenser mic lifts the extreme top (+3 dB shelf @ 11 kHz) → a higher 10 kHz-to-mid tilt.
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
let condenser: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .condenser, sampleRate: sampleRate)
#expect(tiltRatio(condenser, hz: 10000.0) > tiltRatio(off, hz: 10000.0),
"condenser mic did not add top-end air")
}
@Test func micNamesAreUnique() {
let names: [String] = MicVoice.allCases.map { $0.displayName }
#expect(Set(names).count == names.count, "duplicate mic display names")
}
}
@@ -59,13 +59,51 @@ struct CabinetPedalTests {
#expect(ssd > 0, "cabinet selection had no effect on output")
}
@Test func exposesCabinetSelector() throws {
@Test func exposesCabinetAndMicSelectors() throws {
let pedal: CabinetPedal = CabinetPedal()
let labels: [String] = pedal.effectSelectors.map { $0.label }
#expect(labels == ["Cab"])
// One stop per voice, in allCases order.
let stops: [String] = pedal.effectSelectors.first?.stops.map { $0.title } ?? []
#expect(stops == CabinetVoice.allCases.map { $0.displayName })
#expect(labels == ["Cab", "Mic"])
// One Cab stop per voice, one Mic stop per mic voice, both in allCases order.
let cabStops: [String] = pedal.effectSelectors.first { $0.label == "Cab" }?.stops.map { $0.title } ?? []
#expect(cabStops == CabinetVoice.allCases.map { $0.displayName })
let micStops: [String] = pedal.effectSelectors.first { $0.label == "Mic" }?.stops.map { $0.title } ?? []
#expect(micStops == MicVoice.allCases.map { $0.displayName })
}
@Test func micSelectionChangesOutput() throws {
// Mic 0 = No Mic, mic 1 = Dynamic — different baked IRs, different output.
let noMic: [Float] = try render { $0.mic = 0.0 }
let dynamic: [Float] = try render { $0.mic = 1.0 }
#expect(hasNonSilentOutput(noMic) && hasNonSilentOutput(dynamic))
let skip: Int = 4096, window: Int = 4096
guard noMic.count >= skip + window, dynamic.count >= skip + window else { return }
let ssd: Double = zip(noMic[skip..<(skip + window)], dynamic[skip..<(skip + window)]).reduce(0.0) { acc, pair in
let d: Double = Double(pair.0 - pair.1); return acc + d * d
}
#expect(ssd > 0, "mic selection had no effect on output")
}
@Test func micSelectionRoundTripsThroughState() throws {
let pedal: CabinetPedal = CabinetPedal()
pedal.cabinet = 2.0
pedal.mic = 3.0
let restored: CabinetPedal = CabinetPedal()
restored.applyState(pedal.captureState())
#expect(restored.cabinet == 2.0 && restored.mic == 3.0, "cab/mic selection did not round-trip")
}
@Test func outputStaysWithinCeiling() throws {
// The tanh soft-limit + Clip(±1) bound the output so a decoupled amp → cabinet chain can't
// clip the DAC. No render may exceed ±1.
let ceilingEpsilon: Double = 1.0e-4
for cab: Double in [0.0, 2.0, 6.0] {
for micValue: Double in [0.0, 1.0, 2.0, 3.0] {
let out: [Float] = try render { $0.cabinet = cab; $0.mic = micValue }
#expect(out.allSatisfy { $0.isFinite })
let peak: Double = out.reduce(0.0) { Swift.max($0, abs(Double($1))) }
#expect(peak <= 1.0 + ceilingEpsilon, "cab=\(cab) mic=\(micValue) peak \(peak) exceeds ±1")
}
}
}
@Test func cabinetSelectorRebuildsOnChange() throws {