From 9c0122f1993c2d3e55cbb6dbe9c200975776d95d Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Mon, 3 Aug 2026 21:26:35 -0700 Subject: [PATCH] docs(preset): reattach applyState doc above its declaration The legacy-migration fix spliced private declarations between applyState's doc comment and the method, so the doc silently reattached to the private modernHighGainType constant. Move it back above applyState (and note the legacyMigrated normalization + advanced-knob restore). Caught in re-review. Co-Authored-By: Claude Opus 4.8 --- .../Presets/Pedal+Preset.swift | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift b/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift index 29a358d..b1d89f2 100644 --- a/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift +++ b/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift @@ -35,19 +35,6 @@ extension Pedal { ) } - /// Applies a previously captured `PedalState` to this pedal's parameters. - /// - /// For each (knob, value) pair in `zip(knobs, state.knobValues)`, the knob's - /// `UIParamNode` is updated via `node.update(_:)`; switch positions are restored the - /// same way from `zip(effectSwitches, state.switchValues)`. If either array has fewer - /// entries than its controls, the trailing controls retain their current values; extra - /// values are ignored. The `bypass` parameter is always applied regardless of any - /// count mismatch. Presets saved before switches existed carry an empty - /// `switchValues`, leaving switch positions at their defaults. - /// - /// - Parameter state: The state to restore. The `state.type` is not validated - /// against `displayName` — the caller is responsible for matching types before - /// calling this method. /// Modern High-Gain's display name — the one shipped amp whose `Sag` control started life as a /// face knob and later moved to the advanced pop-over. Used to detect its legacy `PedalState` /// layout in ``legacyMigrated(_:)``. @@ -95,6 +82,18 @@ extension Pedal { ) } + /// Applies a previously captured `PedalState` to this pedal's parameters. + /// + /// The incoming state is first normalized by ``legacyMigrated(_:)`` for older on-disk layouts. + /// For each (knob, value) pair in `zip(knobs, state.knobValues)`, the knob's `UIParamNode` is + /// updated via `node.update(_:)`; switch, slider, selector, and advanced-knob positions are + /// restored the same way. If either array has fewer entries than its controls, the trailing + /// controls retain their current values; extra values are ignored. The `bypass` parameter is + /// always applied regardless of any count mismatch. Presets saved before a given control existed + /// carry an empty array for it, leaving those controls at their defaults. + /// + /// - Parameter rawState: The state to restore. The `state.type` is not validated against + /// `displayName` — the caller is responsible for matching types before calling this method. public func applyState(_ rawState: PedalState) { let state: PedalState = Pedal.legacyMigrated(rawState) // Restore the saved identity so the pedal keeps its id across rebuilds; MIDI bindings