docs+test(cabinet): accurate signal-path diagram + honest placement tests

Review follow-ups (no blockers):
- Update the CabinetPedal class doc signal-path diagram to show the full chain
  (mic baked into the IR -> Position/Proximity shelves -> look-ahead limiter),
  which had drifted to the original convolution-only form.
- Reword the placement "neutral defaults" test: it is a default-consistency /
  determinism guard (explicit defaults == default render), not proof of 0 dB
  shelf identity (both sides run the same shelves) -- that identity is the RBJ
  property the reviewer verified. Add loud render-length assertions so a short
  render fails instead of silently passing the guard.

664 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 09:24:24 -07:00
parent f67a5370ff
commit 35ae16040a
2 changed files with 16 additions and 6 deletions
@@ -18,7 +18,10 @@ import LyrebirdUI
///
/// Signal path (inside `effect(_:)`):
/// ```
/// dry → ConvolutionReverb(ir: selectedVoice) → mono out
/// dry → ConvolutionReverb(ir: cab voice + mic voice) (one IR — mic colour baked in)
/// → RBJHighShelf (Position) → RBJLowShelf (Proximity) (live mic-placement shelves)
/// → LookAheadLimiter(±1) (transparent peak safety)
/// → mono out
/// ```
///
/// The wet/dry mix and bypass are handled by the `Pedal` base class.
@@ -32,6 +35,9 @@ import LyrebirdUI
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - `cabinet`: Selects the built-in cabinet voicing (stepped selector over ``CabinetVoice``).
/// - `mic`: Selects the microphone voicing baked into the IR (stepped selector over ``MicVoice``).
/// - `position` / `proximity`: Live mic-placement shelves in the advanced pop-over (on-axis ↔ edge,
/// distant ↔ close).
public final class CabinetPedal: Pedal {
/// One-line description shown in the picker and info panel.
@@ -97,6 +97,7 @@ struct CabinetPedalTests {
let onAxis: [Float] = try render { $0.position = 0.0 }
let edge: [Float] = try render { $0.position = 1.0 }
let skip: Int = 4096, window: Int = 4096
#expect(onAxis.count >= skip + window && edge.count >= skip + window, "render too short")
guard onAxis.count >= skip + window, edge.count >= skip + window else { return }
let ssd: Double = zip(onAxis[skip..<(skip + window)], edge[skip..<(skip + window)]).reduce(0.0) { acc, pair in
let d: Double = Double(pair.0 - pair.1); return acc + d * d
@@ -109,6 +110,7 @@ struct CabinetPedalTests {
let distant: [Float] = try render { $0.proximity = 0.0 }
let close: [Float] = try render { $0.proximity = 1.0 }
let skip: Int = 4096, window: Int = 4096
#expect(distant.count >= skip + window && close.count >= skip + window, "render too short")
guard distant.count >= skip + window, close.count >= skip + window else { return }
let ssd: Double = zip(distant[skip..<(skip + window)], close[skip..<(skip + window)]).reduce(0.0) { acc, pair in
let d: Double = Double(pair.0 - pair.1); return acc + d * d
@@ -116,18 +118,20 @@ struct CabinetPedalTests {
#expect(ssd > 0, "mic Proximity had no effect on output")
}
@Test func placementDefaultsAreNeutral() throws {
// Position = 0 and Proximity = 0 map to 0 dB shelves (bit-exact identity), so setting them
// explicitly to the defaults must match the default render exactly — no placement coloration
// for cabs saved before placement existed.
@Test func explicitDefaultPlacementMatchesImplicit() throws {
// A default-consistency guard: the shipped defaults are position = 0 / proximity = 0, so
// setting them explicitly must reproduce the default render exactly. (That those defaults are
// a *no-op* on the tone follows from the RBJ shelves collapsing to unity at 0 dB — a Lyrebird
// property; this test pins that the defaults are those values and the render is deterministic.)
let byDefault: [Float] = try render()
let explicit: [Float] = try render { $0.position = 0.0; $0.proximity = 0.0 }
let skip: Int = 4096, window: Int = 4096
#expect(byDefault.count >= skip + window && explicit.count >= skip + window, "render too short")
guard byDefault.count >= skip + window, explicit.count >= skip + window else { return }
let ssd: Double = zip(byDefault[skip..<(skip + window)], explicit[skip..<(skip + window)]).reduce(0.0) { acc, pair in
let d: Double = Double(pair.0 - pair.1); return acc + d * d
}
#expect(ssd == 0, "neutral Position/Proximity is not a bit-exact identity")
#expect(ssd == 0, "explicit default placement did not match the default render")
}
@Test func advancedKnobsExposePlacement() throws {