diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..769beb9 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,64 @@ +# ShoeGaze — Claude Context + +A virtual guitar-pedalboard framework built on Lyrebird. Two products: +`LyrebirdShoeGaze` (core pedal/board framework, no SwiftUI) and `LyrebirdShoeGazeUI` +(SwiftUI views). Depends on the published Lyrebird package. + +## Conventions + +- **MIT SPDX header** on every new `.swift` file (first 5 lines): file name, `// Lyrebird`, + blank comment, `// Copyright (c) 2026 Joshua Parmenter / realizedsound`, + `// SPDX-License-Identifier: MIT`, then a blank line. +- **Explicit type annotations** on `let`/`var` bindings, named constants for non-trivial + literals, doc comments on public init params — matches the Lyrebird house style. +- Pedals subclass `Pedal` (in `Sources/LyrebirdShoeGaze/Pedals/`), expose parameters as + `@UIParam`, and surface them via `effectKnobs` / `effectSwitches` / `effectSliders`. +- A pedal's `displayName` **is** its serialization key and its `PedalType.rawValue`, and the + `PedalRegistry.builtIn` key. Keep all three identical when adding a pedal. + +## Adding a new pedal — required checklist + +1. `Sources/LyrebirdShoeGaze/Pedals/Pedal.swift` — subclass `Pedal`, override `effect` + (or `wideEffect`/`stereoEffect`), `effectKnobs`/`effectSwitches`/`effectSliders`. +2. **`summary`** — override `open var summary: String` with a one-line, user-facing + description. **This is mandatory for every pedal** (see "Pedal info" below). +3. Register in `PedalRegistry.builtIn[""]`. +4. Add `PedalType. = PedalType("")`. +5. Enclosure color case in `PedalView.enclosureColor(for:)`. +6. Add to `PedalPaletteView.preferredOrder`. +7. Tests in `Tests/LyrebirdShoeGazeTests/PedalTests.swift` — at minimum: builds + + non-silent, each effect parameter measurably changes the output, knob-list assertion, + and (if it has switches/sliders) a preset round-trip. +8. Use `PedalType` static members at call sites (`appendPedal(.overdrive, to:)`), never raw + strings, except where a string is inherently dynamic (registry / preset load). + +## Pedal info (mandatory) + +Every pedal participates in the pedal-info UI: + +- **`summary`** (required): a short, non-proprietary, user-facing sentence describing what + the pedal does. The picker shows it as a subtitle; the pedal's ⓘ info panel shows it as + the description. A new pedal without a non-empty `summary` is incomplete — a test asserts + every registered pedal has one. +- The info panel lists the **effect controls only** (`effectKnobs` + `effectSliders` + + `effectSwitches`) with their ranges/options — never the common Mix / Level / bypass. Put + the meaningful range and a clear unit in each control's `label`/`range` so the info panel + reads well. + +## dB parameters + +There is no dB→linear generator for a control-rate node. To apply a dB gain to a signal, +convert in the graph: `Exp.Audio($gainDB * dbToLinExpScale)` where +`dbToLinExpScale = ln(10)/20 ≈ 0.11512925464970229` (gives `10^(dB/20)`). RBJ shelving/peaking +filters take gain in dB directly, so pass dB nodes straight through. + +## Build / test + +- Package: `swift build` / `swift test --no-parallel` (the multi-engine suite can hit + Lyrebird's parallel-teardown flake without `--no-parallel`). +- Apps: `Demo/ShoeGaze.xcworkspace` (macOS builder, iPad builder, demos). iOS targets are + iPad-only, landscape. + +## Planned work + +`docs/plans/` holds the next-version feature plans. diff --git a/docs/plans/1.1-chorus-pedal.md b/docs/plans/1.1-chorus-pedal.md new file mode 100644 index 0000000..38bb738 --- /dev/null +++ b/docs/plans/1.1-chorus-pedal.md @@ -0,0 +1,34 @@ +# 1.1 — Chorus pedal (true stereo) + +## Why distinct from Modulation +`ModulationPedal` already wraps Lyrebird's `Chorus.Audio` and **sums to mono** +(`SumChannels`). The new **Chorus** keeps the signal **stereo** (a `widener` pedal) and +exposes more control — a lusher, wider voice than the mono Modulation classic. Keep both. + +## Implementation +`Sources/LyrebirdShoeGaze/Pedals/ChorusPedal.swift` + +- `override var channelKind: PedalChannelKind { .widener }` +- Override `wideEffect(_ dry:) -> (left:right:)` (not `effect`): build one + `Chorus.Audio(input: dry, delayTime:, depth: $depth, rate: $rate, mix: 1.0, + sampleRate: sampleRate, maxDelayTime:)` and return its two channels as L/R + (do **not** `SumChannels`). +- Knobs (`effectKnobs`): `rate` 0.05–6 Hz (def ~0.8), `depth` 0.0005–0.01 s (def ~0.003). + Wet/dry via the base `mix` (`initialMix` ~0.5). +- Constants: `delayTime` ~0.025 s, `maxDelayTime` ~0.1 s (match Modulation). + +## Wiring +- `PedalRegistry.builtIn["Chorus"] = { ChorusPedal() }` +- `PedalType.chorus = PedalType("Chorus")` +- `PedalView` enclosure color case `"Chorus"` +- `PedalPaletteView.preferredOrder` — near Modulation / Phaser +- `summary` override (see info-UI plan) + +## Tests (`Tests/LyrebirdShoeGazeTests/ChorusPedalTests.swift`) +- builds + non-silent +- stereo: L channel ≠ R channel (the point of the pedal) +- rate and depth each change the output + +## Open question +Keep both Modulation (mono) and Chorus (stereo) — recommended. Alternative: rename +Modulation → "Vibrato". Not doing that here. diff --git a/docs/plans/1.1-pedal-info-ui.md b/docs/plans/1.1-pedal-info-ui.md new file mode 100644 index 0000000..b3a01e5 --- /dev/null +++ b/docs/plans/1.1-pedal-info-ui.md @@ -0,0 +1,40 @@ +# 1.1 — Pedal info UI (description + control ranges) + +Show a short description of each pedal in the picker, and an info button on the pedal that +opens a panel with the description and the **effect controls** (knobs / sliders / switches) +plus their value ranges — excluding the common Mix / Level / bypass controls. + +## Model (core, `LyrebirdShoeGaze`) +- Add to `Pedal`: `open var summary: String { "" }` — one-line description, overridden by + every pedal. Single source of truth. +- `PedalRegistry.summary(for displayName: String) -> String` for the palette: instantiates + `builtIn[name]?()` and reads `.summary`. No `engine.add`, so `build()` never runs — only a + cheap object alloc. Cache in the palette view. +- (Optional stretch) richer rows: add `detail: String?` and/or `unit: String?` to + `PedalKnob` / `PedalSlider` / `PedalSwitch`. Not required — `range` / `options` already + carry enough to show ranges. + +## Palette (`PedalPaletteView`) +- Row → `VStack(alignment: .leading)`: name (callout) + `summary` (caption2, secondary, + ~2 lines). Keep the `+` glyph and `.draggable`. + +## Pedal info affordance (`PedalView`) +- Small **ⓘ button** in the name-plate (top-right of the enclosure header). +- Tap → `.sheet` / `.popover` on its **own anchor node** (one presentation per node — same + pattern as the file pickers) presenting a new `PedalInfoView(pedal:)`. + +## `PedalInfoView` (`LyrebirdShoeGazeUI`) +- Title = `pedal.displayName`; body = `pedal.summary`. +- Controls list from `effectKnobs` + `effectSliders` + `effectSwitches` **only** (not + `knobs`, which includes Mix/Level; not bypass): + - knob / slider → `label` + range, e.g. `"200 – 8000"` (raw range; add `unit` later). + - switch → `label` + option titles. + +## Wiring +- Override `summary` on **all** pedals (short sentences). +- Going forward, every new pedal MUST set `summary` — see CLAUDE.md. + +## Tests +- every entry in `PedalRegistry.builtIn` produces a pedal with non-empty `summary`. +- `PedalInfoView` (or a helper that builds its rows) lists exactly the effect controls, + not the common three. diff --git a/docs/plans/1.1-ring-modulator-pedal.md b/docs/plans/1.1-ring-modulator-pedal.md new file mode 100644 index 0000000..5199804 --- /dev/null +++ b/docs/plans/1.1-ring-modulator-pedal.md @@ -0,0 +1,31 @@ +# 1.1 — Ring Modulator pedal + +Multiplies the signal by a tunable carrier → metallic / bell / robot sidebands (sum & +difference of input and carrier). Classic ring mod = `dry × carrier` — no dedicated +Lyrebird generator needed. (`Ring1–4` are SC math variants; `FrequencyShifter` is SSB, +a possible stretch mode.) + +## Implementation +`Sources/LyrebirdShoeGaze/Pedals/RingModulatorPedal.swift` + +- `effect`: `let carrier = OscSin.Audio(freq: $frequency); return dry * carrier` +- Knobs: + - **`frequency`** carrier in Hz. Range ~**20–2000** (def ~220). <~30 Hz ≈ tremolo/AM; + audio range = classic ring mod. + - wet/dry via inherited **`mix`** (`initialMix` ~0.5 — harsh, keep dry present). +- **Optional waveform switch** (`PedalSwitch`): Sine / Square carrier (square = more + sidebands, harsher) — square via `LFSquare`/`OscSquare`. If added, preset round-trip test. +- **Stretch — Mode switch (Ring / Shift):** add an SSB pitch mode wrapping Lyrebird's + `FrequencyShifter`. Base pass = Ring only; Shift is a follow-up. + +## Wiring +- `PedalRegistry.builtIn["Ring Modulator"] = { RingModulatorPedal() }` +- `PedalType.ringModulator = PedalType("Ring Modulator")` +- enclosure color, palette order (group with Phaser / Mutant "filter / weird" section) +- `summary` override, e.g. *"Multiplies your signal by a tunable carrier for metallic, + bell-like, and robotic tones."* + +## Tests (`Tests/LyrebirdShoeGazeTests/RingModulatorPedalTests.swift`) +- builds + non-silent +- frequency change alters output (e.g. 100 Hz vs 800 Hz windows differ) +- (if switch added) square vs sine differ; preset round-trip of the switch diff --git a/docs/plans/1.1-sustainer-pedal.md b/docs/plans/1.1-sustainer-pedal.md new file mode 100644 index 0000000..ae96441 --- /dev/null +++ b/docs/plans/1.1-sustainer-pedal.md @@ -0,0 +1,33 @@ +# 1.1 — Sustainer pedal + +A one-knob sustain: heavy compression + makeup gain to hold notes, distinct from the +`Compressor` pedal (which exposes threshold/ratio directly). + +## Implementation +`Sources/LyrebirdShoeGaze/Pedals/SustainerPedal.swift` + +- `effect`: `Compressor.Audio(in: dry, threshold:, ratio:, attack: ~0.005, + release: ~0.4, kneeWidth: 0, makeupGain:)`. +- **`sustain` knob (0–10, def ~5)** — the single perceptual control. Maps internally: + - threshold: `-6 dB → -36 dB` as sustain rises + - ratio: `2 → 10` + - makeupGain: tracks the added gain reduction (so output stays even) + Implement the map with `LinLin` on the `$sustain` node (or fold into Compressor's + `ValidGeneratorInput` params via arithmetic on `$sustain`). +- **`tone` knob (optional)** — `RBJLowPass.Audio(input:, freq: $tone, q: 0.707)` to round the squashed top end. Range ~800–8000 Hz. +- `level` (inherited) for output trim. `initialMix` = 1.0 (in-line). +- **Stretch — floor/gate:** reuse the NoiseGate idea (`AmplitudeFollower` → `Schmidt` → + `LinLin` floor → `Lag` → ×) so infinite sustain doesn't surface hiss. Optional knob + `floor`, or a fixed gentle gate. Defer if it complicates the one-knob feel. + +## Wiring +- `PedalRegistry.builtIn["Sustainer"] = { SustainerPedal() }` +- `PedalType.sustainer = PedalType("Sustainer")` +- enclosure color, palette order (near Compressor / Limiter) +- `summary` override + +## Tests (`Tests/LyrebirdShoeGazeTests/SustainerPedalTests.swift`) +- builds + non-silent +- sustain knob changes dynamics: low vs high sustain → measurable RMS/level difference on + a decaying input window +- knob list assertion