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:
@@ -350,7 +350,10 @@ open class AmpVoicePedal: Pedal {
|
||||
/// > low-pass) — expected; a cabinet is what tames the top end.
|
||||
var isCabinetBypassed: Bool {
|
||||
guard cab.isFinite else { return false }
|
||||
return Int(cab.rounded()) >= CabinetVoice.allCases.count
|
||||
// Clamp in Double space before converting: a huge finite `cab` (from a corrupted/hand-edited
|
||||
// rig) would otherwise trap `Int(_:)` — same defense as `CabinetVoice.voice(atSelectorValue:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(cab, 0.0), Double(CabinetVoice.allCases.count))
|
||||
return Int(bounded.rounded()) >= CabinetVoice.allCases.count
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: cabinet convolver (or a straight pass at the "None"
|
||||
|
||||
Reference in New Issue
Block a user