2aea609f34
Replace the code-built Garcia with the user's hand-authored version, transcribed verbatim as a ShoeGazeState: Board 1 (Bass Octaver, Mutant, Overdrive, Graphic EQ, Phaser, Delay, Fullerton Reverb) and Board 2 (Overdrive, Graphic EQ, Compressor, Fullerton Reverb), preserving exact mix, graphic-EQ slider, cab-selector and amp sag/bias values. Input source and channel counts are omitted so the rig stays input-agnostic. Adds a FactoryRigBuild.state case (and matching FactoryRig init) for rigs shipped as a pre-captured state rather than a live builder, and bumps seedVersion to 3 so existing libraries refresh Garcia to the new version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
126 lines
5.3 KiB
Swift
126 lines
5.3 KiB
Swift
// 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
|
|
|
|
/// How this rig builds its graph at seed time.
|
|
public let build: FactoryRigBuild
|
|
|
|
/// Creates a single-board factory rig.
|
|
///
|
|
/// The `build` closure receives a fresh, empty ``PedalBoard`` (already returned by
|
|
/// `session.addBoard()`) and appends pedals to it. Do **not** call `finalizeBoard` /
|
|
/// `captureEntry` here — the seeding driver owns that lifecycle.
|
|
///
|
|
/// - 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 = .singleBoard(build)
|
|
}
|
|
|
|
/// Creates a session-scoped factory rig that builds its own boards and/or routers.
|
|
///
|
|
/// Use this for rigs the single-board form can't express — e.g. a two-board signal split via
|
|
/// ``ShoeGaze/makeChainRouter()``. The `sessionBuild` closure gets the whole session and owns the
|
|
/// full lifecycle for what it creates: it must call `addBoard`/`finalizeBoard` (for plain boards)
|
|
/// and/or `makeChainRouter`/`addToA`/`addToB`/`finalize` (for routers) itself. Do **not** call
|
|
/// `captureEntry` here — the seeding driver owns that.
|
|
///
|
|
/// - 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.
|
|
/// - sessionBuild: Graph-building closure run against the session at seed time.
|
|
public init(
|
|
id: UUID,
|
|
name: String,
|
|
blurb: String,
|
|
category: FactoryRigCategory,
|
|
sessionBuild: @escaping @MainActor (_ session: ShoeGaze) throws -> Void
|
|
) {
|
|
self.id = id
|
|
self.name = name
|
|
self.blurb = blurb
|
|
self.category = category
|
|
self.build = .session(sessionBuild)
|
|
}
|
|
|
|
/// Creates a factory rig from a pre-captured ``ShoeGazeState``.
|
|
///
|
|
/// The rig's content is the supplied state verbatim — used for a complex, hand-authored rig
|
|
/// captured from the app. Seeding builds the entry directly from `state` (no live session).
|
|
///
|
|
/// - 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.
|
|
/// - state: The captured rig content to ship.
|
|
@MainActor
|
|
public init(
|
|
id: UUID,
|
|
name: String,
|
|
blurb: String,
|
|
category: FactoryRigCategory,
|
|
state: ShoeGazeState
|
|
) {
|
|
self.id = id
|
|
self.name = name
|
|
self.blurb = blurb
|
|
self.category = category
|
|
self.build = .state({ state })
|
|
}
|
|
}
|