fix(amp): preserve legacy rigs across the Sag/Bias rename + move
Addresses two blocking findings from the external review, both legacy preset-compat (no RT/protocol issues were found): - Rename compat: "Fullerton Princeton" → display "Fullerton Ivy League" would silently drop the pedal from any rig saved under the old name (displayName is the serialization key). Add PedalRegistry.legacyTypeAliases resolved in makePedal (self-healing: loads, then re-saves under the new name). Regression test asserts the old name still resolves. - Knob-shift compat: moving Modern High-Gain's Sag off the face shrank its effectKnobs by one, so an old 11-value knobValues array would misassign Sag→Mix and Mix→Level on load. Add a targeted PedalState migration (Pedal.legacyMigrated) that lifts Sag into advancedValues and keeps Mix/Level in place. Regression test decodes a hand-built legacy preset and asserts correct placement. Also: drop the not-yet-built "Bias X" from a doc comment; de-brand "Vox" from the Chime variants test names (ToneStackModel .vox enum refs kept). 643 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("Chime Vox variants")
|
||||
@Suite("Chime variants")
|
||||
struct ChimeVariantsTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
@@ -71,7 +71,7 @@ struct ChimeVariantsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func inheritCutSurfaceAndVoxStack() throws {
|
||||
@Test func inheritCutSurfaceAndChimeStack() throws {
|
||||
for v: (name: String, make: () -> ChimeAmpPedal) in variants {
|
||||
let pedal: ChimeAmpPedal = v.make()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Cut"], "\(v.name) knobs")
|
||||
|
||||
@@ -124,4 +124,11 @@ struct FullertonVariantsTests {
|
||||
#expect(PedalRegistry.makePedal(type: "Fullerton Deluxe") is FullertonDeluxeAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Fullerton Ivy League") is FullertonPrincetonAmpPedal)
|
||||
}
|
||||
|
||||
@Test func legacyPrincetonNameStillResolves() throws {
|
||||
// The pedal's display name was "Fullerton Princeton" when first shipped; rigs saved then key
|
||||
// on that string. The legacy alias must still reconstruct the (renamed) pedal so it isn't
|
||||
// silently dropped on load.
|
||||
#expect(PedalRegistry.makePedal(type: "Fullerton Princeton") is FullertonPrincetonAmpPedal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,4 +121,26 @@ struct ModernHighGainAmpPedalTests {
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Modern High-Gain") is ModernHighGainAmpPedal)
|
||||
}
|
||||
|
||||
@Test func legacyPresetWithSagOnFaceMigratesWithoutShiftingMixLevel() throws {
|
||||
// A rig saved when Sag was the 9th face knob has 11 knobValues (Gain…Drive, Sag, Mix, Level)
|
||||
// and no advancedValues. Sag has since moved to the advanced pop-over, so the current shape
|
||||
// has 10 knobValues (Gain…Drive, Mix, Level) + 2 advancedValues (Sag, Bias). Loading the
|
||||
// legacy preset must lift Sag into advancedValues and keep Mix/Level in place — never shift
|
||||
// the old Sag onto Mix or the old Mix onto Level.
|
||||
let legacy: PedalState = PedalState(
|
||||
id: UUID(),
|
||||
type: "Modern High-Gain",
|
||||
knobValues: [10.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 15.0, 0.7, 0.8, 0.9],
|
||||
bypass: 0.0
|
||||
)
|
||||
let pedal: ModernHighGainAmpPedal = ModernHighGainAmpPedal()
|
||||
pedal.applyState(legacy)
|
||||
let restored: PedalState = pedal.captureState()
|
||||
// Gain…Drive, then Mix (0.8), Level (0.9) — the old Sag (0.7) is gone from knobValues.
|
||||
#expect(restored.knobValues == [10.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 15.0, 0.8, 0.9],
|
||||
"legacy Sag shifted Mix/Level: \(restored.knobValues)")
|
||||
// Sag lifted into advanced slot 0; Bias had no legacy value → default 0.5.
|
||||
#expect(restored.advancedValues == [0.7, 0.5], "Sag/Bias advanced values wrong: \(restored.advancedValues)")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user