fix(cab): NaN-safe selector compare; correct applyState doc contract

Re-review follow-ups:
- rebuildSelectorValues sanitizes non-finite node values to a sentinel so the
  before/after recall compare (uses !=) can't be forced true by NaN != NaN,
  which would trigger a needless rebuild on every recall.
- ShoeGaze.applyState doc no longer claims "without rebuilding the engine graph":
  it now documents that a board is rebuilt (with the one-block-glitch caveat)
  when a rebuildsOnChange selector value differs from the live rig.

Iteration-during-mutation in applyState confirmed safe: zip over the stored
[PedalBoard] array snapshots it (COW), and PedalBoard is a final class, so
rebuildBoard mutating self.boards mid-loop does not disturb the iteration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-02 20:36:21 -07:00
parent 3fe6b8a50a
commit e1ed4e348c
2 changed files with 13 additions and 3 deletions
+5 -1
View File
@@ -242,7 +242,11 @@ open class Pedal: SynthesizerBase {
/// this before/after applying a snapshot to decide whether the board must be rebuilt (a plain
/// node write does not re-enter `effect(_:)`). Empty for pedals with no such selectors.
public var rebuildSelectorValues: [Double] {
effectSelectors.filter { $0.rebuildsOnChange }.map { $0.node.value }
// Sanitize non-finite to a fixed sentinel: the before/after compare in a recall uses `!=`,
// and `NaN != NaN` would force a spurious rebuild on every recall.
effectSelectors
.filter { $0.rebuildsOnChange }
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
}
/// Effect-specific transport controls, rendered as a row directly below the knobs — above