fix(amp): clamp cab selector before Int() in isCabinetBypassed
External-review blocker: a huge finite cab value (from a corrupted or hand-edited rig JSON, restored unclamped via PedalState.selectorValues) would trap Int(cab.rounded()) at board-build time. Clamp in Double space first, mirroring CabinetVoice.voice(atSelectorValue:). Regression test renders infinity / ±1e20 / NaN / out-of-range cab values without trapping. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -285,6 +285,16 @@ struct AmpVoicePedalTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func extremeCabValuesDoNotTrap() throws {
|
||||
// A corrupted/hand-edited rig can restore any Double into `cab`. Neither the bypass check nor
|
||||
// the voice lookup may trap `Int(_:)` — every value must resolve to a defined, finite render.
|
||||
let extremes: [Double] = [.infinity, -.infinity, 1.0e20, -1.0e20, .nan, 999.0]
|
||||
for cabValue: Double in extremes {
|
||||
let out: [Float] = try render({ CaliforniaAmpPedal() }) { $0.cab = cabValue }
|
||||
#expect(out.allSatisfy { $0.isFinite }, "cab=\(cabValue) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabSelectorExposesNoneStop() throws {
|
||||
let stops: [PedalSelectorKnob.Stop] = CaliforniaAmpPedal().effectSelectors
|
||||
.first { $0.label == "Cab" }?.stops ?? []
|
||||
|
||||
Reference in New Issue
Block a user