Compare commits
103 Commits
09fa4e8d4b
...
v3.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| f8926ecfb8 | |||
| 9873dd258b | |||
| fc6ddb8d9a | |||
| 812a240e55 | |||
| 93ca9076d2 | |||
| 4a9bf0fb30 | |||
| 850b86209a | |||
| 2aea609f34 | |||
| 44e6c35550 | |||
| 5decdd8693 | |||
| 132515b4cd | |||
| 392ae1525a | |||
| ad6ed41674 | |||
| fba32ff0aa | |||
| 2c970aa344 | |||
| 7dccf596f4 | |||
| 75b99a547b | |||
| 965633de34 | |||
| 779c55493d | |||
| bb418ca2e8 | |||
| 4eb1cbdd61 | |||
| 2fd7eaee57 | |||
| 654e80e9c8 | |||
| 292261a088 | |||
| a1ce308082 | |||
| 685bf5833e | |||
| 5a3cbeb372 | |||
| 11ce3f47d2 | |||
| da68864f36 | |||
| ebc660898d | |||
| f9ddd6b160 | |||
| da2c3328ee | |||
| 9b23f99a58 | |||
| d7eb0690ff | |||
| 35ae16040a | |||
| f67a5370ff | |||
| 96ab2a0586 | |||
| 99649c2d89 | |||
| 7f1856e8e5 | |||
| a2fcd59e1b | |||
| 594c501039 | |||
| e8b858f1aa | |||
| 9daffbbdf3 | |||
| 9c0122f199 | |||
| 781577b062 | |||
| 1de14fd879 | |||
| 6cf698dbac | |||
| 0f6d69819d | |||
| 3cdb8d9ddb | |||
| b4a04f6dc8 | |||
| f7787c4ba3 | |||
| 8a8cac3823 | |||
| d32caf6262 | |||
| ac61b47d17 | |||
| 88ad976b8e | |||
| 95839a9e35 | |||
| 573a91f377 | |||
| 31fa1b9cd3 | |||
| 9c0f89bae6 | |||
| 651706126c | |||
| cda596b9d5 | |||
| a7534a29db | |||
| e88db04686 | |||
| da4d5e23ea | |||
| 8cd77ad984 | |||
| 818478ce1b | |||
| 415e99dd62 | |||
| 71d9b44809 | |||
| 4de8379cb8 | |||
| 690030a4c5 | |||
| 8a08264fb4 | |||
| e5deb8f94a | |||
| 9abc613fc3 | |||
| 48dce06f5a | |||
| b9a63eeaf5 | |||
| 9588d77137 | |||
| 5d8e655dab | |||
| 17a0845225 | |||
| 29b1747533 | |||
| 102715ded1 | |||
| 27fb6e6898 | |||
| a9e91ef08c | |||
| c9795f7305 | |||
| 6718914ee0 | |||
| 544a07d569 | |||
| fb50538e84 | |||
| e1ed4e348c | |||
| 3fe6b8a50a | |||
| 59370ee5dd | |||
| 8a266a33dc | |||
| ec4e7dc5a4 | |||
| 733e979c1b | |||
| 1b247cf766 | |||
| 23d607b9fc | |||
| 40fa590196 | |||
| fe31eb6d7d | |||
| 77df1675cb | |||
| 4a5d4009f6 | |||
| 791fbd1b2c | |||
| 323988af7b | |||
| ed3283f645 | |||
| 8983e8829e | |||
| e697789bd7 |
@@ -20,3 +20,6 @@ DerivedData/
|
||||
# Note: Package.resolved is intentionally tracked to pin the Lyrebird dependency.
|
||||
icon-source.png
|
||||
review.diff
|
||||
|
||||
# Local working plan (not shared)
|
||||
docs/plans/amp-expansion-plan.md
|
||||
|
||||
+126
@@ -4,6 +4,132 @@ All notable changes to ShoeGaze are recorded here. The format follows
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
||||
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.1.1] — 2026-08-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Mutant switch captions no longer wrap.** The envelope filter's three segmented switches
|
||||
(Direction / Mode / Range — seven segments in all) were crammed into a single-width pedal,
|
||||
wrapping the "Down" caption to "Do wn". Mutant is now double-width, like the Cabinet and amp
|
||||
pedals, so the switch captions have room.
|
||||
|
||||
## [3.1.0] — 2026-08-13
|
||||
|
||||
Starter rigs and a deeper envelope filter. ShoeGaze now ships a library of ready-to-play
|
||||
rigs grouped by style, two new pedals, and a much more expressive Mutant envelope filter —
|
||||
plus a batch of rig-switching and reverb fixes.
|
||||
|
||||
### Added
|
||||
|
||||
- **18 built-in starter rigs**, seeded into the library on first launch and grouped by
|
||||
style — **Shoegaze Walls**, **Dreampop**, **Classic**, **Ambient**, and **Experimental**.
|
||||
A **Mine / Starters** toggle at the top of the rig sidebar switches between your own rigs
|
||||
and the shipped ones (grouped under category headers); the sidebar opens on whichever
|
||||
group holds the current rig. A **Restore Starter Rigs** action (rig-library menu, or the
|
||||
Starters empty state) reinstalls the shipped rigs at any time.
|
||||
- **Two-board starter rig** — a Garcia-style clean/effects split across two boards, switched
|
||||
with the board Solo / Blend control, showing off multi-board rigs.
|
||||
- **Vibe pedal** — a photocell "vibe": four staggered all-pass stages swept by one LFO, with
|
||||
**Chorus** and **Vibrato** modes and Speed / Intensity controls.
|
||||
- **Sustain Fuzz pedal** — a mid-scooped, high-sustain fuzz (two cascaded soft-clip stages),
|
||||
distinct from the brighter single-stage Fuzz. Sustain / Tone / Scoop controls.
|
||||
- **Mutant (envelope filter) controls** — a **Range** switch (Lo / Hi) that shifts the whole
|
||||
sweep band, matching the original Mu-Tron III, plus **Sweep**, **Attack**, and **Release**
|
||||
in the advanced pop-over. Sweep sets how far your picking drives the cutoff; Attack /
|
||||
Release shape how quickly the filter follows.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Switching rigs keeps your current input.** Loading a rig from the library no longer snaps
|
||||
the input back to the test loop (or the input a rig was saved with) — your live guitar (or
|
||||
whatever input you have selected) carries across the switch. Opening or restoring a rig
|
||||
file still applies its saved input.
|
||||
- **Shimmer Reverb backed off.** The regenerating loop gain is roughly `decay + shimmer`, so
|
||||
the old defaults (0.8 + 0.5) self-oscillated into a screech with little or no input.
|
||||
Defaults are now decay 0.5 / shimmer 0.25 / damp 0.5, and the starter rigs that use it were
|
||||
re-tuned to stay well below self-oscillation.
|
||||
- **Mutant sweep defaults tamed** — resting cutoff 80 → 120 Hz and sweep span 40× → 20×, so
|
||||
the filter is neither muted at rest nor extreme when it opens.
|
||||
- **Starter rigs refresh on update.** Shipped rigs install (and refresh to their current
|
||||
form) by catalog version, so a corrected starter reaches libraries that were seeded
|
||||
earlier — without touching your own rigs.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **No more spurious "Save changes?" prompt when switching rigs.** The unsaved-changes check
|
||||
compared live session settings (input source, engine channel counts) that legitimately
|
||||
differ from a rig's saved values; it now compares rig content only.
|
||||
- **Overwrite guard for starter rigs.** Saving over a loaded starter rig now asks first,
|
||||
offering **Overwrite**, **Save as New Rig**, or **Cancel**, so a shipped rig isn't replaced
|
||||
by accident.
|
||||
- **Multi-board signal-router rigs now save and load.** Routed A/B rigs were previously lost
|
||||
on save; their branch chains and blend now persist.
|
||||
|
||||
## [3.0.0] — 2026-08-04
|
||||
|
||||
The big one: ShoeGaze becomes an amp-modeling rig. This release adds a full lineup of
|
||||
tube-amp voices — each with its own tone stack, onboard effects, and control surface —
|
||||
plus a deep speaker-cabinet and microphone section. Everything is original DSP built in
|
||||
code from the Lyrebird engine; there are no third-party captures or IR packs.
|
||||
|
||||
### Added
|
||||
|
||||
- **26 amp-model pedals**, grouped in their own **Amp Model** palette category:
|
||||
- **Fullerton** blackface combos — Fullerton Reverb, Deluxe, Ivy League, Drive — with
|
||||
spring reverb, tremolo, and a Bright switch.
|
||||
- **California** and **Jazz Clean** clean machines.
|
||||
- **British** stack and combo voices — British, Plexi, JTM, Bluesbreaker, Master, Dual —
|
||||
from early crunch to hot-rodded master-volume lead.
|
||||
- **Chime** top-boost family — Chime, Chime 15, Chime Normal, Chime Baby, Chime Top
|
||||
Boost — with the classic Cut control.
|
||||
- **Boutique and high-gain** — Boutique Lead, Boutique OD, Cali Hi-Gain (with an onboard
|
||||
5-band graphic EQ), and Modern High-Gain (Sag + Tight).
|
||||
- **Character amps** — Command, Citrus, Sixties Combo, Magna Vibrato (true pitch
|
||||
vibrato), and Anaheim (a solid-state-preamp / tube-power-amp hybrid with a built-in
|
||||
limiter).
|
||||
|
||||
Each amp carries its own tone-stack voicing, a selectable speaker cabinet, and a real
|
||||
**master volume** that drives the power-amp stage — not just an output trim.
|
||||
- **Analog-style output limiting.** Every amp ends in a soft `tanh` saturation into a hard
|
||||
±1 ceiling, so a driven amp compresses like the real thing instead of digitally clipping.
|
||||
- **Power-amp feel controls**, tucked behind an advanced pop-over (the sliders button at the
|
||||
top-right of the amp card): **Sag** (power-supply droop and bloom), **Bias**, and **Bias X**
|
||||
(bias balance).
|
||||
- **A full speaker-cabinet and microphone section** on the Cabinet pedal, now in its own
|
||||
**Cabinet** palette category next to the amps:
|
||||
- **Cabinet voices** — eight synthesized speaker voicings.
|
||||
- **Microphone modeling** — No Mic / Dynamic / Ribbon / Condenser, folded into the cab
|
||||
response.
|
||||
- **Mic placement** — Position (on-axis ↔ cone edge) and Proximity (distance / bass lift).
|
||||
- **Dual-mic blend** — add a second mic with its own blend and spacing (comb) control,
|
||||
the classic two-mic technique.
|
||||
- A transparent look-ahead limiter on the cabinet output.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Gain and Drive now read 1–11** — yes, they go to eleven — with a musical taper: fine
|
||||
control at the bottom of the dial, full saturation at the top, instead of a raw internal
|
||||
number.
|
||||
- **The cabinet is now a separate pedal you place in the chain.** Amps keep a built-in cab,
|
||||
plus a **None (direct)** option so you can run a dedicated Cabinet block (and, later, your
|
||||
own impulse response) after the amp.
|
||||
- **Palette:** the Amp Model and Cabinet categories sit together, and the Cabinet card is
|
||||
double-width to fit its cab / mic / second-mic selectors.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Noise Gate no longer pops as a note decays.** The gate now opens fast and closes gently
|
||||
(a slow, tunable fade) instead of snapping shut when a sustained note falls through the
|
||||
threshold — previously that abrupt step, amplified by downstream gain (e.g. a fuzz), was
|
||||
audible as a pop / sudden tone change. New **Attack** and **Release** timing knobs (in the
|
||||
gate's advanced pop-over) dial the close from tight to a gradual swell.
|
||||
|
||||
### Notes
|
||||
|
||||
- All amp, cabinet, and microphone models are original DSP generated in code — not captures
|
||||
of any specific hardware, speaker, microphone, or IR pack. Tube tone stacks follow the
|
||||
published Yeh & Smith analysis of the classic passive tone-stack circuit.
|
||||
|
||||
## [2.1.3] — 2026-07-13
|
||||
|
||||
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output —
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 12;
|
||||
CURRENT_PROJECT_VERSION = "21``";
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@@ -175,7 +175,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 2.1.4;
|
||||
MARKETING_VERSION = 3.1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -193,7 +193,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 12;
|
||||
CURRENT_PROJECT_VERSION = "21``";
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||
@@ -204,7 +204,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 2.1.4;
|
||||
MARKETING_VERSION = 3.1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
CURRENT_PROJECT_VERSION = 8;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
@@ -175,7 +175,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 3.1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
@@ -194,7 +194,7 @@
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
CURRENT_PROJECT_VERSION = 8;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
@@ -203,7 +203,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 3.1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
||||
"version" : "1.2.3"
|
||||
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
|
||||
"version" : "1.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"originHash" : "2a63dcbef74c280c7062a8342821f694fd71a59d391c302b86b3b86b00481260",
|
||||
"originHash" : "eed06b1870eecb6b28d2417331f105ea1cc25e9d6fe588c9d2eff8ca3af096f0",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "63d6e0746fdedce626c9eff832e799bad949708e",
|
||||
"version" : "1.2.4"
|
||||
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
|
||||
"version" : "1.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ let package = Package(
|
||||
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.6.3"),
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.7.2"),
|
||||
],
|
||||
targets: [
|
||||
// The core target depends on LyrebirdUI as well as the synthesis core:
|
||||
|
||||
@@ -11,8 +11,13 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
|
||||
## Features
|
||||
|
||||
- **35 modeled pedals** across gain, dynamics, EQ/filter, modulation, pitch, delay, reverb, and
|
||||
texture — see the catalog below.
|
||||
- **67 modeled pedals** — effects across gain, dynamics, EQ/filter, modulation, pitch, delay,
|
||||
reverb, and texture, plus **26 tube-amp models** with their own tone stacks and a deep
|
||||
speaker-cabinet / microphone section. All original DSP built on the Lyrebird engine — no
|
||||
third-party captures or IR packs. See the catalog below.
|
||||
- **Starter rigs** — a library of ready-to-play rigs ships with the app, grouped by style
|
||||
(Shoegaze Walls, Dreampop, Classic, Ambient, Experimental) and reachable from a **Mine /
|
||||
Starters** toggle in the rig sidebar.
|
||||
- **Multi-board rigs** — build several boards and a board-mixer bar to **Solo** one (amp-channel
|
||||
style) or **Blend** any subset, each with its own level and a click-free crossfade, plus a
|
||||
rig-wide **output volume and mute** on top.
|
||||
@@ -21,8 +26,9 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
volume, with per-binding invert for crossfades. MIDI Learn, one binding per rig.
|
||||
- **Signal-flow editor** — drag pedals in from the palette; reorder, split into parallel or
|
||||
stereo lanes, and merge back to mono.
|
||||
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar; synced across
|
||||
your devices and both apps via iCloud.
|
||||
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar (your own rigs
|
||||
and the shipped starters on separate tabs); synced across your devices and both apps via iCloud.
|
||||
Switching rigs keeps your current input, and saving over a starter rig asks first.
|
||||
- **Sharing** — send a rig or a saved board to anyone as a `.shoegaze` file via the system share
|
||||
sheet (AirDrop, Mail, Messages, Files); export/import the whole library the same way.
|
||||
- **Recording** — capture your output to timestamped files.
|
||||
@@ -37,14 +43,16 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
|
||||
| Category | Pedals |
|
||||
|---|---|
|
||||
| Gain | Overdrive, Distortion, Fuzz |
|
||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate |
|
||||
| EQ & filter | Graphic EQ, Auto-Wah, Mutant |
|
||||
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Rotary, Ring Modulator |
|
||||
| Gain | Overdrive, Distortion, Fuzz, Sustain Fuzz |
|
||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate, Volume |
|
||||
| EQ & filter | Graphic EQ, Auto-Wah, Wah, Mutant |
|
||||
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Vibe, Rotary, Ring Modulator |
|
||||
| Pitch | Bass Octaver, Octave Splitter, Harmonizer |
|
||||
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay |
|
||||
| Reverb | Reverb, Shimmer Reverb, Plate Reverb, Room Reverb, Spring Reverb |
|
||||
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator |
|
||||
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator, Looper |
|
||||
| Amp Model | Fullerton Reverb / Deluxe / Ivy League / Drive, California, Jazz Clean, British / Plexi / JTM / Bluesbreaker / Master / Dual, Chime / Chime Top Boost / 15 / Normal / Baby, Boutique Lead / OD, Cali Hi-Gain, Modern High-Gain, Command, Citrus, Sixties Combo, Magna Vibrato, Anaheim |
|
||||
| Cabinet | Cabinet (speaker-voice + microphone modeling) |
|
||||
|
||||
Every pedal exposes its parameters as knobs/switches and round-trips through the rig save format.
|
||||
|
||||
@@ -52,7 +60,7 @@ Every pedal exposes its parameters as knobs/switches and round-trips through the
|
||||
|
||||
- macOS 15+ / iPadOS 18+ (iPad, landscape)
|
||||
- Swift 6.0 toolchain / Xcode 16+
|
||||
- [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird) 1.2.0+
|
||||
- [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird) 1.7.0+
|
||||
|
||||
## Packages
|
||||
|
||||
|
||||
+54
@@ -1,4 +1,58 @@
|
||||
# Releases
|
||||
## ShoeGaze 3.1.1
|
||||
|
||||
A small fix for the Mutant envelope filter's control panel.
|
||||
|
||||
### Fixed
|
||||
- **Mutant switch captions no longer wrap.** Its three segmented switches (Direction / Mode /
|
||||
Range) were cramped into a single-width pedal, wrapping "Down" to "Do wn". Mutant is now
|
||||
double-width — like the Cabinet and amp pedals — so the captions fit.
|
||||
|
||||
## ShoeGaze 3.1.0
|
||||
|
||||
Starter rigs, two new pedals, and a deeper envelope filter — plus smoother rig switching.
|
||||
|
||||
### Highlights
|
||||
- **Starter rigs** — a library of ready-to-play rigs ships with the app, grouped by style
|
||||
(Shoegaze Walls, Dreampop, Classic, Ambient, Experimental) behind a **Mine / Starters** toggle
|
||||
in the rig sidebar. Includes a two-board clean/effects split. **Restore Starter Rigs** reinstalls
|
||||
them any time.
|
||||
- **Vibe** — a photocell "vibe" (four staggered all-pass stages swept by one LFO) with Chorus and
|
||||
Vibrato modes.
|
||||
- **Sustain Fuzz** — a mid-scooped, high-sustain fuzz, distinct from the brighter single-stage Fuzz.
|
||||
- **A deeper Mutant envelope filter** — a **Range** switch (Lo / Hi) that shifts the whole sweep
|
||||
band like the original Mu-Tron III, plus **Sweep**, **Attack**, and **Release** in the advanced
|
||||
pop-over.
|
||||
- **Rig switching keeps your input** — your live guitar stays selected across a rig change instead
|
||||
of snapping back to the test loop.
|
||||
|
||||
### Fixed
|
||||
- No more spurious "Save changes?" prompt when switching between rigs.
|
||||
- Shimmer Reverb no longer self-oscillates into a screech at its defaults.
|
||||
- Saving over a starter rig asks first (Overwrite / Save as New Rig / Cancel).
|
||||
- Multi-board signal-router rigs now save and load.
|
||||
|
||||
## ShoeGaze 3.0.0
|
||||
|
||||
The big one: ShoeGaze becomes an amp-modeling rig — a full lineup of tube-amp voices plus a deep
|
||||
speaker-cabinet and microphone section, all original DSP built from the Lyrebird engine with no
|
||||
third-party captures or IR packs.
|
||||
|
||||
### Highlights
|
||||
- **26 amp-model pedals** in their own **Amp Model** palette category — Fullerton blackface combos,
|
||||
California and Jazz Clean cleans, British stack / combo voices, the Chime top-boost family,
|
||||
Boutique and high-gain amps, and character amps (Command, Citrus, Sixties Combo, Magna Vibrato,
|
||||
Anaheim). Each has its own tone stack, a selectable speaker cabinet, and a real master volume that
|
||||
drives the power-amp stage.
|
||||
- **Speaker-cabinet + microphone section** on the Cabinet pedal — eight speaker voicings, mic
|
||||
modeling (Dynamic / Ribbon / Condenser), placement and proximity, and a dual-mic blend.
|
||||
- **Power-amp feel controls** — Sag, Bias, and Bias X in an advanced pop-over — and analog-style
|
||||
soft limiting, so a driven amp compresses toward its ceiling instead of clipping harshly.
|
||||
- **Gain and Drive read 1–11** with a musical taper.
|
||||
|
||||
### Fixed
|
||||
- Noise Gate no longer pops as a note decays.
|
||||
|
||||
## ShoeGaze 2.1.3
|
||||
|
||||
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output — even
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"originHash" : "4c33c107b780400f6ccd69fd1203a485fca3ff6a90f93c3aad40bd403ef33702",
|
||||
"originHash" : "9ce521e7cebf3eed8e20837aba069e3f0c5484a64130b1791e8e6fdb7874b9f0",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "5e6534a615af6c075fc539e909cef3a63b038ced",
|
||||
"version" : "1.6.3"
|
||||
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
|
||||
"version" : "1.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// CabIRStage.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// One filter stage in an off-RT cabinet-IR cascade, as a kind plus parameters.
|
||||
///
|
||||
/// Consumed by ``CabinetIRFactory`` when it bakes an impulse response: the cab voice contributes a
|
||||
/// fixed cascade, and a ``MicVoice`` contributes extra stages (presence bump, top-end/low-end
|
||||
/// shelving) appended to it. `q` is used by high-pass / low-pass / peaking stages; `gainDb` by
|
||||
/// peaking and the shelves; shelves use a fixed slope set by the factory.
|
||||
struct CabIRStage {
|
||||
|
||||
/// The biquad kind this stage bakes into.
|
||||
enum Kind {
|
||||
case highPass
|
||||
case lowPass
|
||||
case peaking
|
||||
case lowShelf
|
||||
case highShelf
|
||||
}
|
||||
|
||||
let kind: Kind
|
||||
let freq: Double
|
||||
let q: Double
|
||||
let gainDb: Double
|
||||
|
||||
/// A resonant peak/dip at `freq`.
|
||||
static func peaking(_ freq: Double, q: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .peaking, freq: freq, q: q, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A low-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func lowShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .lowShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A high-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func highShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .highShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
// CabinetIRFactory.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import Darwin
|
||||
|
||||
/// Fraction of the sample rate above which a filter centre frequency is clamped, so the RBJ
|
||||
/// coefficients stay well-behaved below Nyquist even at low sample rates.
|
||||
private let cabinetBiquadNyquistFraction: Double = 0.49
|
||||
/// RBJ-cookbook divisor converting a filter gain in dB to its `A` amplitude term (peaking + shelves).
|
||||
private let cabinetDbToAmplitudeDivisor: Double = 40.0
|
||||
|
||||
/// Synthesizes a short cabinet impulse response for a ``CabinetVoice`` by running a unit
|
||||
/// impulse through a cascade of RBJ biquads (high-pass → two-stage low-pass → low-mid body
|
||||
/// peak → presence peak → cone-breakup peak → mid notch) and capturing the result into a mono
|
||||
/// ``LyrebirdBuffer``.
|
||||
///
|
||||
/// This runs **off the RT thread** (at pedal build time), so it uses plain `Double` math with
|
||||
/// no allocation constraints. The produced buffer is a normal IR consumed by `ConvolutionReverb`.
|
||||
public enum CabinetIRFactory {
|
||||
|
||||
/// Default IR length in frames. 1024 taps (~21 ms at 48 kHz) is ample for a speaker-cab
|
||||
/// magnitude curve, which has no long tail.
|
||||
public static let defaultFrames: Int = 1024
|
||||
|
||||
/// Butterworth Q for the high-pass (low rolloff) stage.
|
||||
private static let highPassQ: Double = 0.707
|
||||
/// Per-stage Q values for a true 4th-order Butterworth low-pass built as two cascaded
|
||||
/// biquads (maximally flat passband). Q ≈ 0.5412 and 1.3066.
|
||||
private static let lowPassCascadeQ: [Double] = [0.541_196_100_146_197, 1.306_562_964_876_377]
|
||||
/// Q for the resonant body / presence peaks.
|
||||
private static let peakQ: Double = 1.2
|
||||
/// Q for the narrower cone-breakup peak (higher than the body/presence peaks).
|
||||
private static let breakupQ: Double = 2.0
|
||||
/// Q for the mid interference notch (narrow, so it dips without gutting the midrange).
|
||||
private static let notchQ: Double = 2.5
|
||||
/// Fixed shelf slope for the ``MicVoice`` low-/high-shelf stages (gentle, like the amp shelves).
|
||||
private static let micShelfSlope: Double = 0.7
|
||||
|
||||
/// Builds the impulse response for `voice` (optionally mic'd by `mic`) at `sampleRate`.
|
||||
///
|
||||
/// The cab voice's fixed cascade is baked first; any ``MicVoice`` stages are appended before the
|
||||
/// impulse is run, so the mic colour is folded into the same single IR (no extra render-time
|
||||
/// cost). ``MicVoice/off`` appends nothing, so the result is byte-for-byte the raw cab voice.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - voice: The cabinet voicing to synthesize.
|
||||
/// - mic: The microphone voicing layered on top. Defaults to ``MicVoice/off`` (no mic).
|
||||
/// - sampleRate: Engine sample rate in Hz.
|
||||
/// - frames: IR length in frames. Defaults to ``defaultFrames``.
|
||||
/// - Returns: A mono `LyrebirdBuffer` holding the normalized IR, tagged with `sampleRate`.
|
||||
public static func makeIR(
|
||||
voice: CabinetVoice,
|
||||
mic: MicVoice = .off,
|
||||
sampleRate: Double,
|
||||
frames: Int = CabinetIRFactory.defaultFrames
|
||||
) -> LyrebirdBuffer {
|
||||
var chain: [OfflineBiquad] = [
|
||||
OfflineBiquad.highPass(freq: voice.highPassHz, q: highPassQ, sampleRate: sampleRate),
|
||||
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[0], sampleRate: sampleRate),
|
||||
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[1], sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.bodyHz, q: peakQ, gainDb: voice.bodyGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.presenceHz, q: peakQ, gainDb: voice.presenceGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.breakupHz, q: breakupQ, gainDb: voice.breakupGainDb, sampleRate: sampleRate),
|
||||
OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate),
|
||||
]
|
||||
|
||||
// Append the mic voicing's stages (none for `.off`) so its colour bakes into the same IR.
|
||||
for stage: CabIRStage in mic.stages {
|
||||
switch stage.kind {
|
||||
case .highPass:
|
||||
chain.append(OfflineBiquad.highPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .lowPass:
|
||||
chain.append(OfflineBiquad.lowPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .peaking:
|
||||
chain.append(OfflineBiquad.peaking(
|
||||
freq: stage.freq, q: stage.q, gainDb: stage.gainDb, sampleRate: sampleRate))
|
||||
case .lowShelf:
|
||||
chain.append(OfflineBiquad.lowShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
case .highShelf:
|
||||
chain.append(OfflineBiquad.highShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
}
|
||||
}
|
||||
|
||||
var ir: [Double] = [Double](repeating: 0.0, count: frames)
|
||||
for n: Int in 0..<frames {
|
||||
var sample: Double = n == 0 ? 1.0 : 0.0
|
||||
for i: Int in chain.indices {
|
||||
sample = chain[i].process(sample)
|
||||
}
|
||||
ir[n] = sample
|
||||
}
|
||||
|
||||
// Peak-normalize so the cab contributes unity-ish level regardless of the filter gains.
|
||||
let peak: Double = ir.reduce(0.0) { Swift.max($0, abs($1)) }
|
||||
if peak > 0.0 {
|
||||
let inv: Double = 1.0 / peak
|
||||
for i: Int in ir.indices { ir[i] *= inv }
|
||||
}
|
||||
|
||||
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: frames, channelCount: 1)
|
||||
buffer.fill(using: { (frame: Int, _: Int) -> Double in ir[frame] })
|
||||
buffer.setSampleRate(sampleRate)
|
||||
return buffer
|
||||
}
|
||||
}
|
||||
|
||||
/// A minimal off-RT RBJ biquad (transposed Direct Form II) used only to render cabinet IRs.
|
||||
private struct OfflineBiquad {
|
||||
private let b0: Double
|
||||
private let b1: Double
|
||||
private let b2: Double
|
||||
private let a1: Double
|
||||
private let a2: Double
|
||||
private var z1: Double = 0.0
|
||||
private var z2: Double = 0.0
|
||||
|
||||
private init(
|
||||
b0: Double,
|
||||
b1: Double,
|
||||
b2: Double,
|
||||
a1: Double,
|
||||
a2: Double
|
||||
) {
|
||||
self.b0 = b0
|
||||
self.b1 = b1
|
||||
self.b2 = b2
|
||||
self.a1 = a1
|
||||
self.a2 = a2
|
||||
}
|
||||
|
||||
/// Centre frequency clamped below Nyquist for the given sample rate.
|
||||
private static func clampedFreq(_ freq: Double, sampleRate: Double) -> Double {
|
||||
Swift.min(freq, sampleRate * cabinetBiquadNyquistFraction)
|
||||
}
|
||||
|
||||
mutating func process(_ x: Double) -> Double {
|
||||
let y: Double = b0 * x + z1
|
||||
z1 = b1 * x - a1 * y + z2
|
||||
z2 = b2 * x - a2 * y
|
||||
return y
|
||||
}
|
||||
|
||||
static func highPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha
|
||||
let b0: Double = (1.0 + cosW0) / 2.0
|
||||
let b1: Double = -(1.0 + cosW0)
|
||||
let b2: Double = (1.0 + cosW0) / 2.0
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
static func lowPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha
|
||||
let b0: Double = (1.0 - cosW0) / 2.0
|
||||
let b1: Double = 1.0 - cosW0
|
||||
let b2: Double = (1.0 - cosW0) / 2.0
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
static func peaking(freq: Double, q: Double, gainDb: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
let a0: Double = 1.0 + alpha / amplitude
|
||||
let b0: Double = 1.0 + alpha * amplitude
|
||||
let b1: Double = -2.0 * cosW0
|
||||
let b2: Double = 1.0 - alpha * amplitude
|
||||
let a1: Double = -2.0 * cosW0
|
||||
let a2: Double = 1.0 - alpha / amplitude
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ low-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func lowShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 - am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = 2.0 * amplitude * (am1 - ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 - am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 + am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = -2.0 * (am1 + ap1 * cosW0)
|
||||
let a2: Double = ap1 + am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ high-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func highShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 + am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = -2.0 * amplitude * (am1 + ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 + am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 - am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = 2.0 * (am1 - ap1 * cosW0)
|
||||
let a2: Double = ap1 - am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// CabinetVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A built-in guitar-speaker-cabinet voicing.
|
||||
///
|
||||
/// Each voice is a compact set of target-response parameters — low/high rolloff, a low-mid
|
||||
/// "body" bump, an upper-mid "presence" peak, a higher cone-"breakup" peak, and a mid
|
||||
/// interference "notch" — from which ``CabinetIRFactory`` synthesizes a short impulse response
|
||||
/// entirely in code. These IRs are **our own content** (MIT, generated, no third-party capture),
|
||||
/// so they ship with the pedal without licensing concerns. (Loading a user-supplied captured
|
||||
/// `.wav` cab IR is a planned follow-up.)
|
||||
///
|
||||
/// The values are deliberately broad-strokes voicings, not measurements of specific hardware.
|
||||
public enum CabinetVoice: String, CaseIterable, Sendable {
|
||||
case americanCombo
|
||||
case britishStack
|
||||
case vintageDark
|
||||
case modernStack
|
||||
case boutiqueOpen
|
||||
case brightCombo
|
||||
case fullRange
|
||||
case loFiBox
|
||||
|
||||
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||
/// range. Used by the cab selector to pick the single voice to instantiate on a board rebuild.
|
||||
///
|
||||
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||
public static func voice(atSelectorValue selectorValue: Double) -> CabinetVoice {
|
||||
let all: [CabinetVoice] = allCases
|
||||
guard selectorValue.isFinite else { return all[0] }
|
||||
// Clamp in Double space first so a huge/NaN-adjacent value can never trap `Int(_:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||
let index: Int = Int(bounded.rounded())
|
||||
return all[index]
|
||||
}
|
||||
|
||||
/// Human-readable name for pickers.
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .americanCombo: return "American 1×12"
|
||||
case .britishStack: return "British 4×12"
|
||||
case .vintageDark: return "Vintage Dark"
|
||||
case .modernStack: return "Modern 4×12"
|
||||
case .boutiqueOpen: return "Boutique 2×12"
|
||||
case .brightCombo: return "Bright 1×12"
|
||||
case .fullRange: return "Full-Range (FRFR)"
|
||||
case .loFiBox: return "Lo-Fi 1×8"
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-frequency rolloff (high-pass cutoff) in Hz — the speaker's bass limit.
|
||||
var highPassHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 80.0
|
||||
case .britishStack: return 95.0
|
||||
case .vintageDark: return 90.0
|
||||
case .modernStack: return 100.0
|
||||
case .boutiqueOpen: return 70.0
|
||||
case .brightCombo: return 85.0
|
||||
case .fullRange: return 45.0
|
||||
case .loFiBox: return 180.0
|
||||
}
|
||||
}
|
||||
|
||||
/// High-frequency rolloff (low-pass cutoff) in Hz — the speaker's top-end limit. Applied as a
|
||||
/// two-stage cascade for a steeper, more speaker-like slope.
|
||||
var lowPassHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 5500.0
|
||||
case .britishStack: return 4500.0
|
||||
case .vintageDark: return 3800.0
|
||||
case .modernStack: return 4000.0
|
||||
case .boutiqueOpen: return 6000.0
|
||||
case .brightCombo: return 6500.0
|
||||
case .fullRange: return 9000.0
|
||||
case .loFiBox: return 3000.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-mid "body" peak centre in Hz.
|
||||
var bodyHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 420.0
|
||||
case .britishStack: return 700.0
|
||||
case .vintageDark: return 500.0
|
||||
case .modernStack: return 900.0
|
||||
case .boutiqueOpen: return 450.0
|
||||
case .brightCombo: return 550.0
|
||||
case .fullRange: return 300.0
|
||||
case .loFiBox: return 900.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Low-mid body peak gain in dB (may be negative for a scoop).
|
||||
var bodyGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 1.5
|
||||
case .britishStack: return -2.0
|
||||
case .vintageDark: return 2.0
|
||||
case .modernStack: return 2.0
|
||||
case .boutiqueOpen: return -1.0
|
||||
case .brightCombo: return 1.0
|
||||
case .fullRange: return 0.0
|
||||
case .loFiBox: return 4.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Presence peak centre in Hz — the upper-mid "bite".
|
||||
var presenceHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 3000.0
|
||||
case .britishStack: return 2500.0
|
||||
case .vintageDark: return 2200.0
|
||||
case .modernStack: return 3200.0
|
||||
case .boutiqueOpen: return 3500.0
|
||||
case .brightCombo: return 3800.0
|
||||
case .fullRange: return 4000.0
|
||||
case .loFiBox: return 2400.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Presence peak gain in dB.
|
||||
var presenceGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 3.0
|
||||
case .britishStack: return 4.0
|
||||
case .vintageDark: return 2.0
|
||||
case .modernStack: return 5.0
|
||||
case .boutiqueOpen: return 2.0
|
||||
case .brightCombo: return 4.0
|
||||
case .fullRange: return 1.0
|
||||
case .loFiBox: return 1.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Cone-"breakup" peak centre in Hz — the higher, narrower bite/clank a real driver adds as
|
||||
/// the cone breaks up. Sits above the presence peak.
|
||||
var breakupHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 4200.0
|
||||
case .britishStack: return 3800.0
|
||||
case .vintageDark: return 3500.0
|
||||
case .modernStack: return 3800.0
|
||||
case .boutiqueOpen: return 5000.0
|
||||
case .brightCombo: return 5200.0
|
||||
case .fullRange: return 6000.0
|
||||
case .loFiBox: return 2600.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Cone-breakup peak gain in dB. Small; `0` disables the peak (identity).
|
||||
var breakupGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 2.0
|
||||
case .britishStack: return 3.0
|
||||
case .vintageDark: return 1.5
|
||||
case .modernStack: return 3.0
|
||||
case .boutiqueOpen: return 1.5
|
||||
case .brightCombo: return 3.0
|
||||
case .fullRange: return 0.5
|
||||
case .loFiBox: return 2.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Mid interference "notch" centre in Hz — the characteristic dip from cone/mic
|
||||
/// comb-filtering, typically ~1.2–2.5 kHz.
|
||||
var notchHz: Double {
|
||||
switch self {
|
||||
case .americanCombo: return 1800.0
|
||||
case .britishStack: return 1600.0
|
||||
case .vintageDark: return 1500.0
|
||||
case .modernStack: return 1700.0
|
||||
case .boutiqueOpen: return 2000.0
|
||||
case .brightCombo: return 2100.0
|
||||
case .fullRange: return 2000.0
|
||||
case .loFiBox: return 1200.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Notch depth in dB (negative). `0` disables the notch (identity).
|
||||
var notchGainDb: Double {
|
||||
switch self {
|
||||
case .americanCombo: return -3.0
|
||||
case .britishStack: return -4.0
|
||||
case .vintageDark: return -2.5
|
||||
case .modernStack: return -5.0
|
||||
case .boutiqueOpen: return -2.0
|
||||
case .brightCombo: return -2.0
|
||||
case .fullRange: return 0.0
|
||||
case .loFiBox: return -1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// MicVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A microphone voicing baked into the cabinet impulse response — the frequency signature of the
|
||||
/// mic in front of the speaker, layered on top of the ``CabinetVoice`` cab curve.
|
||||
///
|
||||
/// Each voice is a compact set of ``CabIRStage`` filter stages (a presence bump, low-end and
|
||||
/// top-end shelving) that ``CabinetIRFactory`` appends to the cab cascade before baking, so mic
|
||||
/// choice costs nothing extra at render time — it is folded into the single convolution IR. These
|
||||
/// are **broad-strokes synthesized curves** (our own MIT content, not captures of any specific
|
||||
/// microphone), analogous to ``CabinetVoice``.
|
||||
///
|
||||
/// ``off`` contributes no stages, so a cab with no mic bakes exactly the raw cab voice — the
|
||||
/// original, mic-less behaviour.
|
||||
public enum MicVoice: String, CaseIterable, Sendable {
|
||||
case off
|
||||
case dynamic
|
||||
case ribbon
|
||||
case condenser
|
||||
|
||||
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||
/// range. Mirrors ``CabinetVoice/voice(atSelectorValue:)`` so a huge / NaN selector never traps.
|
||||
///
|
||||
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||
public static func voice(atSelectorValue selectorValue: Double) -> MicVoice {
|
||||
let all: [MicVoice] = allCases
|
||||
guard selectorValue.isFinite else { return all[0] }
|
||||
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||
let index: Int = Int(bounded.rounded())
|
||||
return all[index]
|
||||
}
|
||||
|
||||
/// Human-readable name for pickers.
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .off: return "No Mic"
|
||||
case .dynamic: return "Dynamic"
|
||||
case .ribbon: return "Ribbon"
|
||||
case .condenser: return "Condenser"
|
||||
}
|
||||
}
|
||||
|
||||
/// The mic's filter stages, appended to the cab cascade before baking. Empty for ``off``.
|
||||
///
|
||||
/// Broad-strokes voicings: the **dynamic** (moving-coil, close-mic staple) adds an upper-mid
|
||||
/// presence bump with a tightened low end and rolled-off extreme top; the **ribbon** is dark and
|
||||
/// smooth (warm low-mid, steep top rolloff, no presence spike); the **condenser** is the most
|
||||
/// extended and airy (gentle top-end lift, light presence sheen).
|
||||
var stages: [CabIRStage] {
|
||||
switch self {
|
||||
case .off:
|
||||
return []
|
||||
case .dynamic:
|
||||
return [
|
||||
CabIRStage.lowShelf(120.0, gainDb: -2.0),
|
||||
CabIRStage.peaking(5500.0, q: 1.0, gainDb: 4.0),
|
||||
CabIRStage.highShelf(9000.0, gainDb: -3.0),
|
||||
]
|
||||
case .ribbon:
|
||||
return [
|
||||
CabIRStage.lowShelf(200.0, gainDb: 2.5),
|
||||
CabIRStage.peaking(2500.0, q: 0.8, gainDb: -1.5),
|
||||
CabIRStage.highShelf(6500.0, gainDb: -7.0),
|
||||
]
|
||||
case .condenser:
|
||||
return [
|
||||
CabIRStage.peaking(8000.0, q: 1.0, gainDb: 1.5),
|
||||
CabIRStage.highShelf(11000.0, gainDb: 3.0),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// OversampledRingModulator.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import Darwin
|
||||
|
||||
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||
private let oversampledRingModZeroBlock: [Double] = makeSampleBuffer()
|
||||
|
||||
/// Ring modulator (`input × sine carrier`) evaluated at 2× or 4× the engine sample rate.
|
||||
///
|
||||
/// A ring modulator's product produces sum-and-difference sidebands at `f_in ± f_carrier`. The
|
||||
/// sum sideband can land above the engine Nyquist and fold back as an inharmonic alias —
|
||||
/// worst with a high carrier and bright input. Evaluating the multiply at an oversampled rate
|
||||
/// (the input upsampled through a halfband FIR, the carrier generated directly at the
|
||||
/// oversampled rate) pushes the sum term below the upsampled Nyquist, then the matching
|
||||
/// downsampler filters it out before returning to the engine rate.
|
||||
///
|
||||
/// Output is mono (channel 0 of the input is used).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to modulate.
|
||||
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public final class OversampledRingModulator: GeneratorBase, AudioGenerator {
|
||||
|
||||
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||
private let inputSource: any ValidGeneratorInput
|
||||
|
||||
/// Resolved carrier-frequency control. Read once per block.
|
||||
private let freqInput: any ValidGeneratorInput
|
||||
|
||||
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||
private let oversampleFactor: Int
|
||||
|
||||
/// Carrier phase in radians, advanced at the oversampled rate and wrapped to `[0, 2π)`.
|
||||
private var phase: Double = 0.0
|
||||
|
||||
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||
private var upsampler2x: HalfbandUpsampler2x
|
||||
private var downsampler2x: HalfbandDownsampler2x
|
||||
|
||||
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||
private var upsampler4x: HalfbandUpsampler4x
|
||||
private var downsampler4x: HalfbandDownsampler4x
|
||||
|
||||
private let twoPi: Double = 2.0 * Double.pi
|
||||
|
||||
/// Creates an oversampled ring modulator.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to modulate.
|
||||
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public init(
|
||||
_ input: any ValidGeneratorInput,
|
||||
freq: any ValidGeneratorInput = 220.0,
|
||||
oversample: Int = 2
|
||||
) {
|
||||
precondition(
|
||||
oversample == 2 || oversample == 4,
|
||||
"OversampledRingModulator: oversample must be 2 or 4"
|
||||
)
|
||||
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||
let resolvedFreq: any ValidGeneratorInput = freq._resolvedInput()
|
||||
inputSource = resolvedInput
|
||||
freqInput = resolvedFreq
|
||||
oversampleFactor = oversample
|
||||
upsampler2x = HalfbandUpsampler2x()
|
||||
downsampler2x = HalfbandDownsampler2x()
|
||||
upsampler4x = HalfbandUpsampler4x()
|
||||
downsampler4x = HalfbandDownsampler4x()
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func _computeSamples(
|
||||
graph: SynthGraph,
|
||||
count: Int
|
||||
) -> [[Double]] {
|
||||
_checkCount(count)
|
||||
guard count > 0 else { return _result }
|
||||
|
||||
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||
?? oversampledRingModZeroBlock
|
||||
let sr: Double = graph.engine.sampleRate
|
||||
// A degenerate sample rate would make phaseInc NaN/Inf and latch NaN into the
|
||||
// persisted phase; zero-fill and bail, matching MoogLadder's guard.
|
||||
guard sr >= 1.0 else {
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
for i: Int in 0..<count { dstP[i] = 0 }
|
||||
}
|
||||
return _result
|
||||
}
|
||||
let freq: Double = freqInput.floatValue(graph: graph)
|
||||
let inCount: Int = input.count
|
||||
let useFourX: Bool = oversampleFactor == 4
|
||||
// Phase increment per oversampled sample.
|
||||
let factor: Double = useFourX ? 4.0 : 2.0
|
||||
let phaseInc: Double = twoPi * freq / (sr * factor)
|
||||
|
||||
var localPhase: Double = phase
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
if useFourX {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b, c, d) = upsampler4x.process(x)
|
||||
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||
let yc: Double = c * sin(localPhase); localPhase += phaseInc
|
||||
let yd: Double = d * sin(localPhase); localPhase += phaseInc
|
||||
// Wrap both directions — a negative carrier frequency drives phaseInc
|
||||
// negative, so an upward-only wrap would let the phase grow unbounded.
|
||||
if localPhase >= twoPi || localPhase < 0 {
|
||||
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||
if localPhase < 0 { localPhase += twoPi }
|
||||
}
|
||||
dstP[i] = downsampler4x.process(ya, yb, yc, yd)
|
||||
}
|
||||
} else {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b) = upsampler2x.process(x)
|
||||
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||
// Wrap both directions (see 4× branch).
|
||||
if localPhase >= twoPi || localPhase < 0 {
|
||||
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||
if localPhase < 0 { localPhase += twoPi }
|
||||
}
|
||||
dstP[i] = downsampler2x.process(ya, yb)
|
||||
}
|
||||
}
|
||||
}
|
||||
phase = localPhase
|
||||
return _result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
// OversampledSaturator.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||
private let oversampledSaturatorZeroBlock: [Double] = makeSampleBuffer()
|
||||
|
||||
/// A waveshaping saturator that evaluates its nonlinearity at 2× or 4× the engine sample
|
||||
/// rate to keep the harmonics it generates from folding back into the audible band as
|
||||
/// aliasing.
|
||||
///
|
||||
/// A hard or steep nonlinearity (`tanh` driven hard, a hard clipper) produces harmonics well
|
||||
/// above the engine Nyquist. Evaluated at the base rate those harmonics alias — an
|
||||
/// inharmonic, buzzy "crackle" that gets worse the louder and brighter the input and the
|
||||
/// harder the drive. This generator upsamples the input, applies the ``SaturationCurve``
|
||||
/// per oversampled sample, then downsamples with the matching halfband FIR, so the aliased
|
||||
/// content is filtered out before returning to the engine rate.
|
||||
///
|
||||
/// Linear stages (DC-block high-pass, tone low-pass, output trim) do **not** alias and should
|
||||
/// stay as ordinary graph nodes around this one — only the nonlinearity needs oversampling.
|
||||
///
|
||||
/// Output is mono (channel 0 of the input is used).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to saturate.
|
||||
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Use `4` for hard-clipping curves whose
|
||||
/// harmonics extend furthest; `2` is enough for `tanh`-family soft saturation. Defaults to `2`.
|
||||
public final class OversampledSaturator: GeneratorBase, AudioGenerator {
|
||||
|
||||
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||
private let inputSource: any ValidGeneratorInput
|
||||
|
||||
/// Resolved drive control. Read once per block.
|
||||
private let driveInput: any ValidGeneratorInput
|
||||
|
||||
/// The waveshaping curve applied per oversampled sample.
|
||||
private let curve: SaturationCurve
|
||||
|
||||
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||
private let oversampleFactor: Int
|
||||
|
||||
/// Lower bound on drive so `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||
private let minDrive: Double = 1.0e-4
|
||||
|
||||
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||
private var upsampler2x: HalfbandUpsampler2x
|
||||
private var downsampler2x: HalfbandDownsampler2x
|
||||
|
||||
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||
private var upsampler4x: HalfbandUpsampler4x
|
||||
private var downsampler4x: HalfbandDownsampler4x
|
||||
|
||||
/// Creates an oversampled saturator.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Signal to saturate.
|
||||
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||
public init(
|
||||
_ input: any ValidGeneratorInput,
|
||||
drive: any ValidGeneratorInput = 1.0,
|
||||
curve: SaturationCurve,
|
||||
oversample: Int = 2
|
||||
) {
|
||||
precondition(
|
||||
oversample == 2 || oversample == 4,
|
||||
"OversampledSaturator: oversample must be 2 or 4"
|
||||
)
|
||||
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||
let resolvedDrive: any ValidGeneratorInput = drive._resolvedInput()
|
||||
inputSource = resolvedInput
|
||||
driveInput = resolvedDrive
|
||||
self.curve = curve
|
||||
oversampleFactor = oversample
|
||||
upsampler2x = HalfbandUpsampler2x()
|
||||
downsampler2x = HalfbandDownsampler2x()
|
||||
upsampler4x = HalfbandUpsampler4x()
|
||||
downsampler4x = HalfbandDownsampler4x()
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func _computeSamples(
|
||||
graph: SynthGraph,
|
||||
count: Int
|
||||
) -> [[Double]] {
|
||||
_checkCount(count)
|
||||
guard count > 0 else { return _result }
|
||||
|
||||
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||
?? oversampledSaturatorZeroBlock
|
||||
let driveRaw: Double = driveInput.floatValue(graph: graph)
|
||||
let drive: Double = Swift.max(minDrive, driveRaw)
|
||||
let inCount: Int = input.count
|
||||
let useFourX: Bool = oversampleFactor == 4
|
||||
|
||||
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||
if useFourX {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b, c, d) = upsampler4x.process(x)
|
||||
dstP[i] = downsampler4x.process(
|
||||
curve.apply(a, drive: drive),
|
||||
curve.apply(b, drive: drive),
|
||||
curve.apply(c, drive: drive),
|
||||
curve.apply(d, drive: drive)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
for i: Int in 0..<count {
|
||||
let x: Double = i < inCount ? input[i] : 0
|
||||
let (a, b) = upsampler2x.process(x)
|
||||
dstP[i] = downsampler2x.process(
|
||||
curve.apply(a, drive: drive),
|
||||
curve.apply(b, drive: drive)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// SaturationCurve.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Darwin
|
||||
|
||||
/// The waveshaping curve applied per (oversampled) sample by ``OversampledSaturator``.
|
||||
///
|
||||
/// Each case reproduces the nonlinearity a specific drive pedal used to build inline from
|
||||
/// stock generators, so moving that pedal onto the oversampled path is voicing-preserving:
|
||||
///
|
||||
/// - `tanhPreGain` — `tanh(drive · x)`. Symmetric soft saturation with the drive applied
|
||||
/// *before* the `tanh` (the fuzz voicing: hard pre-gain squares the wave off).
|
||||
/// - `softClipNormalized` — `tanh(drive · x) / tanh(drive)`. The same curve normalised so a
|
||||
/// unity-drive signal passes near-linearly (the overdrive voicing).
|
||||
/// - `tanhPostGainHardClip(low:high:)` — `clip(tanh(x) · drive, low, high)`. A gentle `tanh`
|
||||
/// stage, post-gained by drive into a hard clipper (the distortion voicing). The hard clip
|
||||
/// is the dominant harmonic source and the reason this curve wants the highest oversampling
|
||||
/// factor.
|
||||
public enum SaturationCurve: Sendable {
|
||||
case tanhPreGain
|
||||
case softClipNormalized
|
||||
case tanhPostGainHardClip(low: Double, high: Double)
|
||||
|
||||
/// Applies the curve to a single sample.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - x: Input sample (already at the oversampled rate).
|
||||
/// - drive: Drive amount. The caller clamps this to a small positive floor so
|
||||
/// `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||
/// - Returns: The shaped sample.
|
||||
@inline(__always)
|
||||
func apply(_ x: Double, drive: Double) -> Double {
|
||||
switch self {
|
||||
case .tanhPreGain:
|
||||
return tanh(drive * x)
|
||||
case .softClipNormalized:
|
||||
return tanh(drive * x) / tanh(drive)
|
||||
case .tanhPostGainHardClip(let low, let high):
|
||||
let shaped: Double = tanh(x) * drive
|
||||
return Swift.min(high, Swift.max(low, shaped))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,11 @@ open class Pedal: SynthesizerBase {
|
||||
/// Output gain as a linear multiplier. `1.0` = unity gain.
|
||||
@UIParam public var level: Double = 1.0
|
||||
|
||||
/// Optional path to an external resource this pedal references (e.g. a neural-amp model file).
|
||||
/// Not a `@UIParam` — it's a `String`, applied at `build()`, and persisted separately in
|
||||
/// ``PedalState/resourcePath``. Default `nil`. Pedals that don't use an external file ignore it.
|
||||
public var resourcePath: String?
|
||||
|
||||
// MARK: - Sample rate
|
||||
|
||||
/// Engine sample rate, injected by `PedalBoard.add(_:)` before the pedal is added
|
||||
@@ -138,8 +143,12 @@ open class Pedal: SynthesizerBase {
|
||||
open func rigWillTeardown() {}
|
||||
|
||||
/// Number of standard enclosure widths this pedal's card occupies in the UI. Defaults
|
||||
/// to `1`. A control-dense pedal (e.g. the looper) overrides to `2` for a wider card.
|
||||
/// The UI multiplies its base enclosure width by this factor; `1` is the normal stompbox.
|
||||
/// to `1`. This sets the card's **base width in knob columns**: `1` = a three-wide card, `≥ 2` =
|
||||
/// four-wide (and the knob grid packs that many across). It is both the grid's column count and
|
||||
/// the card's minimum width, so a `2` pedal is a four-wide card even with few knobs (e.g. the
|
||||
/// Cabinet, to keep its selector captions readable). A pedal whose selector/switch row is wider
|
||||
/// still pushes wider; values above `2` add nothing. (The looper is the sole exception: it
|
||||
/// overrides the UI to a fixed multi-column layout scaled by this value.)
|
||||
open var widthUnits: Int { 1 }
|
||||
|
||||
/// `true` when the board has placed this pedal in a stereo (width-2) region.
|
||||
@@ -232,6 +241,34 @@ open class Pedal: SynthesizerBase {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Secondary "advanced" knobs that read best tucked behind a pop-over rather than on the pedal
|
||||
/// face — deep-cut controls a player reaches for occasionally, not while performing (e.g. an
|
||||
/// amp's power-amp Sag / Bias / Bias X). When non-empty the pedal card shows a small button that
|
||||
/// presents these in a popover; when empty no button is drawn. Defaults to empty.
|
||||
///
|
||||
/// These are ordinary live `@UIParam` knobs — they round-trip through `PedalState` and are not
|
||||
/// topology controls (no `rebuildsOnChange`).
|
||||
open var advancedKnobs: [PedalKnob] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Current values of every ``effectSelectors`` and ``effectSwitches`` entry flagged
|
||||
/// `rebuildsOnChange` — the controls whose choice changes the graph topology (e.g. a cabinet
|
||||
/// voice or a clean/drive channel). A lightweight recall compares this before/after applying a
|
||||
/// snapshot to decide whether the board must be rebuilt (a plain node write does not re-enter
|
||||
/// `effect(_:)`). Empty for pedals with no such controls.
|
||||
public var rebuildTopologyValues: [Double] {
|
||||
// Sanitize non-finite to a fixed sentinel: the before/after compare in a recall uses `!=`,
|
||||
// and `NaN != NaN` would force a spurious rebuild on every recall.
|
||||
let selectorValues: [Double] = effectSelectors
|
||||
.filter { $0.rebuildsOnChange }
|
||||
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||
let switchValues: [Double] = effectSwitches
|
||||
.filter { $0.rebuildsOnChange }
|
||||
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||
return selectorValues + switchValues
|
||||
}
|
||||
|
||||
/// Effect-specific transport controls, rendered as a row directly below the knobs — above
|
||||
/// ``effectButtons``. Use for the persistent state toggles and transport stops that read as
|
||||
/// a group distinct from the momentary "do it now" actions (e.g. a looper's Loop / Stop /
|
||||
@@ -261,11 +298,13 @@ open class Pedal: SynthesizerBase {
|
||||
}
|
||||
|
||||
/// Every continuous control on this pedal that a MIDI Control Change can drive — the pedal's
|
||||
/// knobs (effect knobs + Mix + Level) followed by its vertical-fader sliders. Discrete controls
|
||||
/// (switches, stepped selectors) are excluded; they suit Program Change toggles, not CC sweeps.
|
||||
/// knobs (effect knobs + Mix + Level), then its vertical-fader sliders, then its advanced
|
||||
/// (pop-over) knobs. Discrete controls (switches, stepped selectors) are excluded; they suit
|
||||
/// Program Change toggles, not CC sweeps.
|
||||
///
|
||||
/// Ordering is stable — knobs first, then sliders — so a persisted CC binding addressed by index
|
||||
/// keeps resolving to the same control across launches. Used by MIDI mapping.
|
||||
/// Ordering is stable — knobs, then sliders, then advanced knobs (appended last so existing
|
||||
/// index-addressed CC bindings keep resolving to the same control across launches). Used by MIDI
|
||||
/// mapping.
|
||||
public var ccMappableControls: [PedalControl] {
|
||||
let knobControls: [PedalControl] = knobs.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
@@ -273,7 +312,10 @@ open class Pedal: SynthesizerBase {
|
||||
let sliderControls: [PedalControl] = effectSliders.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
}
|
||||
return knobControls + sliderControls
|
||||
let advancedControls: [PedalControl] = advancedKnobs.map {
|
||||
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||
}
|
||||
return knobControls + sliderControls + advancedControls
|
||||
}
|
||||
|
||||
// MARK: - Tempo sync
|
||||
|
||||
@@ -49,20 +49,31 @@ public struct PedalSelectorKnob {
|
||||
/// contain at least two.
|
||||
public let stops: [Stop]
|
||||
|
||||
/// When `true`, committing a new stop asks the host to rebuild the board (as the Neural Amp
|
||||
/// model loader does) instead of relying on the live graph to react to the node value. Use for
|
||||
/// selectors whose choice changes the *graph topology* — e.g. a cabinet whose voice picks which
|
||||
/// single convolver is instantiated — rather than a value an always-running node reads live.
|
||||
/// Defaults to `false`.
|
||||
public let rebuildsOnChange: Bool
|
||||
|
||||
/// Creates a selector-knob descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short label shown beneath the knob.
|
||||
/// - node: The `UIParamNode` projected value of an `@UIParam` property (`pedal.$voice1`, …).
|
||||
/// - stops: Ordered stops, CCW → CW. At least two.
|
||||
/// - rebuildsOnChange: Ask the host to rebuild the board when a new stop is committed. Use for
|
||||
/// selectors that change graph topology. Defaults to `false`.
|
||||
public init(
|
||||
label: String,
|
||||
node: UIParamNode,
|
||||
stops: [Stop]
|
||||
stops: [Stop],
|
||||
rebuildsOnChange: Bool = false
|
||||
) {
|
||||
precondition(stops.count >= 2, "PedalSelectorKnob requires at least two stops")
|
||||
self.label = label
|
||||
self.node = node
|
||||
self.stops = stops
|
||||
self.rebuildsOnChange = rebuildsOnChange
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ public struct PedalSwitch {
|
||||
/// to their first (off) option — while the tempo indicator is turned off. Defaults to `false`.
|
||||
public let tempoDependent: Bool
|
||||
|
||||
/// When `true`, committing a new position asks the host to rebuild the board — for switches that
|
||||
/// change the *graph topology* (e.g. a clean/drive channel that adds or removes a gain stage),
|
||||
/// the same mechanism as ``PedalSelectorKnob/rebuildsOnChange``. Defaults to `false`.
|
||||
public let rebuildsOnChange: Bool
|
||||
|
||||
/// Creates a switch descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -62,17 +67,21 @@ public struct PedalSwitch {
|
||||
/// (`pedal.$mode`, `pedal.$direction`, …).
|
||||
/// - options: Ordered switch positions, left to right. At least two.
|
||||
/// - tempoDependent: `true` if the switch depends on the tempo/clock. Defaults to `false`.
|
||||
/// - rebuildsOnChange: Ask the host to rebuild the board when a new position is committed. Use
|
||||
/// for switches that change graph topology (e.g. a channel switch). Defaults to `false`.
|
||||
public init(
|
||||
label: String,
|
||||
node: UIParamNode,
|
||||
options: [Option],
|
||||
tempoDependent: Bool = false
|
||||
tempoDependent: Bool = false,
|
||||
rebuildsOnChange: Bool = false
|
||||
) {
|
||||
precondition(options.count >= 2, "PedalSwitch requires at least two options")
|
||||
self.label = label
|
||||
self.node = node
|
||||
self.options = options
|
||||
self.tempoDependent = tempoDependent
|
||||
self.rebuildsOnChange = rebuildsOnChange
|
||||
}
|
||||
|
||||
/// The value of the next option after the one nearest `current`, wrapping to the first — so a
|
||||
|
||||
@@ -44,12 +44,41 @@ public struct PedalType: RawRepresentable, Hashable, Sendable {
|
||||
public extension PedalType {
|
||||
|
||||
// Drive & dynamics
|
||||
static let california = PedalType("California")
|
||||
static let british = PedalType("British")
|
||||
static let britishPlexi = PedalType("British Plexi")
|
||||
static let britishJTM = PedalType("British JTM")
|
||||
static let britishBluesbreaker = PedalType("British Bluesbreaker")
|
||||
static let britishMaster = PedalType("British Master")
|
||||
static let britishDual = PedalType("British Dual")
|
||||
static let boutiqueLead = PedalType("Boutique Lead")
|
||||
static let boutiqueOD = PedalType("Boutique OD")
|
||||
static let caliHiGain = PedalType("Cali Hi-Gain")
|
||||
static let command = PedalType("Command")
|
||||
static let citrus = PedalType("Citrus")
|
||||
static let sixtiesCombo = PedalType("Sixties Combo")
|
||||
static let magnaVibrato = PedalType("Magna Vibrato")
|
||||
static let anaheim = PedalType("Anaheim")
|
||||
static let modernHighGain = PedalType("Modern High-Gain")
|
||||
static let chime = PedalType("Chime")
|
||||
static let chimeFifteen = PedalType("Chime 15")
|
||||
static let chimeNormal = PedalType("Chime Normal")
|
||||
static let chimeBaby = PedalType("Chime Baby")
|
||||
static let fullertonReverb = PedalType("Fullerton Reverb")
|
||||
static let fullertonDeluxe = PedalType("Fullerton Deluxe")
|
||||
static let fullertonPrinceton = PedalType("Fullerton Ivy League")
|
||||
static let fullertonDrive = PedalType("Fullerton Drive")
|
||||
static let jazzClean = PedalType("Jazz Clean")
|
||||
static let chimeTopBoost = PedalType("Chime Top Boost")
|
||||
static let neuralAmp = PedalType("Neural Amp")
|
||||
static let overdrive = PedalType("Overdrive")
|
||||
static let distortion = PedalType("Distortion")
|
||||
static let fuzz = PedalType("Fuzz")
|
||||
static let sustainFuzz = PedalType("Sustain Fuzz")
|
||||
static let compressor = PedalType("Compressor")
|
||||
static let limiter = PedalType("Limiter")
|
||||
static let noiseGate = PedalType("Noise Gate")
|
||||
static let cabinet = PedalType("Cabinet")
|
||||
|
||||
// EQ & filter
|
||||
static let graphicEQ = PedalType("Graphic EQ")
|
||||
@@ -64,6 +93,7 @@ public extension PedalType {
|
||||
static let chorus = PedalType("Chorus")
|
||||
static let flanger = PedalType("Flanger")
|
||||
static let vibrato = PedalType("Vibrato")
|
||||
static let vibe = PedalType("Vibe")
|
||||
static let rotary = PedalType("Rotary")
|
||||
static let ringModulator = PedalType("Ring Modulator")
|
||||
static let diffuser = PedalType("Diffuser")
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
// AmpVoicePedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the tube-amp voice pedals — the fixed-voicing amps and the full-surface amps
|
||||
/// (those adding onboard reverb / tremolo / chorus and switches via the hooks below).
|
||||
///
|
||||
/// Each concrete amp fixes one tone-stack ``ToneStackModel`` and adds one signature control, but
|
||||
/// shares the common chain built here:
|
||||
/// ```
|
||||
/// dry → inputShaping(_:) (subclass hook — e.g. bright switch; default identity)
|
||||
/// → TriodeStage(drive: gain) (preamp)
|
||||
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
|
||||
/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity)
|
||||
/// → powerAmpStage(_:) (power amp — two TriodeStage halves blended by
|
||||
/// Bias X; single-stage tone at biasX = 0)
|
||||
/// → shapeVoice(_:) (subclass signature filter)
|
||||
/// → applySag(_:) (shared power-supply Sag droop; identity at sag = 0)
|
||||
/// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, or None for a
|
||||
/// separate cab block; rebuild on change)
|
||||
/// → TriodeStage(bias: 0) → Clip(±1) (output soft-limit + hard safety ceiling — always on)
|
||||
/// ```
|
||||
/// Fully wet (the amp replaces the dry signal); `Level` is the master. Double-width amp-head card.
|
||||
///
|
||||
/// The `tanh` output stage models output-transformer / speaker compression: a real amp has no
|
||||
/// brickwall, and its analog output can't digital-clip. Small signals pass at ~unit gain (clean
|
||||
/// playing largely intact); peaks soft-limit toward ±1, adding gentle output compression. Because
|
||||
/// that soft-limit sits *after* the cab (the overshoot it guards is a digital convolution /
|
||||
/// oversampling artifact, not literal circuit order) and the `tanh`'s own DC-blocker can leave a
|
||||
/// sub-percent overshoot, a final `Clip(±1)` hard-clamps the residue so the amp stage never emits a
|
||||
/// sample past ±1. At the normal master `Level` (≤ 1) that ceiling carries through to the output.
|
||||
///
|
||||
/// Subclasses override ``toneStackModel``, ``summaryText``, ``signatureKnobs``, and
|
||||
/// ``shapeVoice(_:)``, and may set a voice-appropriate default `gain` in their `init`.
|
||||
open class AmpVoicePedal: Pedal {
|
||||
|
||||
// MARK: - Common parameters
|
||||
|
||||
/// Preamp **Gain** dial in `[1, 11]` (yes, it goes to eleven). Mapped to the tube-drive range
|
||||
/// `[1, 30]` through a musical exponential taper — see ``taperedDrive(_:)`` — so low settings give
|
||||
/// fine control and the top of the dial pushes hard into saturation.
|
||||
@UIParam public var gain: Double = 6.27
|
||||
/// Tone-stack bass control in [0, 1].
|
||||
@UIParam public var bass: Double = 0.5
|
||||
/// Tone-stack mid control in [0, 1].
|
||||
@UIParam public var mid: Double = 0.5
|
||||
/// Tone-stack treble control in [0, 1].
|
||||
@UIParam public var treble: Double = 0.6
|
||||
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
|
||||
@UIParam public var cab: Double = 0.0
|
||||
/// Power-amp **Sag** in `[0, 1]`: `0` = stiff (no droop), `1` = heavy power-supply sag/bloom.
|
||||
/// Surfaced in the advanced pop-over, not on the pedal face. See ``applySag(_:)``.
|
||||
@UIParam public var sag: Double = 0.0
|
||||
/// Power-amp **Bias** in `[0, 1]`, mapped to the power-amp `TriodeStage` grid bias. `0.5` = the
|
||||
/// neutral (symmetric) operating point; lower = colder (tighter, more odd harmonics), higher =
|
||||
/// hotter (warmer, more even harmonics). Surfaced in the advanced pop-over. See
|
||||
/// ``powerAmpBiasInput``.
|
||||
@UIParam public var bias: Double = 0.5
|
||||
/// Power-amp **Bias X** (bias balance) in `[0, 1]`, default `0` = balanced. At `0` the power amp
|
||||
/// is a single stage — the shipped tone, exactly. Turning it up spreads the two power-amp
|
||||
/// half-stages' bias operating points and averages them, re-shaping the saturation knee for a
|
||||
/// distinct power-amp character (named after the "bias balance" trim on amps that expose one).
|
||||
/// Surfaced in the advanced pop-over. See `powerAmpStage(_:)`.
|
||||
@UIParam public var biasX: Double = 0.0
|
||||
|
||||
// MARK: - Subclass configuration
|
||||
|
||||
/// The fixed tone-stack model for this amp voice. Subclasses override.
|
||||
open var toneStackModel: ToneStackModel { .fender }
|
||||
/// One-line description. Subclasses override.
|
||||
open var summaryText: String { "Tube amp." }
|
||||
/// The amp's signature knob(s), appended after Gain/Bass/Mid/Treble. Default none.
|
||||
open var signatureKnobs: [PedalKnob] { [] }
|
||||
|
||||
/// Applies the amp's signature post-power-amp shaping (e.g. a bright/presence shelf or a cut
|
||||
/// low-pass). Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The post-power-amp signal.
|
||||
/// - Returns: The shaped signal fed to the cabinet.
|
||||
open func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Shaping applied to the dry input *before* the preamp — e.g. a bright-switch treble lift that
|
||||
/// hits the tubes pre-distortion. Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The dry input signal.
|
||||
/// - Returns: The shaped signal fed into the preamp.
|
||||
open func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Onboard effects inserted *after* the tone stack and *before* the power amp — the slot a
|
||||
/// combo amp's built-in reverb and tremolo occupy. Default: identity. Subclasses override.
|
||||
///
|
||||
/// - Parameter signal: The post-tone-stack signal.
|
||||
/// - Returns: The signal fed into the power-amp stage.
|
||||
open func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
signal
|
||||
}
|
||||
|
||||
/// Depth scale for the shared ``tremolo(_:speed:depth:enabled:)`` helper — at full depth the
|
||||
/// unipolar sine swings over half the normalised range, so the peak gain is `1.0` and the trough
|
||||
/// is `1 − depth`.
|
||||
private static let tremoloDepthScale: Double = 0.5
|
||||
|
||||
/// A unipolar-sine tremolo: `signal ×` an LFO over `[1 − depth·enabled, 1]`. Returns a bit-exact
|
||||
/// pass-through (a constant-`1.0` LFO) when `depth·enabled == 0`, so a zeroed depth or a
|
||||
/// footswitch `enabled = 0` is a true identity. Shared by the combo amps' `onboardEffects(_:)`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - signal: The signal to amplitude-modulate.
|
||||
/// - speed: LFO rate in Hz.
|
||||
/// - depth: Modulation depth in `[0, 1]`.
|
||||
/// - enabled: Footswitch gate (`0` or `1`) multiplied into the depth.
|
||||
/// - Returns: The amplitude-modulated signal.
|
||||
func tremolo(
|
||||
_ signal: any ValidGeneratorInput,
|
||||
speed: any ValidGeneratorInput,
|
||||
depth: any ValidGeneratorInput,
|
||||
enabled: any ValidGeneratorInput
|
||||
) -> any ValidGeneratorInput {
|
||||
let swing: any ValidGeneratorInput = (depth * enabled) * AmpVoicePedal.tremoloDepthScale
|
||||
let lfo: OscSin.Audio = OscSin.Audio(freq: speed, mul: swing, add: 1.0 - swing)
|
||||
return signal * lfo
|
||||
}
|
||||
|
||||
/// Maps a `Master` knob `[0, 1]` to a power-amp drive range — the canonical body of a
|
||||
/// master-volume amp's ``powerAmpDriveInput`` override. Turning Master up drives the power-amp
|
||||
/// stage harder (real master-volume saturation, unlike `level`).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - master: The `Master` knob node (`[0, 1]`).
|
||||
/// - minDrive: Power-amp drive at `master = 0`.
|
||||
/// - maxDrive: Power-amp drive at `master = 1`.
|
||||
/// - Returns: The mapped drive to feed the power-amp stage.
|
||||
func masterDrive(
|
||||
_ master: any ValidGeneratorInput,
|
||||
minDrive: Double,
|
||||
maxDrive: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
LinLin.Audio(master, inLo: 0.0, inHi: 1.0, outLo: minDrive, outHi: maxDrive)
|
||||
}
|
||||
|
||||
/// The preamp gain stage — the (post-`inputShaping`) input driven through the first tube stage
|
||||
/// at `Gain`. Default: one `TriodeStage`. A channel-switching amp overrides this to cascade an
|
||||
/// extra stage on its drive channel (call `super.preampStage(_:)` for the clean stage first).
|
||||
///
|
||||
/// - Parameter signal: The post-`inputShaping` input signal.
|
||||
/// - Returns: The preamp output fed into the tone stack.
|
||||
open func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: preampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Maps a `Gain` / `Drive` dial `[1, 11]` to the tube-drive range `[dialDriveMin, dialDriveMax]`
|
||||
/// through an exponential (musical) taper: `drive = dialDriveMin · (dialDriveMax/dialDriveMin) ^
|
||||
/// ((dial − 1) / 10)`. A live node, so the dial stays a smooth knob. Every amp's preamp and
|
||||
/// drive-channel stage runs its dial through this so `1` is nearly clean, `11` is full saturation,
|
||||
/// and the useful grind spreads across the dial rather than bunching at the bottom.
|
||||
///
|
||||
/// - Parameter dial: A `[1, 11]` Gain/Drive knob node.
|
||||
/// - Returns: The mapped tube drive to feed a `TriodeStage`.
|
||||
func taperedDrive(_ dial: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
LinExp.Audio(dial, inLo: dialMin, inHi: dialMax, outLo: dialDriveMin, outHi: dialDriveMax)
|
||||
}
|
||||
|
||||
/// Drive into the power-amp `TriodeStage`. Defaults to the fixed power-amp drive. Two kinds of
|
||||
/// amp override it: a **master-volume** amp returns a live `Master` knob mapped to a drive range
|
||||
/// (turning Master up pushes the power-amp stage into saturation — the real master-volume
|
||||
/// behaviour, unlike `level`, which only attenuates the finished output); a **lower-headroom
|
||||
/// variant** returns a fixed value *higher* than the default to model an amp that breaks up
|
||||
/// earlier. Either way, higher drive = more power-amp saturation.
|
||||
open var powerAmpDriveInput: any ValidGeneratorInput { powerAmpDrive }
|
||||
|
||||
/// Oversampling factor for the power-amp stage — `2` or `4`. Any amp that drives the power amp
|
||||
/// harder than the default fixed value (a `Master` control, or a lower-headroom variant with a
|
||||
/// higher fixed drive) should override to `4` for more anti-alias headroom, since higher drive
|
||||
/// generates more high-order harmonics. Defaults to `2` (ample for the lightly-driven fixed
|
||||
/// power stage of the standard voices).
|
||||
open var powerAmpOversample: Int { 2 }
|
||||
|
||||
/// Grid bias fed to the power-amp `TriodeStage`, from the live `Bias` knob: `[0, 1]` mapped to
|
||||
/// `[coldPowerAmpBias, hotPowerAmpBias]`. The neutral `bias = 0.5` maps to `0.0`, so the default
|
||||
/// leaves the power-amp stage symmetric (unchanged from the old fixed bias).
|
||||
var powerAmpBiasInput: any ValidGeneratorInput {
|
||||
LinLin.Audio($bias, inLo: 0.0, inHi: 1.0, outLo: coldPowerAmpBias, outHi: hotPowerAmpBias)
|
||||
}
|
||||
|
||||
/// The power-amp stage. **Bias X** (``biasX``) spreads the two `TriodeStage` halves' bias
|
||||
/// operating points to `powerAmpBiasInput ± (biasX · biasXMaxSpread)` and averages them. At
|
||||
/// `biasX = 0` both halves share the base bias, so the average is bit-identical to a single stage
|
||||
/// (the shipped tone); turning `biasX` up widens the spread, re-shaping the saturation character.
|
||||
///
|
||||
/// > Note: a deliberate approximation — a *character* control on the single-ended power-stage
|
||||
/// > model, not a literal push-pull topology (which would re-voice every amp). It reduces to the
|
||||
/// > exact prior tone at `biasX = 0`. Both halves are always built, so an amp pays two oversampled
|
||||
/// > stages even at `biasX = 0` — a smooth, live knob was preferred over a rebuild-on-change
|
||||
/// > single-stage fast path.
|
||||
///
|
||||
/// - Parameter signal: The post-`onboardEffects` signal into the power amp.
|
||||
/// - Returns: The blended power-amp output.
|
||||
func powerAmpStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let imbalance: any ValidGeneratorInput = $biasX * biasXMaxSpread
|
||||
let hotHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput + imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
let coldHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput - imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
return (hotHalf + coldHalf) * powerAmpHalfBlend
|
||||
}
|
||||
|
||||
/// Applies power-supply **Sag**: an `AmplitudeFollower` on `signal` reduces gain as it gets loud
|
||||
/// (droop) and recovers slowly (bloom). `Sag` scales the depth; at `sag = 0` the droop is `0` and
|
||||
/// the gain is a constant `1.0` (an identity multiply), so a sag-less amp is unchanged.
|
||||
///
|
||||
/// The droop gain is clamped to `[sagGainFloor, 1]`: the envelope tracks a post-power-amp,
|
||||
/// post-`shapeVoice` signal that can exceed 1 (Presence/Depth shelves), so an unclamped
|
||||
/// `1 − sag·env` would go negative and phase-invert loud content instead of attenuating it.
|
||||
///
|
||||
/// - Parameter signal: The post-`shapeVoice` signal to apply sag to.
|
||||
/// - Returns: The sagged signal.
|
||||
func applySag(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: signal, attackTime: sagAttackSeconds, releaseTime: sagReleaseSeconds)
|
||||
let sagGain: any ValidGeneratorInput = Clip.Audio(
|
||||
1.0 - ($sag * envelope), lo: sagGainFloor, hi: 1.0)
|
||||
return signal * sagGain
|
||||
}
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
|
||||
private let preampBias: Double = 0.2
|
||||
/// Oversampling factor for the preamp stage (4× — the preamp can be driven hard by `Gain`).
|
||||
let preampOversample: Int = 4
|
||||
/// Grid bias of a cascaded lead/drive `TriodeStage` — a little asymmetry for even-harmonic
|
||||
/// grind. Shared by the channel/master amps' cascaded ``preampStage(_:)`` overrides.
|
||||
let leadBias: Double = 0.15
|
||||
/// Generic `PedalSwitch` off / on values, shared by every amp that publishes switches.
|
||||
let switchOffValue: Double = 0.0
|
||||
let switchOnValue: Double = 1.0
|
||||
/// Gain/Drive dial endpoints and the tube-drive range they taper onto (see ``taperedDrive(_:)``).
|
||||
/// `11` is the top of the dial; `30` is the maximum tube drive it reaches. `dialDriveMin > 0` is
|
||||
/// required by `LinExp`.
|
||||
let dialMin: Double = 1.0
|
||||
let dialMax: Double = 11.0
|
||||
let dialDriveMin: Double = 1.0
|
||||
let dialDriveMax: Double = 30.0
|
||||
/// Fixed power-amp stage drive (gentler than the preamp).
|
||||
private let powerAmpDrive: Double = 1.5
|
||||
/// Power-amp grid bias at `bias = 0` (coldest) and `bias = 1` (hottest). Symmetric about `0`, so
|
||||
/// the neutral `bias = 0.5` maps to `0.0` — the old fixed power-amp bias — leaving every amp's
|
||||
/// default tone unchanged. Modest magnitude so the control colours the harmonics without
|
||||
/// drastically re-voicing the amp.
|
||||
private let coldPowerAmpBias: Double = -0.25
|
||||
private let hotPowerAmpBias: Double = 0.25
|
||||
/// Maximum push-pull bias imbalance at `biasX = 1` — the offset applied oppositely to the two
|
||||
/// power-amp half-stages. Modest so the control colours the harmonics without destabilising the amp.
|
||||
private let biasXMaxSpread: Double = 0.35
|
||||
/// Equal-weight blend of the two power-amp half-stages. `0.5·(hot + cold)` averages them, so at
|
||||
/// `biasX = 0` (identical halves) the result is bit-identical to a single stage.
|
||||
private let powerAmpHalfBlend: Double = 0.5
|
||||
/// Sag envelope-follower attack — moderately fast (the supply starts drooping under load).
|
||||
private let sagAttackSeconds: Double = 0.02
|
||||
/// Sag envelope-follower release — slow, so the sag lingers and blooms back (supply recovery).
|
||||
private let sagReleaseSeconds: Double = 0.30
|
||||
/// Lowest the sag gain can droop to (~-16 dB). Bounds sag depth and — crucially — keeps the gain
|
||||
/// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped
|
||||
/// `1 − sag·env` would go negative and phase-invert loud content instead of drooping.
|
||||
private let sagGainFloor: Double = 0.15
|
||||
private let cabinetMix: Double = 1.0
|
||||
/// Output soft-limit drive. `1.0` gives unit small-signal gain (clean playing untouched) with a
|
||||
/// hard `tanh` asymptote at ±1 — models output-transformer / speaker compression and keeps the
|
||||
/// amp from ever digital-clipping the DAC.
|
||||
private let outputStageDrive: Double = 1.0
|
||||
/// Symmetric output stage (no even-harmonic bias) — a pure `tanh` limiter, not a tube colour.
|
||||
private let outputStageBias: Double = 0.0
|
||||
/// 2× is enough: the cab low-pass already band-limits the signal feeding this stage.
|
||||
private let outputStageOversample: Int = 2
|
||||
/// Absolute digital ceiling. The `tanh` stage does the musical soft-limiting; this hard clamp
|
||||
/// only ever catches the sub-percent overshoot the oversampling filters and DC-blocker can leave
|
||||
/// just above ±1, guaranteeing the amp stage never emits a sample the DAC would clip.
|
||||
private let outputCeiling: Double = 1.0
|
||||
|
||||
let gainRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
let toneRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
/// Range for a signature control that maps [0, 1] (Bright / Presence / Cut amount).
|
||||
let signatureRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Cab selector value for the "None (direct)" stop — no speaker convolution. Placed one past the
|
||||
/// last `CabinetVoice` index so every existing voice keeps its saved index (append-only).
|
||||
static let cabinetBypassValue: Double = Double(CabinetVoice.allCases.count)
|
||||
|
||||
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, voice: CabinetVoice) in
|
||||
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||
}
|
||||
+ [PedalSelectorKnob.Stop(title: "None (direct)", value: cabinetBypassValue)]
|
||||
|
||||
// MARK: - Chrome
|
||||
|
||||
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
/// Amps use a four-wide knob grid for their Gain/Bass/Mid/Treble + signature controls (the card
|
||||
/// width is sized to content — see `PedalView.enclosureWidth`).
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
public override var summary: String { summaryText }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates an amp voice pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - name: Display name (the amp voice, e.g. "California").
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
name: String,
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: name,
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: AmpVoicePedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Gain", node: $gain, range: gainRange),
|
||||
PedalKnob(label: "Bass", node: $bass, range: toneRange),
|
||||
PedalKnob(label: "Mid", node: $mid, range: toneRange),
|
||||
PedalKnob(label: "Treble", node: $treble, range: toneRange),
|
||||
] + signatureKnobs
|
||||
}
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
[
|
||||
PedalSelectorKnob(
|
||||
label: "Cab", node: $cab, stops: AmpVoicePedal.cabStops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
/// Power-amp deep-cut controls, tucked behind the pedal card's advanced pop-over: **Sag**
|
||||
/// (power-supply droop/bloom), **Bias** (power-amp grid-bias operating point), and **Bias X**
|
||||
/// (power-amp bias balance). None is a topology control — all are live nodes that round-trip
|
||||
/// through the rig save format. Order is append-only (persisted positionally in `advancedValues`).
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sag", node: $sag, range: signatureRange),
|
||||
PedalKnob(label: "Bias", node: $bias, range: toneRange),
|
||||
PedalKnob(label: "Bias X", node: $biasX, range: signatureRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet (or None) → output
|
||||
/// soft-limit.
|
||||
///
|
||||
/// > Note: at most one `ConvolutionReverb` runs — only the voice named by the live `cab` selector
|
||||
/// > is instantiated, and the "None (direct)" stop instantiates none. The `cab` selector is
|
||||
/// > `rebuildsOnChange`, so switching cabs (or to/from None) rebuilds the board rather than
|
||||
/// > running every voice at once.
|
||||
///
|
||||
/// The output soft-limit (``outputLimit(_:)``) always runs, cabinet or not, so the ±1 ceiling
|
||||
/// holds even when the cabinet is bypassed for a separate downstream cab block.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The amped, (optionally) cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
cabinetAndLimit(preCabinetCore(dry))
|
||||
}
|
||||
|
||||
/// The mono pre-cabinet core: `inputShaping → preamp → tone stack → onboardEffects → power amp →
|
||||
/// shapeVoice`. Factored out of `effect(_:)` so a stereo (widener) amp can split into a stereo
|
||||
/// stage (e.g. a stereo chorus) between the core and a per-channel ``cabinetAndLimit(_:)``.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The post-power-amp, pre-cabinet mono signal.
|
||||
func preCabinetCore(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let preShaped: any ValidGeneratorInput = inputShaping(dry)
|
||||
let preamp: any ValidGeneratorInput = preampStage(preShaped)
|
||||
let toned: ToneStack = ToneStack(
|
||||
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
|
||||
let processed: any ValidGeneratorInput = onboardEffects(toned)
|
||||
let powerAmp: any ValidGeneratorInput = powerAmpStage(processed)
|
||||
return applySag(shapeVoice(powerAmp))
|
||||
}
|
||||
|
||||
/// True when the `Cab` selector is on the "None (direct)" stop — the amp emits its limited
|
||||
/// power-amp signal with **no** speaker convolution, so the player can place a separate cabinet
|
||||
/// block (the standalone `Cabinet` pedal, or a future IR loader) downstream. Read at board-build
|
||||
/// time; the selector is `rebuildsOnChange`, so toggling it rebuilds the graph.
|
||||
///
|
||||
/// > Warning: with no cabinet, the amp sounds raw and fizzy (the power-amp `tanh` with no speaker
|
||||
/// > low-pass) — expected; a cabinet is what tames the top end.
|
||||
var isCabinetBypassed: Bool {
|
||||
guard cab.isFinite else { return false }
|
||||
// Clamp in Double space before converting: a huge finite `cab` (from a corrupted/hand-edited
|
||||
// rig) would otherwise trap `Int(_:)` — same defense as `CabinetVoice.voice(atSelectorValue:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(cab, 0.0), Double(CabinetVoice.allCases.count))
|
||||
return Int(bounded.rounded()) >= CabinetVoice.allCases.count
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: cabinet convolver (or a straight pass at the "None"
|
||||
/// stop) → `tanh` soft-limit → `Clip(±1)` safety clamp. Applied once in mono, or once per channel
|
||||
/// by a widener amp.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The (optionally) cab-convolved, soft-limited, ceiling-clamped signal.
|
||||
func cabinetAndLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
outputLimit(cabinet(signal))
|
||||
}
|
||||
|
||||
/// The selected `CabinetVoice` speaker convolver, or `signal` unchanged when the `Cab` selector
|
||||
/// is on "None (direct)". Only the voice named by the live `cab` selector is instantiated, so at
|
||||
/// most one `ConvolutionReverb` runs.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The cab-convolved signal, or `signal` unchanged when the cabinet is bypassed.
|
||||
func cabinet(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
guard !isCabinetBypassed else { return signal }
|
||||
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cab)
|
||||
return ConvolutionReverb.Audio(
|
||||
input: signal,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate),
|
||||
mix: cabinetMix
|
||||
)
|
||||
}
|
||||
|
||||
/// The output soft-limit + hard `Clip(±1)` safety ceiling — **always** applied on the amp,
|
||||
/// cabinet or not, so the ±1 guarantee holds even at the "None (direct)" stop.
|
||||
///
|
||||
/// The `TriodeStage(bias: 0)` is a symmetric `tanh` output limiter: cab convolution and signature
|
||||
/// shelves can push peaks past ±1, which a real analog output soft-compresses rather than
|
||||
/// hard-clips. Unit small-signal gain keeps clean tones intact; peaks soft-limit toward ±1. The
|
||||
/// trailing `Clip(±1)` hard-clamps the sub-percent overshoot the `tanh`'s DC-blocker and the
|
||||
/// halfband filters can leave, so no sample can clip the DAC.
|
||||
///
|
||||
/// - Parameter signal: The (optionally cab-convolved) signal for one channel.
|
||||
/// - Returns: The soft-limited, ceiling-clamped signal.
|
||||
func outputLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let softLimited: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: outputStageDrive,
|
||||
bias: outputStageBias,
|
||||
oversample: outputStageOversample
|
||||
)
|
||||
return Clip.Audio(softLimited, lo: -outputCeiling, hi: outputCeiling)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// AnaheimAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American **hybrid combo** — the Anaheim voice (Music Man lineage): a solid-state-flavoured
|
||||
/// preamp into a tube power stage, with huge clean headroom, a **Bright** switch, a **Deep**
|
||||
/// low-end switch, and a built-in **Limiter**.
|
||||
///
|
||||
/// Distinct from the all-tube voices: the preamp stage runs symmetric (grid `bias 0`) — no
|
||||
/// even-harmonic tube warmth, for the cleaner/more clinical solid-state character — and a
|
||||
/// `LookAheadLimiter` (the amp's onboard limiter) can be switched into the output.
|
||||
///
|
||||
/// > Note: the aggressive hard-knee solid-state clipping when pushed is approximated here by the
|
||||
/// > symmetric preamp + high headroom; a true oversampled hard-clipper is a Lyrebird 1.7.x follow-up.
|
||||
public final class AnaheimAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Deep switch: `0` = flat, `1` = low-end resonance boost engaged.
|
||||
@UIParam public var deep: Double = 0.0
|
||||
/// Limiter footswitch: `1` = the built-in output limiter is engaged, `0` = bypassed.
|
||||
@UIParam public var limiter: Double = 1.0
|
||||
|
||||
/// Symmetric preamp bias (solid-state character — no even-harmonic tube warmth).
|
||||
private let ssPreampBias: Double = 0.0
|
||||
private let brightFreqHz: Double = 3200.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 1.0
|
||||
private let deepFreqHz: Double = 100.0
|
||||
private let deepMaxGainDb: Double = 6.0
|
||||
private let deepSlope: Double = 0.7
|
||||
/// Limiter ceiling when engaged — below full scale, so it actually tames peaks (a peak
|
||||
/// compressor, the amp's built-in limiter); when bypassed the ceiling is raised so it never acts.
|
||||
private let limiterOnCeiling: Double = 0.5
|
||||
private let limiterOffCeiling: Double = 10.0
|
||||
private let limiterLookAhead: Double = 0.005
|
||||
private let limiterRelease: Double = 0.050
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American hybrid combo — solid-state-flavoured clean, huge headroom, Bright / Deep / Limiter."
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Deep",
|
||||
node: $deep,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Limiter",
|
||||
node: $limiter,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates an Anaheim amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Anaheim", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.23 // huge clean headroom
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Symmetric (solid-state-flavoured) preamp stage — `bias 0`, no even-harmonic tube warmth.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: ssPreampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// The built-in limiter, gated by the Limiter switch — placed *before* the power-amp stage (so
|
||||
/// it limits the driven preamp/tone-stack signal, which can exceed the ceiling, rather than a
|
||||
/// signal the power-amp `tanh` has already bounded). Off raises the ceiling so it never acts.
|
||||
///
|
||||
/// > Note: the `LookAheadLimiter` stays in the chain in both states (only its ceiling changes),
|
||||
/// > so the amp carries its ~5 ms look-ahead latency whether or not the Limiter is engaged —
|
||||
/// > a constant, not something the switch toggles.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let ceiling: LinLin.Audio = LinLin.Audio(
|
||||
$limiter, inLo: 0.0, inHi: 1.0, outLo: limiterOffCeiling, outHi: limiterOnCeiling)
|
||||
return LookAheadLimiter(
|
||||
in: signal,
|
||||
maxAmplitude: ceiling,
|
||||
lookAheadTime: limiterLookAhead,
|
||||
releaseTime: limiterRelease,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
}
|
||||
|
||||
/// Deep low-shelf (gated by the Deep switch), post power amp.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let deepGainDb: any ValidGeneratorInput = $deep * deepMaxGainDb
|
||||
return RBJLowShelf.Audio(input: signal, freq: deepFreqHz, gain: deepGainDb, slope: deepSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// BoutiqueAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the boutique high-gain amps (Boutique Lead / Boutique OD) — a footswitchable
|
||||
/// Clean/Lead channel into a master-volume power section, with **Presence** (top-end) and **Depth**
|
||||
/// (low-end resonance) shaping.
|
||||
///
|
||||
/// The Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||
/// `rebuildsOnChange` **Channel** switch, so only the selected channel is built. `Master` drives the
|
||||
/// power-amp stage via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``. Concrete voices override
|
||||
/// ``AmpVoicePedal/toneStackModel`` and gain defaults, and may extend the shaping (e.g. a mid boost).
|
||||
open class BoutiqueAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of top-end lift.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Depth amount in [0, 1] → 0…`depthMaxGainDb` of low-end resonance lift.
|
||||
@UIParam public var depth: Double = 0.3
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.77
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let presenceSlope: Double = 0.7
|
||||
private let depthFreqHz: Double = 120.0
|
||||
private let depthMaxGainDb: Double = 6.0
|
||||
private let depthSlope: Double = 0.7
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: signatureRange),
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Presence (top-end high-shelf) then Depth (low-end low-shelf), post power amp.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let presenceGainDb: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
let presenced: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||||
input: signal, freq: presenceFreqHz, gain: presenceGainDb, slope: presenceSlope)
|
||||
let depthGainDb: LinLin.Audio = LinLin.Audio(
|
||||
$depth, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: depthMaxGainDb)
|
||||
return RBJLowShelf.Audio(
|
||||
input: presenced, freq: depthFreqHz, gain: depthGainDb, slope: depthSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// BoutiqueLeadAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Boutique **super-lead** — the SLO-style high-gain singing lead: aggressive cascaded overdrive on
|
||||
/// the Lead channel, a Master volume, and Presence / Depth power-amp shaping.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` fixed to the Soldano tone stack, defaulting to a hot Lead drive.
|
||||
public final class BoutiqueLeadAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .soldano }
|
||||
public override var summaryText: String {
|
||||
"Boutique super-lead — aggressive cascaded high gain with Master, Presence, and Depth."
|
||||
}
|
||||
|
||||
/// Creates a Boutique Lead amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique Lead", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
drive = 8.76 // hot singing lead
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// BoutiqueODAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Boutique **overdrive special** — the smooth D-style voice: a Fender-derived clean plus a fluid
|
||||
/// overdrive channel, a **Mid Boost** switch, a Master volume, and Presence / Depth shaping.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` on the smoother American tone stack. The Mid Boost adds a midrange peak
|
||||
/// (the D-style "PAB" character) on top of the base Presence/Depth shaping.
|
||||
public final class BoutiqueODAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
/// Mid Boost switch: `0` = flat, `1` = midrange peak engaged.
|
||||
@UIParam public var midBoost: Double = 0.0
|
||||
|
||||
private let midBoostFreqHz: Double = 650.0
|
||||
private let midBoostMaxGainDb: Double = 6.0
|
||||
private let midBoostQ: Double = 1.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"Boutique overdrive special — smooth D-style OD with a Mid Boost, Master, Presence, and Depth."
|
||||
}
|
||||
|
||||
/// Base Channel switch plus the Mid Boost switch (compose `super`).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Mid Boost",
|
||||
node: $midBoost,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Boutique OD amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique OD", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
drive = 7.77
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// The base Presence/Depth shaping, plus a Mid Boost peak when the switch is engaged (its gain
|
||||
/// scales by the switch value, so Off is a true identity, live, no rebuild).
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
|
||||
let midGainDb: any ValidGeneratorInput = $midBoost * midBoostMaxGainDb
|
||||
return RBJPeakingEQ.Audio(input: shaped, freq: midBoostFreqHz, gain: midGainDb, q: midBoostQ)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// BritishAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British-voiced amp (mid-forward crunch) with a **Presence** lift and a **Master** volume.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. The
|
||||
/// Master control drives the power-amp stage (via ``AmpVoicePedal/powerAmpDriveInput``), so raising
|
||||
/// it adds power-amp saturation — turn `Gain` up for preamp grind and use `Master` to set how hard
|
||||
/// that hits the power amp, the classic master-volume interplay.
|
||||
public final class BritishAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`]. The
|
||||
/// default maps to ≈1.5 drive — the amp's prior fixed power-amp drive — so the out-of-box tone
|
||||
/// is unchanged; turn it up for power-amp saturation.
|
||||
@UIParam public var master: Double = 0.22
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let shelfSlope: Double = 0.7
|
||||
/// Power-amp drive at `master = 0` — barely driven (cleanest power stage).
|
||||
private let masterMinDrive: Double = 0.5
|
||||
/// Power-amp drive at `master = 1` — hard into power-amp saturation.
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var summaryText: String {
|
||||
"British crunch — forward mids and bite, with Presence and a Master volume."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
|
||||
/// 4× oversampling on the power-amp stage — Master can drive it well past the fixed value used
|
||||
/// by the non-master amps, so the extra anti-alias headroom keeps the added harmonics clean.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Creates a British amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.77 // crunch-leaning default
|
||||
cab = 1.0 // default to the British 4×12 cab
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: shelfSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// BritishBluesbreakerAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British non-master **2×12 combo** with onboard **tremolo** — the bluesbreaker voice: lower-power
|
||||
/// Marshall crunch that cleans up with the guitar volume, plus a bias-tremolo.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that overlays a tremolo in the onboard-effects
|
||||
/// slot, with Speed / Intensity knobs and a Tremolo footswitch.
|
||||
public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 4.0
|
||||
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||
@UIParam public var intensity: Double = 0.0
|
||||
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||
@UIParam public var tremoloEnabled: Double = 1.0
|
||||
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British 2×12 combo — bluesbreaker crunch with tremolo, Presence, and a Bright switch."
|
||||
}
|
||||
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// The base Bright switch plus a Tremolo footswitch (compose `super` so Bright stays in sync).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Tremolo",
|
||||
node: $tremoloEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a British Bluesbreaker amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Bluesbreaker", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12 voice (combo 2×12 tonally close enough among our cabs)
|
||||
}
|
||||
|
||||
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Identity when depth·enabled == 0.
|
||||
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// BritishComboAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Shared base for the British (Marshall-voiced) amps — the `.marshall` tone stack plus a common
|
||||
/// **Presence** lift (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf).
|
||||
///
|
||||
/// The non-master voices (Plexi / JTM / Bluesbreaker) run a fixed power-amp drive — loudness comes
|
||||
/// from cranking `Gain`; the Bluesbreaker additionally overlays tremolo. The master-volume voices
|
||||
/// (British Master / British Dual) subclass this too, adding a `Master` (via
|
||||
/// ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``) and a cascaded lead ``preampStage(_:)``.
|
||||
///
|
||||
/// Distinct from ``BritishAmpPedal``, the standalone master-volume crunch voice.
|
||||
open class BritishComboAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||
@UIParam public var presence: Double = 0.4
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
|
||||
private let presenceFreqHz: Double = 4500.0
|
||||
private let presenceMaxGainDb: Double = 8.0
|
||||
private let presenceSlope: Double = 0.7
|
||||
private let brightFreqHz: Double = 3500.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 0.7
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[PedalKnob(label: "Presence", node: $presence, range: signatureRange)]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Presence: a post-power-amp high-shelf lift, `[0, 1]` → `[0, presenceMaxGainDb]` dB.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: presenceSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// BritishDualAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **dual-channel master-volume** — the 900/DSL-era Marshall: a footswitchable Clean/Lead
|
||||
/// channel, a Master volume, spring reverb, Presence, and a Bright switch. The modern high-gain
|
||||
/// British workhorse.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that adds a `rebuildsOnChange` **Channel** switch —
|
||||
/// the Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||
/// `Master` (power-amp drive), and spring reverb in the onboard-effects slot.
|
||||
public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.2
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
/// Channel-select threshold: `>= this` selects the Lead channel.
|
||||
private let channelThreshold: Double = 0.5
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British dual-channel master-volume — Clean/Lead switching, reverb, Presence, and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Creates a British Dual amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// BritishJTMAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British non-master **JTM** — the earliest Marshall, Bassman-derived: warmer and lower-gain than
|
||||
/// the plexi Super Lead, a rounder blues-rock crunch.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` with lower gain and a slightly darker top end.
|
||||
public final class BritishJTMAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
public override var summaryText: String {
|
||||
"British non-master combo — warm, lower-gain JTM crunch with Presence and Bright."
|
||||
}
|
||||
|
||||
/// Creates a British JTM amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British JTM", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73 // warmer, lower-gain than the plexi
|
||||
treble = 0.5 // a shade rounder on top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// BritishMasterAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **master-volume lead** — the 800-series single-channel hot-rodded Marshall: a cascaded
|
||||
/// two-stage preamp for singing lead gain, a Master volume, Presence, and a Bright switch.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) whose ``preampStage(_:)`` cascades a second gain
|
||||
/// stage — both driven by `Gain`, so one knob sets the whole preamp grind — and whose `Master`
|
||||
/// drives the power-amp stage (via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``).
|
||||
public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British master-volume lead — cascaded 800-series gain with Presence, Master, and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [PedalKnob(label: "Master", node: $master, range: signatureRange)]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Creates a British Master amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Master", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73 // cascaded, so already a hot lead at moderate Gain
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// Cascaded two-stage preamp: the base stage, then a second `TriodeStage` also driven by `Gain`.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let stage1: any ValidGeneratorInput = super.preampStage(signal)
|
||||
return TriodeStage(input: stage1, drive: taperedDrive($gain), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// BritishPlexiAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British non-master **Super Lead** — the classic plexi-panel stack: big, loud, no master volume,
|
||||
/// clean-ish until cranked and then a singing midrange roar.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` with higher gain and the 4×12 cab. Presence + Bright; loudness and
|
||||
/// breakup both come from `Gain`.
|
||||
public final class BritishPlexiAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
public override var summaryText: String {
|
||||
"British non-master stack — plexi roar with Presence and a Bright switch."
|
||||
}
|
||||
|
||||
/// Creates a British Plexi amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Plexi", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.72 // clean-ish until pushed
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
// CabinetPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Speaker-cabinet simulation via impulse-response convolution.
|
||||
///
|
||||
/// Convolves the input against a cabinet impulse response using Lyrebird's partitioned FFT
|
||||
/// convolver (`ConvolutionReverb`). A single convolver is built at `build()` time for the voice the
|
||||
/// ``cabinet`` selector currently names (each voicing's IR is synthesized in code — our own MIT
|
||||
/// content, see ``CabinetIRFactory``). Changing the selector asks the host to rebuild the board so
|
||||
/// only the selected voice's convolver ever runs — one partitioned-FFT convolver, not one per
|
||||
/// voice. The selection round-trips through the rig save format like every other pedal.
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → ConvolutionReverb(ir: cab voice + mic voice) (one IR — mic colour baked in)
|
||||
/// ├─ (optional) ConvolutionReverb(ir: cab + mic B) → DelayLine(Mic Offset) (parallel 2nd mic)
|
||||
/// │ blended A·(1−Mic Blend) + Bdelayed·(Mic Blend) (comb of two mics)
|
||||
/// → RBJHighShelf (Position) → RBJLowShelf (Proximity) (live mic-placement shelves)
|
||||
/// → LookAheadLimiter(±1) (transparent peak safety)
|
||||
/// → mono out
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry mix and bypass are handled by the `Pedal` base class.
|
||||
///
|
||||
/// > Note: Loading a user-supplied captured `.wav` cab IR is a planned follow-up (it needs a
|
||||
/// > persisted file-path field the current `PedalState` doesn't carry); this first version ships
|
||||
/// > the built-in voicings only.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - `cabinet`: Selects the built-in cabinet voicing (stepped selector over ``CabinetVoice``).
|
||||
/// - `mic`: Selects the microphone voicing baked into the IR (stepped selector over ``MicVoice``).
|
||||
/// - `micB`: Optional second mic (stepped selector over ``MicVoice``; No Mic = single mic). When set,
|
||||
/// a parallel convolver blends in for the classic two-mic technique.
|
||||
/// - `position` / `proximity`: Live mic-placement shelves in the advanced pop-over (on-axis ↔ edge,
|
||||
/// distant ↔ close).
|
||||
/// - `micBlend` / `micOffset`: Advanced pop-over — the A/B balance and the mic-B time offset (comb
|
||||
/// spacing) when a second mic is engaged.
|
||||
public final class CabinetPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Speaker-cabinet impulse-response convolution with selectable built-in voicings."
|
||||
}
|
||||
|
||||
/// Four-wide card (same as the amps), so the Cab / Mic / Mic B selector captions — cabinet and
|
||||
/// mic voice names — stay readable rather than crowding.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Selected cabinet voicing as an index into ``CabinetVoice/allCases``. Snaps to integer
|
||||
/// stops via the ``cabinet`` selector; read at board-build time by `effect(_:)`, which
|
||||
/// instantiates only that voice's convolver (the selector is `rebuildsOnChange`).
|
||||
@UIParam public var cabinet: Double = 0.0
|
||||
/// Selected microphone voicing as an index into ``MicVoice/allCases`` (`0` = No Mic). Baked into
|
||||
/// the same IR as the cab voice, so it costs nothing extra at render time. `rebuildsOnChange`.
|
||||
@UIParam public var mic: Double = 0.0
|
||||
/// Mic **Position** on the speaker in `[0, 1]`: `0` = on-axis (bright, centred on the dust cap),
|
||||
/// `1` = cone edge / off-axis (progressively darker). A live high-shelf cut, so it is a smooth
|
||||
/// knob (no rebake); `0` is a bit-exact 0 dB identity. Surfaced in the advanced pop-over.
|
||||
@UIParam public var position: Double = 0.0
|
||||
/// Mic **Proximity** in `[0, 1]`: `0` = distant (flat lows), `1` = close-mic'd (proximity-effect
|
||||
/// low-end boost). A live low-shelf boost, so it is a smooth knob (no rebake); `0` is a bit-exact
|
||||
/// 0 dB identity. Surfaced in the advanced pop-over.
|
||||
@UIParam public var proximity: Double = 0.0
|
||||
/// Second microphone voicing as an index into ``MicVoice/allCases`` (`0` = No Mic → single mic,
|
||||
/// the default). When engaged, a **second** convolver runs in parallel and blends with the first
|
||||
/// (the classic two-mic technique). `rebuildsOnChange` — toggling it adds/removes the convolver.
|
||||
@UIParam public var micB: Double = 0.0
|
||||
/// **Mic Blend** in `[0, 1]` between mic A (`0`) and mic B (`1`); `0.5` = equal. Only active when
|
||||
/// ``micB`` ≠ No Mic. A live blend, so it is a smooth knob. Surfaced in the advanced pop-over.
|
||||
@UIParam public var micBlend: Double = 0.5
|
||||
/// **Mic Offset** in `[0, 1]`: the relative time offset of mic B, `0` = aligned, `1` = the maximum
|
||||
/// spacing. A short live delay on mic B; summing it with the aligned mic A produces the comb
|
||||
/// filtering of two spaced mics. Only active when ``micB`` ≠ No Mic. Surfaced in the pop-over.
|
||||
///
|
||||
/// > Note: intended as a **set-and-leave** spacing control (dial in the comb, then play). It is a
|
||||
/// > live delay, so *sweeping* it during playback moves the comb — a flanger-like effect rather
|
||||
/// > than a static mic position.
|
||||
@UIParam public var micOffset: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the cabinet sits in-line.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Convolution is taken fully wet here; the `Pedal` base class provides the user wet/dry mix.
|
||||
private let convolutionMix: Double = 1.0
|
||||
|
||||
/// Output peak ceiling. A true look-ahead limiter holds `|output| ≤` this, taming the peaks a
|
||||
/// speaker convolution can push past ±1 (an analog cab can't digital-clip) while leaving signals
|
||||
/// below the ceiling **untouched** — no always-on saturation of clean, below-ceiling material.
|
||||
private let outputCeiling: Double = 1.0
|
||||
/// Limiter look-ahead / output delay. Short (2 ms) so the added latency is negligible in-line
|
||||
/// while still catching the brief convolution-overshoot transients.
|
||||
private let limiterLookAheadSeconds: Double = 0.002
|
||||
/// Limiter gain-release time constant — slow enough not to modulate sustained low frequencies.
|
||||
private let limiterReleaseSeconds: Double = 0.050
|
||||
|
||||
/// Mic-position high-shelf corner (Hz) and its maximum cut (dB) at the cone edge (`position = 1`).
|
||||
/// Moving off-axis toward the cone rolls the top off; on-axis (`0`) is a 0 dB identity.
|
||||
private let positionShelfFreqHz: Double = 3500.0
|
||||
private let positionMaxCutDb: Double = 9.0
|
||||
/// Mic-proximity low-shelf corner (Hz) and its maximum boost (dB) up close (`proximity = 1`) —
|
||||
/// the proximity-effect bass lift; distant (`0`) is a 0 dB identity.
|
||||
private let proximityShelfFreqHz: Double = 150.0
|
||||
private let proximityMaxBoostDb: Double = 6.0
|
||||
/// Shelf slope for the position / proximity live shelves (gentle, like the amp shelves).
|
||||
private let placementShelfSlope: Double = 0.7
|
||||
/// `[0, 1]` range for the Position / Proximity / Mic Blend / Mic Offset pop-over knobs.
|
||||
private static let placementRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
/// Maximum mic-B time offset (seconds) at `micOffset = 1` — a spaced-mic offset (~0.5 m of path
|
||||
/// difference). Sets both the delay-line size and the comb range: the first notch is at
|
||||
/// `1 / (2·offset)` Hz, so full offset places it near 330 Hz (`micOffset = 0` = aligned, no comb).
|
||||
private let maxMicOffsetSeconds: Double = 0.0015
|
||||
|
||||
/// Selector stops, one per ``CabinetVoice`` in `allCases` order (value == index).
|
||||
private static let voiceStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, voice: CabinetVoice) in
|
||||
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||
}
|
||||
|
||||
/// Selector stops, one per ``MicVoice`` in `allCases` order (value == index).
|
||||
private static let micStops: [PedalSelectorKnob.Stop] = MicVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, mic: MicVoice) in
|
||||
PedalSelectorKnob.Stop(title: mic.displayName, value: Double(index))
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a cabinet pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Cabinet",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: CabinetPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
[
|
||||
PedalSelectorKnob(
|
||||
label: "Cab", node: $cabinet, stops: CabinetPedal.voiceStops, rebuildsOnChange: true),
|
||||
PedalSelectorKnob(
|
||||
label: "Mic", node: $mic, stops: CabinetPedal.micStops, rebuildsOnChange: true),
|
||||
PedalSelectorKnob(
|
||||
label: "Mic B", node: $micB, stops: CabinetPedal.micStops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
/// Mic-placement + dual-mic deep-cut controls, tucked behind the pedal card's advanced pop-over:
|
||||
/// **Position** (on-axis ↔ cone edge), **Proximity** (distance / bass lift), and — when a second
|
||||
/// mic is engaged — **Mic Blend** (A/B) and **Mic Offset** (comb spacing). All live (not baked),
|
||||
/// so they are smooth knobs; none is a topology control. Persisted positionally in
|
||||
/// `advancedValues` (append-only order).
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Position", node: $position, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Proximity", node: $proximity, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Mic Blend", node: $micBlend, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Mic Offset", node: $micOffset, range: CabinetPedal.placementRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Convolves the dry signal against the single selected cabinet + mic IR, then soft-limits.
|
||||
///
|
||||
/// Only the voice/mic named by the live selectors is baked, so exactly one partitioned-FFT
|
||||
/// convolver runs; the mic colour is folded into that same IR at no extra render cost. Changing
|
||||
/// either selector triggers a board rebuild (both are `rebuildsOnChange`). Synthesizing the short
|
||||
/// IR happens off the RT thread in `build()`.
|
||||
///
|
||||
/// The closing `LookAheadLimiter` is a transparent peak limiter on the **wet** convolution
|
||||
/// output: a speaker cab is analog and can't digital-clip, and the convolution can push peaks
|
||||
/// past ±1. Unlike a `tanh` saturator, a look-ahead limiter leaves signals **below** the ceiling
|
||||
/// bit-for-bit untouched (no coloration of clean, below-ceiling material) and only pulls gain
|
||||
/// down for the brief peaks that would exceed ±1. It adds a short (2 ms) output delay. At the
|
||||
/// default fully-wet `mix` this bounds the pedal output to ±1 (e.g. a decoupled amp → cabinet
|
||||
/// chain); a partial `mix` re-introduces the dry signal via the base class's equal-power
|
||||
/// crossfade, so at intermediate settings final level is the board's output-stage concern. The
|
||||
/// 2 ms wet delay is uniform at the default fully-wet mix; at a partial mix it sits against the
|
||||
/// undelayed dry path, so a slight comb is expected there (a cab is normally run fully wet).
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The cabinet-convolved, mic-voiced, peak-limited mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let sr: Double = sampleRate
|
||||
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cabinet)
|
||||
let micVoice: MicVoice = MicVoice.voice(atSelectorValue: mic)
|
||||
let convolved: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
input: dry,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, mic: micVoice, sampleRate: sr),
|
||||
mix: convolutionMix
|
||||
)
|
||||
let mixed: any ValidGeneratorInput = blendSecondMic(dry: dry, primary: convolved, voice: voice, sr: sr)
|
||||
let placed: any ValidGeneratorInput = applyPlacement(mixed)
|
||||
return LookAheadLimiter(
|
||||
in: placed,
|
||||
maxAmplitude: outputCeiling,
|
||||
lookAheadTime: limiterLookAheadSeconds,
|
||||
releaseTime: limiterReleaseSeconds,
|
||||
sampleRate: sr
|
||||
)
|
||||
}
|
||||
|
||||
/// Blends a second microphone into the primary convolution when ``micB`` ≠ No Mic — the classic
|
||||
/// two-mic technique. A parallel convolver (same cab voice, mic B's IR) is delayed by up to
|
||||
/// ``maxMicOffsetSeconds`` (``micOffset``) and summed with the aligned primary at the ``micBlend``
|
||||
/// balance; the time offset between the two coherent copies produces comb filtering. When ``micB``
|
||||
/// is No Mic (the default) the primary is returned unchanged — no second convolver is built, so
|
||||
/// the single-mic path costs exactly one convolution and is bit-identical to before this feature.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - dry: The dry input (fed to the second convolver).
|
||||
/// - primary: The primary (mic A) convolution output.
|
||||
/// - voice: The cabinet voice (shared by both mics).
|
||||
/// - sr: Engine sample rate.
|
||||
/// - Returns: The single- or dual-mic blended signal.
|
||||
private func blendSecondMic(
|
||||
dry: any ValidGeneratorInput,
|
||||
primary: any ValidGeneratorInput,
|
||||
voice: CabinetVoice,
|
||||
sr: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
let micBVoice: MicVoice = MicVoice.voice(atSelectorValue: micB)
|
||||
guard micBVoice != .off else { return primary }
|
||||
let secondary: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
input: dry,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, mic: micBVoice, sampleRate: sr),
|
||||
mix: convolutionMix
|
||||
)
|
||||
let delaySeconds: LinLin.Audio = LinLin.Audio(
|
||||
$micOffset, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: maxMicOffsetSeconds)
|
||||
let delayedSecondary: DelayLine = DelayLine(
|
||||
input: secondary, maxDelay: maxMicOffsetSeconds, delay: delaySeconds, sampleRate: sr)
|
||||
// Coherent (same-source) mics sum linearly: A·(1−blend) + Bdelayed·blend.
|
||||
return primary * (1.0 - $micBlend) + delayedSecondary * $micBlend
|
||||
}
|
||||
|
||||
/// Applies the live mic-placement shelves to the convolved signal: a **Position** high-shelf that
|
||||
/// rolls the top off as the mic moves off-axis toward the cone edge, then a **Proximity**
|
||||
/// low-shelf that lifts the low end as the mic moves closer. Both map their knob `[0, 1]` to a
|
||||
/// shelf gain in dB with `0` → `0` dB, so at the default (`0, 0`) each shelf is a bit-exact
|
||||
/// identity and the cabinet sounds exactly as it did before placement existed.
|
||||
///
|
||||
/// - Parameter signal: The (single- or dual-mic) convolved signal.
|
||||
/// - Returns: The placement-shaped signal.
|
||||
private func applyPlacement(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let positionCutDb: LinLin.Audio = LinLin.Audio(
|
||||
$position, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: -positionMaxCutDb)
|
||||
let positioned: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||||
input: signal, freq: positionShelfFreqHz, gain: positionCutDb, slope: placementShelfSlope)
|
||||
let proximityBoostDb: LinLin.Audio = LinLin.Audio(
|
||||
$proximity, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: proximityMaxBoostDb)
|
||||
return RBJLowShelf.Audio(
|
||||
input: positioned, freq: proximityShelfFreqHz, gain: proximityBoostDb, slope: placementShelfSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// CaliHiGainAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// California **Mark-series high-gain** — the cascaded lead voice defined by its onboard **5-band
|
||||
/// graphic EQ**: the sliders sculpt the famous scooped "V" lead tone on top of the amp's own gain.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` (Clean/Lead channel, Master, Presence, Depth) that adds a graphic-EQ bank
|
||||
/// in ``shapeVoice(_:)`` — a low shelf, three peaks, and a high shelf, each a dB fader — cascaded
|
||||
/// after the base Presence/Depth shaping. Defaults to a gentle V.
|
||||
public final class CaliHiGainAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
/// Graphic-EQ band gains in dB, range [-12, 12]. Defaults form a mild scooped "V" — the
|
||||
/// Mark-series signature.
|
||||
/// 80 Hz low-shelf gain in dB.
|
||||
@UIParam public var eq80: Double = 2.0
|
||||
/// 240 Hz peaking gain in dB.
|
||||
@UIParam public var eq240: Double = 0.0
|
||||
/// 750 Hz peaking gain in dB (the mid-scoop band).
|
||||
@UIParam public var eq750: Double = -5.0
|
||||
/// 2.2 kHz peaking gain in dB.
|
||||
@UIParam public var eq2200: Double = 0.0
|
||||
/// 6.6 kHz high-shelf gain in dB.
|
||||
@UIParam public var eq6600: Double = 3.0
|
||||
|
||||
private let eq80Freq: Double = 80.0
|
||||
private let eq240Freq: Double = 240.0
|
||||
private let eq750Freq: Double = 750.0
|
||||
private let eq2200Freq: Double = 2200.0
|
||||
private let eq6600Freq: Double = 6600.0
|
||||
/// Shelf slope for the outer graphic-EQ bands.
|
||||
private let eqShelfSlope: Double = 1.0
|
||||
/// Peaking-band Q — moderate bandwidth so adjacent graphic-EQ bands overlap smoothly.
|
||||
private let eqPeakQ: Double = 0.9
|
||||
private let bandGainRange: ClosedRange<Double> = -12.0 ... 12.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .mesa }
|
||||
public override var summaryText: String {
|
||||
"California Mark-series high gain with an onboard 5-band graphic EQ (scooped-V lead)."
|
||||
}
|
||||
|
||||
/// The five graphic-EQ bands as vertical faders (dB), rendered as a slider bank.
|
||||
public override var effectSliders: [PedalSlider] {
|
||||
[
|
||||
PedalSlider(label: "80", node: $eq80, range: bandGainRange),
|
||||
PedalSlider(label: "240", node: $eq240, range: bandGainRange),
|
||||
PedalSlider(label: "750", node: $eq750, range: bandGainRange),
|
||||
PedalSlider(label: "2.2k", node: $eq2200, range: bandGainRange),
|
||||
PedalSlider(label: "6.6k", node: $eq6600, range: bandGainRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Cali Hi-Gain amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Cali Hi-Gain", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
drive = 9.15 // hot Mark-style lead
|
||||
cab = 1.0 // British 4×12 — tight and aggressive
|
||||
}
|
||||
|
||||
/// Base Presence/Depth shaping, then the 5-band graphic EQ (low shelf → 3 peaks → high shelf),
|
||||
/// each band's gain in dB from its fader.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
|
||||
let low: RBJLowShelf.Audio = RBJLowShelf.Audio(
|
||||
input: shaped, freq: eq80Freq, gain: $eq80, slope: eqShelfSlope)
|
||||
let lowMid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: low, freq: eq240Freq, gain: $eq240, q: eqPeakQ)
|
||||
let mid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: lowMid, freq: eq750Freq, gain: $eq750, q: eqPeakQ)
|
||||
let highMid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: mid, freq: eq2200Freq, gain: $eq2200, q: eqPeakQ)
|
||||
return RBJHighShelf.Audio(
|
||||
input: highMid, freq: eq6600Freq, gain: $eq6600, slope: eqShelfSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// CaliforniaAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American-voiced amp (scooped-mid, bright clean) with a **Bright** high-shelf sparkle control.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the American tone stack, defaulting to a lower gain for headroom.
|
||||
public final class CaliforniaAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Bright high-shelf amount in [0, 1] → 0…`brightMaxGainDb` of lift above `brightFreqHz`.
|
||||
@UIParam public var bright: Double = 0.3
|
||||
|
||||
private let brightFreqHz: Double = 3200.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let shelfSlope: Double = 1.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American clean — scooped mids, glassy top, with a Bright sparkle shelf."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[PedalKnob(label: "Bright", node: $bright, range: signatureRange)]
|
||||
}
|
||||
|
||||
/// Creates a California amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "California", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.08 // clean-leaning default
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||
$bright, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: brightMaxGainDb)
|
||||
return RBJHighShelf.Audio(input: signal, freq: brightFreqHz, gain: gainDB, slope: shelfSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// ChimeAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Chimey/jangly amp (bell-like top boost) with a **Cut** control that rolls off the high end as
|
||||
/// it's turned up — the classic top-boost "Cut" behavior.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the chime tone stack. The base of the chime-voiced family — the
|
||||
/// EL84-combo variants (Chime 15 / Chime Normal / Chime Baby) subclass it and differ by gain, cab,
|
||||
/// and tone defaults (and, for the smaller combos, an earlier power-amp breakup).
|
||||
open class ChimeAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest. Maps to a low-pass cutoff
|
||||
/// swept from `cutOpenHz` down to `cutDarkHz`.
|
||||
@UIParam public var cut: Double = 0.2
|
||||
|
||||
private let cutOpenHz: Double = 9000.0
|
||||
private let cutDarkHz: Double = 2500.0
|
||||
private let cutQ: Double = 0.707
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .vox }
|
||||
public override var summaryText: String {
|
||||
"Chimey top-boost jangle with a Cut control that tames the highs."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[PedalKnob(label: "Cut", node: $cut, range: signatureRange)]
|
||||
}
|
||||
|
||||
/// Creates a Chime amp.
|
||||
///
|
||||
/// The AC-style variants call the inherited `AmpVoicePedal.init(name:inputBus:outputBus:)` to set
|
||||
/// their own name while inheriting the shared Cut voice.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
self.init(name: "Chime", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// cut 0 → cutOpenHz (bright), cut 1 → cutDarkHz (dark).
|
||||
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
|
||||
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// ChimeBabyAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Chime-family **practice combo** — the tiny, low-power amp: low headroom, a small boxy
|
||||
/// speaker, and the earliest breakup of the chime family.
|
||||
///
|
||||
/// A ``ChimeAmpPedal`` (Cut voice) driven hardest into the power stage, with the small lo-fi cab.
|
||||
public final class ChimeBabyAmpPedal: ChimeAmpPedal {
|
||||
|
||||
/// Power-amp drive — the highest of the chime family, so it breaks up earliest.
|
||||
private let babyPowerDrive: Double = 2.5
|
||||
|
||||
public override var summaryText: String {
|
||||
"Chime-style practice combo — tiny, boxy, earliest-breakup chime with a Cut control."
|
||||
}
|
||||
|
||||
/// Driven hardest of the chime family, so 4× oversampling for anti-alias headroom.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { babyPowerDrive }
|
||||
|
||||
/// Creates a Chime Baby amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Baby", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
bass = 0.4 // small speaker, less low end
|
||||
cab = 7.0 // Lo-Fi 1×8 — the small, boxy voice
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// ChimeFifteenAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Chime-family **1×12 EL84 combo** — the lower-powered, earlier-breakup sibling of the top-boost
|
||||
/// voice. Chimey but grittier: the small power section saturates sooner.
|
||||
///
|
||||
/// A ``ChimeAmpPedal`` (Cut voice) with a higher fixed power-amp drive and a bright cab.
|
||||
public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
|
||||
|
||||
/// Power-amp drive — higher than the base's fixed `1.5` so the EL84 stage breaks up earlier.
|
||||
private let fifteenPowerDrive: Double = 2.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"Chime-style 1×12 EL84 combo — chimey but earlier-breakup, with a Cut control."
|
||||
}
|
||||
|
||||
/// Driven harder than the base, so 4× oversampling for anti-alias headroom.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { fifteenPowerDrive }
|
||||
|
||||
/// Creates a Chime 15 amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime 15", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27 // grittier starting point than the big AC voice
|
||||
cab = 5.0 // Bright 1×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// ChimeNormalAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Chime-family **Normal channel** — the big combo's non-top-boost side: warmer and rounder than
|
||||
/// the bright top-boost voice, with the same high clean headroom.
|
||||
///
|
||||
/// A ``ChimeAmpPedal`` (Cut voice) voiced darker (lower treble default, a touch more Cut) to stand
|
||||
/// in for the plainer Normal-channel EQ.
|
||||
public final class ChimeNormalAmpPedal: ChimeAmpPedal {
|
||||
|
||||
public override var summaryText: String {
|
||||
"Chime Normal channel — warm, round, high-headroom chime with a Cut control."
|
||||
}
|
||||
|
||||
/// Creates a Chime Normal amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Normal", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
treble = 0.5 // rounder top than the top-boost voice
|
||||
cut = 0.3 // a shade darker by default
|
||||
cab = 0.0 // American 1×12 — plainer than the bright cab
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// ChimeTopBoostAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British-invasion "top boost" combo with a full control surface: the chimey top-boost EQ, a
|
||||
/// **Cut** control that tames the highs, onboard **tremolo** (Speed / Intensity), and a
|
||||
/// **Brilliant** switch — the jangly clean-to-edge-of-breakup voice.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the chime tone stack that fills both subclass hooks:
|
||||
/// - ``inputShaping(_:)`` applies the Brilliant switch as a pre-preamp treble shelf.
|
||||
/// - ``onboardEffects(_:)`` inserts the tremolo between the tone stack and the power amp.
|
||||
///
|
||||
/// Unlike the American blackface combo this amp has no built-in reverb (that was always outboard),
|
||||
/// so the onboard-effects slot holds only the tremolo. Tremolo defaults off (`Intensity = 0`).
|
||||
public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
|
||||
// MARK: - Signature / onboard-effect parameters
|
||||
|
||||
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest (the top-boost "Cut" control,
|
||||
/// which rolls off the highs as it's turned up).
|
||||
@UIParam public var cut: Double = 0.2
|
||||
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 4.0
|
||||
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||
@UIParam public var intensity: Double = 0.0
|
||||
/// Brilliant switch: `0` = flat, `1` = treble shelf engaged (the brilliant/top-boost sparkle).
|
||||
@UIParam public var brilliant: Double = 0.0
|
||||
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||
@UIParam public var tremoloEnabled: Double = 1.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Cut low-pass cutoff when fully open (`cut = 0`), in Hz.
|
||||
private let cutOpenHz: Double = 9000.0
|
||||
/// Cut low-pass cutoff when fully dark (`cut = 1`), in Hz.
|
||||
private let cutDarkHz: Double = 2500.0
|
||||
/// Cut low-pass Q (Butterworth).
|
||||
private let cutQ: Double = 0.707
|
||||
/// Brilliant-switch shelf corner in Hz.
|
||||
private let brilliantFreqHz: Double = 4000.0
|
||||
/// Brilliant-switch shelf lift in dB when engaged.
|
||||
private let brilliantMaxGainDb: Double = 6.0
|
||||
/// Brilliant-switch shelf slope.
|
||||
private let brilliantSlope: Double = 0.7
|
||||
private let cutRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .vox }
|
||||
public override var summaryText: String {
|
||||
"Chimey top-boost jangle — Cut control, tremolo, and a Brilliant switch."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Cut", node: $cut, range: cutRange),
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Chime Top Boost amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Top Boost", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73
|
||||
cab = 5.0 // Bright 1×12 — the chimey, top-end-forward cab voice
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Brilliant",
|
||||
node: $brilliant,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Tremolo",
|
||||
node: $tremoloEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Hooks
|
||||
|
||||
/// Brilliant switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $brilliant * brilliantMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brilliantFreqHz, gain: shelfGainDb, slope: brilliantSlope)
|
||||
}
|
||||
|
||||
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack. No onboard reverb.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Tremolo gated by the Tremolo footswitch (identity when depth·enabled == 0).
|
||||
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||
}
|
||||
|
||||
/// Cut control: a low-pass whose cutoff sweeps from `cutOpenHz` (bright) down to `cutDarkHz`
|
||||
/// (dark) as `cut` rises — the top-boost "Cut" behaviour, applied post-power-amp.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
|
||||
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// CitrusAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **mid-forward crunch** — the Citrus voice: a thick, punchy midrange with a single
|
||||
/// **Shape** control that tilts the top end from dark to bright.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` on the `.marshall` stack with a fixed mid bump (the amp's signature push)
|
||||
/// and a Shape high-shelf whose gain sweeps from cut to boost.
|
||||
public final class CitrusAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Shape in [0, 1]: `0` = dark (top cut), `0.5` = flat, `1` = bright (top boost).
|
||||
@UIParam public var shape: Double = 0.5
|
||||
|
||||
private let midFreqHz: Double = 800.0
|
||||
private let midBumpDb: Double = 3.0
|
||||
private let midQ: Double = 0.8
|
||||
private let shapeFreqHz: Double = 2600.0
|
||||
private let shapeMinDb: Double = -6.0
|
||||
private let shapeMaxDb: Double = 6.0
|
||||
private let shapeSlope: Double = 0.8
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var summaryText: String {
|
||||
"British mid-forward crunch with a single Shape control (dark ↔ bright top end)."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[PedalKnob(label: "Shape", node: $shape, range: signatureRange)]
|
||||
}
|
||||
|
||||
/// Creates a Citrus amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Citrus", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// A fixed midrange bump (the Citrus push), then the Shape high-shelf tilt.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let midded: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: signal, freq: midFreqHz, gain: midBumpDb, q: midQ)
|
||||
let shapeDb: LinLin.Audio = LinLin.Audio(
|
||||
$shape, inLo: 0.0, inHi: 1.0, outLo: shapeMinDb, outHi: shapeMaxDb)
|
||||
return RBJHighShelf.Audio(input: midded, freq: shapeFreqHz, gain: shapeDb, slope: shapeSlope)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// CommandAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **hi-fi clean** — the Command/DR-style workhorse: very loud, very clean, high headroom,
|
||||
/// with Presence and a Bright switch. Breaks up late and stays tight.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (non-master `.marshall` + Presence + Bright) voiced for maximum
|
||||
/// headroom — a low default gain so it stays clean far up the dial.
|
||||
public final class CommandAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
public override var summaryText: String {
|
||||
"British hi-fi clean — loud, tight, high-headroom, with Presence and a Bright switch."
|
||||
}
|
||||
|
||||
/// Creates a Command amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Command", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.08 // headroom-rich clean
|
||||
treble = 0.55 // a touch of hi-fi top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,12 @@ import LyrebirdUI
|
||||
/// compressed. Range `[-40, 0]` dB. Defaults to `-12.0`.
|
||||
/// - ratio: Compression ratio `≥ 1.0`. `1.0` = bypass, `4.0` = 4:1 compression.
|
||||
/// Range `[1, 20]`. Defaults to `4.0`.
|
||||
///
|
||||
/// A feed-forward compressor can overshoot on fast transients (its attack is non-zero),
|
||||
/// so a hot input plus makeup gain can push peaks past full scale and clip the output.
|
||||
/// The **Safety** switch inserts a brick-wall `LookAheadLimiter` after the compressor to
|
||||
/// catch those peaks; it is off by default (leave adding a limiter to the user) and adds
|
||||
/// a short look-ahead output delay when engaged.
|
||||
public final class CompressorPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -50,6 +56,10 @@ public final class CompressorPedal: Pedal {
|
||||
/// Compression ratio. Range [1, 20].
|
||||
@UIParam public var ratio: Double = 4.0
|
||||
|
||||
/// Safety limiter engage state. `0` = off (compressor may overshoot), `1` = on
|
||||
/// (brick-wall look-ahead limiter catches transient peaks).
|
||||
@UIParam public var safetyLimiter: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
|
||||
@@ -71,6 +81,20 @@ public final class CompressorPedal: Pedal {
|
||||
/// Makeup gain in dB applied after compression to restore perceived loudness.
|
||||
private let makeupGainDB: Double = 4.0
|
||||
|
||||
/// Safety-limiter peak ceiling (linear amplitude), just below full scale.
|
||||
private let safetyCeiling: Double = 0.98
|
||||
|
||||
/// Safety-limiter look-ahead / output delay in seconds. Short enough to catch
|
||||
/// transients without smearing attack; only in circuit when Safety is engaged.
|
||||
private let safetyLookAheadTime: Double = 0.005
|
||||
|
||||
/// Safety-limiter gain-release time in seconds.
|
||||
private let safetyReleaseTime: Double = 0.05
|
||||
|
||||
/// Safety switch position values.
|
||||
private let safetyOffValue: Double = 0.0
|
||||
private let safetyOnValue: Double = 1.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Input-gain knob range in dB.
|
||||
@@ -90,6 +114,19 @@ public final class CompressorPedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Safety",
|
||||
node: $safetyLimiter,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: safetyOffValue),
|
||||
PedalSwitch.Option(title: "On", value: safetyOnValue),
|
||||
]
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a compressor pedal.
|
||||
@@ -121,7 +158,7 @@ public final class CompressorPedal: Pedal {
|
||||
// Convert the input-gain dB to a linear multiplier (10^(dB/20)) and apply before compression.
|
||||
let inputGainLinear: Exp.Audio = Exp.Audio($inputGain * dbToLinExpScale)
|
||||
let boosted: any ValidGeneratorInput = dry * inputGainLinear
|
||||
return Compressor.Audio(
|
||||
let compressed: Compressor.Audio = Compressor.Audio(
|
||||
in: boosted,
|
||||
threshold: $threshold,
|
||||
ratio: $ratio,
|
||||
@@ -130,5 +167,18 @@ public final class CompressorPedal: Pedal {
|
||||
kneeWidth: kneeWidth,
|
||||
makeupGain: makeupGainDB
|
||||
)
|
||||
// Brick-wall safety limiter after the compressor. Both branches are always built;
|
||||
// `Select` picks per the Safety switch (0 = compressor only, 1 = limited).
|
||||
let limited: LookAheadLimiter = LookAheadLimiter(
|
||||
in: compressed,
|
||||
maxAmplitude: safetyCeiling,
|
||||
lookAheadTime: safetyLookAheadTime,
|
||||
releaseTime: safetyReleaseTime,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
return Select.Audio(
|
||||
which: $safetyLimiter,
|
||||
inputs: [compressed, limited]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ import LyrebirdUI
|
||||
|
||||
/// Mid-gain distortion — more saturated than `OverdrivePedal`, more controlled than `FuzzPedal`.
|
||||
///
|
||||
/// A DC-blocking high-pass feeds a `tanh` soft-clipper driven hard by the `Drive` knob; a
|
||||
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip guarantees the
|
||||
/// output stays bounded.
|
||||
/// A DC-blocking high-pass feeds a `tanh` stage that is post-gained by the `Drive` knob into a
|
||||
/// hard clipper — both evaluated at 4× oversampling so the clipper's harmonics don't alias. A
|
||||
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip re-bounds the
|
||||
/// output (the tone low-pass can ring slightly past the ceiling on transients).
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `drive`: Pre-clip gain into the `tanh` stage. Range `[1, 50]`.
|
||||
@@ -87,12 +88,24 @@ public final class DistortionPedal: Pedal {
|
||||
freq: dcBlockFreq,
|
||||
q: filterQ
|
||||
)
|
||||
let driven: Tanh.Audio = Tanh.Audio(dcBlocked, mul: $drive)
|
||||
// tanh soft stage → post-gain by drive → hard clip, all evaluated at 4× so the hard
|
||||
// clipper's harmonics settle above the upsampled Nyquist instead of aliasing back.
|
||||
// The tone low-pass now follows the clip (standard clip→tone order), which also
|
||||
// filters any residual high-band content the downsampler leaves.
|
||||
let clipped: OversampledSaturator = OversampledSaturator(
|
||||
dcBlocked,
|
||||
drive: $drive,
|
||||
curve: .tanhPostGainHardClip(low: clipLow, high: clipHigh),
|
||||
oversample: 4
|
||||
)
|
||||
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||
input: driven,
|
||||
input: clipped,
|
||||
freq: $tone,
|
||||
q: filterQ
|
||||
)
|
||||
// Final hard clip re-establishes the strict output bound: the tone low-pass is linear
|
||||
// and band-limited, so it can overshoot the ceiling slightly on transients, but
|
||||
// clipping its (already band-limited) output adds negligible new aliasing.
|
||||
return Clip.Audio(toned, lo: clipLow, hi: clipHigh)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// FullertonDeluxeAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American blackface **lower-headroom combo** — the smaller-powered sibling of
|
||||
/// ``FullertonReverbAmpPedal``.
|
||||
///
|
||||
/// Same reverb + tremolo + Bright control surface and American cab, but with less clean headroom:
|
||||
/// the power-amp stage runs a higher fixed drive than the Twin, so it breaks up earlier and grittier.
|
||||
/// The go-to blackface combo tone.
|
||||
public final class FullertonDeluxeAmpPedal: FullertonReverbAmpPedal {
|
||||
|
||||
/// Power-amp drive — higher than the Twin's fixed `1.5` so it saturates earlier (less headroom).
|
||||
private let deluxePowerDrive: Double = 2.2
|
||||
|
||||
public override var summaryText: String {
|
||||
"American combo — earlier-breakup blackface tone with reverb, tremolo, and Bright."
|
||||
}
|
||||
|
||||
/// Fixed power-amp drive is higher than the Twin's, so 4× oversampling for anti-alias headroom.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { deluxePowerDrive }
|
||||
|
||||
/// Creates a Fullerton Deluxe amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Deluxe", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.42 // slightly hotter starting point than the Twin
|
||||
bass = 0.45 // a touch less low end than the 2×12
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// FullertonDriveAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American **two-channel combo** — a blackface-style clean plus a hotter overdrive channel, with
|
||||
/// spring reverb and a Bright switch. The modern gigging combo (Hot Rod / Blues Jr. lineage).
|
||||
///
|
||||
/// The **Channel** switch selects Clean or Drive. On the Drive channel a second cascaded
|
||||
/// ``TriodeStage`` (set by the `Drive` knob) is added ahead of the tone stack for preamp overdrive;
|
||||
/// on Clean it is omitted entirely. Because the channel changes the graph topology the switch is
|
||||
/// `rebuildsOnChange` — flipping it rebuilds the board (like the cab selector), so only the selected
|
||||
/// channel's stages are ever built.
|
||||
public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.25
|
||||
/// Drive-channel preamp gain (the cascaded overdrive stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Channel select: `0` = Clean, `1` = Drive (the cascaded overdrive stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let brightFreqHz: Double = 3200.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 1.0
|
||||
/// Grid bias of the cascaded drive stage — a little asymmetry for even-harmonic grind.
|
||||
private let driveBias: Double = 0.25
|
||||
/// Channel-select threshold: `>= this` selects the Drive channel.
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American two-channel combo — blackface clean plus an overdrive channel, with reverb and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Drive", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Fullerton Drive amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Drive", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.08
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Clean preamp, plus a cascaded overdrive stage on the Drive channel. The `channel` value is
|
||||
/// read at board-build time (the switch is `rebuildsOnChange`), so only the selected channel's
|
||||
/// stages exist in the graph.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// FullertonPrincetonAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American blackface **1×10 combo** — the smallest, darkest blackface voice, below
|
||||
/// ``FullertonDeluxeAmpPedal``.
|
||||
///
|
||||
/// Same reverb + tremolo + Bright control surface, but voiced smaller: a darker cabinet, less low
|
||||
/// end, and the earliest, most compressed breakup of the three — the classic small-studio recording
|
||||
/// combo.
|
||||
public final class FullertonPrincetonAmpPedal: FullertonReverbAmpPedal {
|
||||
|
||||
/// Power-amp drive — the highest of the blackface trio, so it breaks up earliest.
|
||||
private let princetonPowerDrive: Double = 2.6
|
||||
|
||||
public override var summaryText: String {
|
||||
"American 1×10 combo — small, dark, early-breakup blackface with reverb, tremolo, and Bright."
|
||||
}
|
||||
|
||||
/// Driven hardest of the blackface trio, so 4× oversampling for anti-alias headroom.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { princetonPowerDrive }
|
||||
|
||||
/// Creates a Fullerton Ivy League amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Ivy League", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.73 // hotter still — the small combo grits up soonest
|
||||
bass = 0.4 // least low end of the trio
|
||||
treble = 0.55 // a shade darker
|
||||
cab = 2.0 // Vintage Dark — the small, dark 1×10 voice
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// FullertonReverbAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American blackface-combo amp with a full onboard control surface: spring **reverb**, **tremolo**
|
||||
/// (Speed / Intensity), and a **Bright** switch — the loud, headroom-rich clean voice.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` fixed to the American tone stack that fills both subclass hooks:
|
||||
/// - ``inputShaping(_:)`` applies the Bright switch as a pre-preamp treble shelf.
|
||||
/// - ``onboardEffects(_:)`` inserts the spring reverb then the tremolo, between the tone stack and
|
||||
/// the power amp — the slot a combo amp's built-in reverb/tremolo occupy.
|
||||
///
|
||||
/// The amp's "vibrato" channel is historically amplitude modulation (tremolo), not pitch vibrato,
|
||||
/// so `Intensity` drives a unipolar-sine gain LFO. Tremolo defaults off (`Intensity = 0`) so the
|
||||
/// amp opens as a clean, reverbed platform.
|
||||
///
|
||||
/// A **Reverb** and a **Vibrato** switch model the amp's two-button footswitch: each bypasses its
|
||||
/// effect (dry pass-through) while preserving the knob positions, so a player can stomp the FX in
|
||||
/// and out without losing their settings.
|
||||
open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
|
||||
// MARK: - Onboard-effect parameters
|
||||
|
||||
/// Spring-reverb wet mix in [0, 1]. `0` = dry, `1` = fully wet.
|
||||
@UIParam public var reverb: Double = 0.25
|
||||
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 4.0
|
||||
/// Tremolo depth in [0, 1]. `0` = off (clean), `1` = full silence-to-unity swing.
|
||||
@UIParam public var intensity: Double = 0.0
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Reverb footswitch: `1` = reverb engaged, `0` = bypassed (dry pass-through, `Reverb` knob
|
||||
/// setting preserved). Models the amp's reverb footswitch.
|
||||
@UIParam public var reverbEnabled: Double = 1.0
|
||||
/// Vibrato footswitch: `1` = tremolo engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||
/// Models the amp's vibrato footswitch.
|
||||
@UIParam public var vibratoEnabled: Double = 1.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Bright-switch shelf corner in Hz.
|
||||
private let brightFreqHz: Double = 2500.0
|
||||
/// Bright-switch shelf lift in dB when engaged.
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
/// Bright-switch shelf slope.
|
||||
private let brightSlope: Double = 0.8
|
||||
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American blackface clean — spring reverb, tremolo, and a Bright switch."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Fullerton Reverb amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
/// The blackface-combo variants (Deluxe / Princeton) call the inherited
|
||||
/// `AmpVoicePedal.init(name:inputBus:outputBus:)` designated init to set their own name while
|
||||
/// inheriting the shared reverb + tremolo + bright control surface.
|
||||
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
self.init(name: "Fullerton Reverb", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.08 // headroom-rich clean default
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Reverb FX", // disambiguated from the "Reverb" level knob
|
||||
node: $reverbEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Vibrato",
|
||||
node: $vibratoEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Hooks
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp. The switch value (`0`/`1`) scales the
|
||||
/// shelf gain, so "Off" is a true identity and the effect is live (no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Spring reverb → tremolo, inserted after the tone stack and before the power amp.
|
||||
///
|
||||
/// The `reverbEnabled` / `vibratoEnabled` footswitches gate each effect live by scaling its wet
|
||||
/// amount to zero: reverb collapses to a dry pass-through and the tremolo LFO collapses to a
|
||||
/// constant `1.0` (identity), each while preserving its knob positions and needing no rebuild.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Footswitch gates the wet mix to 0 → SpringReverb passes the dry signal through.
|
||||
let reverbMix: any ValidGeneratorInput = $reverb * $reverbEnabled
|
||||
let reverbed: SpringReverb.Audio = SpringReverb.Audio(
|
||||
input: signal, mix: reverbMix, sampleRate: sampleRate)
|
||||
// Tremolo gated by the vibrato footswitch (identity when depth·enabled == 0).
|
||||
return tremolo(reverbed, speed: $speed, depth: $intensity, enabled: $vibratoEnabled)
|
||||
}
|
||||
}
|
||||
@@ -105,11 +105,17 @@ public final class FuzzPedal: Pedal {
|
||||
/// - Returns: Fuzzed and tone-shaped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Pre-gain the signal hard, then saturate. `tanh` squares the waveform off as the
|
||||
// drive rises while keeping the level bounded — the hallmark of a fuzz.
|
||||
let driven: any ValidGeneratorInput = dry * $fuzz
|
||||
let saturated: Tanh.Audio = Tanh.Audio(driven, mul: outputTrim)
|
||||
// drive rises while keeping the level bounded — the hallmark of a fuzz. Evaluated at
|
||||
// 2× so the high harmonics the hard pre-gain generates don't fold back as aliasing.
|
||||
let saturated: OversampledSaturator = OversampledSaturator(
|
||||
dry,
|
||||
drive: $fuzz,
|
||||
curve: .tanhPreGain,
|
||||
oversample: 2
|
||||
)
|
||||
let trimmed: any ValidGeneratorInput = saturated * outputTrim
|
||||
return RBJLowPass.Audio(
|
||||
input: saturated,
|
||||
input: trimmed,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
// JazzCleanAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Ultra-clean solid-state combo with its signature lush **stereo chorus**, plus spring reverb and
|
||||
/// a bright switch — the glassy "jazz clean" platform.
|
||||
///
|
||||
/// Unlike the mono amp voices, this amp is a ``PedalChannelKind/widener``: the real amp has two
|
||||
/// power amps and two speakers fed by a stereo chorus, so it takes the mono guitar input and emits a
|
||||
/// genuinely stereo pair. The chorus (mono → stereo) is the stereo splitter — its two taps become
|
||||
/// the left and right channels, each then run through its own cabinet + output stage.
|
||||
///
|
||||
/// Signal path (inside `wideEffect(_:)`):
|
||||
/// ```
|
||||
/// dry → preCabinetCore (bright → preamp → tone → spring reverb → power amp) [mono]
|
||||
/// → Chorus (mono → stereo) [stereo split]
|
||||
/// → L: cabinetAndLimit R: cabinetAndLimit [per channel]
|
||||
/// ```
|
||||
/// A **Chorus** switch models the amp's chorus on/off footswitch: off collapses the chorus to a dry
|
||||
/// pass-through (both channels identical), preserving the Rate/Depth settings.
|
||||
public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
|
||||
// MARK: - Onboard-effect parameters
|
||||
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.2
|
||||
/// Chorus LFO rate in Hz. Range [0.1, 5.0].
|
||||
@UIParam public var chorusRate: Double = 0.8
|
||||
/// Chorus depth as a fraction of the base delay time. Kept in the classic-chorus band
|
||||
/// (~0.001–0.01) so it adds width without pitch wobble.
|
||||
@UIParam public var chorusDepth: Double = 0.005
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Chorus footswitch: `1` = chorus engaged (stereo), `0` = bypassed (dry, mono-equivalent).
|
||||
@UIParam public var chorusEnabled: Double = 1.0
|
||||
/// Drive-channel preamp gain (the onboard distortion). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Channel select: `0` = Clean, `1` = Distortion (the cascaded onboard-distortion stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Bright-switch shelf corner in Hz.
|
||||
private let brightFreqHz: Double = 3000.0
|
||||
/// Bright-switch shelf lift in dB when engaged.
|
||||
private let brightMaxGainDb: Double = 5.0
|
||||
/// Bright-switch shelf slope.
|
||||
private let brightSlope: Double = 0.9
|
||||
/// Fixed chorus wet/dry blend when the chorus is engaged (the amp has no chorus-mix knob).
|
||||
private let chorusMixValue: Double = 0.5
|
||||
|
||||
/// Grid bias of the cascaded distortion stage — solid-state-flavoured, near-symmetric.
|
||||
private let driveBias: Double = 0.1
|
||||
/// Channel-select threshold: `>= this` selects the Distortion channel.
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let chorusRateRange: ClosedRange<Double> = 0.1 ... 5.0
|
||||
private let chorusDepthRange: ClosedRange<Double> = 0.0005 ... 0.015
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"Solid-state clean — lush stereo chorus, spring reverb, a Bright switch, and a Distortion channel."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
PedalKnob(label: "Rate", node: $chorusRate, range: chorusRateRange),
|
||||
PedalKnob(label: "Depth", node: $chorusDepth, range: chorusDepthRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
]
|
||||
}
|
||||
|
||||
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
|
||||
public override var channelKind: PedalChannelKind { .widener }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Jazz Clean amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Jazz Clean", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.23 // clean, low-gain solid-state default
|
||||
cab = 6.0 // Full-Range (FRFR) — the hi-fi, least-coloured voice
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Bright",
|
||||
node: $bright,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Chorus",
|
||||
node: $chorusEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Dist", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Clean preamp, plus the onboard-distortion stage on the Distortion channel. The `channel`
|
||||
/// value is read at board-build time (the switch is `rebuildsOnChange`), so only the selected
|
||||
/// channel's stages exist in the graph.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
// MARK: - Hooks
|
||||
|
||||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||
return RBJHighShelf.Audio(
|
||||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||
}
|
||||
|
||||
/// Spring reverb inside the mono core (before the stereo chorus split).
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
// MARK: - Stereo effect
|
||||
|
||||
/// Mono amp core → stereo chorus split → per-channel cabinet + output stage.
|
||||
///
|
||||
/// The `chorusEnabled` footswitch gates the chorus wet mix to `0` when off, so the chorus passes
|
||||
/// the dry core to both channels (a mono-equivalent output) while preserving Rate/Depth.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The stereo (left, right) amp output.
|
||||
public override func wideEffect(
|
||||
_ dry: any ValidGeneratorInput
|
||||
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||
let core: any ValidGeneratorInput = preCabinetCore(dry)
|
||||
let chorusMix: any ValidGeneratorInput = $chorusEnabled * chorusMixValue
|
||||
let chorus: Chorus.Audio = Chorus.Audio(
|
||||
input: core,
|
||||
depth: $chorusDepth,
|
||||
rate: $chorusRate,
|
||||
mix: chorusMix,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
return (cabinetAndLimit(chorus.left), cabinetAndLimit(chorus.right))
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ import LyrebirdUI
|
||||
/// drive harder into the limiter. Range `[1, 12]`. Defaults to `1.0`.
|
||||
/// - ceiling: Output peak ceiling as a linear amplitude in `[0, 1]`. The limited output
|
||||
/// never exceeds this absolute value. Range `[0.1, 1.0]`. Defaults to `0.95`.
|
||||
/// - release: Gain-release time in seconds. Too short a release modulates the gain
|
||||
/// within a waveform cycle and distorts low notes; longer is cleaner but lets the
|
||||
/// level swell back more slowly. Range `[0.01, 0.5]`. Defaults to `0.05`.
|
||||
public final class LimiterPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -44,6 +47,9 @@ public final class LimiterPedal: Pedal {
|
||||
/// Output peak ceiling (linear amplitude). Range [0.1, 1.0].
|
||||
@UIParam public var ceiling: Double = 0.95
|
||||
|
||||
/// Gain-release time in seconds. Range [0.01, 0.5].
|
||||
@UIParam public var release: Double = 0.05
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the limiter sits in-line.
|
||||
@@ -61,10 +67,14 @@ public final class LimiterPedal: Pedal {
|
||||
/// Ceiling knob range (linear output peak).
|
||||
private let ceilingRange: ClosedRange<Double> = 0.1 ... 1.0
|
||||
|
||||
/// Release knob range in seconds.
|
||||
private let releaseRange: ClosedRange<Double> = 0.01 ... 0.5
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Boost", node: $boost, range: boostRange),
|
||||
PedalKnob(label: "Ceiling", node: $ceiling, range: ceilingRange),
|
||||
PedalKnob(label: "Release", node: $release, range: releaseRange),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -101,6 +111,7 @@ public final class LimiterPedal: Pedal {
|
||||
in: boosted,
|
||||
maxAmplitude: $ceiling,
|
||||
lookAheadTime: lookAheadTime,
|
||||
releaseTime: $release,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// MagnaVibratoAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American clean combo with **true pitch vibrato** — the Magnatone voice: a genuine
|
||||
/// frequency-modulation warble (a swept delay line), not the amplitude-modulation "vibrato" other
|
||||
/// amps label as such.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` (`.fender`) whose onboard effect is a delay line whose read position is swept
|
||||
/// by an LFO — modulating pitch. `Depth` scales the sweep, `Speed` its rate, and a Vibrato
|
||||
/// footswitch bypasses it (a fixed short delay, no warble).
|
||||
public final class MagnaVibratoAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Vibrato LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 5.0
|
||||
/// Vibrato depth in [0, 1] → 0…±`maxSweepSeconds` of delay-time sweep around the base delay
|
||||
/// (the LFO is bipolar, so the delay swings both above and below `baseDelaySeconds`).
|
||||
@UIParam public var depth: Double = 0.3
|
||||
/// Vibrato footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Depth` preserved).
|
||||
@UIParam public var vibratoEnabled: Double = 1.0
|
||||
|
||||
/// Base delay time (the centre the LFO sweeps around), in seconds.
|
||||
private let baseDelaySeconds: Double = 0.005
|
||||
/// Maximum ± sweep at full depth, in seconds.
|
||||
private let maxSweepSeconds: Double = 0.002
|
||||
/// Delay-line capacity — must exceed base + max sweep.
|
||||
private let maxDelaySeconds: Double = 0.010
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American clean combo with true pitch vibrato (a swept delay, not tremolo)."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Vibrato",
|
||||
node: $vibratoEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Magna Vibrato amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Magna Vibrato", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.08 // clean platform for the vibrato
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
/// True pitch vibrato: a delay line whose delay time is swept by a sine LFO. The footswitch
|
||||
/// gates the sweep to zero (a fixed base delay, no warble) while keeping Speed/Depth.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let sweepSeconds: any ValidGeneratorInput = ($depth * $vibratoEnabled) * maxSweepSeconds
|
||||
let delayTime: OscSin.Audio = OscSin.Audio(
|
||||
freq: $speed, mul: sweepSeconds, add: baseDelaySeconds)
|
||||
return DelayLine(
|
||||
input: signal,
|
||||
maxDelay: maxDelaySeconds,
|
||||
delay: delayTime,
|
||||
sampleRate: sampleRate,
|
||||
interpolation: .linear
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// ModernHighGainAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Modern **high-gain rectifier** — the saturated, scooped metal voice: a hot cascaded lead on the
|
||||
/// Mesa tone stack, with a **Sag** control (power-supply droop/bloom) and a **Tight** switch that
|
||||
/// firms up the low end.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` (Clean/Lead channel, Master, Presence, Depth) voiced on the `.mesa` stack.
|
||||
/// **Sag** models the power supply drooping under load: an envelope follower on the power-amp signal
|
||||
/// reduces gain as it gets loud, then recovers slowly — the compression/"bloom" feel of a
|
||||
/// tube-rectified amp. **Tight** high-passes the input to tighten the low end for fast riffing.
|
||||
public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
/// Tight switch: `0` = full low end, `1` = low-cut engaged (tight riffing).
|
||||
@UIParam public var tight: Double = 0.0
|
||||
|
||||
/// Tight low-cut: high-pass corner is ~20 Hz (loose, no cut) or `tightFreqHz` (tight).
|
||||
private let tightLooseFreqHz: Double = 20.0
|
||||
/// Tight-switch-on high-pass corner in Hz.
|
||||
private let tightFreqHz: Double = 120.0
|
||||
/// Tight high-pass Q (Butterworth).
|
||||
private let tightQ: Double = 0.707
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .mesa }
|
||||
public override var summaryText: String {
|
||||
"Modern high-gain rectifier — scooped Mesa lead with Sag (power-supply bloom) and a Tight switch."
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Tight",
|
||||
node: $tight,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Modern High-Gain amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Modern High-Gain", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.72
|
||||
drive = 9.50 // hottest lead of the lineup
|
||||
cab = 1.0 // British 4×12 — tight, aggressive
|
||||
sag = 0.3 // rectifier bloom on by default (shared power-amp Sag from AmpVoicePedal)
|
||||
}
|
||||
|
||||
/// Tight switch: a pre-preamp high-pass whose corner switches between ~20 Hz (loose, negligible
|
||||
/// cut) and `tightFreqHz` (tight), firming the low end — live, no rebuild.
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||
$tight, inLo: 0.0, inHi: 1.0, outLo: tightLooseFreqHz, outHi: tightFreqHz)
|
||||
return RBJHighPass.Audio(input: signal, freq: cutoff, q: tightQ)
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,13 @@ import LyrebirdUI
|
||||
/// keeps every filter state warmed so switch changes are click-free (SuperCollider
|
||||
/// `Select` semantics: every input advances each block).
|
||||
///
|
||||
/// The cutoff sweeps exponentially from a resting frequency (`freqLo`) up to a peak
|
||||
/// (`freqHi`) as the envelope opens: `cutoff = freqLo·(freqHi/freqLo)^envelope`. The
|
||||
/// **Range** switch shifts that whole window low (rhythm / bass) or high (harmonics /
|
||||
/// solos), matching the original pedal; the **Sweep** knob sets how far above the resting
|
||||
/// frequency the envelope drives the cutoff (its "openness"), and **Attack** / **Release**
|
||||
/// shape how quickly the filter follows the input dynamics.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `sensitivity`: Drive into the envelope follower; higher values open the filter on quieter notes.
|
||||
/// - `resonance`: Filter peak emphasis at the swept cutoff.
|
||||
@@ -24,6 +31,12 @@ import LyrebirdUI
|
||||
/// ## Switches
|
||||
/// - `direction` (two-state): `0` = Down (louder closes the filter), `1` = Up (louder opens it).
|
||||
/// - `mode` (three-state): `0` = lowpass, `1` = bandpass (classic vowel wah), `2` = highpass.
|
||||
/// - `range` (two-state): `0` = Low band (rhythm / bass), `1` = High band (harmonics / solos).
|
||||
///
|
||||
/// ## Advanced
|
||||
/// - `sweep`: How far the envelope drives the cutoff above its resting frequency (peak = resting × sweep).
|
||||
/// - `attack`: Envelope attack time in seconds — how fast the filter opens on a transient.
|
||||
/// - `release`: Envelope release time in seconds — how fast it closes after a note.
|
||||
public final class MutantPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -45,19 +58,29 @@ public final class MutantPedal: Pedal {
|
||||
/// Filter resonance (Chamberlin SVF peak emphasis). Clamped to `≥ 1.0` internally.
|
||||
@UIParam public var resonance: Double = 4.0
|
||||
|
||||
/// Frequency-band selector. `0` = Low band, `1` = High band. Shifts the resting cutoff (and with
|
||||
/// it the whole sweep window) up or down. Driven by a two-state switch.
|
||||
@UIParam public var range: Double = 0.0
|
||||
|
||||
/// Sweep amount: the peak cutoff is `restingCutoff × sweep`, so higher values open the filter
|
||||
/// further as the input drives it. Advanced knob.
|
||||
@UIParam public var sweep: Double = 20.0
|
||||
|
||||
/// Envelope attack time in seconds — how fast the filter opens on a transient. Advanced knob.
|
||||
@UIParam public var attack: Double = 0.008
|
||||
|
||||
/// Envelope release time in seconds — how fast the filter closes after a note. Advanced knob.
|
||||
@UIParam public var release: Double = 0.14
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Cutoff at zero envelope, in Hz.
|
||||
private let freqLo: Double = 80.0
|
||||
/// Resting cutoff (in Hz) at `range == Low`.
|
||||
private let rangeLowBaseFreq: Double = 120.0
|
||||
|
||||
/// Cutoff at maximum envelope, in Hz (≈40× sweep over `freqLo`).
|
||||
private let freqHi: Double = 3200.0
|
||||
|
||||
/// Envelope attack/release times, in seconds.
|
||||
private let attackTime: Double = 0.005
|
||||
private let releaseTime: Double = 0.15
|
||||
/// Resting cutoff (in Hz) at `range == High`.
|
||||
private let rangeHighBaseFreq: Double = 380.0
|
||||
|
||||
/// Half-step bias added before each `Select`'s truncate-toward-zero index, turning a
|
||||
/// switch parameter into a round-to-nearest position selector.
|
||||
@@ -69,11 +92,17 @@ public final class MutantPedal: Pedal {
|
||||
private let modeHighpassValue: Double = 2.0
|
||||
private let directionDownValue: Double = 0.0
|
||||
private let directionUpValue: Double = 1.0
|
||||
private let rangeLowValue: Double = 0.0
|
||||
private let rangeHighValue: Double = 1.0
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let sensitivityRange: ClosedRange<Double> = 0.0 ... 4.0
|
||||
private let resonanceRange: ClosedRange<Double> = 1.0 ... 12.0
|
||||
/// Sweep multiplier: peak cutoff = resting × sweep. `1` = no sweep; `50` ≈ 5.6 octaves.
|
||||
private let sweepRange: ClosedRange<Double> = 1.0 ... 50.0
|
||||
private let attackRange: ClosedRange<Double> = 0.001 ... 0.08
|
||||
private let releaseRange: ClosedRange<Double> = 0.02 ... 0.6
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
@@ -84,12 +113,20 @@ public final class MutantPedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sweep", node: $sweep, range: sweepRange),
|
||||
PedalKnob(label: "Attack", node: $attack, range: attackRange),
|
||||
PedalKnob(label: "Release", node: $release, range: releaseRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Sweep",
|
||||
label: "Direction",
|
||||
node: $direction,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Down", value: directionDownValue),
|
||||
@@ -105,9 +142,22 @@ public final class MutantPedal: Pedal {
|
||||
PedalSwitch.Option(title: "HP", value: modeHighpassValue),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Range",
|
||||
node: $range,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Lo", value: rangeLowValue),
|
||||
PedalSwitch.Option(title: "Hi", value: rangeHighValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Double-width so the three segmented switches (Direction / Mode / Range — seven segments in
|
||||
/// all) have room for their captions instead of wrapping ("Do wn"), the same reason the Cabinet
|
||||
/// and amp pedals are double-width.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
@@ -122,23 +172,29 @@ public final class MutantPedal: Pedal {
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Resting cutoff shifts with the Range switch (Low band vs High band); the peak the envelope
|
||||
// reaches is `restingCutoff × sweep`. Both feed all six warmed filters (fan-out).
|
||||
let restingFreq: any ValidGeneratorInput =
|
||||
$range * (rangeHighBaseFreq - rangeLowBaseFreq) + rangeLowBaseFreq
|
||||
let peakFreq: any ValidGeneratorInput = restingFreq * $sweep
|
||||
|
||||
// Inner mode selectors per sweep direction. `Select` rounds the [0, 2] mode switch
|
||||
// to the nearest position and advances all three filters each block (warmed state).
|
||||
let modeWhich: any ValidGeneratorInput = $mode + selectRoundingBias
|
||||
let downModes: Select.Audio = Select.Audio(
|
||||
which: modeWhich,
|
||||
inputs: [
|
||||
makeFilter(dry, mode: .lowpass, direction: .down),
|
||||
makeFilter(dry, mode: .bandpass, direction: .down),
|
||||
makeFilter(dry, mode: .highpass, direction: .down),
|
||||
makeFilter(dry, mode: .lowpass, direction: .down, freqLo: restingFreq, freqHi: peakFreq),
|
||||
makeFilter(dry, mode: .bandpass, direction: .down, freqLo: restingFreq, freqHi: peakFreq),
|
||||
makeFilter(dry, mode: .highpass, direction: .down, freqLo: restingFreq, freqHi: peakFreq),
|
||||
]
|
||||
)
|
||||
let upModes: Select.Audio = Select.Audio(
|
||||
which: modeWhich,
|
||||
inputs: [
|
||||
makeFilter(dry, mode: .lowpass, direction: .up),
|
||||
makeFilter(dry, mode: .bandpass, direction: .up),
|
||||
makeFilter(dry, mode: .highpass, direction: .up),
|
||||
makeFilter(dry, mode: .lowpass, direction: .up, freqLo: restingFreq, freqHi: peakFreq),
|
||||
makeFilter(dry, mode: .bandpass, direction: .up, freqLo: restingFreq, freqHi: peakFreq),
|
||||
makeFilter(dry, mode: .highpass, direction: .up, freqLo: restingFreq, freqHi: peakFreq),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -153,7 +209,9 @@ public final class MutantPedal: Pedal {
|
||||
private func makeFilter(
|
||||
_ dry: any ValidGeneratorInput,
|
||||
mode: MuTronIIIMode,
|
||||
direction: MuTronIIISweep
|
||||
direction: MuTronIIISweep,
|
||||
freqLo: any ValidGeneratorInput,
|
||||
freqHi: any ValidGeneratorInput
|
||||
) -> MuTronIII.Audio {
|
||||
MuTronIII.Audio(
|
||||
input: dry,
|
||||
@@ -163,8 +221,8 @@ public final class MutantPedal: Pedal {
|
||||
peak: $resonance,
|
||||
freqLo: freqLo,
|
||||
freqHi: freqHi,
|
||||
attackTime: attackTime,
|
||||
releaseTime: releaseTime
|
||||
attackTime: $attack,
|
||||
releaseTime: $release
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// NeuralAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Neural amp/pedal capture player: runs a GuitarML Proteus / NeuralPi LSTM model on the input.
|
||||
///
|
||||
/// Load a model with ``loadModel(path:)`` (or set ``Pedal/resourcePath``); the file path is
|
||||
/// persisted in the rig, so a saved rig reloads the same capture. With no model loaded the pedal
|
||||
/// passes the signal through clean.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → × gain → LSTMAmp(model) → mono out (model loaded)
|
||||
/// dry → mono out (no model)
|
||||
/// ```
|
||||
///
|
||||
/// The model is read and built at `build()` (off the RT thread); changing it takes effect on the
|
||||
/// next rebuild. Fully wet when a model is loaded; `Level` is the master.
|
||||
///
|
||||
/// > Model files are **user-supplied and not bundled** — GuitarML models are GPL-3.0. Download a
|
||||
/// > capture (e.g. from the GuitarML Tone Library or Tone3000) and point the pedal at it.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `bypass` and `level` (master) from `Pedal`, plus:
|
||||
/// - `gain`: Input drive into the model (linear). Range `[0.25, 4]`.
|
||||
public final class NeuralAmpPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Plays a neural amp/pedal capture (GuitarML Proteus / NeuralPi model)."
|
||||
}
|
||||
|
||||
/// Fully wet when a model is loaded; hide the Mix control.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Input drive into the model (linear multiplier). Range [0.25, 4].
|
||||
@UIParam public var gain: Double = 1.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
private let gainRange: ClosedRange<Double> = 0.25 ... 4.0
|
||||
|
||||
/// Caches the parsed model per path so a stereo-region build (which calls `effect(_:)` once
|
||||
/// per channel) reads and decodes the file only once. Keyed on the path so a model change
|
||||
/// re-parses. Touched only at `build()` on the main thread.
|
||||
private var loadedModel: (path: String, model: NeuralAmpModel)?
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a neural amp pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Neural Amp",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: NeuralAmpPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
/// Points the pedal at a Proteus/NeuralPi model file. Takes effect on the next rebuild.
|
||||
///
|
||||
/// - Parameter path: Filesystem path to the model `.json`.
|
||||
public func loadModel(path: String) {
|
||||
resourcePath = path
|
||||
}
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Gain", node: $gain, range: gainRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Runs the loaded model on the (gain-trimmed) input; passes through clean if no model is set
|
||||
/// or the file can't be read/parsed.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The model output, or the dry signal when no model is loaded.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
guard let path: String = resourcePath, let model: NeuralAmpModel = resolveModel(path: path) else {
|
||||
return dry
|
||||
}
|
||||
let driven: any ValidGeneratorInput = dry * $gain
|
||||
return LSTMAmp(input: driven, model: model)
|
||||
}
|
||||
|
||||
/// Loads (and caches) the model at `path`, or returns `nil` if the file is missing/unparsable.
|
||||
private func resolveModel(path: String) -> NeuralAmpModel? {
|
||||
if let cached: (path: String, model: NeuralAmpModel) = loadedModel, cached.path == path {
|
||||
return cached.model
|
||||
}
|
||||
guard let data: Data = try? Data(contentsOf: URL(fileURLWithPath: path)),
|
||||
let model: NeuralAmpModel = try? ProteusModelImporter.model(fromProteusJSON: data)
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
loadedModel = (path, model)
|
||||
return model
|
||||
}
|
||||
}
|
||||
@@ -14,15 +14,17 @@ import LyrebirdUI
|
||||
/// dry ─┬─────────────────────────────────────────────────────────┐
|
||||
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │
|
||||
/// → LinLin(0…1 → floor…1) │
|
||||
/// → Lag(smooth) ───────────── × ──┴→ mono out
|
||||
/// → LagUpDown(fast open/slow close) × ─┴→ mono out
|
||||
/// ```
|
||||
///
|
||||
/// An `AmplitudeFollower` tracks the dry signal level. A Schmitt trigger turns that
|
||||
/// envelope into an open/closed gate with hysteresis (opens above `threshold × openRatio`,
|
||||
/// closes below `threshold`) so the gate does not chatter around the threshold. The 0/1
|
||||
/// gate is mapped to a gain in `[floor, 1]` and smoothed before multiplying the dry signal:
|
||||
/// when the gate is closed the signal is attenuated to `floor` rather than hard-muted, so
|
||||
/// `floor` sets how much of the quiet signal/noise tail bleeds through.
|
||||
/// gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** — opening fast so a
|
||||
/// note's attack isn't softened, closing slowly so the gate fades shut instead of snapping (a fast
|
||||
/// close popped audibly when heavy downstream gain amplified the step). When the gate is closed the
|
||||
/// signal is attenuated to `floor` rather than hard-muted, so `floor` sets how much of the quiet
|
||||
/// signal/noise tail bleeds through.
|
||||
///
|
||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||
///
|
||||
@@ -35,6 +37,8 @@ import LyrebirdUI
|
||||
/// the gate. Range `[0, 0.2]`. Defaults to `0.02`.
|
||||
/// - floor: Residual gain applied while the gate is closed, in `[0, 1]`. `0` = full
|
||||
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
|
||||
/// - attack: Gate open time in seconds (advanced pop-over). Range `[0.001, 0.05]`. Defaults to `0.005`.
|
||||
/// - release: Gate close time in seconds (advanced pop-over). Range `[0.01, 0.5]`. Defaults to `0.08`.
|
||||
public final class NoiseGatePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -50,6 +54,15 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// Residual gain while closed, [0, 1]. Range [0, 1].
|
||||
@UIParam public var floor: Double = 0.0
|
||||
|
||||
/// Gate **Attack** (open time) in seconds — how fast the gate opens on a note. Short keeps
|
||||
/// transients crisp. Range `[0.001, 0.05]`. Surfaced in the advanced pop-over.
|
||||
@UIParam public var attack: Double = 0.005
|
||||
|
||||
/// Gate **Release** (close time) in seconds — how gradually the gate fades shut as a note decays
|
||||
/// through the threshold. Short = a tight, fast gate; long = a gentle swell-down (and it rides
|
||||
/// out chatter at the threshold). Range `[0.01, 0.5]`. Surfaced in the advanced pop-over.
|
||||
@UIParam public var release: Double = 0.08
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the gate sits in-line.
|
||||
@@ -65,8 +78,11 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// below `threshold`, giving hysteresis that prevents chatter near the threshold.
|
||||
private let openRatio: Double = 2.0
|
||||
|
||||
/// Gain-smoothing lag time, in seconds — removes the click of an instantaneous 0↔1 gate.
|
||||
private let gainSmoothTime: Double = 0.01
|
||||
// Gate-gain smoothing is **asymmetric** (``attack`` open / ``release`` close) so the gate opens
|
||||
// promptly (a new note's attack isn't softened) but closes gently. A fast symmetric close
|
||||
// snapped the gain from unity to `floor` in ~10 ms, which — with heavy downstream gain
|
||||
// (fuzz/boost) amplifying the step — read as an audible "pop" as a sustained note decayed
|
||||
// through the threshold. A slower `release` fades the gate shut instead and rides out chatter.
|
||||
|
||||
/// Gate signal bounds for the `LinLin` floor map.
|
||||
private let gateLo: Double = 0.0
|
||||
@@ -83,6 +99,12 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// Floor knob range (residual gain).
|
||||
private let floorRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Attack (open-time) knob range, seconds.
|
||||
private let attackRange: ClosedRange<Double> = 0.001 ... 0.05
|
||||
|
||||
/// Release (close-time) knob range, seconds.
|
||||
private let releaseRange: ClosedRange<Double> = 0.01 ... 0.5
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
||||
@@ -90,6 +112,16 @@ public final class NoiseGatePedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Timing controls, tucked behind the pedal card's advanced pop-over: **Attack** (open time) and
|
||||
/// **Release** (close time). Live nodes, append-only in `advancedValues` — a gate saved before
|
||||
/// these existed loads with them at their defaults, no migration.
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Attack", node: $attack, range: attackRange),
|
||||
PedalKnob(label: "Release", node: $release, range: releaseRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a noise-gate pedal.
|
||||
@@ -141,10 +173,12 @@ public final class NoiseGatePedal: Pedal {
|
||||
outHi: openGain
|
||||
)
|
||||
|
||||
// Smooth the gain to remove the click of an instantaneous gate transition.
|
||||
let smoothed: Lag.Audio = Lag.Audio(
|
||||
// Smooth the gain asymmetrically: open fast (prompt on a note), close slowly (gentle fade,
|
||||
// no pop, and it rides out chatter as the envelope hovers at the threshold).
|
||||
let smoothed: LagUpDown.Audio = LagUpDown.Audio(
|
||||
input: gain,
|
||||
time: gainSmoothTime
|
||||
lagUp: $attack,
|
||||
lagDown: $release
|
||||
)
|
||||
|
||||
return dry * smoothed
|
||||
|
||||
@@ -11,7 +11,7 @@ import LyrebirdUI
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → SoftClip(drive:) → RBJLowPass(freq: tone, q: 0.707) → mono out
|
||||
/// dry → OversampledSaturator(curve: .softClipNormalized, drive:) → RBJLowPass(freq: tone, q: 0.707) → mono out
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||
@@ -83,7 +83,14 @@ public final class OverdrivePedal: Pedal {
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Saturated and tone-shaped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let saturated: SoftClip.Audio = SoftClip.Audio(dry, drive: $drive)
|
||||
// Same normalised soft-clip curve as before (`tanh(drive·x) / tanh(drive)`), but
|
||||
// evaluated at 2× so high-drive harmonics don't alias.
|
||||
let saturated: OversampledSaturator = OversampledSaturator(
|
||||
dry,
|
||||
drive: $drive,
|
||||
curve: .softClipNormalized,
|
||||
oversample: 2
|
||||
)
|
||||
return RBJLowPass.Audio(
|
||||
input: saturated,
|
||||
freq: $tone,
|
||||
|
||||
@@ -15,7 +15,7 @@ import LyrebirdUI
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry × OscSin(frequency) → wet
|
||||
/// dry → OversampledRingModulator(freq: frequency, oversample: 2) → wet
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||
@@ -78,7 +78,8 @@ public final class RingModulatorPedal: Pedal {
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The ring-modulated wet signal.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let carrier: OscSin.Audio = OscSin.Audio(freq: $frequency)
|
||||
return dry * carrier
|
||||
// Oversampled multiply: the sum sideband (f_in + f_carrier) can exceed Nyquist and
|
||||
// fold back as an inharmonic alias, so do the product at 2× and filter on the way down.
|
||||
return OversampledRingModulator(dry, freq: $frequency, oversample: 2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,16 @@ public final class ShimmerReverbPedal: Pedal {
|
||||
@UIParam public var size: Double = 0.06
|
||||
|
||||
/// Tail length (feedback). Range [0, 0.92].
|
||||
@UIParam public var decay: Double = 0.8
|
||||
///
|
||||
/// The regenerating loop gain is roughly `decay + shimmer`; keep their sum well under `1` to avoid
|
||||
/// self-oscillation (a sustaining screech with little or no input). Defaults sum to `0.75`.
|
||||
@UIParam public var decay: Double = 0.5
|
||||
|
||||
/// Octave-up regeneration amount. Range [0, 0.85].
|
||||
@UIParam public var shimmer: Double = 0.5
|
||||
/// Octave-up regeneration amount. Range [0, 0.85]. See ``decay`` on keeping `decay + shimmer < 1`.
|
||||
@UIParam public var shimmer: Double = 0.25
|
||||
|
||||
/// High-frequency damping. Range [0, 1].
|
||||
@UIParam public var damp: Double = 0.4
|
||||
@UIParam public var damp: Double = 0.5
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// SixtiesComboAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// American **'60s grit combo** — the small Supro/Silvertone-style amp: low headroom, gritty early
|
||||
/// breakup, and an onboard **tremolo**.
|
||||
///
|
||||
/// A ``AmpVoicePedal`` (`.fender`) driven hard into the power stage for early breakup, with a
|
||||
/// tremolo (Speed / Intensity + footswitch) in the onboard-effects slot.
|
||||
public final class SixtiesComboAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||
@UIParam public var speed: Double = 5.0
|
||||
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||
@UIParam public var intensity: Double = 0.0
|
||||
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||
@UIParam public var tremoloEnabled: Double = 1.0
|
||||
|
||||
/// Power-amp drive — well above the default fixed value so the small combo grits up early.
|
||||
private let grittyPowerDrive: Double = 2.4
|
||||
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
"American '60s grit combo — early-breakup with onboard tremolo."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Tremolo",
|
||||
node: $tremoloEnabled,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Driven hard into the power stage, so 4× oversampling for anti-alias headroom.
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { grittyPowerDrive }
|
||||
|
||||
/// Creates a Sixties Combo amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Sixties Combo", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.72 // gritty starting point
|
||||
cab = 2.0 // Vintage Dark — small, dark
|
||||
}
|
||||
|
||||
/// Onboard tremolo (gated by the Tremolo footswitch), inserted after the tone stack.
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// SustainFuzzPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Sustaining, mid-scooped fuzz: two cascaded soft-clipping stages into a scoop-and-tone filter.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → Saturator(soft, sustain) → Saturator(soft, sustain) → RBJPeakingEQ(−scoop @ 750 Hz) → RBJLowPass(tone) → out
|
||||
/// ```
|
||||
///
|
||||
/// This is the "wall of sustain" fuzz voice — distinct from the single-stage ``FuzzPedal``. Two
|
||||
/// cascaded *soft*-clipping stages compress and stack harmonics for long, smooth, violin-like
|
||||
/// sustain rather than the aggressive bite of a single hard `tanh` stage. A fixed mid **scoop**
|
||||
/// (a bell cut around 750 Hz) hollows the midrange — the defining character of this fuzz family —
|
||||
/// and the **tone** low-pass sets how dark or bright the top end sits.
|
||||
///
|
||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class; base `mix` is fully
|
||||
/// wet so the fuzz replaces the dry signal.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - sustain: Drive into both soft-clip stages. Higher = more sustain and compression.
|
||||
/// Range `[1, 30]`. Defaults to `6.0`.
|
||||
/// - tone: Low-pass tone cutoff in Hz. Range `[800, 6000]`. Defaults to `2500.0`.
|
||||
/// - scoop: Midrange cut depth in dB at 750 Hz (applied as a cut). Range `[0, 18]`. Defaults to `8.0`.
|
||||
public final class SustainFuzzPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Sustaining, mid-scooped fuzz for smooth, violin-like leads and thick walls of sound."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Drive into both cascaded soft-clip stages. Range [1, 30]; higher = more sustain.
|
||||
@UIParam public var sustain: Double = 6.0
|
||||
|
||||
/// Tone low-pass cutoff in Hz. Range [800, 6000].
|
||||
@UIParam public var tone: Double = 2500.0
|
||||
|
||||
/// Midrange cut depth in dB at 750 Hz. Range [0, 18].
|
||||
@UIParam public var scoop: Double = 8.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet so the fuzz completely replaces the dry signal.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Oversampling factor for the soft-clip stages — 2× keeps generated harmonics from folding back.
|
||||
private let oversampleFactor: Int = 2
|
||||
|
||||
/// Centre frequency of the midrange scoop in Hz.
|
||||
private let scoopFreq: Double = 750.0
|
||||
|
||||
/// Q of the midrange scoop bell. Moderately wide for a broad, hollow midrange.
|
||||
private let scoopQ: Double = 0.9
|
||||
|
||||
/// Q of the tone low-pass. Butterworth (no resonant peak).
|
||||
private let toneQ: Double = 0.707
|
||||
|
||||
/// Output trim after two soft-clip stages (each ≈ ±1) plus the mid cut, to sit at a sane level.
|
||||
private let outputTrim: Double = 0.6
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Sustain knob range (drive into the soft-clip stages).
|
||||
private let sustainRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
|
||||
/// Tone knob range in Hz (low-pass cutoff).
|
||||
private let toneRange: ClosedRange<Double> = 800.0 ... 6000.0
|
||||
|
||||
/// Scoop knob range in dB (midrange cut depth).
|
||||
private let scoopRange: ClosedRange<Double> = 0.0 ... 18.0
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sustain", node: $sustain, range: sustainRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
PedalKnob(label: "Scoop", node: $scoop, range: scoopRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a sustain-fuzz pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Sustain Fuzz",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: SustainFuzzPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Cascades two soft-clip stages, scoops the mids, then rolls off the top with the tone control.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Sustained, mid-scooped, tone-shaped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Two cascaded soft-clip stages. `softClipNormalized` keeps the level bounded as sustain
|
||||
// rises, so stacking two stages compresses and sustains rather than runs away.
|
||||
let stage1: OversampledSaturator = OversampledSaturator(
|
||||
dry,
|
||||
drive: $sustain,
|
||||
curve: .softClipNormalized,
|
||||
oversample: oversampleFactor
|
||||
)
|
||||
let stage2: OversampledSaturator = OversampledSaturator(
|
||||
stage1,
|
||||
drive: $sustain,
|
||||
curve: .softClipNormalized,
|
||||
oversample: oversampleFactor
|
||||
)
|
||||
|
||||
// Fixed midrange scoop (cut) — the hollow midrange that defines this fuzz family.
|
||||
let scoopCutDB: any ValidGeneratorInput = 0.0 - $scoop
|
||||
let scooped: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: stage2,
|
||||
freq: scoopFreq,
|
||||
gain: scoopCutDB,
|
||||
q: scoopQ
|
||||
)
|
||||
|
||||
// Tone low-pass rolls off the top end.
|
||||
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||
input: scooped,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
return toned * outputTrim
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,12 @@ import LyrebirdUI
|
||||
/// - sustain: Amount of sustain/compression. `0` = gentle, `10` = maximum squash and hold.
|
||||
/// Range `[0, 10]`. Defaults to `5.0`.
|
||||
/// - tone: Output low-pass cutoff in Hz. Range `[800, 8000]`. Defaults to `6000.0`.
|
||||
///
|
||||
/// At high sustain the compressor applies a low threshold, a high ratio, and up to +18 dB of
|
||||
/// makeup — a feed-forward compressor's non-zero attack lets transients overshoot before the
|
||||
/// gain clamps, so a hot pick can push the output past full scale and clip. The **Safety**
|
||||
/// switch inserts a brick-wall `LookAheadLimiter` after the compressor to catch those peaks;
|
||||
/// it is off by default and adds a short look-ahead output delay when engaged.
|
||||
public final class SustainerPedal: Pedal {
|
||||
|
||||
// MARK: - Parameters
|
||||
@@ -39,6 +45,10 @@ public final class SustainerPedal: Pedal {
|
||||
/// Output low-pass cutoff in Hz. Range [800, 8000].
|
||||
@UIParam public var tone: Double = 6000.0
|
||||
|
||||
/// Safety limiter engage state. `0` = off (compressor may overshoot), `1` = on
|
||||
/// (brick-wall look-ahead limiter catches transient peaks).
|
||||
@UIParam public var safetyLimiter: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
@@ -69,6 +79,19 @@ public final class SustainerPedal: Pedal {
|
||||
private let makeupAtMin: Double = 0.0
|
||||
private let makeupAtMax: Double = 18.0
|
||||
|
||||
/// Safety-limiter peak ceiling (linear amplitude), just below full scale.
|
||||
private let safetyCeiling: Double = 0.98
|
||||
|
||||
/// Safety-limiter look-ahead / output delay in seconds. Only in circuit when Safety is on.
|
||||
private let safetyLookAheadTime: Double = 0.005
|
||||
|
||||
/// Safety-limiter gain-release time in seconds.
|
||||
private let safetyReleaseTime: Double = 0.05
|
||||
|
||||
/// Safety switch position values.
|
||||
private let safetyOffValue: Double = 0.0
|
||||
private let safetyOnValue: Double = 1.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
private let sustainRange: ClosedRange<Double> = 0.0 ... 10.0
|
||||
@@ -81,6 +104,19 @@ public final class SustainerPedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Safety",
|
||||
node: $safetyLimiter,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: safetyOffValue),
|
||||
PedalSwitch.Option(title: "On", value: safetyOnValue),
|
||||
]
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a sustainer pedal.
|
||||
@@ -124,8 +160,22 @@ public final class SustainerPedal: Pedal {
|
||||
kneeWidth: kneeWidth,
|
||||
makeupGain: makeup
|
||||
)
|
||||
// Optional brick-wall safety limiter. Both branches are always built; `Select` picks
|
||||
// per the Safety switch (0 = compressor only, 1 = limited). Engaging it adds the
|
||||
// limiter's short look-ahead delay.
|
||||
let limited: LookAheadLimiter = LookAheadLimiter(
|
||||
in: compressed,
|
||||
maxAmplitude: safetyCeiling,
|
||||
lookAheadTime: safetyLookAheadTime,
|
||||
releaseTime: safetyReleaseTime,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
let guarded: Select.Audio = Select.Audio(
|
||||
which: $safetyLimiter,
|
||||
inputs: [compressed, limited]
|
||||
)
|
||||
return RBJLowPass.Audio(
|
||||
input: compressed,
|
||||
input: guarded,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
// VibePedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Photocell "vibe" pedal: four staggered all-pass stages swept by one shared LFO.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → RBJAllPass(freq₀(t)) → RBJAllPass(freq₁(t)) → RBJAllPass(freq₂(t)) → RBJAllPass(freq₃(t)) → wet
|
||||
/// out = wet·wetAmount + dry·dryAmount (mode: chorus blends dry+wet, vibrato is wet only)
|
||||
/// ```
|
||||
///
|
||||
/// Unlike a phaser (evenly-spaced stages producing symmetric notches), the vibe cascades all-pass
|
||||
/// stages at **staggered** centre frequencies, so the phase relationships between stages produce the
|
||||
/// characteristic uneven, vocal throb. A single low-frequency sine modulates every stage's centre
|
||||
/// frequency together; the `intensity` knob scales the sweep depth and the `speed` knob sets the LFO
|
||||
/// rate. In *chorus* mode the swept signal is blended 50/50 with the dry signal (comb-filter throb);
|
||||
/// in *vibrato* mode only the swept (phase-modulated) signal passes, for a pitch-vibrato-like warble.
|
||||
///
|
||||
/// The bypass switching is handled by the `Pedal` base class. The base `mix` is fixed fully wet — the
|
||||
/// chorus/vibrato dry blend is handled internally so the two modes behave correctly.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `bypass` and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - speed: LFO sweep rate in Hz. Range `[0.1, 12.0]`. Defaults to `3.0`.
|
||||
/// - intensity: Sweep depth as a fraction of each stage's centre frequency. Range `[0, 0.7]`.
|
||||
/// Defaults to `0.5`.
|
||||
/// - mode: `0` = chorus (dry + swept), `1` = vibrato (swept only). Defaults to chorus.
|
||||
public final class VibePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Throbbing photocell vibe — swirling chorus and warbling pitch-vibrato motion."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO sweep rate in Hz. Range [0.1, 12.0].
|
||||
@UIParam public var speed: Double = 3.0
|
||||
|
||||
/// Sweep depth as a fraction of each stage's centre frequency. Range [0, 0.7].
|
||||
@UIParam public var intensity: Double = 0.5
|
||||
|
||||
/// Mode select: `0` = chorus (dry + swept), `1` = vibrato (swept only).
|
||||
@UIParam public var mode: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the chorus/vibrato dry mix is handled inside `effect`.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Q for each all-pass stage. Gentle phase transition for a smooth, vocal vibe (not sharp notches).
|
||||
private let vibeQ: Double = 0.6
|
||||
|
||||
/// Staggered all-pass stage centre frequencies in Hz. Unequal spacing is what distinguishes the
|
||||
/// vibe's uneven throb from an evenly-spaced phaser.
|
||||
private let stageCenterFreqs: [Double] = [300.0, 620.0, 1300.0, 2200.0]
|
||||
|
||||
/// `mode` value selecting chorus (dry + swept).
|
||||
private let modeChorusValue: Double = 0.0
|
||||
|
||||
/// `mode` value selecting vibrato (swept only).
|
||||
private let modeVibratoValue: Double = 1.0
|
||||
|
||||
/// Wet gain at chorus mode (`mode == 0`); the swept signal sits 50/50 with dry.
|
||||
private let chorusWetGain: Double = 0.5
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Speed knob range in Hz (LFO sweep rate).
|
||||
private let speedRange: ClosedRange<Double> = 0.1 ... 12.0
|
||||
|
||||
/// Intensity knob range (sweep depth fraction). Capped below `1.0` so a stage's swept frequency
|
||||
/// never collapses toward `0 Hz` at the bottom of the sweep.
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 0.7
|
||||
|
||||
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[
|
||||
TempoSyncableParam(key: "speed", label: "Speed", node: $speed, kind: .rate, range: speedRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Mode",
|
||||
node: $mode,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Chorus", value: modeChorusValue),
|
||||
PedalSwitch.Option(title: "Vibrato", value: modeVibratoValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a vibe pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Vibe",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: VibePedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Cascades four staggered all-pass stages swept by a shared sine LFO, then blends per mode.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Wet mono vibe output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// One shared low-frequency sine drives every stage: ±1 scaled by intensity gives the sweep.
|
||||
let lfo: any ValidGeneratorInput = OscSin.Audio(freq: $speed)
|
||||
let sweep: any ValidGeneratorInput = lfo * $intensity // ±intensity
|
||||
|
||||
// Cascade the stages. Each stage's centre frequency is centre·(1 + sweep) = centre + centre·sweep.
|
||||
var signal: any ValidGeneratorInput = dry
|
||||
for center: Double in stageCenterFreqs {
|
||||
let stageFreq: any ValidGeneratorInput = sweep * center + center
|
||||
signal = RBJAllPass.Audio(input: signal, freq: stageFreq, q: vibeQ)
|
||||
}
|
||||
let wet: any ValidGeneratorInput = signal
|
||||
|
||||
// Blend by mode. Chorus (mode 0): 0.5·dry + 0.5·wet. Vibrato (mode 1): wet only.
|
||||
let wetAmount: any ValidGeneratorInput = $mode * chorusWetGain + chorusWetGain // 0.5 → 1.0
|
||||
let dryAmount: any ValidGeneratorInput = (modeVibratoValue - $mode) * chorusWetGain // 0.5 → 0.0
|
||||
return wet * wetAmount + dry * dryAmount
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// ChainRouterState.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// Serialisable snapshot of one ``ChainRouter`` — its two linear board chains and its blend state.
|
||||
///
|
||||
/// A router splits one input to two independent boards and blends their outputs. Its branches are
|
||||
/// built linearly (via ``ChainRouter/addToA(_:)`` / ``ChainRouter/addToB(_:)``), so each is captured
|
||||
/// as a flat list of ``PedalState``. The splitter's two branch-enable levels capture the A / B / both
|
||||
/// selection (and any continuous blend between them); the merger's two levels capture the output mix.
|
||||
///
|
||||
/// Persisted as part of ``ShoeGazeState/routers`` so a routed multi-board rig survives save / load.
|
||||
///
|
||||
/// > Note: The router's output-stage master gain (`masterGainNode`) is intentionally not captured,
|
||||
/// > matching the existing behaviour for a plain board's `masterGainNode` in `BoardState` — output
|
||||
/// > level is treated as a live mix control, not part of the saved rig.
|
||||
public struct ChainRouterState: Codable, Equatable {
|
||||
|
||||
/// Pedals on board A (the first branch), in chain order.
|
||||
public let boardA: [PedalState]
|
||||
|
||||
/// Pedals on board B (the second branch), in chain order.
|
||||
public let boardB: [PedalState]
|
||||
|
||||
/// Splitter branch-A enable level in `[0, 1]`. `1` = A audible, `0` = A muted.
|
||||
public let branchA: Double
|
||||
|
||||
/// Splitter branch-B enable level in `[0, 1]`. `1` = B audible, `0` = B muted.
|
||||
public let branchB: Double
|
||||
|
||||
/// Merger board-A output level in `[0, 1]`.
|
||||
public let mergerLevelA: Double
|
||||
|
||||
/// Merger board-B output level in `[0, 1]`.
|
||||
public let mergerLevelB: Double
|
||||
|
||||
/// Creates a router snapshot.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - boardA: Board A's pedals in chain order.
|
||||
/// - boardB: Board B's pedals in chain order.
|
||||
/// - branchA: Splitter branch-A enable level `[0, 1]`.
|
||||
/// - branchB: Splitter branch-B enable level `[0, 1]`.
|
||||
/// - mergerLevelA: Merger board-A output level `[0, 1]`.
|
||||
/// - mergerLevelB: Merger board-B output level `[0, 1]`.
|
||||
public init(
|
||||
boardA: [PedalState],
|
||||
boardB: [PedalState],
|
||||
branchA: Double,
|
||||
branchB: Double,
|
||||
mergerLevelA: Double,
|
||||
mergerLevelB: Double
|
||||
) {
|
||||
self.boardA = boardA
|
||||
self.boardB = boardB
|
||||
self.branchA = branchA
|
||||
self.branchB = branchB
|
||||
self.mergerLevelA = mergerLevelA
|
||||
self.mergerLevelB = mergerLevelB
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// 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 })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FactoryRigBuild.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// How a ``FactoryRig`` builds its graph at seed time.
|
||||
public enum FactoryRigBuild: Sendable {
|
||||
|
||||
/// Appends pedals to a single pre-made, empty board; the seeding driver calls `addBoard` before
|
||||
/// and `finalizeBoard` after.
|
||||
case singleBoard(@MainActor (_ session: ShoeGaze, _ board: PedalBoard) throws -> Void)
|
||||
|
||||
/// Builds the whole graph against the session (boards and/or routers), owning its own
|
||||
/// `addBoard`/`finalizeBoard` and `makeChainRouter`/`finalize` lifecycle.
|
||||
case session(@MainActor (_ session: ShoeGaze) throws -> Void)
|
||||
|
||||
/// Ships a pre-captured ``ShoeGazeState`` directly — the entry is built from it with no live
|
||||
/// session. Use for a complex, hand-authored rig captured from the app, where transcribing the
|
||||
/// exact `PedalState` arrays (mix, sliders, selectors, advanced values) is more faithful than
|
||||
/// re-deriving them through typed setters. The closure returns the state so the case stays
|
||||
/// `Sendable` without requiring `ShoeGazeState` itself to be `Sendable`.
|
||||
case state(@MainActor () -> ShoeGazeState)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// FactoryRigCategory.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Broad sonic grouping for a built-in ``FactoryRig``.
|
||||
///
|
||||
/// Purely presentational: the category lets a rig picker cluster the shipped starter rigs into
|
||||
/// recognisable families ("Shoegaze Walls", "Dreampop", …). It is **not** persisted in the saved
|
||||
/// ``RigEntry`` — a recalled rig is just a board, indistinguishable from a user rig once loaded.
|
||||
public enum FactoryRigCategory: String, CaseIterable, Sendable {
|
||||
|
||||
/// Dense fuzz-and-reverb "wall of sound" textures.
|
||||
case shoegazeWalls = "Shoegaze Walls"
|
||||
|
||||
/// Lush, clean, chorused and delayed dream-pop voices.
|
||||
case dreamPop = "Dreampop"
|
||||
|
||||
/// Classic overdrive / fuzz / wah lead and rhythm tones.
|
||||
case classic = "Classic"
|
||||
|
||||
/// Slow, evolving, reverb-heavy ambient beds.
|
||||
case ambient = "Ambient"
|
||||
|
||||
/// Lo-fi, bit-crushed, and otherwise experimental noise textures.
|
||||
case experimental = "Experimental"
|
||||
|
||||
/// Human-readable name shown as a section header in a rig picker.
|
||||
public var displayName: String { rawValue }
|
||||
}
|
||||
@@ -0,0 +1,842 @@
|
||||
// FactoryRigLibrary.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// MARK: - Typed board-building helper
|
||||
|
||||
extension PedalBoard {
|
||||
|
||||
/// Constructs a concrete pedal, applies `configure` to its typed parameters, and appends it to
|
||||
/// the end of the chain.
|
||||
///
|
||||
/// This is the building block for ``FactoryRig`` recipes: because `configure` receives the
|
||||
/// concrete pedal type, every parameter it touches (`$0.fuzz`, `$0.time`, …) is checked by the
|
||||
/// compiler against the real pedal API — a renamed control is a build error, not a silently
|
||||
/// broken preset. Bus wiring is handled by ``add(_:after:)``.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - pedal: A freshly-constructed pedal (its default buses are overwritten by the board).
|
||||
/// - configure: Sets the pedal's parameters before it is inserted.
|
||||
/// - Returns: The same pedal, now wired into the chain.
|
||||
/// - Throws: `BusAllocatorError.noFreeBus`, `EngineAddError`, or `ShoeGazeError.stereoWidthExceeded`.
|
||||
@discardableResult
|
||||
func append<P: Pedal>(
|
||||
_ pedal: P,
|
||||
configure: (P) -> Void
|
||||
) throws -> P {
|
||||
configure(pedal)
|
||||
try add(pedal)
|
||||
return pedal
|
||||
}
|
||||
}
|
||||
|
||||
extension ChainRouter {
|
||||
|
||||
/// Constructs a concrete pedal, applies `configure`, and appends it to board A of the router.
|
||||
///
|
||||
/// The concrete-type `configure` closure keeps every parameter compile-checked, exactly like
|
||||
/// ``PedalBoard/append(_:configure:)``. Uses ``addToA(_:)`` so ``finalize()`` ordering stays correct.
|
||||
@discardableResult
|
||||
func appendToA<P: Pedal>(_ pedal: P, configure: (P) -> Void) throws -> P {
|
||||
configure(pedal)
|
||||
try addToA(pedal)
|
||||
return pedal
|
||||
}
|
||||
|
||||
/// Constructs a concrete pedal, applies `configure`, and appends it to board B of the router.
|
||||
@discardableResult
|
||||
func appendToB<P: Pedal>(_ pedal: P, configure: (P) -> Void) throws -> P {
|
||||
configure(pedal)
|
||||
try addToB(pedal)
|
||||
return pedal
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Factory rig catalog
|
||||
|
||||
/// The built-in starter rigs shipped with the app and seeded into an empty rig library on first
|
||||
/// launch.
|
||||
///
|
||||
/// Each entry is a ``FactoryRig`` — a compile-checked builder, not a stored JSON blob. Call
|
||||
/// ``makeEntries(makeSession:)`` at seed time to materialise them into ``RigEntry`` snapshots.
|
||||
///
|
||||
/// Rig names and blurbs describe the *sound*; a blurb may reference an era or style but never a
|
||||
/// trademarked product or a specific artist's endorsed setup.
|
||||
@MainActor
|
||||
public enum FactoryRigLibrary {
|
||||
|
||||
/// Catalog seed version. Bump this whenever the shipped starter rigs change — new rigs added, or
|
||||
/// an existing rig's definition corrected — so launch catch-up re-runs on already-populated
|
||||
/// libraries and refreshes every starter to its current form. Within a single version the marker
|
||||
/// only advances once, so a starter the user deletes stays deleted until the next bump.
|
||||
public static let seedVersion: Int = 4
|
||||
|
||||
/// Stable ids of every built-in rig, for detecting whether a library entry is a factory rig.
|
||||
///
|
||||
/// Because factory rigs are seeded with their fixed ``FactoryRig/id``, an entry recalled from the
|
||||
/// library can be identified as shipped-vs-user by id membership here. Callers use this to guard
|
||||
/// destructive actions (e.g. warn before overwriting a starter rig).
|
||||
public static let factoryIDs: Set<UUID> = Set(all.map { $0.id })
|
||||
|
||||
/// Whether `id` belongs to a shipped factory rig.
|
||||
///
|
||||
/// - Parameter id: A ``RigEntry/id`` from the rig library.
|
||||
/// - Returns: `true` if the entry is one of the built-in starter rigs.
|
||||
public static func isFactory(_ id: UUID) -> Bool {
|
||||
factoryIDs.contains(id)
|
||||
}
|
||||
|
||||
/// The ``FactoryRigCategory`` of the shipped rig with this id, or `nil` for a user rig.
|
||||
///
|
||||
/// - Parameter id: A ``RigEntry/id`` from the rig library.
|
||||
/// - Returns: The rig's category, or `nil` if `id` is not a factory rig.
|
||||
public static func category(for id: UUID) -> FactoryRigCategory? {
|
||||
all.first(where: { $0.id == id })?.category
|
||||
}
|
||||
|
||||
/// The shipped rigs of a given category, in catalog order.
|
||||
///
|
||||
/// - Parameter category: The category to filter by.
|
||||
/// - Returns: The `FactoryRig`s in `category`, in the order they appear in ``all``.
|
||||
public static func rigs(in category: FactoryRigCategory) -> [FactoryRig] {
|
||||
all.filter { $0.category == category }
|
||||
}
|
||||
|
||||
/// Every built-in rig, in the order a picker should present them.
|
||||
public static let all: [FactoryRig] = [
|
||||
glideWall,
|
||||
chorusCathedral,
|
||||
fuzzWahClassic,
|
||||
dottedEighthAnthem,
|
||||
ambientShimmerBed,
|
||||
springReverbSurf,
|
||||
octaveFuzzLead,
|
||||
bitcrushNoiseTexture,
|
||||
funkEnvelopeClav,
|
||||
postRockCrescendo,
|
||||
nashvilleCleanComp,
|
||||
dubDelayThrow,
|
||||
ringModTexture,
|
||||
rockabillySlapback,
|
||||
psychVibeLead,
|
||||
comfortablyNumbLead,
|
||||
doomRiffWall,
|
||||
garciaOBELSplit,
|
||||
]
|
||||
|
||||
// MARK: Shoegaze walls
|
||||
|
||||
/// Dense detuned fuzz + reverse swells + plate bloom.
|
||||
static let glideWall: FactoryRig = FactoryRig(
|
||||
id: stableID("Glide Wall"),
|
||||
name: "90s Glide Wall",
|
||||
blurb: "A dense, saturated fuzz wall with reverse swells blooming around it. Hold big open "
|
||||
+ "chords and let the reverse delay and plate wash carry them — early-'90s British "
|
||||
+ "shoegaze territory.",
|
||||
category: .shoegazeWalls
|
||||
) { _, board in
|
||||
try board.append(FuzzPedal()) { p in
|
||||
p.fuzz = 42.0
|
||||
p.tone = 2600.0
|
||||
}
|
||||
try board.append(ChimeTopBoostAmpPedal()) { p in
|
||||
p.gain = 6.5
|
||||
p.bass = 0.6
|
||||
p.mid = 0.4
|
||||
p.treble = 0.7
|
||||
p.cut = 0.3
|
||||
p.brilliant = 1.0
|
||||
}
|
||||
try board.append(ReverseDelayPedal()) { p in
|
||||
p.time = 0.45
|
||||
p.feedback = 0.4
|
||||
}
|
||||
try board.append(PlateReverbPedal()) { p in
|
||||
p.decay = 0.8
|
||||
p.tone = 0.7
|
||||
p.damp = 0.25
|
||||
p.mod = 0.7
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Dreampop
|
||||
|
||||
/// Glassy clean chorus into cascading delay and octave-up shimmer.
|
||||
static let chorusCathedral: FactoryRig = FactoryRig(
|
||||
id: stableID("Chorus Cathedral"),
|
||||
name: "Dreampop Chorus Cathedral",
|
||||
blurb: "Glassy clean chorus into cascading delay and octave-up shimmer — lush and "
|
||||
+ "weightless. Play slow arpeggios and let every note ring into the next.",
|
||||
category: .dreamPop
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 3.0
|
||||
p.threshold = -18.0
|
||||
p.ratio = 3.0
|
||||
}
|
||||
try board.append(FullertonReverbAmpPedal()) { p in
|
||||
p.gain = 3.5
|
||||
p.bass = 0.5
|
||||
p.mid = 0.5
|
||||
p.treble = 0.6
|
||||
// Lean on the shimmer reverb downstream rather than the amp's own tank.
|
||||
p.reverbEnabled = 0.0
|
||||
p.vibratoEnabled = 0.0
|
||||
}
|
||||
// Chorus is a mono→stereo widener; keep it the only width change in the chain.
|
||||
try board.append(ChorusPedal()) { p in
|
||||
p.rate = 0.5
|
||||
p.depth = 0.005
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.4
|
||||
p.feedback = 1.5
|
||||
}
|
||||
try board.append(ShimmerReverbPedal()) { p in
|
||||
// Keep decay + shimmer well below self-oscillation — the loop gain is ~decay + shimmer, so
|
||||
// high values screech into runaway feedback with little or no input.
|
||||
p.size = 0.09
|
||||
p.decay = 0.5
|
||||
p.shimmer = 0.25
|
||||
p.damp = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Classic
|
||||
|
||||
/// Envelope-wah into thick fuzz and a cranked British stack.
|
||||
static let fuzzWahClassic: FactoryRig = FactoryRig(
|
||||
id: stableID("Fuzz Wah Classic"),
|
||||
name: "Fuzz + Wah Classic",
|
||||
blurb: "Envelope-wah into thick fuzz and a cranked British stack — an expressive, vocal "
|
||||
+ "lead voice with a touch of spring. Dig in and the wah opens up under your picking.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(AutoWahPedal()) { p in
|
||||
p.sensitivity = 2.5
|
||||
p.resonance = 4.0
|
||||
p.range = 2600.0
|
||||
}
|
||||
try board.append(FuzzPedal()) { p in
|
||||
p.fuzz = 38.0
|
||||
p.tone = 3200.0
|
||||
}
|
||||
try board.append(BritishPlexiAmpPedal()) { p in
|
||||
p.gain = 8.0
|
||||
p.bass = 0.6
|
||||
p.mid = 0.6
|
||||
p.treble = 0.6
|
||||
p.presence = 0.5
|
||||
p.bright = 1.0
|
||||
}
|
||||
try board.append(SpringReverbPedal()) { p in
|
||||
p.decay = 1.8
|
||||
p.tension = 0.5
|
||||
p.damp = 0.3
|
||||
}
|
||||
}
|
||||
|
||||
/// Chiming overdrive with a rhythmic dotted-eighth delay.
|
||||
static let dottedEighthAnthem: FactoryRig = FactoryRig(
|
||||
id: stableID("Dotted Eighth Anthem"),
|
||||
name: "Dotted-Eighth Anthem",
|
||||
blurb: "Chiming overdrive with a dotted-eighth delay that turns single notes into "
|
||||
+ "cascading patterns — bright, anthemic, arena-sized. Tuned to a dotted eighth at 120 "
|
||||
+ "BPM; play on the beat and let the echoes fill the gaps.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(OverdrivePedal()) { p in
|
||||
p.drive = 5.0
|
||||
p.tone = 4200.0
|
||||
}
|
||||
try board.append(ChimeTopBoostAmpPedal()) { p in
|
||||
p.gain = 5.0
|
||||
p.bass = 0.5
|
||||
p.mid = 0.5
|
||||
p.treble = 0.65
|
||||
p.cut = 0.25
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
// Dotted eighth at 120 BPM = 0.375 s.
|
||||
p.time = 0.375
|
||||
p.feedback = 1.6
|
||||
}
|
||||
try board.append(PlateReverbPedal()) { p in
|
||||
p.decay = 0.6
|
||||
p.tone = 0.8
|
||||
p.damp = 0.3
|
||||
p.mod = 0.4
|
||||
}
|
||||
}
|
||||
|
||||
/// Wet spring reverb and throbbing tremolo through a clean combo.
|
||||
static let springReverbSurf: FactoryRig = FactoryRig(
|
||||
id: stableID("Spring Reverb Surf"),
|
||||
name: "Spring-Reverb Surf",
|
||||
blurb: "Drippy spring reverb and throbbing tremolo through a clean Fullerton-style combo — "
|
||||
+ "classic surf voicing. Stab chords and ride the tremolo.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(TremoloPedal()) { p in
|
||||
p.rate = 5.5
|
||||
p.depth = 0.6
|
||||
}
|
||||
try board.append(FullertonReverbAmpPedal()) { p in
|
||||
p.gain = 3.5
|
||||
p.bass = 0.55
|
||||
p.mid = 0.5
|
||||
p.treble = 0.6
|
||||
p.reverb = 0.5
|
||||
p.reverbEnabled = 1.0
|
||||
p.vibratoEnabled = 0.0
|
||||
}
|
||||
try board.append(SpringReverbPedal()) { p in
|
||||
p.decay = 2.2
|
||||
p.tension = 0.6
|
||||
p.damp = 0.25
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Ambient
|
||||
|
||||
/// Long feedback echoes into octave-up shimmer and a cavernous room.
|
||||
static let ambientShimmerBed: FactoryRig = FactoryRig(
|
||||
id: stableID("Ambient Shimmer Bed"),
|
||||
name: "Ambient Shimmer Bed",
|
||||
blurb: "Long feedback echoes wash into octave-up shimmer and a cavernous room — a slow, "
|
||||
+ "evolving bed for swells and volume-knob fades. Play sparse and let it bloom.",
|
||||
category: .ambient
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 4.0
|
||||
p.threshold = -20.0
|
||||
p.ratio = 4.0
|
||||
}
|
||||
try board.append(FeedbackDelayPedal()) { p in
|
||||
p.time = 0.6
|
||||
p.feedback = 5.0
|
||||
p.tone = 3500.0
|
||||
}
|
||||
try board.append(ShimmerReverbPedal()) { p in
|
||||
// Long ambient tail, but decay + shimmer kept under ~0.8 so it never self-oscillates; the
|
||||
// room reverb downstream supplies the extra length.
|
||||
p.size = 0.11
|
||||
p.decay = 0.6
|
||||
p.shimmer = 0.2
|
||||
p.damp = 0.5
|
||||
}
|
||||
try board.append(RoomReverbPedal()) { p in
|
||||
p.size = 60.0
|
||||
p.decay = 8.0
|
||||
p.damp = 0.5
|
||||
p.tail = 0.7
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Experimental
|
||||
|
||||
/// A sub-octave layered under saturated fuzz for a thick, synth-like lead.
|
||||
static let octaveFuzzLead: FactoryRig = FactoryRig(
|
||||
id: stableID("Octave Fuzz Lead"),
|
||||
name: "Octave-Fuzz Lead",
|
||||
blurb: "A sub-octave layered under saturated fuzz for a thick, synth-like lead, pushed "
|
||||
+ "through a British master-volume voice. Single-note lines turn huge.",
|
||||
category: .experimental
|
||||
) { _, board in
|
||||
try board.append(BassOctaverPedal()) { p in
|
||||
p.oct1 = 0.8
|
||||
p.oct2 = 0.2
|
||||
p.direct = 0.9
|
||||
// Track mode: follow the played pitch rather than octave-flip.
|
||||
p.mode = 1.0
|
||||
}
|
||||
try board.append(FuzzPedal()) { p in
|
||||
p.fuzz = 45.0
|
||||
p.tone = 2800.0
|
||||
}
|
||||
try board.append(BritishMasterAmpPedal()) { p in
|
||||
p.gain = 7.0
|
||||
p.master = 0.5
|
||||
p.bass = 0.55
|
||||
p.mid = 0.6
|
||||
p.treble = 0.55
|
||||
p.presence = 0.4
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.28
|
||||
p.feedback = 1.4
|
||||
}
|
||||
}
|
||||
|
||||
/// Gritty sample-rate crushing into runaway feedback delay and a wide room.
|
||||
static let bitcrushNoiseTexture: FactoryRig = FactoryRig(
|
||||
id: stableID("Bitcrush Noise Texture"),
|
||||
name: "Bitcrush Noise Texture",
|
||||
blurb: "Gritty sample-rate crushing into runaway feedback delay and a wide room — harsh, "
|
||||
+ "lo-fi and unstable in the best way. Made for drones and glitch textures.",
|
||||
category: .experimental
|
||||
) { _, board in
|
||||
try board.append(BitcrusherPedal()) { p in
|
||||
p.crush = 6.0
|
||||
p.bits = 5.0
|
||||
p.tone = 3200.0
|
||||
}
|
||||
try board.append(FeedbackDelayPedal()) { p in
|
||||
p.time = 0.33
|
||||
p.feedback = 4.0
|
||||
p.tone = 2800.0
|
||||
}
|
||||
try board.append(ReverbPedal()) { p in
|
||||
p.roomSize = 0.8
|
||||
p.damping = 0.4
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: More classic voices
|
||||
|
||||
/// Envelope filter into light overdrive and a clean amp — funky, vocal, touch-sensitive.
|
||||
static let funkEnvelopeClav: FactoryRig = FactoryRig(
|
||||
id: stableID("Funk Envelope Clav"),
|
||||
name: "Funk Envelope Clav",
|
||||
blurb: "An envelope filter that opens with your picking, into light grit and a clean amp — "
|
||||
+ "funky and vocal, the classic auto-wah clav voice. Play staccato and let your "
|
||||
+ "dynamics work the filter.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(MutantPedal()) { p in
|
||||
p.sensitivity = 3.0
|
||||
p.resonance = 6.0
|
||||
}
|
||||
try board.append(OverdrivePedal()) { p in
|
||||
p.drive = 3.0
|
||||
p.tone = 4500.0
|
||||
}
|
||||
try board.append(JazzCleanAmpPedal()) { p in
|
||||
p.gain = 4.0
|
||||
p.bass = 0.5
|
||||
p.mid = 0.6
|
||||
p.treble = 0.6
|
||||
p.reverb = 0.15
|
||||
p.chorusEnabled = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Compressed clean into slapback echo and spring — bright, springy country/rockabilly.
|
||||
static let nashvilleCleanComp: FactoryRig = FactoryRig(
|
||||
id: stableID("Nashville Clean Comp"),
|
||||
name: "Nashville Clean Comp",
|
||||
blurb: "Squashed clean tone into a short slapback and spring reverb — bright, snappy and "
|
||||
+ "articulate, the Nashville country voice. Hybrid-pick and let the compressor even it "
|
||||
+ "out.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 3.0
|
||||
p.threshold = -16.0
|
||||
p.ratio = 4.0
|
||||
}
|
||||
try board.append(FullertonReverbAmpPedal()) { p in
|
||||
p.gain = 3.0
|
||||
p.bass = 0.5
|
||||
p.mid = 0.55
|
||||
p.treble = 0.65
|
||||
p.reverb = 0.3
|
||||
p.reverbEnabled = 1.0
|
||||
p.vibratoEnabled = 0.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
// Short slapback.
|
||||
p.time = 0.11
|
||||
p.feedback = 0.3
|
||||
}
|
||||
}
|
||||
|
||||
/// Compressed chime into tight slapback and spring — classic rockabilly.
|
||||
static let rockabillySlapback: FactoryRig = FactoryRig(
|
||||
id: stableID("Rockabilly Slapback"),
|
||||
name: "Rockabilly Slapback",
|
||||
blurb: "Compressed chime with a tight tape-style slapback and spring — the rockabilly "
|
||||
+ "bounce. Palm-mute and dig in for the classic '50s snap.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 2.0
|
||||
p.threshold = -14.0
|
||||
p.ratio = 3.0
|
||||
}
|
||||
try board.append(ChimeTopBoostAmpPedal()) { p in
|
||||
p.gain = 4.0
|
||||
p.bass = 0.5
|
||||
p.mid = 0.5
|
||||
p.treble = 0.65
|
||||
p.cut = 0.2
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
// Very short slapback echo.
|
||||
p.time = 0.09
|
||||
p.feedback = 0.25
|
||||
}
|
||||
try board.append(SpringReverbPedal()) { p in
|
||||
p.decay = 1.2
|
||||
p.tension = 0.6
|
||||
p.damp = 0.3
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: More ambient / experimental voices
|
||||
|
||||
/// Overdriven arpeggios into long delay and shimmer — a swelling post-rock build.
|
||||
static let postRockCrescendo: FactoryRig = FactoryRig(
|
||||
id: stableID("Post-Rock Crescendo"),
|
||||
name: "Post-Rock Crescendo",
|
||||
blurb: "Warm overdrive into a long delay and octave-up shimmer — a swelling, cinematic "
|
||||
+ "post-rock build. Layer arpeggios and let the wash grow into a crescendo.",
|
||||
category: .ambient
|
||||
) { _, board in
|
||||
try board.append(OverdrivePedal()) { p in
|
||||
p.drive = 6.0
|
||||
p.tone = 4000.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.5
|
||||
p.feedback = 2.5
|
||||
}
|
||||
try board.append(ShimmerReverbPedal()) { p in
|
||||
p.size = 0.1
|
||||
p.decay = 0.55
|
||||
p.shimmer = 0.25
|
||||
p.damp = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/// A dub-style feedback echo washing into deep spring — sparse, spacious, delay-forward.
|
||||
static let dubDelayThrow: FactoryRig = FactoryRig(
|
||||
id: stableID("Dub Delay Throw"),
|
||||
name: "Dub Delay Throw",
|
||||
blurb: "A long, dark feedback echo washing into deep spring reverb — the dub delay-throw. "
|
||||
+ "Play sparse skanks and ride the feedback for runaway repeats.",
|
||||
category: .ambient
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 2.0
|
||||
p.threshold = -16.0
|
||||
p.ratio = 3.0
|
||||
}
|
||||
try board.append(FeedbackDelayPedal()) { p in
|
||||
p.time = 0.45
|
||||
p.feedback = 6.0
|
||||
p.tone = 2500.0
|
||||
}
|
||||
try board.append(SpringReverbPedal()) { p in
|
||||
p.decay = 2.5
|
||||
p.tension = 0.5
|
||||
p.damp = 0.35
|
||||
}
|
||||
}
|
||||
|
||||
/// Ring modulation into delay and reverb — clangorous, inharmonic, otherworldly.
|
||||
static let ringModTexture: FactoryRig = FactoryRig(
|
||||
id: stableID("Ring-Mod Texture"),
|
||||
name: "Ring-Mod Texture",
|
||||
blurb: "Ring modulation into delay and a wide room — clangorous, inharmonic and "
|
||||
+ "otherworldly. Try single notes and let the metallic overtones ring out.",
|
||||
category: .experimental
|
||||
) { _, board in
|
||||
try board.append(RingModulatorPedal()) { p in
|
||||
p.frequency = 180.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.3
|
||||
p.feedback = 1.8
|
||||
}
|
||||
try board.append(ReverbPedal()) { p in
|
||||
p.roomSize = 0.75
|
||||
p.damping = 0.4
|
||||
}
|
||||
}
|
||||
|
||||
/// Fuzz swirled by a throbbing vibe into delay and plate — vintage psychedelic lead.
|
||||
static let psychVibeLead: FactoryRig = FactoryRig(
|
||||
id: stableID("Psych Vibe Lead"),
|
||||
name: "Psychedelic Vibe Lead",
|
||||
blurb: "Thick fuzz swirled by a throbbing photocell vibe, into delay and plate — the "
|
||||
+ "late-'60s psychedelic lead voice. Hold notes and let the vibe pulse underneath.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(FuzzPedal()) { p in
|
||||
p.fuzz = 30.0
|
||||
p.tone = 3000.0
|
||||
}
|
||||
try board.append(VibePedal()) { p in
|
||||
p.speed = 2.5
|
||||
p.intensity = 0.6
|
||||
// Chorus mode: dry + swept, the classic vibe throb.
|
||||
p.mode = 0.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.4
|
||||
p.feedback = 2.0
|
||||
}
|
||||
try board.append(PlateReverbPedal()) { p in
|
||||
p.decay = 0.6
|
||||
p.tone = 0.75
|
||||
p.damp = 0.3
|
||||
p.mod = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/// Compressed sustaining fuzz into a dotted delay and shimmer — a soaring, singing lead.
|
||||
static let comfortablyNumbLead: FactoryRig = FactoryRig(
|
||||
id: stableID("Comfortably Numb Lead"),
|
||||
name: "Comfortably Numb Lead",
|
||||
blurb: "Compressed, mid-scooped sustain fuzz into a dotted delay and octave-up shimmer — a "
|
||||
+ "soaring, singing lead that holds forever. Bend into long notes and let them bloom.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 4.0
|
||||
p.threshold = -18.0
|
||||
p.ratio = 4.0
|
||||
}
|
||||
try board.append(SustainFuzzPedal()) { p in
|
||||
p.sustain = 14.0
|
||||
p.tone = 3000.0
|
||||
p.scoop = 10.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
// Dotted eighth at ~100 BPM.
|
||||
p.time = 0.45
|
||||
p.feedback = 2.2
|
||||
}
|
||||
try board.append(ShimmerReverbPedal()) { p in
|
||||
p.size = 0.09
|
||||
p.decay = 0.55
|
||||
p.shimmer = 0.25
|
||||
p.damp = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-octave under a huge scooped fuzz into a cavernous room — heavy, slow doom.
|
||||
static let doomRiffWall: FactoryRig = FactoryRig(
|
||||
id: stableID("Doom Riff Wall"),
|
||||
name: "Doom Riff Wall",
|
||||
blurb: "A sub-octave stacked under a huge mid-scooped fuzz, into a cavernous room — crushing, "
|
||||
+ "slow doom. Down-tune, play half-time and let the low end swallow the room.",
|
||||
category: .experimental
|
||||
) { _, board in
|
||||
try board.append(BassOctaverPedal()) { p in
|
||||
p.oct1 = 0.8
|
||||
p.oct2 = 0.3
|
||||
p.direct = 0.9
|
||||
// Track mode: follow the played pitch.
|
||||
p.mode = 1.0
|
||||
}
|
||||
try board.append(SustainFuzzPedal()) { p in
|
||||
p.sustain = 22.0
|
||||
p.tone = 2200.0
|
||||
p.scoop = 6.0
|
||||
}
|
||||
try board.append(RoomReverbPedal()) { p in
|
||||
p.size = 70.0
|
||||
p.decay = 6.0
|
||||
p.damp = 0.55
|
||||
p.tail = 0.7
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Two-board split
|
||||
|
||||
/// Two boards — a full effects chain and a clean direct path — switched with the board selector.
|
||||
static let garciaOBELSplit: FactoryRig = FactoryRig(
|
||||
id: stableID("Garcia OBEL Split"),
|
||||
name: "Garcia OBEL Clean/Effects Split",
|
||||
blurb: "Two boards, one selector: Board 1 is an effects/lead chain (octave, envelope filter, "
|
||||
+ "overdrive, graphic EQ, phaser, delay, reverb); Board 2 is a fuller direct voice "
|
||||
+ "(overdrive, graphic EQ, compression, reverb). Use the board Solo / Blend control at the "
|
||||
+ "top to switch between them, like an on-board effects loop. In the spirit of a certain "
|
||||
+ "improvising guitarist's late-'80s rig.",
|
||||
category: .classic,
|
||||
// Hand-authored in the app and shipped as a captured state — transcribing the exact pedal
|
||||
// values (mix, graphic-EQ sliders, cab selector, amp sag/bias) is more faithful than
|
||||
// re-deriving them through typed setters. Input source / channel counts are intentionally
|
||||
// omitted so the rig is input-agnostic.
|
||||
state: garciaState
|
||||
)
|
||||
|
||||
/// The shipped Garcia rig content. `static let` so its (default) pedal ids are stable per process,
|
||||
/// keeping seeding deterministic.
|
||||
private static let garciaState: ShoeGazeState = ShoeGazeState(
|
||||
boards: [
|
||||
BoardState(label: "Board 1", pedals: [
|
||||
PedalState(type: "Bass Octaver",
|
||||
knobValues: [0.5, 0, 1, 1, 1], switchValues: [1], bypass: 0),
|
||||
PedalState(type: "Mutant",
|
||||
knobValues: [2.5, 4.45515625, 1, 1], switchValues: [1, 0], bypass: 0),
|
||||
PedalState(type: "Overdrive",
|
||||
knobValues: [5, 4200, 1, 1], bypass: 0),
|
||||
PedalState(type: "Graphic EQ",
|
||||
knobValues: [1, 1],
|
||||
sliderValues: [-4.7786931818181815, -2.214204545454546, 1.552840909090909,
|
||||
1.8536931818181799, -3.3426136363636374, -0.45852272727272947],
|
||||
bypass: 0),
|
||||
PedalState(type: "Phaser",
|
||||
knobValues: [0.4, 0.4, 0.5, 1], bypass: 0),
|
||||
PedalState(type: "Delay",
|
||||
knobValues: [0.35, 1.8, 0.35, 1], bypass: 0),
|
||||
PedalState(type: "Fullerton Reverb",
|
||||
knobValues: [2.5505078125, 0.5, 0.5, 0.6, 0.25, 4, 0, 1, 1],
|
||||
switchValues: [0, 1, 0], selectorValues: [4],
|
||||
advancedValues: [0, 0.5, 0], bypass: 0),
|
||||
]),
|
||||
BoardState(label: "Board 2", pedals: [
|
||||
PedalState(type: "Overdrive",
|
||||
knobValues: [6.54533203125, 4000, 1, 1], bypass: 0),
|
||||
PedalState(type: "Graphic EQ",
|
||||
knobValues: [1, 1],
|
||||
sliderValues: [2.957386363636365, 0, 2.7741477272727266,
|
||||
1.940624999999999, -0.6767045454545446, 0],
|
||||
bypass: 0),
|
||||
PedalState(type: "Compressor",
|
||||
knobValues: [2, -16, 3, 1, 1], switchValues: [0], bypass: 0),
|
||||
PedalState(type: "Fullerton Reverb",
|
||||
knobValues: [5.08, 0.5, 0.5, 0.6, 0.13624999999999998, 4, 0, 1, 1],
|
||||
switchValues: [0, 1, 0], selectorValues: [4],
|
||||
advancedValues: [0, 0.5, 0], bypass: 0),
|
||||
]),
|
||||
],
|
||||
bpm: 120,
|
||||
tempoEnabled: true
|
||||
)
|
||||
|
||||
// MARK: - Seeding
|
||||
|
||||
/// Builds every factory rig into a ``RigEntry`` snapshot suitable for the rig library.
|
||||
///
|
||||
/// Each rig is constructed in a fresh, **never-started** ``ShoeGaze`` session (capturing a rig
|
||||
/// only reads `@UIParam` values — no audio is rendered), captured with the rig's stable `id`, and
|
||||
/// the session is torn down before the next. Because ids are stable, re-running this against an
|
||||
/// already-seeded library overwrites entries in place rather than duplicating them.
|
||||
///
|
||||
/// - Parameter makeSession: Returns a fresh, empty session (typically backed by an offline
|
||||
/// engine). Called once per rig.
|
||||
/// - Returns: One ``RigEntry`` per ``all`` rig, in catalog order.
|
||||
/// - Throws: Any error from session creation, board building, or finalisation.
|
||||
public static func makeEntries(
|
||||
makeSession: @MainActor () throws -> ShoeGaze
|
||||
) throws -> [RigEntry] {
|
||||
var entries: [RigEntry] = []
|
||||
entries.reserveCapacity(all.count)
|
||||
for rig: FactoryRig in all {
|
||||
// A state-backed rig needs no live session — build its entry directly from the state.
|
||||
if case .state(let makeState) = rig.build {
|
||||
entries.append(RigEntry(id: rig.id, name: rig.name, state: makeState()))
|
||||
continue
|
||||
}
|
||||
|
||||
let session: ShoeGaze = try makeSession()
|
||||
// Tear down on every exit from this iteration, including a throw from a builder, so a
|
||||
// failing rig never leaks its throwaway engine's buses/nodes.
|
||||
defer { session.teardown() }
|
||||
switch rig.build {
|
||||
case .singleBoard(let build):
|
||||
let board: PedalBoard = try session.addBoard()
|
||||
try build(session, board)
|
||||
try session.finalizeBoard(board)
|
||||
case .session(let build):
|
||||
// The builder owns its own board/router lifecycle (addBoard/finalizeBoard,
|
||||
// makeChainRouter/finalize).
|
||||
try build(session)
|
||||
case .state:
|
||||
continue // handled above
|
||||
}
|
||||
entries.append(session.captureEntry(name: rig.name, id: rig.id))
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
/// Builds every factory rig using a self-contained offline engine per rig.
|
||||
///
|
||||
/// Convenience over ``makeEntries(makeSession:)`` for callers with no session of their own (the
|
||||
/// first-launch seeding path). Each rig gets a fresh ``NRTDriver``-backed engine that is never
|
||||
/// started — no audio is rendered and no output file is written (the driver only touches disk in
|
||||
/// `start()`), so the temporary URL handed to the driver never comes into existence.
|
||||
///
|
||||
/// - Returns: One ``RigEntry`` per ``all`` rig, in catalog order.
|
||||
/// - Throws: Any error from board building or finalisation.
|
||||
public static func makeEntries() throws -> [RigEntry] {
|
||||
try makeEntries(makeSession: makeOfflineSeedSession)
|
||||
}
|
||||
|
||||
/// Block size for the throwaway seeding engine. Matches the framework default; never renders.
|
||||
private static let seedBlockSize: Int = 512
|
||||
|
||||
/// Sample rate for the throwaway seeding engine. Only affects `@UIParam` capture indirectly; no
|
||||
/// audio is produced.
|
||||
private static let seedSampleRate: Double = 44_100.0
|
||||
|
||||
/// Audio bus count for the throwaway seeding engine — generous headroom for the longest chain.
|
||||
private static let seedAudioBusCount: Int = 128
|
||||
|
||||
/// Control bus count for the throwaway seeding engine.
|
||||
private static let seedControlBusCount: Int = 512
|
||||
|
||||
/// Nominal render duration handed to the offline driver. Unused — the engine is never started.
|
||||
private static let seedRenderDuration: Double = 0.05
|
||||
|
||||
/// Creates a fresh, never-started offline ``ShoeGaze`` session for building one factory rig.
|
||||
private static func makeOfflineSeedSession() -> ShoeGaze {
|
||||
let outputURL: URL = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent(UUID().uuidString + ".caf")
|
||||
let driver: NRTDriver = NRTDriver(outputURL: outputURL, duration: seedRenderDuration)
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: seedBlockSize,
|
||||
sampleRate: seedSampleRate,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: seedAudioBusCount,
|
||||
numControlBuses: seedControlBusCount,
|
||||
driver: driver
|
||||
)
|
||||
return ShoeGaze(engine: engine, inputSource: .testLoop)
|
||||
}
|
||||
|
||||
// MARK: - Stable identifiers
|
||||
|
||||
/// Deterministic UUID derived from a rig's identity string via two FNV-1a hashes.
|
||||
///
|
||||
/// Gives each rig a stable library id across launches without a hand-written UUID literal, and
|
||||
/// keeps seeding idempotent (same id ⇒ overwrite in place). Not a cryptographic identifier —
|
||||
/// only stability and per-rig uniqueness matter here.
|
||||
static func stableID(_ seed: String) -> UUID {
|
||||
let fnvOffset: UInt64 = 0xcbf2_9ce4_8422_2325
|
||||
let fnvPrime: UInt64 = 0x0000_0100_0000_01b3
|
||||
|
||||
func hash(_ string: String) -> UInt64 {
|
||||
var value: UInt64 = fnvOffset
|
||||
for byte: UInt8 in string.utf8 {
|
||||
value = (value ^ UInt64(byte)) &* fnvPrime
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
let high: UInt64 = hash(seed)
|
||||
let low: UInt64 = hash(seed + "\u{1}salt")
|
||||
|
||||
func byte(_ source: UInt64, _ shift: UInt64) -> UInt8 {
|
||||
UInt8((source >> shift) & 0xFF)
|
||||
}
|
||||
|
||||
let bytes: uuid_t = (
|
||||
byte(high, 56), byte(high, 48), byte(high, 40), byte(high, 32),
|
||||
byte(high, 24), byte(high, 16), byte(high, 8), byte(high, 0),
|
||||
byte(low, 56), byte(low, 48), byte(low, 40), byte(low, 32),
|
||||
byte(low, 24), byte(low, 16), byte(low, 8), byte(low, 0)
|
||||
)
|
||||
return UUID(uuid: bytes)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ extension Pedal {
|
||||
let switchValues: [Double] = effectSwitches.map { $0.node.value }
|
||||
let sliderValues: [Double] = effectSliders.map { $0.node.value }
|
||||
let selectorValues: [Double] = effectSelectors.map { $0.node.value }
|
||||
let advancedValues: [Double] = advancedKnobs.map { $0.node.value }
|
||||
return PedalState(
|
||||
id: id,
|
||||
type: displayName,
|
||||
@@ -27,25 +28,74 @@ extension Pedal {
|
||||
switchValues: switchValues,
|
||||
sliderValues: sliderValues,
|
||||
selectorValues: selectorValues,
|
||||
advancedValues: advancedValues,
|
||||
bypass: bypass,
|
||||
tempoSync: tempoSync.isEmpty ? nil : tempoSync
|
||||
tempoSync: tempoSync.isEmpty ? nil : tempoSync,
|
||||
resourcePath: resourcePath
|
||||
)
|
||||
}
|
||||
|
||||
/// Modern High-Gain's display name — the one shipped amp whose `Sag` control started life as a
|
||||
/// face knob and later moved to the advanced pop-over. Used to detect its legacy `PedalState`
|
||||
/// layout in ``legacyMigrated(_:)``.
|
||||
private static let modernHighGainType: String = "Modern High-Gain"
|
||||
/// A legacy Modern High-Gain `PedalState` has 11 `knobValues`: `Gain, Bass, Mid, Treble,
|
||||
/// Presence, Depth, Master, Drive, Sag, Mix, Level`.
|
||||
private static let modernHighGainLegacyKnobCount: Int = 11
|
||||
/// Index of `Sag` in that legacy `knobValues` array (the 9th knob).
|
||||
private static let modernHighGainLegacySagIndex: Int = 8
|
||||
|
||||
/// Normalizes a `PedalState` saved under a superseded on-disk layout to the current shape, so old
|
||||
/// rigs load without corruption.
|
||||
///
|
||||
/// Currently one case: **Modern High-Gain** shipped `Sag` as its 9th face knob (`knobValues`
|
||||
/// index 8, ahead of the trailing `Mix`/`Level`); `Sag` has since moved to the advanced pop-over,
|
||||
/// so it is no longer in `knobValues`. Because `knobValues` is a flat positional array, loading a
|
||||
/// legacy preset against the current 10-knob shape would misassign the old `Sag` onto `Mix` and
|
||||
/// the old `Mix` onto `Level`. Detected by the legacy shape (11 `knobValues`, empty
|
||||
/// `advancedValues`) and rewritten: `Sag` is lifted out of `knobValues` into `advancedValues`,
|
||||
/// leaving `Gain…Drive, Mix, Level` in order. `Bias` (the second advanced knob) had no legacy
|
||||
/// value, so it stays at its default.
|
||||
///
|
||||
/// - Parameter state: The decoded state, possibly in a legacy layout.
|
||||
/// - Returns: The state in the current layout, or `state` unchanged when no migration applies.
|
||||
private static func legacyMigrated(_ state: PedalState) -> PedalState {
|
||||
guard state.type == modernHighGainType,
|
||||
state.advancedValues.isEmpty,
|
||||
state.knobValues.count == modernHighGainLegacyKnobCount else {
|
||||
return state
|
||||
}
|
||||
let sag: Double = state.knobValues[modernHighGainLegacySagIndex]
|
||||
var knobValues: [Double] = state.knobValues
|
||||
knobValues.remove(at: modernHighGainLegacySagIndex)
|
||||
return PedalState(
|
||||
id: state.id,
|
||||
type: state.type,
|
||||
knobValues: knobValues,
|
||||
switchValues: state.switchValues,
|
||||
sliderValues: state.sliderValues,
|
||||
selectorValues: state.selectorValues,
|
||||
advancedValues: [sag],
|
||||
bypass: state.bypass,
|
||||
tempoSync: state.tempoSync,
|
||||
resourcePath: state.resourcePath
|
||||
)
|
||||
}
|
||||
|
||||
/// Applies a previously captured `PedalState` to this pedal's parameters.
|
||||
///
|
||||
/// For each (knob, value) pair in `zip(knobs, state.knobValues)`, the knob's
|
||||
/// `UIParamNode` is updated via `node.update(_:)`; switch positions are restored the
|
||||
/// same way from `zip(effectSwitches, state.switchValues)`. If either array has fewer
|
||||
/// entries than its controls, the trailing controls retain their current values; extra
|
||||
/// values are ignored. The `bypass` parameter is always applied regardless of any
|
||||
/// count mismatch. Presets saved before switches existed carry an empty
|
||||
/// `switchValues`, leaving switch positions at their defaults.
|
||||
/// The incoming state is first normalized by ``legacyMigrated(_:)`` for older on-disk layouts.
|
||||
/// For each (knob, value) pair in `zip(knobs, state.knobValues)`, the knob's `UIParamNode` is
|
||||
/// updated via `node.update(_:)`; switch, slider, selector, and advanced-knob positions are
|
||||
/// restored the same way. If either array has fewer entries than its controls, the trailing
|
||||
/// controls retain their current values; extra values are ignored. The `bypass` parameter is
|
||||
/// always applied regardless of any count mismatch. Presets saved before a given control existed
|
||||
/// carry an empty array for it, leaving those controls at their defaults.
|
||||
///
|
||||
/// - Parameter state: The state to restore. The `state.type` is not validated
|
||||
/// against `displayName` — the caller is responsible for matching types before
|
||||
/// calling this method.
|
||||
public func applyState(_ state: PedalState) {
|
||||
/// - Parameter rawState: The state to restore. The `state.type` is not validated against
|
||||
/// `displayName` — the caller is responsible for matching types before calling this method.
|
||||
public func applyState(_ rawState: PedalState) {
|
||||
let state: PedalState = Pedal.legacyMigrated(rawState)
|
||||
// Restore the saved identity so the pedal keeps its id across rebuilds; MIDI bindings
|
||||
// address pedals by this id.
|
||||
id = state.id
|
||||
@@ -61,10 +111,14 @@ extension Pedal {
|
||||
for (selector, value) in zip(effectSelectors, state.selectorValues) {
|
||||
selector.node.update(value)
|
||||
}
|
||||
for (advancedKnob, value) in zip(advancedKnobs, state.advancedValues) {
|
||||
advancedKnob.node.update(value)
|
||||
}
|
||||
bypass = state.bypass
|
||||
// Restore tempo-sync state. The synced values themselves are recomputed from the rig's
|
||||
// tempo by `ShoeGaze` after the rebuild, so no clock is required here.
|
||||
tempoSync = state.tempoSync ?? [:]
|
||||
tempoSyncRevision.bump()
|
||||
resourcePath = state.resourcePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,42 @@ public enum PedalRegistry {
|
||||
/// `ShoeGaze.loadRig(from:)` updates `inputBus`/`outputBus` when adding the pedal
|
||||
/// to a board via `board.add(_:)`.
|
||||
public static let builtIn: [String: @MainActor () -> Pedal] = [
|
||||
"California": { CaliforniaAmpPedal() },
|
||||
"British": { BritishAmpPedal() },
|
||||
"British Plexi": { BritishPlexiAmpPedal() },
|
||||
"British JTM": { BritishJTMAmpPedal() },
|
||||
"British Bluesbreaker": { BritishBluesbreakerAmpPedal() },
|
||||
"British Master": { BritishMasterAmpPedal() },
|
||||
"British Dual": { BritishDualAmpPedal() },
|
||||
"Boutique Lead": { BoutiqueLeadAmpPedal() },
|
||||
"Boutique OD": { BoutiqueODAmpPedal() },
|
||||
"Cali Hi-Gain": { CaliHiGainAmpPedal() },
|
||||
"Command": { CommandAmpPedal() },
|
||||
"Citrus": { CitrusAmpPedal() },
|
||||
"Sixties Combo": { SixtiesComboAmpPedal() },
|
||||
"Magna Vibrato": { MagnaVibratoAmpPedal() },
|
||||
"Anaheim": { AnaheimAmpPedal() },
|
||||
"Modern High-Gain": { ModernHighGainAmpPedal() },
|
||||
"Chime": { ChimeAmpPedal() },
|
||||
"Chime 15": { ChimeFifteenAmpPedal() },
|
||||
"Chime Normal": { ChimeNormalAmpPedal() },
|
||||
"Chime Baby": { ChimeBabyAmpPedal() },
|
||||
"Fullerton Reverb": { FullertonReverbAmpPedal() },
|
||||
"Fullerton Deluxe": { FullertonDeluxeAmpPedal() },
|
||||
"Fullerton Ivy League": { FullertonPrincetonAmpPedal() },
|
||||
"Fullerton Drive": { FullertonDriveAmpPedal() },
|
||||
"Jazz Clean": { JazzCleanAmpPedal() },
|
||||
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
|
||||
// "Neural Amp" intentionally NOT registered -- hidden from the palette while the neural
|
||||
// model-loader's security-scoped file access is unresolved. NeuralAmpPedal + its UI are kept
|
||||
// for later iteration; re-add this entry (and the palette order below) to re-enable.
|
||||
"Overdrive": { OverdrivePedal() },
|
||||
"Distortion": { DistortionPedal() },
|
||||
"Delay": { DelayPedal() },
|
||||
"Reverb": { ReverbPedal() },
|
||||
"Modulation": { ModulationPedal() },
|
||||
"Fuzz": { FuzzPedal() },
|
||||
"Sustain Fuzz": { SustainFuzzPedal() },
|
||||
"Tremolo": { TremoloPedal() },
|
||||
"Phaser": { PhaserPedal() },
|
||||
"Compressor": { CompressorPedal() },
|
||||
@@ -56,11 +86,13 @@ public enum PedalRegistry {
|
||||
"Room Reverb": { RoomReverbPedal() },
|
||||
"Spring Reverb": { SpringReverbPedal() },
|
||||
"Limiter": { LimiterPedal() },
|
||||
"Cabinet": { CabinetPedal() },
|
||||
"Noise Gate": { NoiseGatePedal() },
|
||||
"Graphic EQ": { GraphicEQPedal() },
|
||||
"Chorus": { ChorusPedal() },
|
||||
"Flanger": { FlangerPedal() },
|
||||
"Vibrato": { VibratoPedal() },
|
||||
"Vibe": { VibePedal() },
|
||||
"Rotary": { RotaryPedal() },
|
||||
"Sustainer": { SustainerPedal() },
|
||||
"Ring Modulator": { RingModulatorPedal() },
|
||||
@@ -71,6 +103,15 @@ public enum PedalRegistry {
|
||||
"Looper": { LooperPedal() },
|
||||
]
|
||||
|
||||
/// Maps a pedal `displayName` that has since been renamed to its current registry key, so rigs
|
||||
/// saved under the old name still load (the `displayName` **is** the serialization key — see
|
||||
/// ``BoardSegmentState`` — so a bare rename would silently drop the pedal on load). A loaded
|
||||
/// pedal takes the new name and re-saves under it, so this is self-healing. Extend when renaming
|
||||
/// any shipped pedal's `displayName`.
|
||||
static let legacyTypeAliases: [String: String] = [
|
||||
"Fullerton Princeton": "Fullerton Ivy League",
|
||||
]
|
||||
|
||||
/// Returns a new `Pedal` instance for the given type string, or `nil` if the type
|
||||
/// is not in the built-in registry.
|
||||
///
|
||||
@@ -78,11 +119,15 @@ public enum PedalRegistry {
|
||||
/// the caller is responsible for routing it via `board.add(_:)` before the engine
|
||||
/// processes any audio.
|
||||
///
|
||||
/// A ``legacyTypeAliases`` entry is resolved first, so a rig saved under a pedal's old
|
||||
/// `displayName` still reconstructs the renamed pedal.
|
||||
///
|
||||
/// - Parameter type: The `displayName` of the pedal (e.g. `"Overdrive"`, `"Delay"`).
|
||||
/// - Returns: A freshly allocated `Pedal` subclass instance, or `nil` for unknown types.
|
||||
@MainActor
|
||||
public static func makePedal(type: String) -> Pedal? {
|
||||
guard let constructor: @MainActor () -> Pedal = builtIn[type] else { return nil }
|
||||
let resolvedType: String = legacyTypeAliases[type] ?? type
|
||||
guard let constructor: @MainActor () -> Pedal = builtIn[resolvedType] else { return nil }
|
||||
return constructor()
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ public struct PedalState: Codable, Equatable {
|
||||
/// no selectors. Absent in presets saved before selectors existed — decodes to `[]`.
|
||||
public let selectorValues: [Double]
|
||||
|
||||
/// Advanced (pop-over) knob values in the same order as `Pedal.advancedKnobs`. Empty for pedals
|
||||
/// with no advanced knobs. Absent in presets saved before advanced knobs existed — decodes to `[]`.
|
||||
public let advancedValues: [Double]
|
||||
|
||||
/// Bypass parameter value. `0.0` = engaged, `1.0` = bypassed.
|
||||
public let bypass: Double
|
||||
|
||||
@@ -50,6 +54,10 @@ public struct PedalState: Codable, Equatable {
|
||||
/// decode to "all parameters free".
|
||||
public let tempoSync: [String: TempoSync]?
|
||||
|
||||
/// Optional path to an external resource the pedal references (e.g. a neural-amp model file).
|
||||
/// `nil` for pedals that use no external file, and for presets saved before this existed.
|
||||
public let resourcePath: String?
|
||||
|
||||
/// Creates a pedal state snapshot.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -58,8 +66,11 @@ public struct PedalState: Codable, Equatable {
|
||||
/// - switchValues: Current switch values in `Pedal.effectSwitches` order. Defaults to empty.
|
||||
/// - sliderValues: Current slider values in `Pedal.effectSliders` order. Defaults to empty.
|
||||
/// - selectorValues: Current selector values in `Pedal.effectSelectors` order. Defaults to empty.
|
||||
/// - advancedValues: Current advanced-knob values in `Pedal.advancedKnobs` order. Defaults to empty.
|
||||
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
||||
/// - tempoSync: Tempo-sync state per syncable parameter, or `nil` for none. Defaults to `nil`.
|
||||
/// - resourcePath: Path to an external resource the pedal references (e.g. a neural-amp
|
||||
/// model file), or `nil`. Defaults to `nil`.
|
||||
public init(
|
||||
id: UUID = UUID(),
|
||||
type: String,
|
||||
@@ -67,8 +78,10 @@ public struct PedalState: Codable, Equatable {
|
||||
switchValues: [Double] = [],
|
||||
sliderValues: [Double] = [],
|
||||
selectorValues: [Double] = [],
|
||||
advancedValues: [Double] = [],
|
||||
bypass: Double,
|
||||
tempoSync: [String: TempoSync]? = nil
|
||||
tempoSync: [String: TempoSync]? = nil,
|
||||
resourcePath: String? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.type = type
|
||||
@@ -76,8 +89,10 @@ public struct PedalState: Codable, Equatable {
|
||||
self.switchValues = switchValues
|
||||
self.sliderValues = sliderValues
|
||||
self.selectorValues = selectorValues
|
||||
self.advancedValues = advancedValues
|
||||
self.bypass = bypass
|
||||
self.tempoSync = tempoSync
|
||||
self.resourcePath = resourcePath
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -87,12 +102,14 @@ public struct PedalState: Codable, Equatable {
|
||||
case switchValues
|
||||
case sliderValues
|
||||
case selectorValues
|
||||
case advancedValues
|
||||
case bypass
|
||||
case tempoSync
|
||||
case resourcePath
|
||||
}
|
||||
|
||||
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
|
||||
/// `selectorValues` / `tempoSync` existed by defaulting the missing keys.
|
||||
/// `selectorValues` / `advancedValues` / `tempoSync` existed by defaulting the missing keys.
|
||||
public init(from decoder: any Decoder) throws {
|
||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.id = try container.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()
|
||||
@@ -101,7 +118,9 @@ public struct PedalState: Codable, Equatable {
|
||||
self.switchValues = try container.decodeIfPresent([Double].self, forKey: .switchValues) ?? []
|
||||
self.sliderValues = try container.decodeIfPresent([Double].self, forKey: .sliderValues) ?? []
|
||||
self.selectorValues = try container.decodeIfPresent([Double].self, forKey: .selectorValues) ?? []
|
||||
self.advancedValues = try container.decodeIfPresent([Double].self, forKey: .advancedValues) ?? []
|
||||
self.bypass = try container.decode(Double.self, forKey: .bypass)
|
||||
self.tempoSync = try container.decodeIfPresent([String: TempoSync].self, forKey: .tempoSync)
|
||||
self.resourcePath = try container.decodeIfPresent(String.self, forKey: .resourcePath)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,16 @@ extension ShoeGaze {
|
||||
/// - Returns: A `ShoeGazeState` reflecting the current rig.
|
||||
public func captureState() -> ShoeGazeState {
|
||||
let boardStates: [BoardState] = boards.map { $0.captureState() }
|
||||
let routerStates: [ChainRouterState] = routers.map { router in
|
||||
ChainRouterState(
|
||||
boardA: router.boardA.pedals.map { $0.captureState() },
|
||||
boardB: router.boardB.pedals.map { $0.captureState() },
|
||||
branchA: router.splitter.branchAEnabled,
|
||||
branchB: router.splitter.branchBEnabled,
|
||||
mergerLevelA: router.merger?.levelA ?? 1.0,
|
||||
mergerLevelB: router.merger?.levelB ?? 1.0
|
||||
)
|
||||
}
|
||||
return ShoeGazeState(
|
||||
boards: boardStates,
|
||||
midiMap: midiMap,
|
||||
@@ -25,7 +35,10 @@ extension ShoeGaze {
|
||||
tempoEnabled: tempoEnabled,
|
||||
inputSource: inputSource,
|
||||
numInputChannels: engine.numInputChannels,
|
||||
numOutputChannels: engine.numOutputChannels
|
||||
numOutputChannels: engine.numOutputChannels,
|
||||
// `nil` rather than `[]` when there are no routers, so a routerless rig's JSON is
|
||||
// unchanged and byte-identical to one saved before router persistence existed.
|
||||
routers: routerStates.isEmpty ? nil : routerStates
|
||||
)
|
||||
}
|
||||
|
||||
@@ -94,9 +107,18 @@ extension ShoeGaze {
|
||||
/// rebuilds every board with the all-or-nothing semantics of ``rebuildAllBoards(from:)``.
|
||||
///
|
||||
/// - Important: Call with the engine **stopped**, as with ``loadRig(from:)``.
|
||||
/// - Parameter state: The rig snapshot to restore.
|
||||
/// - Parameters:
|
||||
/// - state: The rig snapshot to restore.
|
||||
/// - keepingCurrentInput: When `true`, the session's current ``inputSource`` is preserved and
|
||||
/// the rig's saved input is ignored — used when the player switches between rigs, so the live
|
||||
/// input (e.g. a plugged-in guitar) doesn't snap back to the test loop a rig was authored
|
||||
/// with. When `false` (the default, used by file open and launch restore), the rig's saved
|
||||
/// input is applied so a saved/loaded rig recreates its authored input. Defaults to `false`.
|
||||
/// - Throws: `PresetError.unsupportedVersion` for a too-new snapshot, or any board-build error.
|
||||
public func loadRig(from state: ShoeGazeState) throws {
|
||||
public func loadRig(
|
||||
from state: ShoeGazeState,
|
||||
keepingCurrentInput: Bool = false
|
||||
) throws {
|
||||
guard state.version <= presetFormatVersion else {
|
||||
throw PresetError.unsupportedVersion(state.version)
|
||||
}
|
||||
@@ -107,11 +129,12 @@ extension ShoeGaze {
|
||||
// enable-live-input flow (rebuild engine to 1 input, then load a rig saved with 0). Apply a
|
||||
// rig's saved layout deliberately via `applyChannelLayout(from:)` / the config UI instead.
|
||||
|
||||
// Restore the saved input source before rebuilding, since board construction reads it. A
|
||||
// saved live-input channel that no longer exists on this engine falls back to the test loop
|
||||
// (same guard as reconfigureEngine), so the rebuild's addBoard() can't throw on a stale
|
||||
// channel. Absent (older rig) → leave the current input source untouched.
|
||||
if let savedInput: InputSource = state.inputSource {
|
||||
// Restore the saved input source before rebuilding, since board construction reads it — unless
|
||||
// the caller is switching rigs (`keepingCurrentInput`), in which case the current input is
|
||||
// kept so the player's live input survives the switch. A saved live-input channel that no
|
||||
// longer exists on this engine falls back to the test loop (same guard as reconfigureEngine),
|
||||
// so the rebuild's addBoard() can't throw on a stale channel. Absent (older rig) → untouched.
|
||||
if !keepingCurrentInput, let savedInput: InputSource = state.inputSource {
|
||||
if case .liveInput(let channel) = savedInput,
|
||||
channel < 0 || channel >= engine.numInputChannels {
|
||||
inputSource = .testLoop
|
||||
@@ -162,6 +185,9 @@ extension ShoeGaze {
|
||||
try rebuildSegments(boardState.segments, into: board)
|
||||
try finalizeBoard(board)
|
||||
}
|
||||
for routerState: ChainRouterState in snapshot.routers ?? [] {
|
||||
try rebuildRouter(routerState)
|
||||
}
|
||||
} catch {
|
||||
// Leave no partial rig behind: tear down whatever was built, then rethrow.
|
||||
teardown()
|
||||
@@ -169,6 +195,32 @@ extension ShoeGaze {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reconstructs one ``ChainRouter`` from a saved snapshot: creates the router, replays both linear
|
||||
/// branches (skipping unknown pedal types), finalizes, then restores the splitter branch levels
|
||||
/// and merger output levels so the saved A / B / blend selection is preserved.
|
||||
///
|
||||
/// - Parameter state: The router snapshot to reconstruct.
|
||||
/// - Throws: `BusAllocatorError`, `EngineAddError`, or `ShoeGazeError` from router construction.
|
||||
private func rebuildRouter(_ state: ChainRouterState) throws {
|
||||
let router: ChainRouter = try makeChainRouter()
|
||||
for pedalState: PedalState in state.boardA {
|
||||
if let pedal: Pedal = makeAndApply(pedalState) {
|
||||
try router.addToA(pedal)
|
||||
}
|
||||
}
|
||||
for pedalState: PedalState in state.boardB {
|
||||
if let pedal: Pedal = makeAndApply(pedalState) {
|
||||
try router.addToB(pedal)
|
||||
}
|
||||
}
|
||||
try router.finalize()
|
||||
// Restore the blend after finalize: the splitter exists from init, the merger only after.
|
||||
router.splitter.branchAEnabled = state.branchA
|
||||
router.splitter.branchBEnabled = state.branchB
|
||||
router.merger?.levelA = state.mergerLevelA
|
||||
router.merger?.levelB = state.mergerLevelB
|
||||
}
|
||||
|
||||
/// Loads a rig from a JSON preset file and rebuilds the engine graph.
|
||||
///
|
||||
/// This method:
|
||||
@@ -334,8 +386,8 @@ extension ShoeGaze {
|
||||
|
||||
// MARK: - Lightweight recall
|
||||
|
||||
/// Applies parameter values from `state` to the current rig topology without
|
||||
/// rebuilding the engine graph.
|
||||
/// Applies parameter values from `state` to the current rig topology, rebuilding only the
|
||||
/// boards where a graph-topology selector changed.
|
||||
///
|
||||
/// This is a lightweight "recall settings" path intended for topologically identical
|
||||
/// rigs (same board count, same segment order, same pedal types). Boards, segments, and
|
||||
@@ -345,12 +397,41 @@ extension ShoeGaze {
|
||||
/// is thrown and remaining
|
||||
/// entries continue to be processed.
|
||||
///
|
||||
/// Most parameters apply live with no graph change. The exception is a `rebuildsOnChange`
|
||||
/// selector (e.g. a cabinet voice, which picks which convolver is instantiated): if such a
|
||||
/// selector's value differs from the live rig, that board is rebuilt via `rebuildBoard(_:from:)`
|
||||
/// so the new selection takes effect — which carries the same at-most-one-block glitch as any
|
||||
/// rebuild on a running engine. Boards without such a selector stay fully live.
|
||||
///
|
||||
/// Use `loadRig(from:)` when you need a full topology rebuild.
|
||||
///
|
||||
/// - Parameter state: The `ShoeGazeState` whose parameter values should be applied.
|
||||
public func applyState(_ state: ShoeGazeState) {
|
||||
for (board, boardState) in zip(boards, state.boards) {
|
||||
applySegmentParams(boardState.segments, to: board.orderedSegments)
|
||||
let topologyChanged: Bool = applySegmentParams(boardState.segments, to: board.orderedSegments)
|
||||
// A `rebuildsOnChange` selector (e.g. a cabinet voice) picks which nodes exist in the
|
||||
// graph, so a plain node write during recall is invisible until the board is rebuilt.
|
||||
// Rebuild only the boards where such a selector actually changed value.
|
||||
if topologyChanged {
|
||||
do {
|
||||
_ = try rebuildBoard(board, from: board.captureState())
|
||||
} catch {
|
||||
print("[ShoeGaze] board rebuild after recall failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Routers recall positionally too: their branch pedals' params and the splitter/merger
|
||||
// blend. Topology (pedal counts/types) is assumed identical for a lightweight recall — a
|
||||
// mismatch is skipped, exactly as for boards. A `rebuildsOnChange` selector inside a router
|
||||
// branch is not handled here (routers have no per-branch rebuild path); use `loadRig(from:)`
|
||||
// for that.
|
||||
for (router, routerState): (ChainRouter, ChainRouterState) in zip(routers, state.routers ?? []) {
|
||||
applyLinearParams(routerState.boardA, to: router.boardA.pedals)
|
||||
applyLinearParams(routerState.boardB, to: router.boardB.pedals)
|
||||
router.splitter.branchAEnabled = routerState.branchA
|
||||
router.splitter.branchBEnabled = routerState.branchB
|
||||
router.merger?.levelA = routerState.mergerLevelA
|
||||
router.merger?.levelB = routerState.mergerLevelB
|
||||
}
|
||||
// A recall restores each pedal's tempo-sync state but not its derived values (no clock is
|
||||
// consulted in `Pedal.applyState`), so recompute them against the rig's current tempo —
|
||||
@@ -360,33 +441,51 @@ extension ShoeGaze {
|
||||
}
|
||||
}
|
||||
|
||||
/// Positionally applies pedal parameter snapshots to a live linear pedal chain (e.g. a router
|
||||
/// branch). A position whose live pedal type doesn't match the snapshot is skipped, matching the
|
||||
/// silent-skip semantics of the board recall path.
|
||||
private func applyLinearParams(_ states: [PedalState], to pedals: [Pedal]) {
|
||||
for (pedal, state): (Pedal, PedalState) in zip(pedals, states) where pedal.displayName == state.type {
|
||||
pedal.applyState(state)
|
||||
}
|
||||
}
|
||||
|
||||
/// Positionally applies segment parameter snapshots to live board segments, including
|
||||
/// branch pedals and split routing modes. Type or topology mismatches at any position are
|
||||
/// skipped silently (lightweight recall is for topologically identical rigs).
|
||||
/// - Returns: `true` if any pedal's `rebuildsOnChange` selector value changed, meaning the board
|
||||
/// must be rebuilt for the new selection to take effect.
|
||||
@discardableResult
|
||||
private func applySegmentParams(
|
||||
_ states: [BoardSegmentState],
|
||||
to segments: [BoardSegment]
|
||||
) {
|
||||
) -> Bool {
|
||||
var topologyChanged: Bool = false
|
||||
for (segment, segmentState) in zip(segments, states) {
|
||||
switch (segment, segmentState) {
|
||||
case let (.pedal(pedal), .pedal(pedalState)):
|
||||
if pedal.displayName == pedalState.type {
|
||||
let before: [Double] = pedal.rebuildTopologyValues
|
||||
pedal.applyState(pedalState)
|
||||
if pedal.rebuildTopologyValues != before { topologyChanged = true }
|
||||
}
|
||||
|
||||
case let (.parallel(section), .parallel(parallelState)):
|
||||
applyBranchParams(parallelState.branchA, to: section.branchA.pedals)
|
||||
applyBranchParams(parallelState.branchB, to: section.branchB.pedals)
|
||||
let a: Bool = applyBranchParams(parallelState.branchA, to: section.branchA.pedals)
|
||||
let b: Bool = applyBranchParams(parallelState.branchB, to: section.branchB.pedals)
|
||||
if a || b { topologyChanged = true }
|
||||
section.splitter.mode = parallelState.mode
|
||||
|
||||
case let (.stereoSplit(section), .stereoSplit(stereoState)):
|
||||
applyBranchParams(stereoState.left, to: section.left.pedals)
|
||||
applyBranchParams(stereoState.right, to: section.right.pedals)
|
||||
let l: Bool = applyBranchParams(stereoState.left, to: section.left.pedals)
|
||||
let r: Bool = applyBranchParams(stereoState.right, to: section.right.pedals)
|
||||
if l || r { topologyChanged = true }
|
||||
section.route = stereoState.route
|
||||
|
||||
case let (.stereoUnzip(section), .stereoUnzip(unzipState)):
|
||||
applyBranchParams(unzipState.left, to: section.left.pedals)
|
||||
applyBranchParams(unzipState.right, to: section.right.pedals)
|
||||
let l: Bool = applyBranchParams(unzipState.left, to: section.left.pedals)
|
||||
let r: Bool = applyBranchParams(unzipState.right, to: section.right.pedals)
|
||||
if l || r { topologyChanged = true }
|
||||
section.route = unzipState.route
|
||||
|
||||
default:
|
||||
@@ -394,12 +493,20 @@ extension ShoeGaze {
|
||||
continue
|
||||
}
|
||||
}
|
||||
return topologyChanged
|
||||
}
|
||||
|
||||
/// Positionally applies branch pedal snapshots to live branch pedals, matching by type.
|
||||
private func applyBranchParams(_ states: [PedalState], to pedals: [Pedal]) {
|
||||
///
|
||||
/// - Returns: `true` if any branch pedal's `rebuildsOnChange` selector value changed.
|
||||
@discardableResult
|
||||
private func applyBranchParams(_ states: [PedalState], to pedals: [Pedal]) -> Bool {
|
||||
var topologyChanged: Bool = false
|
||||
for (pedal, pedalState) in zip(pedals, states) where pedal.displayName == pedalState.type {
|
||||
let before: [Double] = pedal.rebuildTopologyValues
|
||||
pedal.applyState(pedalState)
|
||||
if pedal.rebuildTopologyValues != before { topologyChanged = true }
|
||||
}
|
||||
return topologyChanged
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
/// persistence. Reapplied on load under the same conditions as ``numInputChannels``.
|
||||
public let numOutputChannels: Int?
|
||||
|
||||
/// The rig's chain routers (two-board split/blend units), or `nil` for a rig saved before router
|
||||
/// persistence existed. Additive: decoded with `decodeIfPresent`, so older rigs — which never had
|
||||
/// routers — decode cleanly to `nil` without a format-version bump.
|
||||
public let routers: [ChainRouterState]?
|
||||
|
||||
/// Creates a rig state snapshot.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -68,6 +73,7 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
/// - inputSource: The rig's input selection, or `nil` to not persist one. Defaults to `nil`.
|
||||
/// - numInputChannels: The engine input-channel count, or `nil`. Defaults to `nil`.
|
||||
/// - numOutputChannels: The engine output-channel count, or `nil`. Defaults to `nil`.
|
||||
/// - routers: The rig's chain routers, or `nil` when there are none. Defaults to `nil`.
|
||||
public init(
|
||||
version: Int = presetFormatVersion,
|
||||
boards: [BoardState],
|
||||
@@ -76,7 +82,8 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
tempoEnabled: Bool? = nil,
|
||||
inputSource: InputSource? = nil,
|
||||
numInputChannels: Int? = nil,
|
||||
numOutputChannels: Int? = nil
|
||||
numOutputChannels: Int? = nil,
|
||||
routers: [ChainRouterState]? = nil
|
||||
) {
|
||||
self.version = version
|
||||
self.boards = boards
|
||||
@@ -86,6 +93,7 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
self.inputSource = inputSource
|
||||
self.numInputChannels = numInputChannels
|
||||
self.numOutputChannels = numOutputChannels
|
||||
self.routers = routers
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -97,6 +105,7 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
case inputSource
|
||||
case numInputChannels
|
||||
case numOutputChannels
|
||||
case routers
|
||||
}
|
||||
|
||||
/// Decodes a rig snapshot, tolerating an absent, malformed, OR legacy-format `midiMap`.
|
||||
@@ -129,5 +138,22 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
self.inputSource = try container.decodeIfPresent(InputSource.self, forKey: .inputSource)
|
||||
self.numInputChannels = try container.decodeIfPresent(Int.self, forKey: .numInputChannels)
|
||||
self.numOutputChannels = try container.decodeIfPresent(Int.self, forKey: .numOutputChannels)
|
||||
self.routers = try container.decodeIfPresent([ChainRouterState].self, forKey: .routers)
|
||||
}
|
||||
|
||||
/// Whether two snapshots describe the same **rig** — its boards, routers, MIDI map, and tempo —
|
||||
/// ignoring live session settings that are not part of the recalled rig: the input source and the
|
||||
/// engine's channel counts.
|
||||
///
|
||||
/// Use this for unsaved-changes detection. Those session fields are deliberately not applied when
|
||||
/// switching rigs (see ``ShoeGaze/loadRig(from:keepingCurrentInput:)``), so a plain `==` would
|
||||
/// report a freshly-loaded rig as "changed" merely because the player's current input differs from
|
||||
/// the input the rig was saved with — producing a spurious "save changes?" prompt.
|
||||
public func hasSameRigContent(as other: ShoeGazeState) -> Bool {
|
||||
boards == other.boards
|
||||
&& routers == other.routers
|
||||
&& midiMap == other.midiMap
|
||||
&& bpm == other.bpm
|
||||
&& tempoEnabled == other.tempoEnabled
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,10 @@ public final class ShoeGaze {
|
||||
|
||||
/// All chain routers created via ``makeChainRouter()``.
|
||||
/// Routers are torn down (in reverse-creation order) by ``teardown()``.
|
||||
private var routers: [ChainRouter] = []
|
||||
///
|
||||
/// `internal` (not `private`) so the preset capture/rebuild path in `ShoeGaze+Preset.swift` can
|
||||
/// snapshot and reconstruct routers.
|
||||
var routers: [ChainRouter] = []
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
@@ -248,6 +251,16 @@ public final class ShoeGaze {
|
||||
return result
|
||||
}
|
||||
|
||||
/// The top-level board that contains `pedal`, searching the main chain **and** parallel /
|
||||
/// stereo-split branch sections. Returns `nil` if the pedal isn't in a main board (e.g. it
|
||||
/// lives in a chain-router branch, which `rebuildBoard(_:from:)` doesn't operate on).
|
||||
///
|
||||
/// Used by the UI to rebuild the right board after a non-`@UIParam` pedal change (e.g. the
|
||||
/// Neural Amp loading a model file).
|
||||
public func board(containing pedal: Pedal) -> PedalBoard? {
|
||||
boards.first { board in pedals(in: board).contains { $0 === pedal } }
|
||||
}
|
||||
|
||||
/// Every live `Pedal` in one board, including pedals inside its parallel and stereo-split
|
||||
/// branch sections (branch pedals live in their section objects, not as top-level segments).
|
||||
private func pedals(in board: PedalBoard) -> [Pedal] {
|
||||
|
||||
@@ -93,6 +93,76 @@ public struct HelpView: View {
|
||||
"Reorder rigs into a set list by dragging a row, or via each rig's Move Up / "
|
||||
+ "Move Down menu. The order is saved and travels with an exported archive; "
|
||||
+ "the top ten map to ⌘⇧1–⌘⇧0.",
|
||||
"Switching rigs keeps your current input — your live guitar stays selected "
|
||||
+ "instead of snapping back to the test loop.",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "guitars",
|
||||
title: "Starter Rigs",
|
||||
intro: "ShoeGaze ships a library of ready-to-play rigs so you always have somewhere "
|
||||
+ "to start.",
|
||||
steps: [
|
||||
"The Rigs sidebar has a Mine / Starters toggle at the top: Mine is your own "
|
||||
+ "saved rigs; Starters is the shipped set, grouped by style — Shoegaze "
|
||||
+ "Walls, Dreampop, Classic, Ambient, and Experimental.",
|
||||
"Tap a starter to load it. To keep your tweaks, use Save As or Duplicate to make "
|
||||
+ "your own copy — saving directly over a starter asks first and offers Save "
|
||||
+ "as New Rig.",
|
||||
"Restore Starter Rigs (the rig-library ⋯ menu, or the Starters empty state) "
|
||||
+ "reinstalls the shipped rigs — handy if you deleted some, or to refresh "
|
||||
+ "them after an update.",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "amplifier",
|
||||
title: "Amp Models",
|
||||
intro: "Amp Model pedals are complete guitar amplifiers — preamp, tone stack, power "
|
||||
+ "amp, and a built-in speaker cabinet in one pedal. They live in the Amp Model "
|
||||
+ "row of the palette.",
|
||||
steps: [
|
||||
"Pick an amp from the Amp Model category. Each has its own voice: Gain (preamp "
|
||||
+ "drive), a Bass / Mid / Treble tone stack, and a Cab selector for its "
|
||||
+ "built-in speaker. Full-surface amps add signature controls — Master, "
|
||||
+ "Presence, Reverb, Tremolo, a channel switch, and so on.",
|
||||
"Gain (and a drive channel's Drive) read 1–11 with a musical taper: most of the "
|
||||
+ "usable grit spreads across the dial, with full saturation at the top.",
|
||||
"Master vs Level: Master drives the power-amp stage — turning it up saturates the "
|
||||
+ "amp like a real master volume. Level is a clean output trim applied after "
|
||||
+ "the amp; it changes loudness, not tone.",
|
||||
"No digital clipping: every amp ends in an analog-style soft limiter, so a driven "
|
||||
+ "amp compresses toward its ceiling instead of clipping harshly.",
|
||||
"Advanced controls (the sliders button at the top-right of the amp card open a "
|
||||
+ "pop-over): Sag, Bias, and Bias X — power-amp \"feel\" controls kept off the "
|
||||
+ "main face. Sag models power-supply droop and bloom (compression and touch "
|
||||
+ "response as you dig in); Bias sets the power tubes' operating point (cold = "
|
||||
+ "tighter, more bite; hot = warmer, rounder); Bias X balances the push-pull "
|
||||
+ "pair to shift the harmonic character. All are subtle set-and-leave voicing "
|
||||
+ "controls that default to neutral.",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "hifispeaker",
|
||||
title: "Cabinets & Microphones",
|
||||
intro: "Every amp has a built-in cabinet, but you can also run a dedicated Cabinet "
|
||||
+ "pedal for full speaker-and-microphone control.",
|
||||
steps: [
|
||||
"Built-in vs standalone: an amp's Cab selector picks its onboard speaker voicing "
|
||||
+ "— the quick path, one knob. For deeper control, set the amp's Cab to "
|
||||
+ "\"None (direct)\" and add a Cabinet pedal after it. (On \"None\" the amp "
|
||||
+ "sounds raw and fizzy by itself — expected; the Cabinet pedal is what "
|
||||
+ "supplies the speaker.)",
|
||||
"The Cabinet pedal's Cab selector chooses the speaker voicing, and Mic chooses the "
|
||||
+ "microphone — Dynamic, Ribbon, Condenser, or No Mic. The mic colour is baked "
|
||||
+ "into the same speaker response, so it costs nothing extra.",
|
||||
"Mic placement (the Cabinet's advanced pop-over, again via the top-right sliders "
|
||||
+ "button): Position moves the mic from on-axis (bright, on the dust cap) "
|
||||
+ "toward the cone edge (darker, smoother); Proximity runs from a distant, "
|
||||
+ "flat low end to a close-mic'd bass lift.",
|
||||
"Dual-mic (same pop-over): set Mic B to a second microphone to blend two mics. "
|
||||
+ "Mic Blend sets the A/B balance; Mic Offset spaces them apart for the comb "
|
||||
+ "colour of a real two-mic setup (a set-and-leave spacing control — sweeping "
|
||||
+ "it live acts like a flanger).",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
@@ -165,6 +235,26 @@ public struct HelpView: View {
|
||||
+ "CC to two controls and invert one for a crossfade.",
|
||||
]
|
||||
)
|
||||
|
||||
topicSection(
|
||||
icon: "checkmark.seal",
|
||||
title: "Acknowledgments",
|
||||
intro: "ShoeGaze is built on the Lyrebird audio-synthesis engine. Third-party resources "
|
||||
+ "and techniques used in this app:",
|
||||
steps: [
|
||||
"Lyrebird audio engine (Joshua Parmenter / realizedsound) — MIT licensed.",
|
||||
"Filter design follows the RBJ Audio EQ Cookbook by Robert Bristow-Johnson — the "
|
||||
+ "standard biquad coefficient formulas, used to synthesize the Cabinet pedal's "
|
||||
+ "built-in speaker impulse responses.",
|
||||
"The Cabinet pedal's built-in cab and microphone voicings are original impulse "
|
||||
+ "responses generated in code — not captures of any third-party speaker, "
|
||||
+ "microphone, or IR pack.",
|
||||
"The tube-amp voice pedals' tone stacks "
|
||||
+ "follow the Yeh & Smith analysis of the classic passive tone-stack circuit (\"Discretization "
|
||||
+ "of the '59 Fender Bassman Tone Stack\", DAFx-06); their models are original code, not "
|
||||
+ "captures of specific hardware.",
|
||||
]
|
||||
)
|
||||
}
|
||||
.navigationTitle("ShoeGaze Help")
|
||||
.toolbar {
|
||||
|
||||
@@ -10,6 +10,8 @@ import SwiftUI
|
||||
/// drive the "filter by type" menu. Purely a UI concern: the mapping from a pedal's `displayName`
|
||||
/// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order.
|
||||
public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
case amp = "Amp Model"
|
||||
case cabinet = "Cabinet"
|
||||
case gain = "Gain"
|
||||
case dynamics = "Dynamics"
|
||||
case filter = "EQ & Filter"
|
||||
@@ -24,6 +26,8 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
/// Accent colour used to tint the palette card and the filter chip.
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .amp: return Color(red: 0.70, green: 0.45, blue: 0.18) // warm valve-glow copper
|
||||
case .cabinet: return Color(red: 0.50, green: 0.36, blue: 0.18) // tweed / cabinet tan
|
||||
case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12)
|
||||
case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32)
|
||||
case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55)
|
||||
@@ -42,9 +46,11 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
}
|
||||
|
||||
private static let mapping: [String: PedalCategory] = [
|
||||
"California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "British Master": .amp, "British Dual": .amp, "Boutique Lead": .amp, "Boutique OD": .amp, "Cali Hi-Gain": .amp, "Command": .amp, "Citrus": .amp, "Sixties Combo": .amp, "Magna Vibrato": .amp, "Anaheim": .amp, "Modern High-Gain": .amp, "Chime": .amp, "Chime 15": .amp, "Chime Normal": .amp, "Chime Baby": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Ivy League": .amp, "Fullerton Drive": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp,
|
||||
"Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain,
|
||||
"Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics,
|
||||
"Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter,
|
||||
"Cabinet": .cabinet,
|
||||
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
|
||||
"Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .modulation,
|
||||
"Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch,
|
||||
|
||||
@@ -54,9 +54,9 @@ public struct PedalPaletteView: View {
|
||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||
private static let preferredOrder: [String] = [
|
||||
"Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Cabinet", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", "Sustain Fuzz",
|
||||
"Volume",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Vibe", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
||||
"Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
|
||||
@@ -159,6 +159,24 @@ public struct PedalPaletteView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// The `.amp` bucket on its own, or `nil` when no amp models are visible. Split out so the
|
||||
/// horizontal picker can drop the (large) amp list into the second row (with Routing and the
|
||||
/// Cabinet) instead of letting it stretch the head of the effects row.
|
||||
private var ampGroup: (category: PedalCategory, names: [String])? {
|
||||
groupedVisiblePedals.first { $0.category == .amp }
|
||||
}
|
||||
|
||||
/// The `.cabinet` bucket on its own, or `nil` when no cabinet is visible. Sits on the second row
|
||||
/// between Routing and the amp models (rig-structure controls grouped together).
|
||||
private var cabinetGroup: (category: PedalCategory, names: [String])? {
|
||||
groupedVisiblePedals.first { $0.category == .cabinet }
|
||||
}
|
||||
|
||||
/// Visible pedal groups excluding the amp models and the cabinet — the actual effects row (row 1).
|
||||
private var effectGroups: [(category: PedalCategory, names: [String])] {
|
||||
groupedVisiblePedals.filter { $0.category != .amp && $0.category != .cabinet }
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
public var body: some View {
|
||||
@@ -171,6 +189,12 @@ public struct PedalPaletteView: View {
|
||||
/// Full-width column for a left sidebar.
|
||||
private var verticalBody: some View {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
sectionTitle("ROUTING")
|
||||
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
||||
routingCard(title: option.title, caption: option.caption, action: option.action)
|
||||
}
|
||||
}
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
HStack {
|
||||
sectionTitle("PEDALS")
|
||||
@@ -181,18 +205,12 @@ public struct PedalPaletteView: View {
|
||||
pedalRow(name)
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
sectionTitle("ROUTING")
|
||||
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
||||
routingCard(title: option.title, caption: option.caption, action: option.action)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Horizontal scroller: a PEDALS row (leading filter + colour-coded cards) with the ROUTING
|
||||
/// row stacked beneath it.
|
||||
/// Horizontal scroller: a PEDALS row (leading filter + colour-coded effect cards) with a second
|
||||
/// row that carries the amp models alongside the ROUTING cards. Amps live with routing rather
|
||||
/// than at the head of the effects row so the effects row stays short.
|
||||
private var horizontalBody: some View {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) {
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.sectionSpacing) {
|
||||
@@ -200,7 +218,7 @@ public struct PedalPaletteView: View {
|
||||
sectionTitle("PEDALS")
|
||||
if showsFilterMenu { filterMenu }
|
||||
}
|
||||
ForEach(groupedVisiblePedals, id: \.category) { group in
|
||||
ForEach(effectGroups, id: \.category) { group in
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
categoryLabel(group.category)
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
@@ -211,10 +229,34 @@ public struct PedalPaletteView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
sectionTitle("ROUTING")
|
||||
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
||||
routingCard(title: option.title, caption: option.caption, action: option.action)
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.sectionSpacing) {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
sectionTitle("ROUTING")
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
ForEach(PedalPaletteView.routingOptions, id: \.title) { option in
|
||||
routingCard(title: option.title, caption: option.caption, action: option.action)
|
||||
}
|
||||
}
|
||||
}
|
||||
if let cabinet: (category: PedalCategory, names: [String]) = cabinetGroup {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
categoryLabel(cabinet.category)
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
ForEach(cabinet.names, id: \.self) { name in
|
||||
pedalRow(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let amps: (category: PedalCategory, names: [String]) = ampGroup {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
categoryLabel(amps.category)
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
ForEach(amps.names, id: \.self) { name in
|
||||
pedalRow(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// PedalRebuildEnvironment.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
/// Environment action a leaf pedal control can call to ask the host to rebuild the board that
|
||||
/// contains the given pedal — needed when a pedal setting that is *not* a live `@UIParam` (e.g.
|
||||
/// the Neural Amp's model file, stored in ``Pedal/resourcePath``) changes and only takes effect
|
||||
/// after the pedal's graph is rebuilt. Set once near the builder root; defaults to a no-op.
|
||||
private struct PedalRebuildActionKey: EnvironmentKey {
|
||||
static let defaultValue: @MainActor @Sendable (Pedal) -> Void = { _ in }
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
/// Rebuilds the board containing the passed pedal. No-op unless the host installs it.
|
||||
var pedalRebuildAction: @MainActor @Sendable (Pedal) -> Void {
|
||||
get { self[PedalRebuildActionKey.self] }
|
||||
set { self[PedalRebuildActionKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ struct PedalSelectorKnobView: View {
|
||||
// MARK: - Input
|
||||
|
||||
private let selector: PedalSelectorKnob
|
||||
/// Called once when a drag ends on a different stop than it began — used to trigger a board
|
||||
/// rebuild for `rebuildsOnChange` selectors. `nil` for plain live-value selectors.
|
||||
private let onCommit: (() -> Void)?
|
||||
|
||||
// MARK: - Drag state
|
||||
|
||||
@@ -37,8 +40,9 @@ struct PedalSelectorKnobView: View {
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
init(_ selector: PedalSelectorKnob) {
|
||||
init(_ selector: PedalSelectorKnob, onCommit: (() -> Void)? = nil) {
|
||||
self.selector = selector
|
||||
self.onCommit = onCommit
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
@@ -100,7 +104,11 @@ struct PedalSelectorKnobView: View {
|
||||
selector.node.update(value)
|
||||
}
|
||||
}
|
||||
.onEnded { _ in dragInProgress = false }
|
||||
.onEnded { _ in
|
||||
let changed: Bool = currentIndex != dragStartIndex
|
||||
dragInProgress = false
|
||||
if changed { onCommit?() }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
@@ -49,6 +49,9 @@ public struct PedalSwitchView: View {
|
||||
// MARK: - Properties
|
||||
|
||||
private let pedalSwitch: PedalSwitch
|
||||
/// Called once when a tap commits a different position — used to trigger a board rebuild for
|
||||
/// `rebuildsOnChange` switches (e.g. a channel switch). `nil` for plain switches.
|
||||
private let onCommit: (() -> Void)?
|
||||
|
||||
@Environment(\.shoeGazeTempoEnabled) private var tempoEnabled: Bool
|
||||
|
||||
@@ -56,9 +59,13 @@ public struct PedalSwitchView: View {
|
||||
|
||||
/// Creates a segmented switch view.
|
||||
///
|
||||
/// - Parameter pedalSwitch: The discrete switch descriptor to render.
|
||||
public init(_ pedalSwitch: PedalSwitch) {
|
||||
/// - Parameters:
|
||||
/// - pedalSwitch: The discrete switch descriptor to render.
|
||||
/// - onCommit: Called when a tap selects a different position. Used for `rebuildsOnChange`
|
||||
/// switches; `nil` otherwise.
|
||||
public init(_ pedalSwitch: PedalSwitch, onCommit: (() -> Void)? = nil) {
|
||||
self.pedalSwitch = pedalSwitch
|
||||
self.onCommit = onCommit
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
@@ -87,6 +94,7 @@ public struct PedalSwitchView: View {
|
||||
Text(inert ? "\(pedalSwitch.label) (tempo off)" : pedalSwitch.label)
|
||||
.font(.system(size: PedalSwitchView.captionFontSize))
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.disabled(inert)
|
||||
.opacity(inert ? PedalSwitchView.tempoDisabledOpacity : 1.0)
|
||||
@@ -96,7 +104,9 @@ public struct PedalSwitchView: View {
|
||||
|
||||
private func segment(option: PedalSwitch.Option, isActive: Bool) -> some View {
|
||||
Button(action: {
|
||||
let changed: Bool = option.value != pedalSwitch.node.value
|
||||
pedalSwitch.node.update(option.value)
|
||||
if changed { onCommit?() }
|
||||
}) {
|
||||
Text(option.title)
|
||||
.font(.system(size: PedalSwitchView.fontSize, weight: .semibold))
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
@@ -16,6 +17,33 @@ import LyrebirdShoeGaze
|
||||
/// here in the UI target. Unrecognised names fall through to `.gray`.
|
||||
private func enclosureColor(for displayName: String) -> Color {
|
||||
switch displayName {
|
||||
case "California": return Color(red: 0.20, green: 0.28, blue: 0.34) // West-Coast steel blue
|
||||
case "British": return Color(red: 0.30, green: 0.16, blue: 0.10) // oxblood tolex
|
||||
case "British Plexi": return Color(red: 0.34, green: 0.20, blue: 0.10) // gold-panel plexi
|
||||
case "British JTM": return Color(red: 0.36, green: 0.24, blue: 0.12) // warm JTM bronze
|
||||
case "British Bluesbreaker": return Color(red: 0.28, green: 0.22, blue: 0.12) // bluesbreaker tan
|
||||
case "British Master": return Color(red: 0.26, green: 0.14, blue: 0.09) // hot-rodded oxblood
|
||||
case "British Dual": return Color(red: 0.24, green: 0.13, blue: 0.11) // modern high-gain
|
||||
case "Boutique Lead": return Color(red: 0.28, green: 0.12, blue: 0.16) // boutique oxblood
|
||||
case "Boutique OD": return Color(red: 0.30, green: 0.20, blue: 0.10) // D-style amber
|
||||
case "Cali Hi-Gain": return Color(red: 0.16, green: 0.16, blue: 0.18) // Mark-series black
|
||||
case "Command": return Color(red: 0.20, green: 0.22, blue: 0.16) // hi-fi olive
|
||||
case "Citrus": return Color(red: 0.85, green: 0.50, blue: 0.10) // orange tolex
|
||||
case "Sixties Combo": return Color(red: 0.42, green: 0.30, blue: 0.16) // tweed brown
|
||||
case "Magna Vibrato": return Color(red: 0.34, green: 0.26, blue: 0.44) // vibrato violet
|
||||
case "Anaheim": return Color(red: 0.24, green: 0.30, blue: 0.32) // hybrid slate
|
||||
case "Modern High-Gain": return Color(red: 0.12, green: 0.12, blue: 0.14) // recto black
|
||||
case "Chime": return Color(red: 0.16, green: 0.24, blue: 0.22) // vintage green
|
||||
case "Chime 15": return Color(red: 0.18, green: 0.28, blue: 0.22) // brighter chime green
|
||||
case "Chime Normal": return Color(red: 0.20, green: 0.26, blue: 0.20) // warm chime green
|
||||
case "Chime Baby": return Color(red: 0.22, green: 0.30, blue: 0.24) // pale chime green
|
||||
case "Fullerton Reverb": return Color(red: 0.15, green: 0.22, blue: 0.30) // blackface panel
|
||||
case "Fullerton Deluxe": return Color(red: 0.17, green: 0.20, blue: 0.26) // blackface, warmer
|
||||
case "Fullerton Ivy League": return Color(red: 0.19, green: 0.19, blue: 0.23) // small blackface
|
||||
case "Fullerton Drive": return Color(red: 0.22, green: 0.18, blue: 0.24) // two-channel combo
|
||||
case "Jazz Clean": return Color(red: 0.14, green: 0.30, blue: 0.34) // solid-state silver-teal
|
||||
case "Chime Top Boost": return Color(red: 0.20, green: 0.32, blue: 0.20) // chime-green tolex
|
||||
case "Neural Amp": return Color(red: 0.22, green: 0.16, blue: 0.30) // deep neural violet
|
||||
case "Overdrive": return Color(red: 0.85, green: 0.42, blue: 0.08) // warm orange
|
||||
case "Distortion": return Color(red: 0.80, green: 0.26, blue: 0.12) // hot rust
|
||||
case "Delay": return Color(red: 0.10, green: 0.55, blue: 0.55) // teal
|
||||
@@ -26,8 +54,10 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Spring Reverb": return Color(red: 0.20, green: 0.46, blue: 0.64) // steel cyan
|
||||
case "Modulation": return Color(red: 0.12, green: 0.58, blue: 0.22) // green
|
||||
case "Fuzz": return Color(red: 0.55, green: 0.10, blue: 0.10) // deep crimson
|
||||
case "Sustain Fuzz": return Color(red: 0.72, green: 0.24, blue: 0.10) // rust / burnt orange
|
||||
case "Tremolo": return Color(red: 0.20, green: 0.38, blue: 0.72) // cobalt blue
|
||||
case "Phaser": return Color(red: 0.60, green: 0.22, blue: 0.62) // violet
|
||||
case "Vibe": return Color(red: 0.28, green: 0.20, blue: 0.62) // deep indigo
|
||||
case "Compressor": return Color(red: 0.18, green: 0.42, blue: 0.32) // forest green
|
||||
case "Mutant": return Color(red: 0.70, green: 0.12, blue: 0.48) // magenta / plum
|
||||
case "Auto-Wah": return Color(red: 0.80, green: 0.62, blue: 0.10) // gold
|
||||
@@ -39,6 +69,7 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Limiter": return Color(red: 0.62, green: 0.16, blue: 0.20) // brick red
|
||||
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
||||
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
||||
case "Cabinet": return Color(red: 0.50, green: 0.36, blue: 0.18) // tweed / cabinet tan
|
||||
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
||||
case "Flanger": return Color(red: 0.28, green: 0.52, blue: 0.78) // steel blue
|
||||
case "Vibrato": return Color(red: 0.42, green: 0.30, blue: 0.70) // violet-blue
|
||||
@@ -393,9 +424,12 @@ public struct PedalView: View {
|
||||
|
||||
// MARK: - Layout constants
|
||||
|
||||
/// Wide enough for three ~55 pt knobs (dial + label + value) plus padding in a
|
||||
/// single row, so the effect controls never overlap.
|
||||
/// Base card width — used by the looper's fixed multi-unit layout. Other pedals size to content
|
||||
/// via ``enclosureColumnWidth`` (see `enclosureWidth(for:)`).
|
||||
private static let enclosureWidth: CGFloat = 220
|
||||
/// Per-column width for the content-sized enclosure — one knob/selector/switch slot (a ~50 pt
|
||||
/// dial plus its caption). Card width = `2·padding + columns·this + (columns−1)·knobSpacing`.
|
||||
private static let enclosureColumnWidth: CGFloat = 68
|
||||
private static let enclosureCornerRadius: CGFloat = 12
|
||||
private static let enclosurePadding: CGFloat = 14
|
||||
private static let screwInset: CGFloat = 6
|
||||
@@ -414,6 +448,10 @@ public struct PedalView: View {
|
||||
/// Horizontal gap between the Level knob and the bypass control in the bottom row.
|
||||
private static let bottomControlsSpacing: CGFloat = 18
|
||||
private static let sectionSpacing: CGFloat = 14
|
||||
/// Neural Amp model row: label/button spacing, caption size, and caption opacity.
|
||||
private static let neuralRowSpacing: CGFloat = 6
|
||||
private static let neuralRowFontSize: CGFloat = 11
|
||||
private static let neuralRowLabelOpacity: Double = 0.85
|
||||
private static let namePlateCornerRadius: CGFloat = 8
|
||||
private static let namePlatePaddingH: CGFloat = 10
|
||||
private static let namePlatePaddingV: CGFloat = 4
|
||||
@@ -437,6 +475,14 @@ public struct PedalView: View {
|
||||
/// Insets placing the ⓘ info button just under the top-left corner screw.
|
||||
private static let infoButtonLeading: CGFloat = 5
|
||||
private static let infoButtonTop: CGFloat = 20
|
||||
/// Insets placing the advanced (gear) button just under the top-right corner screw, mirroring
|
||||
/// the info button.
|
||||
private static let advancedButtonTrailing: CGFloat = 5
|
||||
private static let advancedButtonTop: CGFloat = 20
|
||||
/// Layout of the advanced-controls pop-over: knobs per row and the inter-knob gap.
|
||||
private static let advancedPopoverColumns: Int = 2
|
||||
private static let advancedPopoverSpacing: CGFloat = 14
|
||||
private static let advancedPopoverPadding: CGFloat = 16
|
||||
private static let outerBorderLineWidth: CGFloat = 1.5
|
||||
private static let innerHighlightLineWidth: CGFloat = 1
|
||||
private static let innerHighlightPadding: CGFloat = 1
|
||||
@@ -449,6 +495,16 @@ public struct PedalView: View {
|
||||
/// Presentation flag for the pedal info panel (description + control ranges).
|
||||
@State private var showInfo: Bool = false
|
||||
|
||||
/// Presentation flag for the advanced-controls pop-over (amp Sag / Bias).
|
||||
@State private var showAdvanced: Bool = false
|
||||
|
||||
/// Presentation flag for the Neural Amp model-file importer.
|
||||
@State private var showModelImporter: Bool = false
|
||||
|
||||
/// Rebuilds this pedal's board after a non-`@UIParam` change (Neural Amp model file). Injected
|
||||
/// by the builder; no-op elsewhere.
|
||||
@Environment(\.pedalRebuildAction) private var pedalRebuildAction: @MainActor @Sendable (Pedal) -> Void
|
||||
|
||||
/// The rig's control map, injected by the builder so the pedal can draw a mapping strip. `nil`
|
||||
/// when the rig has no bindings (or in contexts that don't set it) — the strip renders nothing.
|
||||
@Environment(\.controlMappingMap) private var controlMappingMap: MIDIMap?
|
||||
@@ -519,6 +575,15 @@ public struct PedalView: View {
|
||||
.padding(.leading, PedalView.infoButtonLeading)
|
||||
.padding(.top, PedalView.infoButtonTop)
|
||||
}
|
||||
// Advanced (gear) button, tucked under the top-right corner screw — only for pedals that
|
||||
// publish advanced knobs (e.g. an amp's Sag / Bias).
|
||||
.overlay(alignment: .topTrailing) {
|
||||
if !pedal.advancedKnobs.isEmpty {
|
||||
advancedButton
|
||||
.padding(.trailing, PedalView.advancedButtonTrailing)
|
||||
.padding(.top, PedalView.advancedButtonTop)
|
||||
}
|
||||
}
|
||||
.shadow(
|
||||
color: Color.black.opacity(PedalView.shadowOpacity),
|
||||
radius: PedalView.shadowRadius,
|
||||
@@ -538,6 +603,7 @@ public struct PedalView: View {
|
||||
VStack(spacing: PedalView.sectionSpacing) {
|
||||
namePlate
|
||||
knobGrid
|
||||
neuralModelRow
|
||||
selectorRow
|
||||
switchRow
|
||||
// Keyed on the pedal instance so the buttons' live captions (which poll the pedal
|
||||
@@ -560,20 +626,20 @@ public struct PedalView: View {
|
||||
namePlate
|
||||
HStack(alignment: .top, spacing: PedalView.looperColumnSpacing) {
|
||||
// Left column: timeline, then the Free/Sync switch, then the Reset footswitch.
|
||||
// No trailing Spacer — the flow canvas offers the row its full viewport height,
|
||||
// and a greedy Spacer here would stretch the whole card to fill it (leaving a
|
||||
// large empty gap). Each column sizes to its content, like every other pedal.
|
||||
VStack(spacing: PedalView.sectionSpacing) {
|
||||
LooperTimelineView(pedal: looper)
|
||||
switchRow
|
||||
looperResetCell
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.frame(width: PedalView.looperTimelineColumnWidth)
|
||||
|
||||
// Centre column: the four effect knobs (2×2), with the Level + Bypass footer at the
|
||||
// bottom. The Mix slot is reserved (empty) so Bypass stays horizontally centred,
|
||||
// matching a normal pedal's footer.
|
||||
// Centre column: the four effect knobs (2×2), with the Level + Bypass footer
|
||||
// directly beneath (no greedy Spacer — see the left column note).
|
||||
VStack(spacing: PedalView.sectionSpacing) {
|
||||
looperEffectKnobs(columns: 2)
|
||||
Spacer(minLength: 0)
|
||||
looperFooter
|
||||
}
|
||||
|
||||
@@ -583,6 +649,9 @@ public struct PedalView: View {
|
||||
}
|
||||
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
||||
}
|
||||
// Pin to intrinsic height so the enclosure hugs its content even though the flow
|
||||
// canvas offers the row its full viewport height.
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
|
||||
/// The looper's effect knobs (everything except the trailing `Mix` / `Level`) laid out in
|
||||
@@ -687,6 +756,46 @@ public struct PedalView: View {
|
||||
.help("About this pedal")
|
||||
}
|
||||
|
||||
/// Advanced-controls (gear) button tucked under the top-right corner screw. Presents
|
||||
/// ``advancedPanel`` — the pedal's ``Pedal/advancedKnobs`` — in a popover. Only drawn when the
|
||||
/// pedal publishes advanced knobs (the caller gates on `advancedKnobs.isEmpty`).
|
||||
private var advancedButton: some View {
|
||||
Button {
|
||||
showAdvanced = true
|
||||
} label: {
|
||||
Image(systemName: "slider.horizontal.3")
|
||||
.font(.system(size: PedalView.fontSizeNamePlate))
|
||||
.foregroundStyle(Color.white.opacity(PedalView.infoButtonOpacity))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Advanced controls")
|
||||
.popover(isPresented: $showAdvanced) {
|
||||
advancedPanel
|
||||
.presentationCompactAdaptation(.popover)
|
||||
}
|
||||
}
|
||||
|
||||
/// Grid of the pedal's ``Pedal/advancedKnobs`` shown in the advanced popover, laid out in rows of
|
||||
/// ``advancedPopoverColumns``. Plain `ParameterKnob`s — these are live, non-topology controls.
|
||||
private var advancedPanel: some View {
|
||||
let knobs: [PedalKnob] = pedal.advancedKnobs
|
||||
let columns: Int = PedalView.advancedPopoverColumns
|
||||
let rows: [[PedalKnob]] = stride(from: 0, to: knobs.count, by: columns).map { startIndex in
|
||||
Array(knobs[startIndex ..< min(startIndex + columns, knobs.count)])
|
||||
}
|
||||
return VStack(spacing: PedalView.advancedPopoverSpacing) {
|
||||
ForEach(Array(rows.enumerated()), id: \.offset) { rowPair in
|
||||
HStack(alignment: .top, spacing: PedalView.advancedPopoverSpacing) {
|
||||
ForEach(Array(rowPair.element.enumerated()), id: \.offset) { knobPair in
|
||||
ParameterKnob(knobPair.element.label, node: knobPair.element.node, range: knobPair.element.range)
|
||||
.foregroundStyle(Color.white)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(PedalView.advancedPopoverPadding)
|
||||
}
|
||||
|
||||
/// Grid of the effect knobs, in rows of up to `knobColumnCount`.
|
||||
///
|
||||
/// The trailing `Mix` and `Level` knobs (the last two entries of `pedal.knobs`) are
|
||||
@@ -749,29 +858,58 @@ public struct PedalView: View {
|
||||
|
||||
/// Row of stepped selector knobs drawn from `pedal.effectSelectors`, beneath the knob grid.
|
||||
/// Renders nothing when the pedal publishes no selectors.
|
||||
/// A pedal that hides the Mix knob (e.g. an amp) and publishes exactly one selector surfaces
|
||||
/// that selector in the bottom row beside Level/Bypass — giving the amps a compact
|
||||
/// `Level · Bypass · Cab` footer — instead of a full-width selector row of its own.
|
||||
private var footerSelector: PedalSelectorKnob? {
|
||||
guard !pedal.showsMixControl else { return nil }
|
||||
let selectors: [PedalSelectorKnob] = pedal.effectSelectors
|
||||
return selectors.count == 1 ? selectors.first : nil
|
||||
}
|
||||
|
||||
/// Selectors rendered in their own row above the switches — everything except one promoted to
|
||||
/// the bottom-row footer via ``footerSelector``.
|
||||
private var inlineSelectors: [PedalSelectorKnob] {
|
||||
footerSelector == nil ? pedal.effectSelectors : []
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var selectorRow: some View {
|
||||
let selectors: [PedalSelectorKnob] = pedal.effectSelectors
|
||||
let selectors: [PedalSelectorKnob] = inlineSelectors
|
||||
if !selectors.isEmpty {
|
||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||
Spacer(minLength: 0)
|
||||
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in
|
||||
PedalSelectorKnobView(pair.element)
|
||||
// Keyed by the (unique-per-pedal) selector label, not the array offset, so each
|
||||
// selector keeps a stable SwiftUI identity across board rebuilds — a rebuildsOnChange
|
||||
// selector must not inherit a sibling's drag @State.
|
||||
ForEach(selectors, id: \.label) { selector in
|
||||
PedalSelectorKnobView(
|
||||
selector,
|
||||
onCommit: selector.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Row of segmented switches drawn from `pedal.effectSwitches`, one per row, beneath
|
||||
/// the knob grid. Renders nothing when the pedal publishes no switches.
|
||||
/// Row of segmented switches drawn from `pedal.effectSwitches`, laid out side by side beneath
|
||||
/// the knob grid. Renders nothing when the pedal publishes no switches. `.top` alignment keeps
|
||||
/// the segment bars level even if one switch's caption wraps differently.
|
||||
@ViewBuilder
|
||||
private var switchRow: some View {
|
||||
let switches: [PedalSwitch] = pedal.effectSwitches
|
||||
if !switches.isEmpty {
|
||||
VStack(spacing: PedalView.knobSpacing) {
|
||||
HStack(alignment: .top, spacing: PedalView.knobSpacing) {
|
||||
ForEach(Array(switches.enumerated()), id: \.offset) { pair in
|
||||
PedalSwitchView(pair.element)
|
||||
PedalSwitchView(
|
||||
pair.element,
|
||||
onCommit: pair.element.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -825,32 +963,101 @@ public struct PedalView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Enclosure width — the base stompbox width scaled by the pedal's `widthUnits`
|
||||
/// (a control-dense pedal such as the looper asks for a double-width card), widened
|
||||
/// further to fit a wide vertical-fader bank (e.g. a multi-band graphic EQ) so its
|
||||
/// faders are never clipped.
|
||||
/// Enclosure width, sized to the pedal's **content** rather than a flat `widthUnits × base`
|
||||
/// multiple (which left control-sparse multi-unit cards — amps, the Cabinet — mostly empty).
|
||||
///
|
||||
/// The card is `columns` wide, where `columns` is the pedal's base knob-grid width from
|
||||
/// `widthUnits` (`1` → `knobColumnCount`, `≥ 2` → `wideKnobColumnCount`) — so a `widthUnits: 2`
|
||||
/// pedal is always a four-wide card even if it carries fewer knobs (this is how the Cabinet
|
||||
/// matches the amps so its selector captions stay readable). A pedal whose selector or switch row
|
||||
/// is wider than that pushes wider still. It is widened further to fit a vertical-fader bank
|
||||
/// (e.g. a multi-band graphic EQ) so its faders are never clipped.
|
||||
///
|
||||
/// The looper is the exception: its bespoke three-column layout (timeline · knobs · transport)
|
||||
/// genuinely needs the full multi-unit width, so it keeps the flat multiple.
|
||||
private func enclosureWidth(for sliders: [PedalSlider]) -> CGFloat {
|
||||
let unitWidth: CGFloat = PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits))
|
||||
if pedal is LooperPedal {
|
||||
return PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits))
|
||||
}
|
||||
let gridColumns: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount
|
||||
let columns: Int = max(gridColumns, inlineSelectors.count, pedal.effectSwitches.count)
|
||||
let contentWidth: CGFloat = 2 * PedalView.enclosurePadding
|
||||
+ CGFloat(columns) * PedalView.enclosureColumnWidth
|
||||
+ CGFloat(max(0, columns - 1)) * PedalView.knobSpacing
|
||||
|
||||
let sliderCount: Int = sliders.count
|
||||
guard sliderCount > 0 else { return unitWidth }
|
||||
guard sliderCount > 0 else { return contentWidth }
|
||||
let bankContentWidth: CGFloat =
|
||||
CGFloat(sliderCount) * PedalView.sliderBankItemWidth
|
||||
+ CGFloat(max(0, sliderCount - 1)) * PedalView.sliderBankSpacing
|
||||
let needed: CGFloat = bankContentWidth + 2 * PedalView.enclosurePadding
|
||||
return max(unitWidth, needed)
|
||||
return max(contentWidth, needed)
|
||||
}
|
||||
|
||||
/// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,
|
||||
/// side-by-side and centred — a symmetric knob-switch-knob footer shared by all pedals.
|
||||
/// Neural Amp only: shows the loaded model file name and a picker to load a `.json` capture.
|
||||
/// Setting the model changes the graph, so after a pick it asks the host to rebuild the board.
|
||||
@ViewBuilder
|
||||
private var neuralModelRow: some View {
|
||||
if let neural: NeuralAmpPedal = pedal as? NeuralAmpPedal {
|
||||
VStack(spacing: PedalView.neuralRowSpacing) {
|
||||
Text(neuralModelLabel(neural))
|
||||
.font(.system(size: PedalView.neuralRowFontSize, weight: .medium))
|
||||
.foregroundStyle(Color.white.opacity(PedalView.neuralRowLabelOpacity))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
Button("Load Model…") { showModelImporter = true }
|
||||
.buttonStyle(.bordered)
|
||||
.controlSize(.small)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.fileImporter(
|
||||
isPresented: $showModelImporter,
|
||||
allowedContentTypes: [.json]
|
||||
) { (result: Result<URL, Error>) in
|
||||
guard case .success(let url) = result else { return }
|
||||
// The app is unsandboxed, so a plain path read works; still bracket access defensively.
|
||||
let accessed: Bool = url.startAccessingSecurityScopedResource()
|
||||
neural.resourcePath = url.path
|
||||
if accessed { url.stopAccessingSecurityScopedResource() }
|
||||
pedalRebuildAction(neural)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Loaded-model caption for the Neural Amp row — the model file's base name, or a prompt.
|
||||
private func neuralModelLabel(_ neural: NeuralAmpPedal) -> String {
|
||||
guard let path: String = neural.resourcePath, !path.isEmpty else { return "No model loaded" }
|
||||
return (path as NSString).lastPathComponent
|
||||
}
|
||||
|
||||
private var bottomControls: some View {
|
||||
HStack(alignment: .center, spacing: PedalView.bottomControlsSpacing) {
|
||||
levelControl
|
||||
bypassControl
|
||||
mixControl
|
||||
footerTrailing
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
/// The trailing slot of the bottom row: the Mix knob when the pedal shows one, otherwise the
|
||||
/// promoted ``footerSelector`` (e.g. an amp's Cab) — giving amps `Level · Bypass · Cab`. Empty
|
||||
/// when neither applies, which keeps Bypass centred.
|
||||
@ViewBuilder
|
||||
private var footerTrailing: some View {
|
||||
if pedal.showsMixControl {
|
||||
mixControl
|
||||
} else if let selector: PedalSelectorKnob = footerSelector {
|
||||
PedalSelectorKnobView(
|
||||
selector,
|
||||
onCommit: selector.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The `Level` knob — the last entry of `pedal.knobs` — placed left of the bypass switch.
|
||||
@ViewBuilder
|
||||
private var levelControl: some View {
|
||||
|
||||
@@ -10,44 +10,87 @@ import LyrebirdShoeGaze
|
||||
/// Setup of the rig library for an app shell, split so nothing blocks the launch path.
|
||||
///
|
||||
/// ``makeStore()`` returns an auto-resolving store instantly (safe to construct in a synchronous
|
||||
/// initializer and hand to the UI). ``start(_:seedFrom:seedName:)`` then does the blocking work —
|
||||
/// resolving the iCloud-or-local location and the initial load — off the main thread, and seeds the
|
||||
/// library from the current working rig **only after** the real (possibly iCloud) contents are
|
||||
/// known, so a first launch can't create a duplicate "Default" rig on every synced device.
|
||||
/// initializer and hand to the UI). ``start(_:seedFrom:)`` then does the blocking work — resolving
|
||||
/// the iCloud-or-local location and the initial load — off the main thread, then performs a one-time
|
||||
/// catch-up seed of any missing shipped starter rigs.
|
||||
@MainActor
|
||||
public enum RigLibraryBootstrap {
|
||||
|
||||
/// `UserDefaults` key holding the highest ``FactoryRigLibrary/seedVersion`` this device has
|
||||
/// already seeded. Per-device (not synced): the seed is idempotent by stable rig id, so a device
|
||||
/// that receives the rigs via iCloud sync simply finds them already present and seeds nothing.
|
||||
private static let seedVersionKey: String = "net.realizedsound.shoegaze.factorySeedVersion"
|
||||
|
||||
/// Creates an auto-resolving store. Construct this synchronously at launch; call
|
||||
/// ``start(_:seedFrom:seedName:)`` afterwards (e.g. from a SwiftUI `.task` or a `Task`).
|
||||
/// ``start(_:seedFrom:)`` afterwards (e.g. from a SwiftUI `.task` or a `Task`).
|
||||
public static func makeStore() -> RigLibraryStore {
|
||||
RigLibraryStore()
|
||||
}
|
||||
|
||||
/// Resolves + loads `store` off the main thread, then seeds it from `shoeGaze` if it is still
|
||||
/// empty after loading (first run). Idempotent enough to call once at launch.
|
||||
/// Resolves + loads `store` off the main thread, then performs a one-time catch-up install of the
|
||||
/// shipped starter rigs. Idempotent — safe to call once at every launch.
|
||||
///
|
||||
/// Installing (re)saves every factory rig by its stable id, so it **adds** missing starters and
|
||||
/// **refreshes** existing ones to their current shipped definition (a corrected rig replaces the
|
||||
/// stale copy in place, keeping its library position). User rigs are never touched — factory rigs
|
||||
/// have their own fixed ids. It runs at most once per ``FactoryRigLibrary/seedVersion``: a first
|
||||
/// launch installs every starter; a launch after a version bump refreshes/adds; and within a
|
||||
/// version a starter the user deletes stays deleted (the marker has already advanced). This
|
||||
/// deliberately replaces the old "only seed an empty library" rule so existing users get starters.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - store: The store from ``makeStore()``.
|
||||
/// - shoeGaze: The session whose current rig seeds the library when it is first empty.
|
||||
/// - seedName: Name for the seeded first rig. Defaults to `"Default"`.
|
||||
/// - shoeGaze: The working session (currently unused by seeding; kept for call-site stability
|
||||
/// and future working-rig seeding needs).
|
||||
public static func start(
|
||||
_ store: RigLibraryStore,
|
||||
seedFrom shoeGaze: ShoeGaze,
|
||||
seedName: String = "Default"
|
||||
seedFrom shoeGaze: ShoeGaze
|
||||
) async {
|
||||
await store.start()
|
||||
|
||||
// Seed only after the (possibly iCloud) library has loaded: an empty library here means a
|
||||
// genuine first run, not a not-yet-synced one.
|
||||
guard store.entries.isEmpty, !shoeGaze.boards.isEmpty else { return }
|
||||
let entry: RigEntry = shoeGaze.captureEntry(name: seedName)
|
||||
let defaults: UserDefaults = .standard
|
||||
let seededVersion: Int = defaults.integer(forKey: seedVersionKey) // 0 when never seeded
|
||||
guard seededVersion < FactoryRigLibrary.seedVersion else { return }
|
||||
|
||||
// Install the starters. Only advance the marker if it succeeded, so a transient failure
|
||||
// (which should not happen for this deterministic data) is retried on the next launch.
|
||||
if installFactoryRigs(into: store) != nil {
|
||||
defaults.set(FactoryRigLibrary.seedVersion, forKey: seedVersionKey)
|
||||
}
|
||||
}
|
||||
|
||||
/// (Re)installs every shipped starter rig to its current definition. Safe to call anytime.
|
||||
///
|
||||
/// Drives the user-facing "Restore Starter Rigs" action: it re-adds starters the user deleted,
|
||||
/// adds newly-shipped ones, and refreshes any stale copies — all without disturbing the user's own
|
||||
/// rigs — and advances the seed marker so automatic catch-up won't fight the manual restore.
|
||||
///
|
||||
/// - Parameter store: The library to install into.
|
||||
/// - Returns: The number of starter rigs written (0 on a build/encode failure).
|
||||
@discardableResult
|
||||
public static func restoreStarterRigs(into store: RigLibraryStore) -> Int {
|
||||
// Advance the seed marker only on success, mirroring `start()` — a failed restore must not
|
||||
// suppress the automatic catch-up seed on the next launch.
|
||||
guard let written: Int = installFactoryRigs(into: store) else { return 0 }
|
||||
UserDefaults.standard.set(FactoryRigLibrary.seedVersion, forKey: seedVersionKey)
|
||||
return written
|
||||
}
|
||||
|
||||
/// Builds every starter rig and saves it, overwriting any existing entry with the same stable id
|
||||
/// (`store.save` upserts by id, keeping an overwritten entry's library position).
|
||||
///
|
||||
/// - Parameter store: The library to install into.
|
||||
/// - Returns: The number of rigs written, or `nil` if building/encoding failed.
|
||||
private static func installFactoryRigs(into store: RigLibraryStore) -> Int? {
|
||||
do {
|
||||
try store.save(entry)
|
||||
// The seeded entry was captured from the working graph, so it is the session's source
|
||||
// rig — record it so the sidebar highlights it and the autosave envelope carries it.
|
||||
shoeGaze.currentRigID = entry.id
|
||||
let entries: [RigEntry] = try FactoryRigLibrary.makeEntries()
|
||||
for entry: RigEntry in entries {
|
||||
try store.save(entry)
|
||||
}
|
||||
return entries.count
|
||||
} catch {
|
||||
print("[RigLibraryBootstrap] seeding library failed: \(error)")
|
||||
print("[RigLibraryBootstrap] installing factory rigs failed: \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ struct RigLibrarySidebarView: View {
|
||||
private static let subtitleOpacity: Double = 0.5
|
||||
private static let headerOpacity: Double = 0.65
|
||||
private static let emptyOpacity: Double = 0.4
|
||||
private static let tabPickerWidth: CGFloat = 168
|
||||
|
||||
// MARK: - Inputs
|
||||
|
||||
@@ -45,6 +46,9 @@ struct RigLibrarySidebarView: View {
|
||||
let onImportArchive: () -> Void
|
||||
let onExportArchive: () -> Void
|
||||
|
||||
/// Invoked to (re-)install any shipped starter rigs missing from the library. Defaults to a no-op.
|
||||
var onRestoreStarters: () -> Void = {}
|
||||
|
||||
/// Invoked when the local-only (iCloud-unavailable) status icon is tapped, so the host can
|
||||
/// explain how to re-enable iCloud sync. Defaults to a no-op.
|
||||
var onShowCloudStatus: () -> Void = {}
|
||||
@@ -52,6 +56,16 @@ struct RigLibrarySidebarView: View {
|
||||
private static let timestampFormat: Date.FormatStyle =
|
||||
Date.FormatStyle(date: .abbreviated, time: .shortened)
|
||||
|
||||
/// Which group of rigs the list is currently showing.
|
||||
private enum RigTab: String, CaseIterable, Identifiable {
|
||||
case mine = "Mine"
|
||||
case starters = "Starters"
|
||||
var id: String { rawValue }
|
||||
}
|
||||
|
||||
/// The selected list tab. Defaults to the user's own rigs.
|
||||
@State private var tab: RigTab = .mine
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
var body: some View {
|
||||
@@ -63,6 +77,18 @@ struct RigLibrarySidebarView: View {
|
||||
actionBar
|
||||
}
|
||||
.frame(width: RigLibrarySidebarView.width)
|
||||
// Open on the tab that contains the currently-loaded rig, so a session restored on a starter
|
||||
// rig (e.g. Garcia) shows Starters, and one on a user rig shows Mine.
|
||||
.onAppear { tab = tabForCurrentRig() }
|
||||
.onChange(of: currentRigID) { tab = tabForCurrentRig() }
|
||||
}
|
||||
|
||||
/// The tab whose group contains the currently-loaded rig: Starters for a factory rig, else Mine.
|
||||
private func tabForCurrentRig() -> RigTab {
|
||||
if let id: UUID = currentRigID, FactoryRigLibrary.isFactory(id) {
|
||||
return .starters
|
||||
}
|
||||
return .mine
|
||||
}
|
||||
|
||||
// MARK: - Header
|
||||
@@ -99,34 +125,105 @@ struct RigLibrarySidebarView: View {
|
||||
|
||||
// MARK: - List
|
||||
|
||||
@ViewBuilder
|
||||
private var rigList: some View {
|
||||
ScrollView(.vertical, showsIndicators: true) {
|
||||
LazyVStack(alignment: .leading, spacing: RigLibrarySidebarView.rowSpacing) {
|
||||
if !store.isLoaded {
|
||||
HStack(spacing: 6) {
|
||||
ProgressView().controlSize(.small)
|
||||
Text("Loading…")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.emptyOpacity))
|
||||
if !store.isLoaded {
|
||||
HStack(spacing: 6) {
|
||||
ProgressView().controlSize(.small)
|
||||
Text("Loading…")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.emptyOpacity))
|
||||
}
|
||||
.padding(.vertical, RigLibrarySidebarView.rowPadding)
|
||||
.frame(maxHeight: .infinity, alignment: .top)
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: RigLibrarySidebarView.rowSpacing) {
|
||||
tabPicker
|
||||
ScrollView(.vertical, showsIndicators: true) {
|
||||
LazyVStack(alignment: .leading, spacing: RigLibrarySidebarView.rowSpacing) {
|
||||
switch tab {
|
||||
case .mine: mineList
|
||||
case .starters: startersList
|
||||
}
|
||||
}
|
||||
.padding(.vertical, RigLibrarySidebarView.rowPadding)
|
||||
} else if store.entries.isEmpty {
|
||||
Text("No saved rigs yet.\nTap New or Save to add one.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.emptyOpacity))
|
||||
.padding(.vertical, RigLibrarySidebarView.rowPadding)
|
||||
}
|
||||
ForEach(store.entries) { entry in
|
||||
rigRow(entry)
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Segmented Mine / Starters switch, centered at the top of the list.
|
||||
private var tabPicker: some View {
|
||||
Picker("", selection: $tab) {
|
||||
ForEach(RigTab.allCases) { option in
|
||||
Text(option.rawValue).tag(option)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.labelsHidden()
|
||||
// Constrain the control's own width, then center it in the full column width.
|
||||
.frame(maxWidth: RigLibrarySidebarView.tabPickerWidth)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
|
||||
/// The user's own rigs — a flat, reorderable list.
|
||||
@ViewBuilder
|
||||
private var mineList: some View {
|
||||
let userRigs: [RigEntry] = userEntries
|
||||
if userRigs.isEmpty {
|
||||
Text("No saved rigs yet.\nTap New or Save to add one.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.emptyOpacity))
|
||||
.padding(.vertical, RigLibrarySidebarView.rowPadding)
|
||||
} else {
|
||||
ForEach(userRigs) { entry in
|
||||
rigRow(entry, reorderable: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The shipped starter rigs, grouped by category (fixed catalog order, not reorderable).
|
||||
@ViewBuilder
|
||||
private var startersList: some View {
|
||||
let sections: [(category: FactoryRigCategory, entries: [RigEntry])] = factorySections
|
||||
if sections.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("No starter rigs installed.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.emptyOpacity))
|
||||
Button("Restore Starter Rigs") { onRestoreStarters() }
|
||||
.buttonStyle(.bordered)
|
||||
.tint(.orange)
|
||||
.controlSize(.small)
|
||||
}
|
||||
.padding(.vertical, RigLibrarySidebarView.rowPadding)
|
||||
} else {
|
||||
ForEach(sections, id: \.category) { section in
|
||||
sectionHeader(section.category.displayName)
|
||||
ForEach(section.entries) { entry in
|
||||
rigRow(entry, reorderable: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
|
||||
private func rigRow(_ entry: RigEntry) -> some View {
|
||||
/// A small uppercase section header for a group of rigs.
|
||||
private func sectionHeader(_ title: String) -> some View {
|
||||
Text(title.uppercased())
|
||||
.font(.caption2)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.headerOpacity))
|
||||
.padding(.top, RigLibrarySidebarView.rowPadding)
|
||||
.padding(.horizontal, 2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
/// One rig row. `reorderable` rows (the user's own rigs) accept drag-to-reorder and expose
|
||||
/// Move Up / Down; starter rigs are fixed and show a "Starter rig" subtitle instead of a date.
|
||||
@ViewBuilder
|
||||
private func rigRow(_ entry: RigEntry, reorderable: Bool) -> some View {
|
||||
let isSelected: Bool = entry.id == currentRigID
|
||||
return Button {
|
||||
let button = Button {
|
||||
onSelect(entry)
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
@@ -134,7 +231,9 @@ struct RigLibrarySidebarView: View {
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
Text(entry.savedAt.formatted(RigLibrarySidebarView.timestampFormat))
|
||||
Text(reorderable
|
||||
? entry.savedAt.formatted(RigLibrarySidebarView.timestampFormat)
|
||||
: "Starter rig")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(RigLibrarySidebarView.subtitleOpacity))
|
||||
.lineLimit(1)
|
||||
@@ -149,45 +248,81 @@ struct RigLibrarySidebarView: View {
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
// Drag the row onto another to reorder; dropping inserts it just before the target. Works
|
||||
// on macOS (mouse drag) and iPad (long-press drag); taps still select.
|
||||
.draggable(entry.id.uuidString)
|
||||
.dropDestination(for: String.self) { droppedIDs, _ in
|
||||
guard let first: String = droppedIDs.first else { return false }
|
||||
moveDragged(first, onto: entry)
|
||||
return true
|
||||
}
|
||||
.contextMenu {
|
||||
Button("Move Up") { store.moveUp(entry) }
|
||||
.disabled(isFirst(entry))
|
||||
Button("Move Down") { store.moveDown(entry) }
|
||||
.disabled(isLast(entry))
|
||||
Divider()
|
||||
Button("Rename…") { onRename(entry) }
|
||||
Button("Duplicate…") { onDuplicate(entry) }
|
||||
// Encoding a fully-concrete RigEntry to JSON does not fail in practice; on the
|
||||
// unreachable failure path the Share item is simply omitted.
|
||||
if let shareItem: RigShareItem = try? RigShareItem(rig: entry) {
|
||||
ShareLink(
|
||||
item: shareItem,
|
||||
preview: SharePreview(entry.name)
|
||||
) {
|
||||
Label("Share…", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
Button("Delete", role: .destructive) { onDelete(entry) }
|
||||
rowContextMenu(entry, reorderable: reorderable)
|
||||
}
|
||||
|
||||
if reorderable {
|
||||
// Drag the row onto another to reorder; dropping inserts it just before the target. Works
|
||||
// on macOS (mouse drag) and iPad (long-press drag); taps still select.
|
||||
button
|
||||
.draggable(entry.id.uuidString)
|
||||
.dropDestination(for: String.self) { droppedIDs, _ in
|
||||
guard let first: String = droppedIDs.first else { return false }
|
||||
moveDragged(first, onto: entry)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
button
|
||||
}
|
||||
}
|
||||
|
||||
/// The context menu for a rig row. Move Up / Down appear only for reorderable (user) rigs.
|
||||
@ViewBuilder
|
||||
private func rowContextMenu(_ entry: RigEntry, reorderable: Bool) -> some View {
|
||||
if reorderable {
|
||||
Button("Move Up") { store.moveUp(entry) }
|
||||
.disabled(isFirstUser(entry))
|
||||
Button("Move Down") { store.moveDown(entry) }
|
||||
.disabled(isLastUser(entry))
|
||||
Divider()
|
||||
}
|
||||
Button("Rename…") { onRename(entry) }
|
||||
Button("Duplicate…") { onDuplicate(entry) }
|
||||
// Encoding a fully-concrete RigEntry to JSON does not fail in practice; on the
|
||||
// unreachable failure path the Share item is simply omitted.
|
||||
if let shareItem: RigShareItem = try? RigShareItem(rig: entry) {
|
||||
ShareLink(
|
||||
item: shareItem,
|
||||
preview: SharePreview(entry.name)
|
||||
) {
|
||||
Label("Share…", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
Button("Delete", role: .destructive) { onDelete(entry) }
|
||||
}
|
||||
|
||||
// MARK: - Grouping
|
||||
|
||||
/// The starter-rig sections: each non-empty ``FactoryRigCategory`` present in the library, in
|
||||
/// catalog order, paired with its entries (also in catalog order).
|
||||
private var factorySections: [(category: FactoryRigCategory, entries: [RigEntry])] {
|
||||
let byID: [UUID: RigEntry] = Dictionary(
|
||||
store.entries.map { ($0.id, $0) },
|
||||
uniquingKeysWith: { first, _ in first }
|
||||
)
|
||||
return FactoryRigCategory.allCases.compactMap { category in
|
||||
let entries: [RigEntry] = FactoryRigLibrary.rigs(in: category).compactMap { byID[$0.id] }
|
||||
return entries.isEmpty ? nil : (category, entries)
|
||||
}
|
||||
}
|
||||
|
||||
/// The user's own (non-factory) rigs, in library order.
|
||||
private var userEntries: [RigEntry] {
|
||||
store.entries.filter { !FactoryRigLibrary.isFactory($0.id) }
|
||||
}
|
||||
|
||||
// MARK: - Reorder helpers
|
||||
|
||||
private func isFirst(_ entry: RigEntry) -> Bool {
|
||||
store.entries.first?.id == entry.id
|
||||
/// Whether `entry` is the first among the user's own rigs (so Move Up is disabled for it).
|
||||
private func isFirstUser(_ entry: RigEntry) -> Bool {
|
||||
userEntries.first?.id == entry.id
|
||||
}
|
||||
|
||||
private func isLast(_ entry: RigEntry) -> Bool {
|
||||
store.entries.last?.id == entry.id
|
||||
/// Whether `entry` is the last among the user's own rigs (so Move Down is disabled for it).
|
||||
private func isLastUser(_ entry: RigEntry) -> Bool {
|
||||
userEntries.last?.id == entry.id
|
||||
}
|
||||
|
||||
/// Moves the dragged entry (by id string) to sit just before `target` in the set list.
|
||||
@@ -217,6 +352,8 @@ struct RigLibrarySidebarView: View {
|
||||
Button("Import Archive…") { onImportArchive() }
|
||||
Button("Export Archive…") { onExportArchive() }
|
||||
Divider()
|
||||
Button("Restore Starter Rigs") { onRestoreStarters() }
|
||||
Divider()
|
||||
Button("Erase All Rigs…", role: .destructive) { onEraseAll() }
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
|
||||
@@ -149,6 +149,18 @@ public struct ShoeGazeBuilderView: View {
|
||||
let message: String
|
||||
}
|
||||
|
||||
/// A pending confirmation to overwrite a built-in factory rig. Non-`nil` shows the dialog;
|
||||
/// carries the target entry and the follow-up to run once the user resolves the choice (so the
|
||||
/// "Save & Clear" flow still clears after a confirmed overwrite).
|
||||
private struct FactoryOverwriteRequest: Identifiable {
|
||||
let id: UUID = UUID()
|
||||
let entry: RigEntry
|
||||
let completion: () -> Void
|
||||
}
|
||||
|
||||
/// Drives the "overwrite a starter rig?" confirmation dialog. `nil` = not shown.
|
||||
@State private var factoryOverwrite: FactoryOverwriteRequest?
|
||||
|
||||
/// Archive export state. Cross-platform: backs the sidebar's Export Archive and the
|
||||
/// "Save & Clear" flow is separate (it saves to the library, not a file).
|
||||
@State private var showExporter: Bool = false
|
||||
@@ -297,13 +309,43 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var presentationChrome: some View {
|
||||
// Split off the first half of the presentation chain into its own computed property: the full
|
||||
// modifier chain is long enough to blow the Swift expression type-checker's budget, so this
|
||||
// boundary keeps each half small enough to type-check quickly.
|
||||
private var chromeWithPrompts: some View {
|
||||
layoutChrome
|
||||
.background(boardsSheetAnchor)
|
||||
.background(rigExportAnchor)
|
||||
.background(rigImportAnchor)
|
||||
.background(actionErrorAnchor)
|
||||
.rigNamePrompt($namePrompt)
|
||||
.confirmationDialog(
|
||||
"Starter rig",
|
||||
isPresented: Binding(
|
||||
get: { factoryOverwrite != nil },
|
||||
set: { presented in if !presented { factoryOverwrite = nil } }
|
||||
),
|
||||
titleVisibility: .visible,
|
||||
presenting: factoryOverwrite
|
||||
) { request in
|
||||
// A starter rig is managed content: it is refreshed to the shipped version whenever the
|
||||
// starter catalog updates, so it deliberately cannot be overwritten in place — that would
|
||||
// silently revert on the next update. The player keeps their changes as a new rig instead.
|
||||
Button("Save as New Rig…") {
|
||||
// Defer one runloop hop: presenting the name-entry alert while the confirmation
|
||||
// dialog is still dismissing can drop the new presentation on some SwiftUI versions.
|
||||
let completion: () -> Void = request.completion
|
||||
DispatchQueue.main.async { promptSaveAs(then: completion) }
|
||||
}
|
||||
Button("Cancel", role: .cancel) { }
|
||||
} message: { request in
|
||||
Text("“\(request.entry.name)” is a built-in starter rig and can't be changed in place. "
|
||||
+ "Save your changes as a new rig to keep them.")
|
||||
}
|
||||
}
|
||||
|
||||
private var presentationChrome: some View {
|
||||
chromeWithPrompts
|
||||
.confirmationDialog(
|
||||
"Erase all rigs?",
|
||||
isPresented: $showEraseAllDialog,
|
||||
@@ -607,10 +649,18 @@ public struct ShoeGazeBuilderView: View {
|
||||
onEraseAll: { showEraseAllDialog = true },
|
||||
onImportArchive: { showImporter = true },
|
||||
onExportArchive: { exportArchiveAction() },
|
||||
onRestoreStarters: { restoreStarterRigs() },
|
||||
onShowCloudStatus: { showICloudUnavailableAlert = true }
|
||||
)
|
||||
}
|
||||
|
||||
/// (Re-)installs any shipped starter rigs missing from the library. Non-destructive: user rigs
|
||||
/// are untouched, and already-present starters are skipped (matched by stable id).
|
||||
private func restoreStarterRigs() {
|
||||
let added: Int = RigLibraryBootstrap.restoreStarterRigs(into: library)
|
||||
print("[ShoeGazeBuilderView] restored \(added) starter rig(s)")
|
||||
}
|
||||
|
||||
// MARK: - Sleep / iCloud status
|
||||
|
||||
/// Platform name for the settings app, used in the iCloud guidance alert.
|
||||
@@ -670,6 +720,18 @@ public struct ShoeGazeBuilderView: View {
|
||||
// Feed the rig's control map into the board tree so each pedal can draw its mapping strip.
|
||||
// Reading `shoeGaze.midiMap` here (observable) refreshes every strip when a binding changes.
|
||||
.environment(\.controlMappingMap, shoeGaze.midiMap)
|
||||
// Let a pedal (e.g. Neural Amp on a model-file change) request a rebuild of its board.
|
||||
// Captures only `shoeGaze` (a @MainActor session); `rebuildBoard` is safe on a running
|
||||
// engine (at most one block of glitch).
|
||||
.environment(\.pedalRebuildAction, { @MainActor [shoeGaze] (pedal: Pedal) in
|
||||
// Branch-aware lookup — the pedal may live inside a parallel / stereo-split section.
|
||||
guard let board: PedalBoard = shoeGaze.board(containing: pedal) else { return }
|
||||
do {
|
||||
_ = try shoeGaze.rebuildBoard(board, from: board.captureState())
|
||||
} catch {
|
||||
print("[ShoeGaze] board rebuild after model change failed: \(error)")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: - Compact layout (iPhone / narrow iPad)
|
||||
@@ -1575,7 +1637,9 @@ public struct ShoeGazeBuilderView: View {
|
||||
let wasRunning: Bool = shoeGaze.engine.isRunning
|
||||
if wasRunning { shoeGaze.engine.stop() }
|
||||
do {
|
||||
try shoeGaze.loadRig(from: entry.state)
|
||||
// Keep the player's currently-chosen input across the switch (e.g. a live guitar), rather
|
||||
// than snapping to the input the selected rig was authored with.
|
||||
try shoeGaze.loadRig(from: entry.state, keepingCurrentInput: true)
|
||||
currentRigID = entry.id
|
||||
selectedBoardIndex = 0
|
||||
autosave()
|
||||
@@ -1610,12 +1674,16 @@ public struct ShoeGazeBuilderView: View {
|
||||
|
||||
/// Whether the working rig differs from the library entry it was loaded from. A working rig with
|
||||
/// no backing entry counts as dirty when it has any boards.
|
||||
///
|
||||
/// Compares rig content only (boards, routers, MIDI, tempo) — not the live input source or engine
|
||||
/// channel counts, which are intentionally kept across a rig switch and so must not register as
|
||||
/// unsaved changes (otherwise switching between rigs always prompts to save).
|
||||
private func isCurrentRigDirty() -> Bool {
|
||||
guard let id: UUID = currentRigID,
|
||||
let entry: RigEntry = library.entries.first(where: { $0.id == id }) else {
|
||||
return !shoeGaze.boards.isEmpty
|
||||
}
|
||||
return shoeGaze.captureState() != entry.state
|
||||
return !shoeGaze.captureState().hasSameRigContent(as: entry.state)
|
||||
}
|
||||
|
||||
/// Saves the current session over the loaded library entry, or prompts for a name when no entry
|
||||
@@ -1637,6 +1705,12 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
return
|
||||
}
|
||||
// Overwriting a built-in starter rig replaces it in the library. Confirm first, offering a
|
||||
// non-destructive "Save as New Rig" so the shipped original can be kept.
|
||||
if FactoryRigLibrary.isFactory(existing.id) {
|
||||
factoryOverwrite = FactoryOverwriteRequest(entry: existing, completion: completion)
|
||||
return
|
||||
}
|
||||
persist(shoeGaze.captureEntry(name: existing.name, id: id), then: completion)
|
||||
}
|
||||
|
||||
@@ -1652,13 +1726,16 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
|
||||
/// Prompts for a name and saves the current session as a new library entry (new id).
|
||||
private func promptSaveAs() {
|
||||
///
|
||||
/// - Parameter completion: Follow-up run once the new entry is persisted (e.g. the "Save & Clear"
|
||||
/// clear step, or the pending action from a factory-rig overwrite prompt).
|
||||
private func promptSaveAs(then completion: @escaping () -> Void = { }) {
|
||||
namePrompt = RigNamePrompt(
|
||||
title: "Save Rig As",
|
||||
initialText: currentRigName() ?? defaultNewRigName(),
|
||||
confirmLabel: "Save"
|
||||
) { name in
|
||||
persist(shoeGaze.captureEntry(name: name))
|
||||
persist(shoeGaze.captureEntry(name: name), then: completion)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
// AmpVoicePedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("AmpVoicePedal")
|
||||
struct AmpVoicePedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
/// Sum-of-squared-differences after RMS-normalizing each window, so a pure level difference
|
||||
/// collapses to ~0 and only a genuine waveshape (saturation) change registers.
|
||||
private func rmsNormalizedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||
func rms(_ x: ArraySlice<Float>) -> Double {
|
||||
let sumSq: Double = x.reduce(0.0) { $0 + Double($1) * Double($1) }
|
||||
return (sumSq / Double(x.count)).squareRoot()
|
||||
}
|
||||
let ra: Double = rms(aw)
|
||||
let rb: Double = rms(bw)
|
||||
guard ra > 0.0, rb > 0.0 else { return 0.0 }
|
||||
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0) / ra - Double(pair.1) / rb
|
||||
return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
/// The three concrete voices under test, keyed by their display name / registry key.
|
||||
private let voices: [(name: String, make: () -> AmpVoicePedal)] = [
|
||||
("California", { CaliforniaAmpPedal() }),
|
||||
("British", { BritishAmpPedal() }),
|
||||
("Chime", { ChimeAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allVoicesBuildNonSilentFiniteOutput() throws {
|
||||
for voice in voices {
|
||||
let samples: [Float] = try render(voice.make)
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "\(voice.name) produced silence")
|
||||
#expect(samples.allSatisfy { $0.isFinite }, "\(voice.name) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func gainChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let clean: [Float] = try render(voice.make) { $0.gain = 2.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 10.5 }
|
||||
#expect(windowedSSD(clean, hot) > 0, "\(voice.name) gain had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func gainDialRunsOneToEleven() throws {
|
||||
// The Gain knob is a 1–11 dial (it goes to eleven), mapped to tube drive via a taper.
|
||||
for voice in voices {
|
||||
let gainKnob: PedalKnob? = voice.make().effectKnobs.first { $0.label == "Gain" }
|
||||
#expect(gainKnob?.range == 1.0 ... 11.0, "\(voice.name) Gain range should be 1...11")
|
||||
}
|
||||
// The Boutique amps' Drive channel is the same 1–11 dial.
|
||||
let driveKnob: PedalKnob? = BoutiqueLeadAmpPedal().effectKnobs.first { $0.label == "Drive" }
|
||||
#expect(driveKnob?.range == 1.0 ... 11.0, "Drive range should be 1...11")
|
||||
}
|
||||
|
||||
@Test func gainTaperIsMonotonicAndSaturatesMore() throws {
|
||||
// Turning the dial up must add saturation (waveshape change), and the exponential taper means
|
||||
// the jump from 9→11 shapes the wave more than 1→3 — most grind lives up top. Use the
|
||||
// California voice; RMS-normalize so level differences don't masquerade as waveshape change.
|
||||
let low: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 1.0 }
|
||||
let mid: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 3.0 }
|
||||
let hi: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 9.0 }
|
||||
let top: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 11.0 }
|
||||
#expect(rmsNormalizedSSD(low, mid) > 0, "1→3 should change the waveshape")
|
||||
#expect(rmsNormalizedSSD(hi, top) > rmsNormalizedSSD(low, mid),
|
||||
"the top of the taper should shape more than the bottom (exponential)")
|
||||
}
|
||||
|
||||
@Test func toneControlsChangeOutput() throws {
|
||||
for voice in voices {
|
||||
let dark: [Float] = try render(voice.make) { $0.treble = 0.0; $0.bass = 1.0 }
|
||||
let bright: [Float] = try render(voice.make) { $0.treble = 1.0; $0.bass = 0.0 }
|
||||
#expect(windowedSSD(dark, bright) > 0, "\(voice.name) tone controls had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func midChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let scooped: [Float] = try render(voice.make) { $0.mid = 0.0 }
|
||||
let full: [Float] = try render(voice.make) { $0.mid = 1.0 }
|
||||
#expect(windowedSSD(scooped, full) > 0, "\(voice.name) mid control had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let cabA: [Float] = try render(voice.make) { $0.cab = 0.0 }
|
||||
let cabB: [Float] = try render(voice.make) { $0.cab = 2.0 }
|
||||
#expect(windowedSSD(cabA, cabB) > 0, "\(voice.name) cab selection had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinDigitalCeiling() throws {
|
||||
// The tanh soft-limits and the trailing Clip(±1) hard-clamps, so no sample may exceed ±1
|
||||
// (a tiny epsilon covers float round-trip through the CAF). Drive every voice hard.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) peak \(peak) exceeds the ±1 ceiling")
|
||||
#expect(peak > 0.3, "\(voice.name) unexpectedly quiet at max gain: \(peak)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Signature controls
|
||||
|
||||
@Test func californiaBrightChangesOutput() throws {
|
||||
let flat: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 0.0 }
|
||||
let sparkle: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 1.0 }
|
||||
#expect(windowedSSD(flat, sparkle) > 0, "California Bright had no effect")
|
||||
}
|
||||
|
||||
@Test func britishPresenceChangesOutput() throws {
|
||||
let flat: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 0.0 }
|
||||
let lifted: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 1.0 }
|
||||
#expect(windowedSSD(flat, lifted) > 0, "British Presence had no effect")
|
||||
}
|
||||
|
||||
@Test func britishMasterDrivesPowerAmp() throws {
|
||||
// Master drives the power-amp stage into saturation — so it must change the *waveshape*, not
|
||||
// just the level (which is what `level` would do). RMS-normalize each window before diffing:
|
||||
// a pure level change collapses to ~0, so a clearly-positive normalized SSD proves genuine
|
||||
// power-amp saturation.
|
||||
let low: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 8.3; $0.master = 0.1 }
|
||||
let high: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 8.3; $0.master = 1.0 }
|
||||
#expect(hasNonSilentOutput(low) && hasNonSilentOutput(high))
|
||||
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "Master changed level but not tone (no power-amp saturation)")
|
||||
}
|
||||
|
||||
@Test func britishStaysWithinCeilingAtMaxMaster() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render({ BritishAmpPedal() }) { (pedal: BritishAmpPedal) in
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.master = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "British peak \(peak) exceeds the ±1 ceiling at max Master")
|
||||
}
|
||||
|
||||
@Test func britishMasterRoundTripsThroughState() throws {
|
||||
let pedal: BritishAmpPedal = BritishAmpPedal()
|
||||
pedal.master = 0.8
|
||||
let restored: BritishAmpPedal = BritishAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.master == 0.8, "Master did not round-trip")
|
||||
}
|
||||
|
||||
@Test func chimeCutChangesOutput() throws {
|
||||
let open: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 0.0 }
|
||||
let dark: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 1.0 }
|
||||
#expect(windowedSSD(open, dark) > 0, "Chime Cut had no effect")
|
||||
}
|
||||
|
||||
// MARK: - Power-amp Sag / Bias (shared)
|
||||
|
||||
@Test func sagChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let stiff: [Float] = try render(voice.make) { $0.gain = 9.8; $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render(voice.make) { $0.gain = 9.8; $0.sag = 1.0 }
|
||||
#expect(windowedSSD(stiff, saggy) > 0, "\(voice.name) Sag had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func sagStaysWithinCeilingWithoutPhaseInversion() throws {
|
||||
// Sag is a gain droop; it must attenuate loud content, never phase-invert it. The envelope
|
||||
// tracks a post-power-amp signal that can exceed 1, so the droop gain is clamped positive.
|
||||
// Assert the sagged output correlates positively with the stiff one (not an inverted copy)
|
||||
// and never breaches the ±1 ceiling.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let cfg: (AmpVoicePedal) -> Void = { (p: AmpVoicePedal) in
|
||||
p.gain = 10.5; p.bass = 1.0; p.treble = 1.0
|
||||
}
|
||||
let stiff: [Float] = try render(voice.make) { cfg($0); $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render(voice.make) { cfg($0); $0.sag = 1.0 }
|
||||
let peak: Double = saggy.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) sagged peak \(peak) exceeds ±1")
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
guard stiff.count >= skip + window, saggy.count >= skip + window else {
|
||||
Issue.record("\(voice.name) render too short"); continue
|
||||
}
|
||||
let dotProduct: Double = zip(stiff[skip..<(skip + window)], saggy[skip..<(skip + window)])
|
||||
.reduce(0.0) { acc, pair in acc + Double(pair.0) * Double(pair.1) }
|
||||
#expect(dotProduct > 0, "\(voice.name) Sag phase-inverted the signal (dot \(dotProduct) < 0)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func biasChangesWaveshape() throws {
|
||||
// Bias shifts the power-amp tanh operating point → changes the even/odd harmonic mix (a
|
||||
// waveshape change), not merely the level. RMS-normalize so a pure level difference collapses.
|
||||
for voice in voices {
|
||||
let cold: [Float] = try render(voice.make) { $0.gain = 10.2; $0.bias = 0.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 10.2; $0.bias = 1.0 }
|
||||
#expect(hasNonSilentOutput(cold) && hasNonSilentOutput(hot))
|
||||
#expect(rmsNormalizedSSD(cold, hot) > 1.0e-4, "\(voice.name) Bias changed level but not waveshape")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func neutralBiasAndZeroSagAreIdentityDefault() throws {
|
||||
// The shipped defaults are sag = 0, bias = 0.5, biasX = 0 (all neutral). Setting them
|
||||
// explicitly to those values must be bit-for-bit identical to leaving them at their defaults
|
||||
// — proof the pop-over controls don't perturb any existing amp's voice at their neutral point.
|
||||
for voice in voices {
|
||||
let byDefault: [Float] = try render(voice.make)
|
||||
let explicit: [Float] = try render(voice.make) { $0.sag = 0.0; $0.bias = 0.5; $0.biasX = 0.0 }
|
||||
#expect(windowedSSD(byDefault, explicit) == 0, "\(voice.name) neutral Sag/Bias/Bias X is not identity")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func biasXChangesWaveshape() throws {
|
||||
// Bias X spreads the two power-amp half-stages' operating points → changes the even/odd
|
||||
// harmonic mix (a waveshape change), not merely the level. RMS-normalize so a pure level
|
||||
// difference collapses.
|
||||
for voice in voices {
|
||||
let balanced: [Float] = try render(voice.make) { $0.gain = 10.2; $0.biasX = 0.0 }
|
||||
let imbalanced: [Float] = try render(voice.make) { $0.gain = 10.2; $0.biasX = 1.0 }
|
||||
#expect(hasNonSilentOutput(balanced) && hasNonSilentOutput(imbalanced))
|
||||
#expect(rmsNormalizedSSD(balanced, imbalanced) > 1.0e-4,
|
||||
"\(voice.name) Bias X changed level but not waveshape")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func biasXStaysWithinCeiling() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0; pedal.biasX = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) Bias X peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func extremeBiasAndBiasXStayWithinCeiling() throws {
|
||||
// Bias (hot) + Bias X (max) together drive a half-stage bias to ±0.6 (base ±0.25 ± spread
|
||||
// 0.35). The tanh stays bounded and outputLimit clamps — output must stay finite and ≤ ±1.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0; pedal.bias = 1.0; pedal.biasX = 1.0
|
||||
}
|
||||
#expect(hot.allSatisfy { $0.isFinite }, "\(voice.name) bias+biasX produced non-finite output")
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) bias+biasX peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func advancedKnobsExposeSagBiasAndBiasX() throws {
|
||||
for voice in voices {
|
||||
let pedal: AmpVoicePedal = voice.make()
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias", "Bias X"],
|
||||
"\(voice.name) advanced knobs")
|
||||
// These are pop-over-only — they must NOT also appear on the pedal face.
|
||||
let faceLabels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(!faceLabels.contains("Sag") && !faceLabels.contains("Bias") && !faceLabels.contains("Bias X"),
|
||||
"\(voice.name) leaked an advanced knob onto the pedal face")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func sagBiasRoundTripThroughState() throws {
|
||||
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
pedal.sag = 0.7
|
||||
pedal.bias = 0.2
|
||||
pedal.biasX = 0.6
|
||||
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.sag == 0.7 && restored.bias == 0.2 && restored.biasX == 0.6,
|
||||
"Sag/Bias/Bias X did not round-trip through state")
|
||||
}
|
||||
|
||||
// MARK: - Cabinet decoupling
|
||||
|
||||
@Test func cabNoneBypassesConvolution() throws {
|
||||
for voice in voices {
|
||||
let withCab: [Float] = try render(voice.make) { $0.cab = 0.0 }
|
||||
let none: [Float] = try render(voice.make) { $0.cab = AmpVoicePedal.cabinetBypassValue }
|
||||
#expect(hasNonSilentOutput(none) && none.allSatisfy { $0.isFinite },
|
||||
"\(voice.name) None-cab output silent or non-finite")
|
||||
#expect(windowedSSD(withCab, none) > 0, "\(voice.name) None did not bypass the cabinet")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabNoneStillLimitsToCeiling() throws {
|
||||
// With the cabinet bypassed the output soft-limit must still run — the ±1 ceiling has to hold.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0
|
||||
pedal.cab = AmpVoicePedal.cabinetBypassValue
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon,
|
||||
"\(voice.name) None-cab peak \(peak) exceeds ±1 (output limiter lost)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func extremeCabValuesDoNotTrap() throws {
|
||||
// A corrupted/hand-edited rig can restore any Double into `cab`. Neither the bypass check nor
|
||||
// the voice lookup may trap `Int(_:)` — every value must resolve to a defined, finite render.
|
||||
let extremes: [Double] = [.infinity, -.infinity, 1.0e20, -1.0e20, .nan, 999.0]
|
||||
for cabValue: Double in extremes {
|
||||
let out: [Float] = try render({ CaliforniaAmpPedal() }) { $0.cab = cabValue }
|
||||
#expect(out.allSatisfy { $0.isFinite }, "cab=\(cabValue) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabSelectorExposesNoneStop() throws {
|
||||
let stops: [PedalSelectorKnob.Stop] = CaliforniaAmpPedal().effectSelectors
|
||||
.first { $0.label == "Cab" }?.stops ?? []
|
||||
#expect(stops.last?.title == "None (direct)", "Cab selector missing the None stop")
|
||||
#expect(stops.last?.value == AmpVoicePedal.cabinetBypassValue, "None stop has the wrong value")
|
||||
}
|
||||
|
||||
@Test func ampWithNoneCabIntoStandaloneCabinetWorks() throws {
|
||||
// Decoupled chain: amp (Cab = None) → standalone Cabinet pedal. The amp emits its limited,
|
||||
// cab-less signal; the separate Cabinet block does the speaker convolution downstream.
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let midBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(midBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let amp: CaliforniaAmpPedal = CaliforniaAmpPedal(inputBus: srcBus.index, outputBus: midBus.index)
|
||||
amp.sampleRate = sampleRate
|
||||
amp.cab = AmpVoicePedal.cabinetBypassValue
|
||||
let cabinet: CabinetPedal = CabinetPedal(inputBus: midBus.index, outputBus: dstBus.index)
|
||||
cabinet.sampleRate = sampleRate
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(amp, position: NodePosition.after(source))
|
||||
try engine.add(cabinet, position: NodePosition.after(amp))
|
||||
try engine.add(master, position: NodePosition.after(cabinet))
|
||||
try engine.start()
|
||||
let out: [Float] = readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
#expect(hasNonSilentOutput(out) && out.allSatisfy { $0.isFinite }, "decoupled amp+cabinet silent/non-finite")
|
||||
// Note: the amp guarantees its OWN output ≤ ±1 (see `cabNoneStillLimitsToCeiling`), but a
|
||||
// downstream standalone Cabinet convolves that signal and — like any post-amp pedal — may
|
||||
// overshoot ±1. The board's final output stage, not the amp, owns end-of-chain level. So this
|
||||
// asserts the decoupled chain works (non-silent, finite), not a ±1 ceiling it never promised.
|
||||
}
|
||||
|
||||
// MARK: - Chrome / config
|
||||
|
||||
@Test func exposesControls() throws {
|
||||
#expect(CaliforniaAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Bright"])
|
||||
#expect(BritishAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"])
|
||||
#expect(ChimeAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Cut"])
|
||||
for voice in voices {
|
||||
let pedal: AmpVoicePedal = voice.make()
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(voice.name) selectors")
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true,
|
||||
"\(voice.name) cab selector should rebuild on change")
|
||||
#expect(pedal.widthUnits == 2, "\(voice.name) amp head should use a double-width card")
|
||||
#expect(pedal.showsMixControl == false, "\(voice.name) should be fully wet")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func distinctToneStackModels() throws {
|
||||
#expect(CaliforniaAmpPedal().toneStackModel == .fender)
|
||||
#expect(BritishAmpPedal().toneStackModel == .marshall)
|
||||
#expect(ChimeAmpPedal().toneStackModel == .vox)
|
||||
}
|
||||
|
||||
@Test func selectionsRoundTripThroughState() throws {
|
||||
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
pedal.gain = 8.3
|
||||
pedal.cab = 2.0
|
||||
pedal.bright = 0.8
|
||||
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.gain == 8.3 && restored.cab == 2.0 && restored.bright == 0.8,
|
||||
"California controls did not round-trip")
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "California") is CaliforniaAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British") is BritishAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Chime") is ChimeAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -461,6 +461,33 @@ struct BoardEditAPITests {
|
||||
#expect(hasNonSilentOutput(samples), "stereo-split board should render audio")
|
||||
}
|
||||
|
||||
@Test func boardContainingFindsMainAndBranchPedals() throws {
|
||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive"])
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
// Main-chain pedal is found.
|
||||
guard let mainPedal: Pedal = board.pedals.first else {
|
||||
Issue.record("no main pedal"); return
|
||||
}
|
||||
#expect(sg.board(containing: mainPedal) === board)
|
||||
|
||||
// A pedal inside a stereo-split branch is also found (the fix: not just the main chain).
|
||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||
var branchPedal: Pedal?
|
||||
for segment: BoardSegment in live.orderedSegments {
|
||||
if case .stereoSplit(let section) = segment { branchPedal = section.left.pedals.first }
|
||||
}
|
||||
guard let branch: Pedal = branchPedal else {
|
||||
Issue.record("no branch pedal"); return
|
||||
}
|
||||
#expect(sg.board(containing: branch) === live, "branch pedal should resolve to its board")
|
||||
|
||||
// A pedal not in any board resolves to nil.
|
||||
#expect(sg.board(containing: OverdrivePedal()) == nil)
|
||||
}
|
||||
|
||||
@Test func removePedalFromBranchLane() throws {
|
||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive"])
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
// BoutiqueAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("Boutique high-gain amps")
|
||||
struct BoutiqueAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private func rmsNormalizedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||
func rms(_ x: ArraySlice<Float>) -> Double {
|
||||
let sumSq: Double = x.reduce(0.0) { $0 + Double($1) * Double($1) }
|
||||
return (sumSq / Double(x.count)).squareRoot()
|
||||
}
|
||||
let ra: Double = rms(aw)
|
||||
let rb: Double = rms(bw)
|
||||
guard ra > 0.0, rb > 0.0 else { return 0.0 }
|
||||
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0) / ra - Double(pair.1) / rb
|
||||
return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private func peak(_ s: [Float]) -> Double { s.reduce(0.0) { Swift.max($0, abs(Double($1))) } }
|
||||
|
||||
private let voices: [(name: String, make: () -> BoutiqueAmpPedal)] = [
|
||||
("Boutique Lead", { BoutiqueLeadAmpPedal() }),
|
||||
("Boutique OD", { BoutiqueODAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allBuildNonSilentFinite() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let s: [Float] = try render(v.make)
|
||||
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func channelSwitchChangesOutputAndRebuilds() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let clean: [Float] = try render(v.make) { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 9.5 }
|
||||
#expect(windowedSSD(clean, lead) > 0, "\(v.name) channel switch had no effect")
|
||||
let channel: PedalSwitch? = v.make().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true, "\(v.name) Channel should rebuild on change")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func presenceAndDepthChangeOutput() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let pLow: [Float] = try render(v.make) { $0.presence = 0.0 }
|
||||
let pHigh: [Float] = try render(v.make) { $0.presence = 1.0 }
|
||||
#expect(windowedSSD(pLow, pHigh) > 0, "\(v.name) Presence had no effect")
|
||||
let dLow: [Float] = try render(v.make) { $0.depth = 0.0 }
|
||||
let dHigh: [Float] = try render(v.make) { $0.depth = 1.0 }
|
||||
#expect(windowedSSD(dLow, dHigh) > 0, "\(v.name) Depth had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func masterDrivesPowerAmp() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let low: [Float] = try render(v.make) { $0.gain = 8.0; $0.master = 0.1 }
|
||||
let high: [Float] = try render(v.make) { $0.gain = 8.0; $0.master = 1.0 }
|
||||
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "\(v.name) Master changed level but not tone")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func driveKnobChangesLeadChannel() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let low: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 2.0 }
|
||||
let high: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 10.5 }
|
||||
#expect(windowedSSD(low, high) > 0, "\(v.name) Drive had no effect on the lead channel")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func stayWithinCeilingOnLeadChannel() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let hot: [Float] = try render(v.make) { (p: BoutiqueAmpPedal) in
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0
|
||||
p.presence = 1.0; p.depth = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 11.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "\(v.name) exceeds the ±1 ceiling on the lead channel")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func exposesControlSurfaces() throws {
|
||||
let lead: BoutiqueLeadAmpPedal = BoutiqueLeadAmpPedal()
|
||||
#expect(lead.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
|
||||
#expect(lead.effectSwitches.map { $0.label } == ["Channel"])
|
||||
#expect(lead.widthUnits == 2)
|
||||
#expect(lead.toneStackModel == .soldano)
|
||||
#expect(lead.powerAmpOversample == 4)
|
||||
|
||||
let od: BoutiqueODAmpPedal = BoutiqueODAmpPedal()
|
||||
#expect(od.effectSwitches.map { $0.label } == ["Channel", "Mid Boost"])
|
||||
#expect(od.toneStackModel == .fender)
|
||||
}
|
||||
|
||||
@Test func odMidBoostChangesOutput() throws {
|
||||
let flat: [Float] = try render({ BoutiqueODAmpPedal() }) { $0.midBoost = 0.0 }
|
||||
let boosted: [Float] = try render({ BoutiqueODAmpPedal() }) { $0.midBoost = 1.0 }
|
||||
#expect(windowedSSD(flat, boosted) > 0, "Mid Boost had no effect")
|
||||
}
|
||||
|
||||
@Test func roundTripsThroughState() throws {
|
||||
let pedal: BoutiqueODAmpPedal = BoutiqueODAmpPedal()
|
||||
pedal.presence = 0.6; pedal.depth = 0.7; pedal.master = 0.8; pedal.drive = 8.3
|
||||
pedal.channel = 1.0; pedal.midBoost = 1.0; pedal.cab = 2.0
|
||||
let restored: BoutiqueODAmpPedal = BoutiqueODAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.presence == 0.6 && restored.depth == 0.7 && restored.master == 0.8)
|
||||
#expect(restored.drive == 8.3 && restored.channel == 1.0 && restored.midBoost == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Boutique Lead") is BoutiqueLeadAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Boutique OD") is BoutiqueODAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// BritishComboAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("British non-master combos")
|
||||
struct BritishComboAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private let voices: [(name: String, make: () -> BritishComboAmpPedal)] = [
|
||||
("British Plexi", { BritishPlexiAmpPedal() }),
|
||||
("British JTM", { BritishJTMAmpPedal() }),
|
||||
("British Bluesbreaker", { BritishBluesbreakerAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allBuildNonSilentFinite() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let s: [Float] = try render(v.make)
|
||||
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func presenceChangesOutput() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let low: [Float] = try render(v.make) { $0.presence = 0.0 }
|
||||
let high: [Float] = try render(v.make) { $0.presence = 1.0 }
|
||||
#expect(windowedSSD(low, high) > 0, "\(v.name) Presence had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func brightSwitchChangesOutput() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let flat: [Float] = try render(v.make) { $0.bright = 0.0 }
|
||||
let bright: [Float] = try render(v.make) { $0.bright = 1.0 }
|
||||
#expect(windowedSSD(flat, bright) > 0, "\(v.name) Bright had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func areMarshallVoicedNonMaster() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let pedal: BritishComboAmpPedal = v.make()
|
||||
#expect(pedal.toneStackModel == .marshall, "\(v.name) tone stack")
|
||||
// Non-master: no "Master" knob (that is the separate BritishAmpPedal voice).
|
||||
#expect(!pedal.effectKnobs.map { $0.label }.contains("Master"), "\(v.name) should be non-master")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func plexiAndJTMExposePresenceAndBright() throws {
|
||||
for pedal: BritishComboAmpPedal in [BritishPlexiAmpPedal(), BritishJTMAmpPedal()] {
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||
}
|
||||
}
|
||||
|
||||
@Test func voicesDifferFromEachOther() throws {
|
||||
let cfg: (BritishComboAmpPedal) -> Void = { $0.gain = 6.0 }
|
||||
let plexi: [Float] = try render({ BritishPlexiAmpPedal() }, configure: cfg)
|
||||
let jtm: [Float] = try render({ BritishJTMAmpPedal() }, configure: cfg)
|
||||
#expect(windowedSSD(plexi, jtm) > 0, "Plexi and JTM should voice differently")
|
||||
}
|
||||
|
||||
// MARK: - Bluesbreaker tremolo
|
||||
|
||||
@Test func bluesbreakerExposesTremolo() throws {
|
||||
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Speed", "Intensity"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Tremolo"])
|
||||
#expect(pedal.widthUnits == 2)
|
||||
}
|
||||
|
||||
@Test func bluesbreakerTremoloIntensityChangesOutput() throws {
|
||||
let off: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||
let on: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||
#expect(windowedSSD(off, on) > 0, "Bluesbreaker tremolo had no effect")
|
||||
}
|
||||
|
||||
@Test func bluesbreakerTremoloFootswitchBypassesToIdentity() throws {
|
||||
let bypassed: [Float] = try render({ BritishBluesbreakerAmpPedal() }) {
|
||||
$0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0
|
||||
}
|
||||
let noTremolo: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||
}
|
||||
|
||||
@Test func stayWithinCeilingAtMaxGain() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let hot: [Float] = try render(v.make) { (pedal: BritishComboAmpPedal) in
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.presence = 1.0
|
||||
pedal.bright = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(v.name) peak \(peak) exceeds the ±1 ceiling")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func roundTripsThroughState() throws {
|
||||
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
pedal.presence = 0.7
|
||||
pedal.bright = 1.0
|
||||
pedal.speed = 9.0
|
||||
pedal.intensity = 0.5
|
||||
pedal.tremoloEnabled = 0.0
|
||||
pedal.cab = 2.0
|
||||
let restored: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.presence == 0.7 && restored.bright == 1.0 && restored.speed == 9.0)
|
||||
#expect(restored.intensity == 0.5 && restored.tremoloEnabled == 0.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "British Plexi") is BritishPlexiAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British JTM") is BritishJTMAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British Bluesbreaker") is BritishBluesbreakerAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
// BritishMasterAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("British master-volume amps")
|
||||
struct BritishMasterAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
/// RMS-normalized SSD — isolates a waveshape (saturation) change from a pure level change.
|
||||
private func rmsNormalizedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||
func rms(_ x: ArraySlice<Float>) -> Double {
|
||||
let sumSq: Double = x.reduce(0.0) { $0 + Double($1) * Double($1) }
|
||||
return (sumSq / Double(x.count)).squareRoot()
|
||||
}
|
||||
let ra: Double = rms(aw)
|
||||
let rb: Double = rms(bw)
|
||||
guard ra > 0.0, rb > 0.0 else { return 0.0 }
|
||||
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0) / ra - Double(pair.1) / rb
|
||||
return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private func peak(_ s: [Float]) -> Double { s.reduce(0.0) { Swift.max($0, abs(Double($1))) } }
|
||||
|
||||
// MARK: - British Master
|
||||
|
||||
@Test func masterBuildsAndDrivesPowerAmp() throws {
|
||||
let samples: [Float] = try render({ BritishMasterAmpPedal() })
|
||||
#expect(hasNonSilentOutput(samples) && samples.allSatisfy { $0.isFinite })
|
||||
// Master drives the power-amp stage → a waveshape change, not just level.
|
||||
let low: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 10.0; $0.master = 0.1 }
|
||||
let high: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 10.0; $0.master = 1.0 }
|
||||
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "Master changed level but not tone")
|
||||
}
|
||||
|
||||
@Test func masterHasCascadedGainVsPlexi() throws {
|
||||
// The cascaded two-stage preamp makes British Master hotter/different from the single-stage
|
||||
// non-master Plexi at the same Gain.
|
||||
let masterAmp: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 6.0 }
|
||||
let plexi: [Float] = try render({ BritishPlexiAmpPedal() }) { $0.gain = 6.0 }
|
||||
#expect(windowedSSD(masterAmp, plexi) > 0, "cascaded lead should differ from the Plexi")
|
||||
}
|
||||
|
||||
@Test func masterExposesControlSurface() throws {
|
||||
let pedal: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .marshall)
|
||||
#expect(pedal.powerAmpOversample == 4)
|
||||
}
|
||||
|
||||
@Test func masterStaysWithinCeiling() throws {
|
||||
let hot: [Float] = try render({ BritishMasterAmpPedal() }) { (p: BritishMasterAmpPedal) in
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0; p.master = 1.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "British Master exceeds the ±1 ceiling")
|
||||
}
|
||||
|
||||
@Test func masterRoundTrips() throws {
|
||||
let pedal: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
pedal.master = 0.8; pedal.presence = 0.7; pedal.bright = 1.0; pedal.cab = 2.0
|
||||
let restored: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.master == 0.8 && restored.presence == 0.7 && restored.bright == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
// MARK: - British Dual
|
||||
|
||||
@Test func dualChannelSwitchChangesOutput() throws {
|
||||
let clean: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 9.0 }
|
||||
#expect(hasNonSilentOutput(clean) && hasNonSilentOutput(lead))
|
||||
#expect(windowedSSD(clean, lead) > 0, "channel switch had no effect")
|
||||
let channel: PedalSwitch? = BritishDualAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true, "Channel switch should rebuild on change")
|
||||
}
|
||||
|
||||
@Test func dualDriveAndReverbAndMasterWork() throws {
|
||||
let low: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 2.0 }
|
||||
let high: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 10.5 }
|
||||
#expect(windowedSSD(low, high) > 0, "Drive had no effect on the lead channel")
|
||||
let dry: [Float] = try render({ BritishDualAmpPedal() }) { $0.reverb = 0.0 }
|
||||
let wet: [Float] = try render({ BritishDualAmpPedal() }) { $0.reverb = 0.9 }
|
||||
#expect(windowedSSD(dry, wet) > 0, "reverb had no effect")
|
||||
let mLow: [Float] = try render({ BritishDualAmpPedal() }) { $0.gain = 10.0; $0.master = 0.1 }
|
||||
let mHigh: [Float] = try render({ BritishDualAmpPedal() }) { $0.gain = 10.0; $0.master = 1.0 }
|
||||
#expect(rmsNormalizedSSD(mLow, mHigh) > 1.0e-3, "Master changed level but not tone")
|
||||
}
|
||||
|
||||
@Test func dualExposesControlSurface() throws {
|
||||
let pedal: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Master", "Drive", "Reverb"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Channel"])
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .marshall)
|
||||
#expect(pedal.powerAmpOversample == 4)
|
||||
}
|
||||
|
||||
@Test func dualStaysWithinCeilingOnLeadChannel() throws {
|
||||
let hot: [Float] = try render({ BritishDualAmpPedal() }) { (p: BritishDualAmpPedal) in
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0
|
||||
p.master = 1.0; p.channel = 1.0; p.drive = 11.0; p.reverb = 1.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "British Dual exceeds the ±1 ceiling on the lead channel")
|
||||
}
|
||||
|
||||
@Test func dualRoundTrips() throws {
|
||||
let pedal: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
pedal.master = 0.7; pedal.drive = 8.3; pedal.reverb = 0.5; pedal.channel = 1.0
|
||||
pedal.presence = 0.6; pedal.bright = 1.0; pedal.cab = 2.0
|
||||
let restored: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.master == 0.7 && restored.drive == 8.3 && restored.reverb == 0.5)
|
||||
#expect(restored.channel == 1.0 && restored.presence == 0.6 && restored.bright == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "British Master") is BritishMasterAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British Dual") is BritishDualAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// CabinetIRFactoryTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("CabinetIRFactory")
|
||||
struct CabinetIRFactoryTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
/// Goertzel magnitude of the IR's frequency response at `hz`.
|
||||
private func responseMagnitude(_ ir: LyrebirdBuffer, hz: Double) -> Double {
|
||||
let omega: Double = 2.0 * Double.pi * hz / sampleRate
|
||||
let cosine: Double = cos(omega)
|
||||
let sine: Double = sin(omega)
|
||||
let coeff: Double = 2.0 * cosine
|
||||
var s1: Double = 0.0
|
||||
var s2: Double = 0.0
|
||||
for i: Int in 0..<ir.count {
|
||||
let s0: Double = ir[i, 0] + coeff * s1 - s2
|
||||
s2 = s1
|
||||
s1 = s0
|
||||
}
|
||||
let real: Double = s1 - s2 * cosine
|
||||
let imag: Double = s2 * sine
|
||||
return (real * real + imag * imag).squareRoot()
|
||||
}
|
||||
|
||||
@Test func producesFiniteNormalizedMonoIR() {
|
||||
for voice: CabinetVoice in CabinetVoice.allCases {
|
||||
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate)
|
||||
#expect(ir.channelCount == 1)
|
||||
#expect(ir.count == CabinetIRFactory.defaultFrames)
|
||||
var peak: Double = 0.0
|
||||
for i: Int in 0..<ir.count {
|
||||
let v: Double = ir[i, 0]
|
||||
#expect(v.isFinite, "\(voice) IR had non-finite sample")
|
||||
peak = Swift.max(peak, abs(v))
|
||||
}
|
||||
#expect(peak > 0.9 && peak <= 1.0001, "\(voice) IR not peak-normalized: \(peak)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func rollsOffLowAndHighFrequencies() {
|
||||
// A speaker cab attenuates sub-bass and high treble relative to the midrange.
|
||||
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||
let low: Double = responseMagnitude(ir, hz: 40.0) // below the ~80 Hz high-pass
|
||||
let mid: Double = responseMagnitude(ir, hz: 800.0) // passband
|
||||
let high: Double = responseMagnitude(ir, hz: 12000.0) // above the ~5.5 kHz low-pass
|
||||
#expect(mid > low * 2.0, "low end not attenuated (mid=\(mid) low=\(low))")
|
||||
#expect(mid > high * 2.0, "high end not attenuated (mid=\(mid) high=\(high))")
|
||||
}
|
||||
|
||||
@Test func voicesDifferInResponse() {
|
||||
let american: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||
let dark: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .vintageDark, sampleRate: sampleRate)
|
||||
// The darker voice rolls off earlier, so it has less 5 kHz energy than the American voice.
|
||||
let americanHigh: Double = responseMagnitude(american, hz: 5000.0)
|
||||
let darkHigh: Double = responseMagnitude(dark, hz: 5000.0)
|
||||
#expect(americanHigh > darkHigh, "vintageDark should be darker at 5 kHz")
|
||||
}
|
||||
|
||||
@Test func fullRangeExtendsHigherThanCombo() {
|
||||
// Full-Range (FRFR) has a ~9 kHz low-pass vs the American combo's ~5.5 kHz, so it keeps
|
||||
// markedly more energy at 8 kHz.
|
||||
let frfr: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, sampleRate: sampleRate)
|
||||
let combo: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||
let frfrHigh: Double = responseMagnitude(frfr, hz: 8000.0)
|
||||
let comboHigh: Double = responseMagnitude(combo, hz: 8000.0)
|
||||
#expect(frfrHigh > comboHigh * 2.0, "FRFR should keep more 8 kHz than the combo")
|
||||
}
|
||||
|
||||
@Test func notchCreatesMidDip() {
|
||||
// Modern 4×12 has a deep interference notch at 1.7 kHz. Its response there should dip below
|
||||
// the surrounding midrange (points chosen clear of the body / presence peaks).
|
||||
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .modernStack, sampleRate: sampleRate)
|
||||
let atNotch: Double = responseMagnitude(ir, hz: 1700.0)
|
||||
let below: Double = responseMagnitude(ir, hz: 1100.0)
|
||||
let above: Double = responseMagnitude(ir, hz: 2400.0)
|
||||
#expect(atNotch < below, "notch did not dip below the lower midrange")
|
||||
#expect(atNotch < above, "notch did not dip below the upper midrange")
|
||||
}
|
||||
|
||||
@Test func loFiIsDarkerThanFullRange() {
|
||||
// Lo-Fi 1×8 rolls off at ~3 kHz vs Full-Range's ~9 kHz, so it is markedly darker at 4 kHz.
|
||||
let loFi: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .loFiBox, sampleRate: sampleRate)
|
||||
let frfr: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, sampleRate: sampleRate)
|
||||
#expect(responseMagnitude(frfr, hz: 4000.0) > responseMagnitude(loFi, hz: 4000.0),
|
||||
"Lo-Fi should be darker than Full-Range at 4 kHz")
|
||||
}
|
||||
|
||||
@Test func breakupPeakLiftsUpperMid() {
|
||||
// Bright 1×12 (breakup +3 dB @ 5.2 kHz, LP 6.5 kHz) keeps more ~5.1 kHz energy than
|
||||
// Boutique 2×12 (breakup +1.5 dB @ 5.0 kHz, LP 6.0 kHz) — both the stronger breakup boost
|
||||
// and the higher low-pass push the same direction.
|
||||
let bright: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .brightCombo, sampleRate: sampleRate)
|
||||
let boutique: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .boutiqueOpen, sampleRate: sampleRate)
|
||||
#expect(responseMagnitude(bright, hz: 5100.0) > responseMagnitude(boutique, hz: 5100.0),
|
||||
"brightCombo should have more upper-mid bite than boutiqueOpen at 5.1 kHz")
|
||||
}
|
||||
|
||||
@Test func voiceNamesAreUnique() {
|
||||
let names: [String] = CabinetVoice.allCases.map { $0.displayName }
|
||||
#expect(Set(names).count == names.count, "duplicate cabinet display names")
|
||||
}
|
||||
|
||||
// MARK: - Mic voicing
|
||||
|
||||
/// Ratio of the IR's magnitude at `hz` to a mid-band reference (800 Hz). Peak-normalization
|
||||
/// scales the whole IR, so it cancels in this ratio — letting a mic's *relative* boost/cut at a
|
||||
/// frequency be compared across IRs regardless of their independent normalization.
|
||||
private func tiltRatio(_ ir: LyrebirdBuffer, hz: Double) -> Double {
|
||||
let reference: Double = responseMagnitude(ir, hz: 800.0)
|
||||
guard reference > 0.0 else { return 0.0 }
|
||||
return responseMagnitude(ir, hz: hz) / reference
|
||||
}
|
||||
|
||||
@Test func noMicMatchesRawCabIR() {
|
||||
// MicVoice.off must append no stages, so the IR is byte-identical to the mic-less default —
|
||||
// the backward-compatible path for cabs saved before mic voicing existed.
|
||||
for voice: CabinetVoice in CabinetVoice.allCases {
|
||||
let raw: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate)
|
||||
let offMic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, mic: .off, sampleRate: sampleRate)
|
||||
#expect(raw.count == offMic.count)
|
||||
var identical: Bool = true
|
||||
for i: Int in 0..<raw.count where raw[i, 0] != offMic[i, 0] { identical = false; break }
|
||||
#expect(identical, "\(voice) No-Mic IR differs from the raw cab IR")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func dynamicMicLiftsPresence() {
|
||||
// The dynamic mic adds a presence bump at ~5.5 kHz → a higher 5.5 kHz-to-mid tilt than no mic.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .off, sampleRate: sampleRate)
|
||||
let dynamic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .dynamic, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(dynamic, hz: 5500.0) > tiltRatio(off, hz: 5500.0),
|
||||
"dynamic mic did not lift the presence region")
|
||||
}
|
||||
|
||||
@Test func ribbonMicDarkensTop() {
|
||||
// The ribbon mic rolls the top off (−7 dB shelf @ 6.5 kHz) → a lower 8 kHz-to-mid tilt.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
|
||||
let ribbon: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .ribbon, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(ribbon, hz: 8000.0) < tiltRatio(off, hz: 8000.0),
|
||||
"ribbon mic did not darken the top end")
|
||||
}
|
||||
|
||||
@Test func condenserMicAddsAir() {
|
||||
// The condenser mic lifts the extreme top (+3 dB shelf @ 11 kHz) → a higher 10 kHz-to-mid tilt.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
|
||||
let condenser: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .condenser, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(condenser, hz: 10000.0) > tiltRatio(off, hz: 10000.0),
|
||||
"condenser mic did not add top-end air")
|
||||
}
|
||||
|
||||
@Test func micNamesAreUnique() {
|
||||
let names: [String] = MicVoice.allCases.map { $0.displayName }
|
||||
#expect(Set(names).count == names.count, "duplicate mic display names")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
// CabinetPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("CabinetPedal")
|
||||
struct CabinetPedalTests {
|
||||
|
||||
private func render(configure: (CabinetPedal) -> Void = { _ in }) throws -> [Float] {
|
||||
let sampleRate: Double = 48000.0
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: CabinetPedal = CabinetPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let samples: [Float] = try render()
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "CabinetPedal produced silence")
|
||||
}
|
||||
|
||||
@Test func cabinetSelectionChangesOutput() throws {
|
||||
// Index 0 = American 1×12, index 2 = Vintage Dark — different voicings, different output.
|
||||
let american: [Float] = try render { $0.cabinet = 0.0 }
|
||||
let dark: [Float] = try render { $0.cabinet = 2.0 }
|
||||
#expect(hasNonSilentOutput(american) && hasNonSilentOutput(dark))
|
||||
|
||||
let skip: Int = 4096
|
||||
let window: Int = 4096
|
||||
guard american.count >= skip + window, dark.count >= skip + window else { return }
|
||||
let ssd: Double = zip(american[skip..<(skip + window)], dark[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "cabinet selection had no effect on output")
|
||||
}
|
||||
|
||||
@Test func exposesCabinetAndMicSelectors() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
let labels: [String] = pedal.effectSelectors.map { $0.label }
|
||||
#expect(labels == ["Cab", "Mic", "Mic B"])
|
||||
// One Cab stop per voice, and one stop per mic voice for both Mic and Mic B, in allCases order.
|
||||
let cabStops: [String] = pedal.effectSelectors.first { $0.label == "Cab" }?.stops.map { $0.title } ?? []
|
||||
#expect(cabStops == CabinetVoice.allCases.map { $0.displayName })
|
||||
let micStops: [String] = pedal.effectSelectors.first { $0.label == "Mic" }?.stops.map { $0.title } ?? []
|
||||
#expect(micStops == MicVoice.allCases.map { $0.displayName })
|
||||
let micBStops: [String] = pedal.effectSelectors.first { $0.label == "Mic B" }?.stops.map { $0.title } ?? []
|
||||
#expect(micBStops == MicVoice.allCases.map { $0.displayName })
|
||||
}
|
||||
|
||||
@Test func micSelectionChangesOutput() throws {
|
||||
// Mic 0 = No Mic, mic 1 = Dynamic — different baked IRs, different output.
|
||||
let noMic: [Float] = try render { $0.mic = 0.0 }
|
||||
let dynamic: [Float] = try render { $0.mic = 1.0 }
|
||||
#expect(hasNonSilentOutput(noMic) && hasNonSilentOutput(dynamic))
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
guard noMic.count >= skip + window, dynamic.count >= skip + window else { return }
|
||||
let ssd: Double = zip(noMic[skip..<(skip + window)], dynamic[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic selection had no effect on output")
|
||||
}
|
||||
|
||||
@Test func micSelectionRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.cabinet = 2.0
|
||||
pedal.mic = 3.0
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.cabinet == 2.0 && restored.mic == 3.0, "cab/mic selection did not round-trip")
|
||||
}
|
||||
|
||||
@Test func positionChangesOutput() throws {
|
||||
// Position sweeps a live high-shelf cut (on-axis → cone edge), so it must change the output.
|
||||
let onAxis: [Float] = try render { $0.position = 0.0 }
|
||||
let edge: [Float] = try render { $0.position = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(onAxis.count >= skip + window && edge.count >= skip + window, "render too short")
|
||||
guard onAxis.count >= skip + window, edge.count >= skip + window else { return }
|
||||
let ssd: Double = zip(onAxis[skip..<(skip + window)], edge[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic Position had no effect on output")
|
||||
}
|
||||
|
||||
@Test func proximityChangesOutput() throws {
|
||||
// Proximity sweeps a live low-shelf boost (distant → close), so it must change the output.
|
||||
let distant: [Float] = try render { $0.proximity = 0.0 }
|
||||
let close: [Float] = try render { $0.proximity = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(distant.count >= skip + window && close.count >= skip + window, "render too short")
|
||||
guard distant.count >= skip + window, close.count >= skip + window else { return }
|
||||
let ssd: Double = zip(distant[skip..<(skip + window)], close[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic Proximity had no effect on output")
|
||||
}
|
||||
|
||||
@Test func explicitDefaultPlacementMatchesImplicit() throws {
|
||||
// A default-consistency guard: the shipped defaults are position = 0 / proximity = 0, so
|
||||
// setting them explicitly must reproduce the default render exactly. (That those defaults are
|
||||
// a *no-op* on the tone follows from the RBJ shelves collapsing to unity at 0 dB — a Lyrebird
|
||||
// property; this test pins that the defaults are those values and the render is deterministic.)
|
||||
let byDefault: [Float] = try render()
|
||||
let explicit: [Float] = try render { $0.position = 0.0; $0.proximity = 0.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(byDefault.count >= skip + window && explicit.count >= skip + window, "render too short")
|
||||
guard byDefault.count >= skip + window, explicit.count >= skip + window else { return }
|
||||
let ssd: Double = zip(byDefault[skip..<(skip + window)], explicit[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd == 0, "explicit default placement did not match the default render")
|
||||
}
|
||||
|
||||
@Test func advancedKnobsExposePlacementAndDualMic() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Position", "Proximity", "Mic Blend", "Mic Offset"])
|
||||
}
|
||||
|
||||
// MARK: - Dual mic
|
||||
|
||||
@Test func secondMicChangesOutput() throws {
|
||||
// Engaging Mic B (a second parallel convolver) must change the output vs the single mic.
|
||||
let single: [Float] = try render { $0.micB = 0.0 }
|
||||
let dual: [Float] = try render { $0.micB = 2.0 } // Ribbon as the second mic
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(single.count >= skip + window && dual.count >= skip + window, "render too short")
|
||||
guard single.count >= skip + window, dual.count >= skip + window else { return }
|
||||
let ssd: Double = zip(single[skip..<(skip + window)], dual[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "engaging Mic B had no effect")
|
||||
}
|
||||
|
||||
@Test func micBOffMakesBlendAndOffsetInert() throws {
|
||||
// With Mic B = No Mic, the second convolver is not built, so Mic Blend / Mic Offset must have
|
||||
// no effect — proving the single-mic default path is untouched by the dual-mic controls.
|
||||
let a: [Float] = try render { $0.micB = 0.0; $0.micBlend = 0.0; $0.micOffset = 0.0 }
|
||||
let b: [Float] = try render { $0.micB = 0.0; $0.micBlend = 1.0; $0.micOffset = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(a.count >= skip + window && b.count >= skip + window, "render too short")
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return }
|
||||
let ssd: Double = zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd == 0, "Mic Blend/Offset changed output while Mic B was Off")
|
||||
}
|
||||
|
||||
@Test func micBlendAndOffsetChangeOutputWhenEngaged() throws {
|
||||
// With Mic B engaged, both the blend balance and the comb offset must change the output.
|
||||
let blendA: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.0 }
|
||||
let blendB: [Float] = try render { $0.micB = 2.0; $0.micBlend = 1.0 }
|
||||
let offset0: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.5; $0.micOffset = 0.0 }
|
||||
let offset1: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.5; $0.micOffset = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
func ssd(_ x: [Float], _ y: [Float]) -> Double {
|
||||
guard x.count >= skip + window, y.count >= skip + window else { return 0.0 }
|
||||
return zip(x[skip..<(skip + window)], y[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
#expect(ssd(blendA, blendB) > 0, "Mic Blend had no effect when engaged")
|
||||
#expect(ssd(offset0, offset1) > 0, "Mic Offset (comb) had no effect when engaged")
|
||||
}
|
||||
|
||||
@Test func dualMicRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.micB = 3.0
|
||||
pedal.micBlend = 0.3
|
||||
pedal.micOffset = 0.6
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.micB == 3.0 && restored.micBlend == 0.3 && restored.micOffset == 0.6,
|
||||
"dual-mic controls did not round-trip")
|
||||
}
|
||||
|
||||
@Test func dualMicStaysWithinCeiling() throws {
|
||||
// Two convolvers summed can exceed ±1 pre-limiter; the look-ahead limiter must still bound it.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let out: [Float] = try render { $0.micB = 1.0; $0.micBlend = 0.5; $0.micOffset = 0.5 }
|
||||
#expect(out.allSatisfy { $0.isFinite })
|
||||
let peak: Double = out.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "dual-mic peak \(peak) exceeds ±1")
|
||||
}
|
||||
|
||||
@Test func placementRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.position = 0.7
|
||||
pedal.proximity = 0.4
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.position == 0.7 && restored.proximity == 0.4, "placement did not round-trip")
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinCeiling() throws {
|
||||
// The tanh soft-limit + Clip(±1) bound the output so a decoupled amp → cabinet chain can't
|
||||
// clip the DAC. No render may exceed ±1.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for cab: Double in [0.0, 2.0, 6.0] {
|
||||
for micValue: Double in [0.0, 1.0, 2.0, 3.0] {
|
||||
let out: [Float] = try render { $0.cabinet = cab; $0.mic = micValue }
|
||||
#expect(out.allSatisfy { $0.isFinite })
|
||||
let peak: Double = out.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "cab=\(cab) mic=\(micValue) peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
// Placement extremes (max proximity bass lift) must still be caught by the limiter.
|
||||
let placed: [Float] = try render { $0.position = 1.0; $0.proximity = 1.0 }
|
||||
#expect(placed.allSatisfy { $0.isFinite })
|
||||
let placedPeak: Double = placed.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(placedPeak <= 1.0 + ceilingEpsilon, "placement extremes peak \(placedPeak) exceeds ±1")
|
||||
}
|
||||
|
||||
@Test func cabinetSelectorRebuildsOnChange() throws {
|
||||
// Only the selected voice's convolver is built, so changing it must rebuild the board.
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
}
|
||||
|
||||
@Test func voiceAtSelectorValueClampsAndRounds() throws {
|
||||
let all: [CabinetVoice] = CabinetVoice.allCases
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 0.0) == all[0])
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 2.0) == all[2])
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 1.4) == all[1], "should round to nearest stop")
|
||||
#expect(CabinetVoice.voice(atSelectorValue: -5.0) == all[0], "clamp below 0")
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 999.0) == all[all.count - 1], "clamp above max")
|
||||
}
|
||||
|
||||
@Test func cabinetSelectionRoundTripsThroughState() throws {
|
||||
// The selector value must survive capture/apply (preset round-trip).
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.cabinet = 2.0
|
||||
let state: PedalState = pedal.captureState()
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(state)
|
||||
#expect(restored.cabinet == 2.0, "cabinet selection did not round-trip through PedalState")
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Cabinet")
|
||||
#expect(pedal is CabinetPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// CaliHiGainAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("CaliHiGainAmpPedal")
|
||||
struct CaliHiGainAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render(configure: (CaliHiGainAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: CaliHiGainAmpPedal = CaliHiGainAmpPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsNonSilentFiniteOutput() throws {
|
||||
let s: [Float] = try render()
|
||||
#expect(hasNonSilentOutput(s) && s.allSatisfy { $0.isFinite })
|
||||
}
|
||||
|
||||
@Test func graphicEQBandsChangeOutput() throws {
|
||||
// Each band moves the tone: sweep the mid-scoop band and an outer band.
|
||||
let midCut: [Float] = try render { $0.eq750 = -12.0 }
|
||||
let midBoost: [Float] = try render { $0.eq750 = 12.0 }
|
||||
#expect(windowedSSD(midCut, midBoost) > 0, "750 Hz band had no effect")
|
||||
let trebleFlat: [Float] = try render { $0.eq6600 = 0.0 }
|
||||
let trebleBoost: [Float] = try render { $0.eq6600 = 12.0 }
|
||||
#expect(windowedSSD(trebleFlat, trebleBoost) > 0, "6.6 kHz band had no effect")
|
||||
}
|
||||
|
||||
@Test func inheritedChannelAndMasterWork() throws {
|
||||
let clean: [Float] = try render { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render { $0.channel = 1.0 }
|
||||
#expect(windowedSSD(clean, lead) > 0, "channel switch had no effect")
|
||||
let channel: PedalSwitch? = CaliHiGainAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true)
|
||||
}
|
||||
|
||||
@Test func staysWithinCeilingWithEQAndGainMaxed() throws {
|
||||
let hot: [Float] = try render { (p: CaliHiGainAmpPedal) in
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 11.0
|
||||
p.eq80 = 12.0; p.eq240 = 12.0; p.eq750 = 12.0; p.eq2200 = 12.0; p.eq6600 = 12.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + 1.0e-4, "Cali Hi-Gain exceeds the ±1 ceiling with EQ + gain maxed: \(peak)")
|
||||
}
|
||||
|
||||
@Test func exposesControlSurface() throws {
|
||||
let pedal: CaliHiGainAmpPedal = CaliHiGainAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
|
||||
#expect(pedal.effectSliders.map { $0.label } == ["80", "240", "750", "2.2k", "6.6k"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Channel"])
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .mesa)
|
||||
}
|
||||
|
||||
@Test func controlsRoundTripThroughState() throws {
|
||||
let pedal: CaliHiGainAmpPedal = CaliHiGainAmpPedal()
|
||||
pedal.eq80 = 4.0; pedal.eq750 = -8.0; pedal.eq6600 = 6.0
|
||||
pedal.channel = 1.0; pedal.master = 0.7; pedal.cab = 2.0
|
||||
let restored: CaliHiGainAmpPedal = CaliHiGainAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.eq80 == 4.0 && restored.eq750 == -8.0 && restored.eq6600 == 6.0)
|
||||
#expect(restored.channel == 1.0 && restored.master == 0.7 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Cali Hi-Gain") is CaliHiGainAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// ChainRouterPersistenceTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("ChainRouter persistence")
|
||||
struct ChainRouterPersistenceTests {
|
||||
|
||||
@Test func routerRigRoundTripsThroughJSONAndRenders() throws {
|
||||
// Build a routed session: two-pedal board A, one-pedal board B, selecting board B.
|
||||
let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.1, numAudioBuses: 128)
|
||||
defer { try? FileManager.default.removeItem(at: urlA) }
|
||||
let sessionA: ShoeGaze = ShoeGaze(engine: engineA)
|
||||
let router: ChainRouter = try sessionA.makeChainRouter()
|
||||
try router.addToA(FuzzPedal())
|
||||
try router.addToA(OverdrivePedal())
|
||||
try router.addToB(ReverbPedal())
|
||||
router.mode = .b
|
||||
try router.finalize()
|
||||
|
||||
let state: ShoeGazeState = sessionA.captureState()
|
||||
#expect(state.routers?.count == 1, "router was not captured")
|
||||
#expect(state.boards.isEmpty, "router rig should have no plain boards")
|
||||
|
||||
// JSON round-trip.
|
||||
let data: Data = try JSONEncoder().encode(state)
|
||||
let decoded: ShoeGazeState = try JSONDecoder().decode(ShoeGazeState.self, from: data)
|
||||
#expect(decoded == state, "router state did not survive a JSON round-trip")
|
||||
|
||||
// Load into a fresh session and verify the router was rebuilt structurally.
|
||||
let (engineB, urlB): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.2, numAudioBuses: 128)
|
||||
defer { try? FileManager.default.removeItem(at: urlB) }
|
||||
let sessionB: ShoeGaze = ShoeGaze(engine: engineB)
|
||||
try sessionB.loadRig(from: decoded)
|
||||
|
||||
#expect(sessionB.routers.count == 1, "router was not rebuilt on load")
|
||||
guard let rebuilt: ChainRouter = sessionB.routers.first else {
|
||||
Issue.record("no rebuilt router")
|
||||
return
|
||||
}
|
||||
#expect(rebuilt.boardA.pedals.count == 2, "board A pedal count not restored")
|
||||
#expect(rebuilt.boardB.pedals.count == 1, "board B pedal count not restored")
|
||||
#expect(rebuilt.boardA.pedals.map { $0.displayName } == ["Fuzz", "Overdrive"])
|
||||
#expect(rebuilt.boardB.pedals.map { $0.displayName } == ["Reverb"])
|
||||
// mode == .b → branch A muted, branch B active.
|
||||
#expect(rebuilt.splitter.branchAEnabled == 0.0, "branch A level not restored")
|
||||
#expect(rebuilt.splitter.branchBEnabled == 1.0, "branch B level not restored")
|
||||
|
||||
// The rebuilt router should render audio (board B is the active path).
|
||||
try engineB.start()
|
||||
let samples: [Float] = readStereoCAF(url: urlB)
|
||||
#expect(hasNonSilentOutput(samples), "rebuilt router produced silence")
|
||||
}
|
||||
|
||||
@Test func applyStateRecallsRouterParamsLive() throws {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.1, numAudioBuses: 128)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
let session: ShoeGaze = ShoeGaze(engine: engine)
|
||||
let router: ChainRouter = try session.makeChainRouter()
|
||||
let fuzz: FuzzPedal = FuzzPedal()
|
||||
fuzz.fuzz = 20.0
|
||||
try router.addToA(fuzz)
|
||||
try router.addToB(ReverbPedal())
|
||||
router.mode = .a
|
||||
try router.finalize()
|
||||
|
||||
let original: ShoeGazeState = session.captureState()
|
||||
|
||||
// Mutate live: change a router pedal param and flip the A/B selection.
|
||||
fuzz.fuzz = 55.0
|
||||
router.mode = .b
|
||||
|
||||
// Lightweight recall should restore the router pedal param and blend without a rebuild.
|
||||
session.applyState(original)
|
||||
|
||||
#expect(fuzz.fuzz == 20.0, "router pedal param was not recalled")
|
||||
#expect(router.splitter.branchAEnabled == 1.0, "branch A level not recalled")
|
||||
#expect(router.splitter.branchBEnabled == 0.0, "branch B level not recalled")
|
||||
}
|
||||
|
||||
@Test func routerlessRigStoresNoRoutersKey() throws {
|
||||
// A plain single-board session must not gain a `routers` payload (byte-compat with rigs
|
||||
// saved before router persistence existed).
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.1, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
let session: ShoeGaze = ShoeGaze(engine: engine)
|
||||
let board: PedalBoard = try session.addBoard()
|
||||
try board.add(FuzzPedal())
|
||||
try session.finalizeBoard(board)
|
||||
|
||||
let state: ShoeGazeState = session.captureState()
|
||||
#expect(state.routers == nil, "routerless rig should capture nil routers")
|
||||
|
||||
let json: String = String(data: try JSONEncoder().encode(state), encoding: .utf8) ?? ""
|
||||
#expect(!json.contains("\"routers\""), "routerless JSON should omit the routers key")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// CharacterAmpsTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("Character amps")
|
||||
struct CharacterAmpsTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private func peak(_ s: [Float]) -> Double { s.reduce(0.0) { Swift.max($0, abs(Double($1))) } }
|
||||
|
||||
private let all: [(name: String, make: () -> AmpVoicePedal)] = [
|
||||
("Command", { CommandAmpPedal() }),
|
||||
("Citrus", { CitrusAmpPedal() }),
|
||||
("Sixties Combo", { SixtiesComboAmpPedal() }),
|
||||
("Magna Vibrato", { MagnaVibratoAmpPedal() }),
|
||||
("Anaheim", { AnaheimAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allBuildNonSilentFiniteWithinCeiling() throws {
|
||||
for a: (name: String, make: () -> AmpVoicePedal) in all {
|
||||
let hot: [Float] = try render(a.make) { $0.gain = 11.0; $0.bass = 1.0; $0.treble = 1.0 }
|
||||
#expect(hasNonSilentOutput(hot), "\(a.name) silent")
|
||||
#expect(hot.allSatisfy { $0.isFinite }, "\(a.name) non-finite")
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "\(a.name) exceeds ±1 ceiling: \(peak(hot))")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func toneStackModels() throws {
|
||||
#expect(CommandAmpPedal().toneStackModel == .marshall)
|
||||
#expect(CitrusAmpPedal().toneStackModel == .marshall)
|
||||
#expect(SixtiesComboAmpPedal().toneStackModel == .fender)
|
||||
#expect(MagnaVibratoAmpPedal().toneStackModel == .fender)
|
||||
#expect(AnaheimAmpPedal().toneStackModel == .fender)
|
||||
}
|
||||
|
||||
// MARK: - Command (Hiwatt)
|
||||
|
||||
@Test func commandInheritsPresenceAndBright() throws {
|
||||
let pedal: CommandAmpPedal = CommandAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||
let flat: [Float] = try render({ CommandAmpPedal() }) { $0.presence = 0.0 }
|
||||
let lifted: [Float] = try render({ CommandAmpPedal() }) { $0.presence = 1.0 }
|
||||
#expect(windowedSSD(flat, lifted) > 0, "Command Presence had no effect")
|
||||
}
|
||||
|
||||
// MARK: - Citrus (Orange)
|
||||
|
||||
@Test func citrusShapeChangesOutput() throws {
|
||||
let dark: [Float] = try render({ CitrusAmpPedal() }) { $0.shape = 0.0 }
|
||||
let bright: [Float] = try render({ CitrusAmpPedal() }) { $0.shape = 1.0 }
|
||||
#expect(windowedSSD(dark, bright) > 0, "Citrus Shape had no effect")
|
||||
#expect(CitrusAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Shape"])
|
||||
}
|
||||
|
||||
// MARK: - Sixties Combo (Supro)
|
||||
|
||||
@Test func sixtiesTremoloWorksAndBypasses() throws {
|
||||
let off: [Float] = try render({ SixtiesComboAmpPedal() }) { $0.intensity = 0.0 }
|
||||
let on: [Float] = try render({ SixtiesComboAmpPedal() }) { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||
#expect(windowedSSD(off, on) > 0, "Sixties tremolo had no effect")
|
||||
// Footswitch off with intensity up == no tremolo (bit-exact, shared tremolo helper).
|
||||
let bypassed: [Float] = try render({ SixtiesComboAmpPedal() }) {
|
||||
$0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0
|
||||
}
|
||||
let noTrem: [Float] = try render({ SixtiesComboAmpPedal() }) { $0.intensity = 0.0 }
|
||||
#expect(windowedSSD(bypassed, noTrem) == 0.0, "Sixties tremolo footswitch off should be identity")
|
||||
}
|
||||
|
||||
// MARK: - Magna Vibrato (Magnatone)
|
||||
|
||||
@Test func magnaPitchVibratoWorks() throws {
|
||||
let off: [Float] = try render({ MagnaVibratoAmpPedal() }) { $0.vibratoEnabled = 0.0; $0.depth = 0.5 }
|
||||
let on: [Float] = try render({ MagnaVibratoAmpPedal() }) { $0.vibratoEnabled = 1.0; $0.depth = 0.5; $0.speed = 6.0 }
|
||||
#expect(windowedSSD(off, on) > 0, "Magna vibrato had no effect")
|
||||
// With vibrato off the sweep is zero → the delay is fixed, so Speed is irrelevant (identical).
|
||||
let offSlow: [Float] = try render({ MagnaVibratoAmpPedal() }) { $0.vibratoEnabled = 0.0; $0.speed = 1.0 }
|
||||
let offFast: [Float] = try render({ MagnaVibratoAmpPedal() }) { $0.vibratoEnabled = 0.0; $0.speed = 10.0 }
|
||||
#expect(windowedSSD(offSlow, offFast) == 0.0, "vibrato off should ignore Speed (fixed delay)")
|
||||
#expect(MagnaVibratoAmpPedal().effectSwitches.map { $0.label } == ["Vibrato"])
|
||||
}
|
||||
|
||||
// MARK: - Anaheim (Music Man)
|
||||
|
||||
@Test func anaheimSwitchesWork() throws {
|
||||
let a: AnaheimAmpPedal = AnaheimAmpPedal()
|
||||
#expect(a.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble"])
|
||||
#expect(a.effectSwitches.map { $0.label } == ["Bright", "Deep", "Limiter"])
|
||||
let flat: [Float] = try render({ AnaheimAmpPedal() }) { $0.bright = 0.0 }
|
||||
let bright: [Float] = try render({ AnaheimAmpPedal() }) { $0.bright = 1.0 }
|
||||
#expect(windowedSSD(flat, bright) > 0, "Anaheim Bright had no effect")
|
||||
let noDeep: [Float] = try render({ AnaheimAmpPedal() }) { $0.deep = 0.0 }
|
||||
let deep: [Float] = try render({ AnaheimAmpPedal() }) { $0.deep = 1.0 }
|
||||
#expect(windowedSSD(noDeep, deep) > 0, "Anaheim Deep had no effect")
|
||||
}
|
||||
|
||||
@Test func anaheimLimiterActsWhenDrivenHot() throws {
|
||||
// Driven hard, the built-in limiter (on) compresses vs bypassed (off) → different output.
|
||||
let limited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 10.5; $0.limiter = 1.0 }
|
||||
let unlimited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 10.5; $0.limiter = 0.0 }
|
||||
#expect(windowedSSD(limited, unlimited) > 0, "Anaheim limiter had no effect")
|
||||
}
|
||||
|
||||
@Test func roundTripThroughState() throws {
|
||||
let pedal: AnaheimAmpPedal = AnaheimAmpPedal()
|
||||
pedal.bright = 1.0; pedal.deep = 1.0; pedal.limiter = 0.0; pedal.cab = 2.0
|
||||
let restored: AnaheimAmpPedal = AnaheimAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.bright == 1.0 && restored.deep == 1.0 && restored.limiter == 0.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Command") is CommandAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Citrus") is CitrusAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Sixties Combo") is SixtiesComboAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Magna Vibrato") is MagnaVibratoAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Anaheim") is AnaheimAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
// ChimeTopBoostAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("ChimeTopBoostAmpPedal")
|
||||
struct ChimeTopBoostAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render(configure: (ChimeTopBoostAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal(
|
||||
inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsNonSilentFiniteOutput() throws {
|
||||
let samples: [Float] = try render()
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "Chime Top Boost produced silence")
|
||||
#expect(samples.allSatisfy { $0.isFinite }, "Chime Top Boost produced non-finite output")
|
||||
}
|
||||
|
||||
@Test func cutChangesOutput() throws {
|
||||
let open: [Float] = try render { $0.cut = 0.0 }
|
||||
let dark: [Float] = try render { $0.cut = 1.0 }
|
||||
#expect(windowedSSD(open, dark) > 0, "Cut had no effect")
|
||||
}
|
||||
|
||||
@Test func tremoloIntensityChangesOutput() throws {
|
||||
let off: [Float] = try render { $0.intensity = 0.0 }
|
||||
let on: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||
#expect(windowedSSD(off, on) > 0, "tremolo intensity had no effect")
|
||||
}
|
||||
|
||||
@Test func tremoloSpeedChangesOutput() throws {
|
||||
let slow: [Float] = try render { $0.intensity = 1.0; $0.speed = 1.0 }
|
||||
let fast: [Float] = try render { $0.intensity = 1.0; $0.speed = 10.0 }
|
||||
#expect(windowedSSD(slow, fast) > 0, "tremolo speed had no effect")
|
||||
}
|
||||
|
||||
@Test func brilliantSwitchChangesOutput() throws {
|
||||
let flat: [Float] = try render { $0.brilliant = 0.0 }
|
||||
let bright: [Float] = try render { $0.brilliant = 1.0 }
|
||||
#expect(windowedSSD(flat, bright) > 0, "brilliant switch had no effect")
|
||||
}
|
||||
|
||||
@Test func tremoloFootswitchBypassesToIdentity() throws {
|
||||
// Footswitch off with Intensity up must equal no tremolo (Intensity 0), and differ from on.
|
||||
// The differing `speed` is harmless: with depth gated to 0 the LFO is a constant 1.0.
|
||||
let bypassed: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0 }
|
||||
let noTremolo: [Float] = try render { $0.intensity = 0.0 }
|
||||
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||
let engaged: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 1.0 }
|
||||
#expect(windowedSSD(bypassed, engaged) > 0, "tremolo footswitch had no effect")
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render { (pedal: ChimeTopBoostAmpPedal) in
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.brilliant = 1.0
|
||||
pedal.intensity = 1.0
|
||||
pedal.speed = 6.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "peak \(peak) exceeds the ±1 ceiling")
|
||||
#expect(peak > 0.3, "unexpectedly quiet at max gain: \(peak)")
|
||||
}
|
||||
|
||||
@Test func exposesFullControlSurface() throws {
|
||||
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Cut", "Speed", "Intensity"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Brilliant", "Tremolo"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.showsMixControl == false)
|
||||
#expect(pedal.toneStackModel == .vox)
|
||||
}
|
||||
|
||||
@Test func controlsRoundTripThroughState() throws {
|
||||
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
pedal.gain = 7.0
|
||||
pedal.cut = 0.6
|
||||
pedal.speed = 9.0
|
||||
pedal.intensity = 0.5
|
||||
pedal.brilliant = 1.0
|
||||
pedal.tremoloEnabled = 0.0
|
||||
pedal.cab = 2.0
|
||||
let restored: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.gain == 7.0)
|
||||
#expect(restored.cut == 0.6)
|
||||
#expect(restored.speed == 9.0)
|
||||
#expect(restored.intensity == 0.5)
|
||||
#expect(restored.brilliant == 1.0)
|
||||
#expect(restored.tremoloEnabled == 0.0)
|
||||
#expect(restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Chime Top Boost") is ChimeTopBoostAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// ChimeVariantsTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("Chime variants")
|
||||
struct ChimeVariantsTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.outputBus = dstBus.index
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private let variants: [(name: String, make: () -> ChimeAmpPedal)] = [
|
||||
("Chime 15", { ChimeFifteenAmpPedal() }),
|
||||
("Chime Normal", { ChimeNormalAmpPedal() }),
|
||||
("Chime Baby", { ChimeBabyAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allBuildNonSilentFinite() throws {
|
||||
for v: (name: String, make: () -> ChimeAmpPedal) in variants {
|
||||
let s: [Float] = try render(v.make)
|
||||
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cutChangesOutput() throws {
|
||||
for v: (name: String, make: () -> ChimeAmpPedal) in variants {
|
||||
let open: [Float] = try render(v.make) { $0.cut = 0.0 }
|
||||
let dark: [Float] = try render(v.make) { $0.cut = 1.0 }
|
||||
#expect(windowedSSD(open, dark) > 0, "\(v.name) Cut had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@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")
|
||||
#expect(pedal.toneStackModel == .vox, "\(v.name) tone stack")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func breakupVariantsOversampleAtFour() throws {
|
||||
// Chime 15 and Chime Baby drive the power amp harder → 4× oversample; Normal keeps the base.
|
||||
#expect(ChimeFifteenAmpPedal().powerAmpOversample == 4)
|
||||
#expect(ChimeBabyAmpPedal().powerAmpOversample == 4)
|
||||
#expect(ChimeNormalAmpPedal().powerAmpOversample == 2)
|
||||
}
|
||||
|
||||
@Test func variantsDifferFromEachOther() throws {
|
||||
let cfg: (ChimeAmpPedal) -> Void = { $0.gain = 6.0; $0.cut = 0.2 }
|
||||
let fifteen: [Float] = try render({ ChimeFifteenAmpPedal() }, configure: cfg)
|
||||
let normal: [Float] = try render({ ChimeNormalAmpPedal() }, configure: cfg)
|
||||
let baby: [Float] = try render({ ChimeBabyAmpPedal() }, configure: cfg)
|
||||
#expect(windowedSSD(fifteen, normal) > 0, "Chime 15 and Normal should voice differently")
|
||||
#expect(windowedSSD(normal, baby) > 0, "Chime Normal and Baby should voice differently")
|
||||
#expect(windowedSSD(fifteen, baby) > 0, "Chime 15 and Baby should voice differently")
|
||||
}
|
||||
|
||||
@Test func stayWithinCeilingAtMaxGain() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> ChimeAmpPedal) in variants {
|
||||
let hot: [Float] = try render(v.make) { (pedal: ChimeAmpPedal) in
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.cut = 0.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(v.name) peak \(peak) exceeds the ±1 ceiling")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cutRoundTripsThroughState() throws {
|
||||
let pedal: ChimeBabyAmpPedal = ChimeBabyAmpPedal()
|
||||
pedal.cut = 0.7
|
||||
pedal.cab = 3.0
|
||||
let restored: ChimeBabyAmpPedal = ChimeBabyAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.cut == 0.7 && restored.cab == 3.0, "Chime Baby state did not round-trip")
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Chime 15") is ChimeFifteenAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Chime Normal") is ChimeNormalAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "Chime Baby") is ChimeBabyAmpPedal)
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,82 @@ struct CompressorPedalTests {
|
||||
#expect(labels == ["Input", "Threshold", "Ratio"])
|
||||
}
|
||||
|
||||
@Test func exposesSafetySwitch() throws {
|
||||
let pedal: CompressorPedal = CompressorPedal()
|
||||
let switchLabels: [String] = pedal.effectSwitches.map { $0.label }
|
||||
#expect(switchLabels == ["Safety"])
|
||||
let optionTitles: [String] = pedal.effectSwitches.first?.options.map { $0.title } ?? []
|
||||
#expect(optionTitles == ["Off", "On"])
|
||||
}
|
||||
|
||||
@Test func safetyLimiterCapsPeaks() throws {
|
||||
// Drive the compressor hard (hot input + makeup gain) so its non-zero attack lets
|
||||
// transients overshoot. With the safety limiter engaged the output peak must stay
|
||||
// near full scale; the two switch states must also produce different output.
|
||||
let renderDuration: Double = 0.1
|
||||
let sampleRate: Double = 44100.0
|
||||
|
||||
func render(safety: Double) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: CompressorPedal = CompressorPedal(
|
||||
inputBus: srcBus.index,
|
||||
outputBus: dstBus.index
|
||||
)
|
||||
pedal.sampleRate = sampleRate
|
||||
pedal.inputGain = 24.0
|
||||
pedal.threshold = -30.0
|
||||
pedal.ratio = 8.0
|
||||
pedal.safetyLimiter = safety
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
let off: [Float] = try render(safety: 0.0)
|
||||
let on: [Float] = try render(safety: 1.0)
|
||||
|
||||
#expect(hasNonSilentOutput(off), "safety-off render was silent")
|
||||
#expect(hasNonSilentOutput(on), "safety-on render was silent")
|
||||
|
||||
// Skip the safety limiter's look-ahead fill window before measuring the peak.
|
||||
let lookAheadFillSamples: Int = 2048
|
||||
guard on.count > lookAheadFillSamples else { return }
|
||||
let onWindow: ArraySlice<Float> = on[lookAheadFillSamples...]
|
||||
let onPeak: Float = onWindow.reduce(0) { Swift.max($0, abs($1)) }
|
||||
|
||||
// Safety ceiling is just under full scale; downstream master only attenuates.
|
||||
let ceilingTolerance: Float = 0.05
|
||||
#expect(onPeak <= 1.0 + ceilingTolerance, "safety limiter failed to cap peak: \(onPeak)")
|
||||
|
||||
// The two switch positions must differ.
|
||||
let skip: Int = lookAheadFillSamples
|
||||
let window: Int = 2048
|
||||
guard off.count >= skip + window, on.count >= skip + window else { return }
|
||||
let offWindow: [Float] = Array(off[skip..<(skip + window)])
|
||||
let onWindow2: [Float] = Array(on[skip..<(skip + window)])
|
||||
let ssd: Double = zip(offWindow, onWindow2).reduce(0.0) { acc, pair in
|
||||
let diff: Double = Double(pair.0 - pair.1)
|
||||
return acc + diff * diff
|
||||
}
|
||||
#expect(ssd > 0, "safety switch had no effect on output")
|
||||
}
|
||||
|
||||
@Test func inputGainChangesOutput() throws {
|
||||
// The pre-compression input gain stage must alter the output: boosting the input
|
||||
// drives more of the signal past the threshold, changing the compressed result.
|
||||
|
||||
@@ -84,6 +84,16 @@ struct DistortionPedalTests {
|
||||
#expect(labels == ["Drive", "Tone"])
|
||||
}
|
||||
|
||||
@Test func outputStaysBoundedAtHighDrive() throws {
|
||||
// The final hard clip (after the tone low-pass) must re-establish the ±1 output bound
|
||||
// even at extreme drive, despite the oversampled clip sitting before the low-pass.
|
||||
let samples: [Float] = try render { pedal in pedal.drive = 50.0; pedal.tone = 6000.0 }
|
||||
let skip: Int = 2048
|
||||
guard samples.count > skip else { return }
|
||||
let peak: Float = samples[skip...].reduce(0) { Swift.max($0, abs($1)) }
|
||||
#expect(peak <= 1.05, "distortion output exceeded the clip ceiling: peak=\(peak)")
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Distortion")
|
||||
#expect(pedal is DistortionPedal)
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// FactoryRigLibraryTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("FactoryRigLibrary")
|
||||
struct FactoryRigLibraryTests {
|
||||
|
||||
// MARK: - Catalog integrity
|
||||
|
||||
@Test func catalogIsWellFormed() {
|
||||
let rigs: [FactoryRig] = FactoryRigLibrary.all
|
||||
#expect(rigs.count >= 6, "expected a full starter slate")
|
||||
|
||||
let ids: Set<UUID> = Set(rigs.map { $0.id })
|
||||
#expect(ids.count == rigs.count, "rig ids must be unique")
|
||||
|
||||
let names: Set<String> = Set(rigs.map { $0.name })
|
||||
#expect(names.count == rigs.count, "rig names must be unique")
|
||||
|
||||
let minBlurbLength: Int = 20
|
||||
for rig: FactoryRig in rigs {
|
||||
#expect(!rig.name.isEmpty, "\(rig.name) has empty name")
|
||||
#expect(rig.blurb.count >= minBlurbLength, "\(rig.name) blurb too short")
|
||||
}
|
||||
|
||||
// The slate should span more than one sonic family.
|
||||
let categories: Set<FactoryRigCategory> = Set(rigs.map { $0.category })
|
||||
#expect(categories.count >= 3, "starter slate should cover several categories")
|
||||
}
|
||||
|
||||
@Test func blurbsAvoidTrademarkedProductNames() {
|
||||
// Guard against a blurb accidentally naming a real amp/pedal brand: factory rigs describe
|
||||
// the sound, never a trademarked product.
|
||||
let forbidden: [String] = [
|
||||
"marshall", "fender", "vox", "mesa", "boss", "orange", "dumble", "roland", "ibanez",
|
||||
]
|
||||
for rig: FactoryRig in FactoryRigLibrary.all {
|
||||
let haystack: String = (rig.name + " " + rig.blurb).lowercased()
|
||||
for brand: String in forbidden {
|
||||
#expect(!haystack.contains(brand), "\(rig.name) mentions '\(brand)'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test func factoryDetectionRecognisesEveryRigAndRejectsOthers() {
|
||||
let rigs: [FactoryRig] = FactoryRigLibrary.all
|
||||
#expect(FactoryRigLibrary.factoryIDs.count == rigs.count)
|
||||
for rig: FactoryRig in rigs {
|
||||
#expect(FactoryRigLibrary.isFactory(rig.id), "\(rig.name) not recognised as factory")
|
||||
}
|
||||
// A freshly generated id is not a factory rig.
|
||||
#expect(!FactoryRigLibrary.isFactory(UUID()))
|
||||
}
|
||||
|
||||
@Test func categoryLookupAndGroupingCoverEveryRigOnce() {
|
||||
for rig: FactoryRig in FactoryRigLibrary.all {
|
||||
#expect(FactoryRigLibrary.category(for: rig.id) == rig.category,
|
||||
"\(rig.name) category lookup mismatch")
|
||||
}
|
||||
#expect(FactoryRigLibrary.category(for: UUID()) == nil, "a random id has no category")
|
||||
|
||||
// Each category grouping contains only its own rigs, in catalog order.
|
||||
for category: FactoryRigCategory in FactoryRigCategory.allCases {
|
||||
let rigs: [FactoryRig] = FactoryRigLibrary.rigs(in: category)
|
||||
#expect(rigs.allSatisfy { $0.category == category })
|
||||
}
|
||||
|
||||
// Grouping by every category partitions the catalog exactly (no rig lost or duplicated).
|
||||
let grouped: [FactoryRig] = FactoryRigCategory.allCases.flatMap { FactoryRigLibrary.rigs(in: $0) }
|
||||
#expect(grouped.count == FactoryRigLibrary.all.count, "grouping dropped or duplicated a rig")
|
||||
}
|
||||
|
||||
// MARK: - Seeding entries
|
||||
|
||||
@Test func makeEntriesMatchesCatalogAndIsStable() throws {
|
||||
let entries: [RigEntry] = try FactoryRigLibrary.makeEntries()
|
||||
let rigs: [FactoryRig] = FactoryRigLibrary.all
|
||||
|
||||
#expect(entries.count == rigs.count, "one entry per rig")
|
||||
for (entry, rig): (RigEntry, FactoryRig) in zip(entries, rigs) {
|
||||
#expect(entry.id == rig.id, "entry id must be the rig's stable id")
|
||||
#expect(entry.name == rig.name)
|
||||
// A rig builds either plain boards or a router (or both) — never nothing.
|
||||
let routerStates: [ChainRouterState] = entry.state.routers ?? []
|
||||
#expect(!entry.state.boards.isEmpty || !routerStates.isEmpty, "\(rig.name) built nothing")
|
||||
let boardPedals: Int = entry.state.boards.reduce(0) { $0 + $1.pedals.count }
|
||||
let routerPedals: Int = routerStates.reduce(0) { $0 + $1.boardA.count + $1.boardB.count }
|
||||
#expect(boardPedals + routerPedals >= 3, "\(rig.name) should build a non-trivial chain")
|
||||
}
|
||||
|
||||
// Stable ids: re-seeding yields identical ids (so a re-seed overwrites in place).
|
||||
let again: [RigEntry] = try FactoryRigLibrary.makeEntries()
|
||||
#expect(entries.map { $0.id } == again.map { $0.id })
|
||||
}
|
||||
|
||||
@Test func entriesRoundTripThroughJSON() throws {
|
||||
let encoder: JSONEncoder = JSONEncoder()
|
||||
let decoder: JSONDecoder = JSONDecoder()
|
||||
for entry: RigEntry in try FactoryRigLibrary.makeEntries() {
|
||||
let data: Data = try encoder.encode(entry)
|
||||
let decoded: RigEntry = try decoder.decode(RigEntry.self, from: data)
|
||||
#expect(decoded == entry, "\(entry.name) did not survive a JSON round-trip")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Load + render (full ship path)
|
||||
|
||||
@Test func everyFactoryEntryLoadsAndRenders() throws {
|
||||
let renderDuration: Double = 0.2
|
||||
let numAudioBuses: Int = 128
|
||||
|
||||
for entry: RigEntry in try FactoryRigLibrary.makeEntries() {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
numAudioBuses: numAudioBuses
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let session: ShoeGaze = ShoeGaze(engine: engine)
|
||||
try session.loadRig(from: entry.state)
|
||||
|
||||
try engine.start()
|
||||
let samples: [Float] = readStereoCAF(url: url)
|
||||
#expect(hasNonSilentOutput(samples), "\(entry.name) rendered silence")
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user