Replace stringly-typed pedal API with PedalType tokens

appendPedal(type: String, to:) is replaced by appendPedal(_ kind: PedalType, to:),
where PedalType is an extensible RawRepresentable struct with static members for
the built-in pedals:

    try shoeGaze.appendPedal(.overdrive, to: board)

Discoverable/autocompleting call sites, still open for custom pedals
(PedalType("My Pedal")). rawValue == the pedal's displayName, so PedalRegistry
and the rig JSON format are unchanged — saved rigs load exactly as before.

Named PedalType (not PedalKind) to avoid colliding with Lyrebird's score-notation
PedalKind enum, which is visible when both modules are imported. The UI palette
wraps its registry-key strings as PedalType(key); demos/tests use the static
members. PedalRegistry.makePedal(type:) stays string-keyed as the serialization
boundary used by loadRig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 20:34:45 -07:00
parent 24ce4564e8
commit 21b9123a87
11 changed files with 109 additions and 34 deletions
@@ -50,7 +50,7 @@ struct BoardEditAPITests {
try makeRig(pedals: ["Overdrive", "Delay"])
defer { try? FileManager.default.removeItem(at: url) }
let edited: PedalBoard = try sg.appendPedal(type: "Reverb", to: board)
let edited: PedalBoard = try sg.appendPedal(.reverb, to: board)
#expect(names(edited) == ["Overdrive", "Delay", "Reverb"])
#expect(sg.boards.count == 1, "append should not change board count")
@@ -64,7 +64,7 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
#expect(throws: ShoeGazeError.unknownPedalType("Nope")) {
try sg.appendPedal(type: "Nope", to: board)
try sg.appendPedal(PedalType("Nope"), to: board)
}
}
@@ -135,7 +135,7 @@ struct BoardEditAPITests {
try sg.finalizeBoard(board)
// Append a linear pedal; the stereo split region must survive untouched.
let edited: PedalBoard = try sg.appendPedal(type: "Fuzz", to: board)
let edited: PedalBoard = try sg.appendPedal(.fuzz, to: board)
#expect(names(edited).contains("Fuzz"), "appended linear pedal should be present")
let after: BoardState = edited.captureState()
@@ -215,8 +215,8 @@ struct BoardEditAPITests {
var live: PedalBoard = try sg.appendStereoSplit(to: board)
// The split region is the second top-level segment (after the Overdrive pedal).
let region: Int = 1
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: region))
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: region))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: region))
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: region))
guard let state: StereoSplitState = stereoState(live) else {
Issue.record("No stereo split segment after building one")
@@ -236,8 +236,8 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
var live: PedalBoard = try sg.appendStereoSplit(to: board)
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .left(region: 1))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
live = try sg.appendPedal(.fuzz, to: live, lane: .left(region: 1))
live = try sg.removePedal(at: 0, from: live, lane: .left(region: 1))
#expect(stereoState(live)?.left.map { $0.type } == ["Fuzz"], "left lane should drop Delay")
@@ -249,7 +249,7 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
// Octave Splitter is a widener → board becomes stereo; a second split is then invalid.
let live: PedalBoard = try sg.appendPedal(type: "Octave Splitter", to: board)
let live: PedalBoard = try sg.appendPedal(.octaveSplitter, to: board)
#expect(live.width == 2, "widener should make the board stereo")
#expect(throws: ShoeGazeError.cannotSplitStereoChain) {
try sg.appendStereoSplit(to: live)
@@ -262,7 +262,7 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
var live: PedalBoard = try sg.appendStereoSplit(to: board)
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
#expect(stereoState(live) != nil, "split region present before removal")
live = try sg.removeSegment(at: 1, from: live)
@@ -319,8 +319,8 @@ struct BoardEditAPITests {
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
#expect(sg.isStereoUnzip(afterSegment: 0, in: live), "toggle should report unzip present")
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .left(region: 1))
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: 1))
live = try sg.appendPedal(.fuzz, to: live, lane: .left(region: 1))
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
guard let state: StereoUnzipState = unzipState(live) else {
Issue.record("No stereo unzip segment")
@@ -375,8 +375,8 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: 1))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
if let section: StereoSplitSection = live.stereoUnzipSections.first {
section.route = .rightOnly
}
@@ -410,8 +410,8 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
var live: PedalBoard = try sg.appendParallelSplit(to: board)
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .right(region: 1))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
live = try sg.appendPedal(.fuzz, to: live, lane: .right(region: 1))
var foundParallel: Bool = false
for segment: BoardSegmentState in live.captureState().segments {
@@ -528,7 +528,7 @@ struct BoardEditAPITests {
defer { try? FileManager.default.removeItem(at: url) }
var live: PedalBoard = try sg.appendStereoSplit(to: board)
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
// Edit the branch pedal's first knob via the node path.
guard let stereo: StereoSplitSection = live.stereoSplitSections.first,
@@ -562,7 +562,7 @@ struct BoardEditAPITests {
try makeRig(pedals: ["Overdrive", "Delay"])
defer { try? FileManager.default.removeItem(at: url) }
try sg.appendPedal(type: "Reverb", to: board)
try sg.appendPedal(.reverb, to: board)
try sg.removePedal(at: 0, from: sg.boards[0]) // drop Overdrive → [Delay, Reverb]
let preset: URL = FileManager.default.temporaryDirectory