fix(amps): recall rebuilds on a rebuildsOnChange switch (channel)

Review blocker: lightweight recall (ShoeGaze.applyState) detected topology change
only via Pedal.rebuildSelectorValues (effectSelectors), so a channel switch —
the first rebuildsOnChange *switch* — flipped during a scene recall wrote the
node value but never rebuilt, leaving the stale channel topology (wrong preamp).

- Rename/extend to Pedal.rebuildTopologyValues: folds in effectSwitches flagged
  rebuildsOnChange alongside the selectors (both NaN-sanitized). Recall call sites
  in ShoeGaze+Preset updated.
- FullertonDrive: rename channel constants to generic switchOff/On (used by the
  Bright switch too).
- Test: applyStateRebuildsBoardWhenChannelSwitchChanges — recall flipping the
  channel rebuilds the board and applies the recalled channel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-03 13:10:23 -07:00
parent da4d5e23ea
commit e88db04686
4 changed files with 51 additions and 16 deletions
+11 -6
View File
@@ -237,16 +237,21 @@ open class Pedal: SynthesizerBase {
[]
}
/// Current values of every ``effectSelectors`` entry flagged `rebuildsOnChange` — the selectors
/// whose choice changes the graph topology (e.g. a cabinet voice). A lightweight recall compares
/// 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] {
/// Current values of every ``effectSelectors`` and ``effectSwitches`` entry flagged
/// `rebuildsOnChange` — the controls whose choice changes the graph topology (e.g. a cabinet
/// voice or a clean/drive channel). A lightweight recall compares 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 controls.
public var rebuildTopologyValues: [Double] {
// 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
let selectorValues: [Double] = effectSelectors
.filter { $0.rebuildsOnChange }
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
let switchValues: [Double] = effectSwitches
.filter { $0.rebuildsOnChange }
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
return selectorValues + switchValues
}
/// Effect-specific transport controls, rendered as a row directly below the knobs — above