// FactoryRig.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import Foundation /// A single built-in starter rig: a named, described pedal chain shipped with the app and seeded /// into a fresh rig library on first launch. /// /// A `FactoryRig` is a *builder*, not a stored snapshot. Its ``build`` closure constructs the chain /// against a live ``ShoeGaze`` session using the concrete pedal editing API, so the recipe is /// type-checked against the real pedal parameters at compile time — a renamed pedal control breaks /// the build (a compile error) rather than silently corrupting a hand-written JSON preset. The /// builder is run once at seed time (see ``FactoryRigLibrary/makeEntries(makeSession:)``), captured /// to a ``RigEntry`` via ``ShoeGaze/captureEntry(name:id:)``, and thereafter behaves exactly like a /// user-saved rig. /// /// The rig names and blurbs are deliberately descriptive of the *sound*, not any trademarked pedal, /// amplifier, or artist; a blurb may nod at the era or style a tone evokes, but a factory rig is /// never presented as a named product or a specific performer's endorsed setup. public struct FactoryRig: Identifiable, Sendable { /// Stable identifier for this rig. /// /// Fixed per rig (a literal, not freshly generated) so re-seeding an already-populated library /// overwrites the same entry in place rather than creating a duplicate — `RigLibraryStore.save` /// keys on the entry `id`. public let id: UUID /// Human-readable rig name shown in the picker and used as the saved ``RigEntry`` name. public let name: String /// One- or two-sentence, user-facing description of the sound and how to play it. Shown as the /// picker subtitle / info blurb. Descriptive of the tone only — never a trademarked product or /// an artist endorsement. public let blurb: String /// Sonic family this rig belongs to, for grouping in a picker. Presentational only. public let category: FactoryRigCategory /// Builds the rig's pedal chain into `board`, an empty board freshly returned by /// `session.addBoard()`. Set pedal parameters via the typed `configure` closures of /// ``FactoryRigLibrary``'s helpers. Do **not** call `finalizeBoard` / `captureEntry` here — the /// seeding driver owns that lifecycle. public let build: @MainActor (_ session: ShoeGaze, _ board: PedalBoard) throws -> Void /// Creates a factory rig descriptor. /// /// - Parameters: /// - id: Stable identifier (a fixed literal per rig — see ``id``). /// - name: Rig name (picker title + saved entry name). /// - blurb: User-facing description of the sound. /// - category: Sonic family for picker grouping. /// - build: Chain-building closure run against a fresh, empty board at seed time. public init( id: UUID, name: String, blurb: String, category: FactoryRigCategory, build: @escaping @MainActor (_ session: ShoeGaze, _ board: PedalBoard) throws -> Void ) { self.id = id self.name = name self.blurb = blurb self.category = category self.build = build } }