fix(cab): rebuild board on lightweight recall of a topology selector

Review follow-up to the single-convolver cab change. Now that only the selected
cabinet voice's convolver is built, any path that changes the selector value
without rebuilding leaves audio on the stale convolver. The UI drag already
rebuilds; the gap was ShoeGaze.applyState (lightweight scene recall), which
applies param snapshots to live pedals without a rebuild.

- Pedal.rebuildSelectorValues: values of effectSelectors flagged rebuildsOnChange.
- applyState/applySegmentParams/applyBranchParams: detect when a rebuildsOnChange
  selector value actually changes during recall and rebuild only those boards;
  boards without such a selector keep the cheap live-apply path.
- CabinetVoice.voice(atSelectorValue:): guard non-finite and clamp in Double
  space so Int() can never trap on a corrupt preset value.
- Doc fixes: CabinetPedal.cabinet and AmpVoicePedal chain diagram no longer claim
  a live Select.

MIDI CC is unaffected: selectors are not in ccMappableControls (knobs + sliders
only). Tests: recall changing the cab voice rebuilds and applies; recall with an
unchanged voice does not rebuild.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-02 20:27:39 -07:00
parent 59370ee5dd
commit 3fe6b8a50a
6 changed files with 106 additions and 14 deletions
@@ -31,9 +31,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable {
/// - Returns: The corresponding voice, clamped to `allCases`.
public static func voice(atSelectorValue selectorValue: Double) -> CabinetVoice {
let all: [CabinetVoice] = allCases
let index: Int = Int(selectorValue.rounded())
let clamped: Int = Swift.min(Swift.max(index, 0), all.count - 1)
return all[clamped]
guard selectorValue.isFinite else { return all[0] }
// Clamp in Double space first so a huge/NaN-adjacent value can never trap `Int(_:)`.
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.