Compare commits
86 Commits
651706126c
..
v3.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ef09a771a | |||
| 3f05cfa416 | |||
| 4cae1e6fd0 | |||
| 24ac361c48 | |||
| 52c676605f | |||
| 10a6e122bf | |||
| 9dfadb129d | |||
| 1f5b70edc7 | |||
| a8bd0242a3 | |||
| 4c09825c2e | |||
| b1e59d2c03 | |||
| 0873bbd82e | |||
| 843ae5b5f6 | |||
| 0a8a8e549f | |||
| 3e3f86b737 | |||
| 097c38283e | |||
| 89a34016de | |||
| d1f823e54c | |||
| 75de04160b | |||
| 74227400ad | |||
| 243be726ea | |||
| 20b2034fed | |||
| 3edd64e782 | |||
| 53b506adeb | |||
| 4e8f6e280c | |||
| a434b14f4b | |||
| 0ddf350f1f | |||
| 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 |
@@ -23,3 +23,4 @@ review.diff
|
||||
|
||||
# Local working plan (not shared)
|
||||
docs/plans/amp-expansion-plan.md
|
||||
docs/plans/pedal-expansion-plan.md
|
||||
|
||||
+127
@@ -4,6 +4,133 @@ 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.
|
||||
- **Starter rigs can't be overwritten by accident.** A built-in starter rig is managed content
|
||||
(refreshed to the shipped version on updates), so saving over a loaded starter offers **Save
|
||||
as New Rig** or **Cancel** — your changes are kept as your own rig rather than replacing the
|
||||
shipped one.
|
||||
- **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 —
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2660;
|
||||
LastUpgradeCheck = 2700;
|
||||
TargetAttributes = {
|
||||
C3B100000000000000000014 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
@@ -163,7 +163,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 14;
|
||||
CURRENT_PROJECT_VERSION = 23;
|
||||
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.6;
|
||||
MARKETING_VERSION = 3.3;
|
||||
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 = 14;
|
||||
CURRENT_PROJECT_VERSION = 23;
|
||||
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.6;
|
||||
MARKETING_VERSION = 3.3;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -216,6 +216,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -279,6 +280,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -366,7 +368,8 @@
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
kind = versionRange;
|
||||
maximumVersion = 3.0.0;
|
||||
minimumVersion = 1.2.0;
|
||||
};
|
||||
};
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
||||
"version" : "1.2.3"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2660"
|
||||
LastUpgradeVersion = "2700"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -55,6 +55,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
private let shoeGaze: ShoeGaze
|
||||
private let window: LyrebirdWindow
|
||||
|
||||
/// Multi-level undo / redo for structural rig edits. The same instance backs both the Edit-menu
|
||||
/// items here and `ShoeGazeBuilderView`'s own edits, so ⌘Z works from the menu and the canvas.
|
||||
private let undo: UndoCoordinator
|
||||
|
||||
/// Foot-controller MIDI input. The macOS engine is never rebuilt, so this is created once and
|
||||
/// started at launch.
|
||||
private let midi: MIDIController
|
||||
@@ -73,6 +77,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
/// match the current bypass state (which may also change from the UI or MIDI).
|
||||
private var bypassMenuItem: NSMenuItem?
|
||||
|
||||
/// Undo / Redo items, retained so `validateMenuItem(_:)` can enable them and refresh their
|
||||
/// titles to the next action (e.g. "Undo Add Reverb").
|
||||
private var undoMenuItem: NSMenuItem?
|
||||
private var redoMenuItem: NSMenuItem?
|
||||
|
||||
/// The Rigs ▸ Set List submenu, retained so its item titles can be refreshed to the current
|
||||
/// library order each time it opens (via `menuNeedsUpdate(_:)`).
|
||||
private var setListMenu: NSMenu?
|
||||
@@ -109,6 +118,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
self.coreDriver = coreDriver
|
||||
self.engine = engine
|
||||
self.shoeGaze = shoeGaze
|
||||
self.undo = UndoCoordinator(shoeGaze: shoeGaze)
|
||||
self.midi = MIDIController(engine: engine, shoeGaze: shoeGaze)
|
||||
self.window = LyrebirdWindow(
|
||||
title: "ShoeGaze Builder — Lyrebird Pedalboard",
|
||||
@@ -158,12 +168,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
let driver: CoreAudioDriver = coreDriver
|
||||
let rigLibrary: RigLibraryStore = library
|
||||
let midiController: MIDIController = midi
|
||||
let undoCoordinator: UndoCoordinator = undo
|
||||
window.open {
|
||||
ShoeGazeBuilderView(
|
||||
shoeGaze: session,
|
||||
library: rigLibrary,
|
||||
hardwareSampleRate: { driver.deviceSampleRate },
|
||||
midi: midiController
|
||||
midi: midiController,
|
||||
undo: undoCoordinator
|
||||
)
|
||||
}
|
||||
anchorWindowLeft()
|
||||
@@ -302,6 +314,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
addItem(to: fileMenu, title: "Export Archive…", action: #selector(exportArchiveAction(_:)), key: "e")
|
||||
addItem(to: fileMenu, title: "Import Archive…", action: #selector(importArchiveAction(_:)), key: "i")
|
||||
|
||||
// Edit menu — multi-level undo / redo of structural rig edits (add / remove / move pedals,
|
||||
// boards, routing). ⌘Z / ⇧⌘Z; titles + enabled state refresh in `validateMenuItem(_:)`.
|
||||
let editMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(editMenuItem)
|
||||
let editMenu: NSMenu = NSMenu(title: "Edit")
|
||||
editMenuItem.submenu = editMenu
|
||||
self.undoMenuItem = addItem(
|
||||
to: editMenu,
|
||||
title: "Undo",
|
||||
action: #selector(undoAction(_:)),
|
||||
key: "z"
|
||||
)
|
||||
self.redoMenuItem = addItem(
|
||||
to: editMenu,
|
||||
title: "Redo",
|
||||
action: #selector(redoAction(_:)),
|
||||
key: "z"
|
||||
)
|
||||
self.redoMenuItem?.keyEquivalentModifierMask = [.command, .shift]
|
||||
|
||||
// Board menu — add board + transport.
|
||||
let boardMenuItem: NSMenuItem = NSMenuItem()
|
||||
mainMenu.addItem(boardMenuItem)
|
||||
@@ -311,13 +343,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
// config and the mismatch alert), so the Board menu only adds boards.
|
||||
addItem(to: boardMenu, title: "Add Board", action: #selector(addBoardAction(_:)), key: "b")
|
||||
boardMenu.addItem(NSMenuItem.separator())
|
||||
// ⌘Z toggles rig mute (a hard silence of all output; distinct from Bypass Rig's dry
|
||||
// passthrough). Owns the ⌘Z key equivalent on macOS; the in-window view binds it on iOS.
|
||||
// ⌘M toggles rig mute (a hard silence of all output; distinct from Bypass Rig's dry
|
||||
// passthrough). ⌘Z / ⇧⌘Z are Undo / Redo (Edit menu); the in-window view binds ⌘M on iOS.
|
||||
self.muteMenuItem = addItem(
|
||||
to: boardMenu,
|
||||
title: "Mute Rig",
|
||||
action: #selector(toggleMuteAction(_:)),
|
||||
key: "z"
|
||||
key: "m"
|
||||
)
|
||||
// Bypass Rig routes every board to its dry input (pedals skipped) — distinct from Mute's
|
||||
// hard silence. No key equivalent: ⌘B is Add Board, and Bypass has a prominent on-screen button.
|
||||
@@ -401,6 +433,28 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
|
||||
// MARK: - Menu actions
|
||||
|
||||
/// Reverts the most recent structural rig edit — unless a text field is being edited, in which
|
||||
/// case its own field editor handles ⌘Z (so typing a rig name keeps normal text undo).
|
||||
@objc private func undoAction(_ sender: Any?) {
|
||||
if let editor: NSText = NSApp.keyWindow?.firstResponder as? NSText,
|
||||
let manager: UndoManager = editor.undoManager {
|
||||
manager.undo()
|
||||
return
|
||||
}
|
||||
undo.undo()
|
||||
}
|
||||
|
||||
/// Re-applies the most recently undone structural rig edit, deferring to a text field's own redo
|
||||
/// while one is being edited (mirrors ``undoAction(_:)``).
|
||||
@objc private func redoAction(_ sender: Any?) {
|
||||
if let editor: NSText = NSApp.keyWindow?.firstResponder as? NSText,
|
||||
let manager: UndoManager = editor.undoManager {
|
||||
manager.redo()
|
||||
return
|
||||
}
|
||||
undo.redo()
|
||||
}
|
||||
|
||||
/// Opens (or re-opens) the Help window hosting the shared ``HelpView``.
|
||||
@objc private func showHelpAction(_ sender: Any?) {
|
||||
let helpWidth: CGFloat = 560
|
||||
@@ -476,9 +530,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
@objc private func addBoardAction(_ sender: Any?) {
|
||||
var created: PedalBoard?
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
created = board
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
// Record as an undo checkpoint, matching the in-window Add Board.
|
||||
try undo.perform("Add Board") {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
created = board
|
||||
try shoeGaze.finalizeBoard(board)
|
||||
}
|
||||
} catch {
|
||||
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||
print("[ShoeGazeBuilder] addBoard failed: \(error)")
|
||||
@@ -547,6 +604,23 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
menuItem.state = shoeGaze.rigBypassed ? .on : .off
|
||||
return true
|
||||
}
|
||||
if menuItem == undoMenuItem {
|
||||
// Name the next action so the menu reads "Undo Add Reverb"; disable when there's none.
|
||||
if let label: String = undo.undoActionLabel {
|
||||
menuItem.title = "Undo \(label)"
|
||||
} else {
|
||||
menuItem.title = "Undo"
|
||||
}
|
||||
return undo.canUndo
|
||||
}
|
||||
if menuItem == redoMenuItem {
|
||||
if let label: String = undo.redoActionLabel {
|
||||
menuItem.title = "Redo \(label)"
|
||||
} else {
|
||||
menuItem.title = "Redo"
|
||||
}
|
||||
return undo.canRedo
|
||||
}
|
||||
if setListMenuItems.contains(menuItem) {
|
||||
// A slot is live only when the library actually holds a rig at that position.
|
||||
return menuItem.tag < library.entries.count
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1600;
|
||||
LastUpgradeCheck = 2660;
|
||||
LastUpgradeCheck = 2700;
|
||||
TargetAttributes = {
|
||||
C3C100000000000000000011 = {
|
||||
CreatedOnToolsVersion = 16.0;
|
||||
@@ -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 = 10;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
@@ -175,11 +175,13 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
@@ -194,7 +196,7 @@
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
CURRENT_PROJECT_VERSION = 10;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
@@ -203,11 +205,13 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = 2;
|
||||
@@ -218,6 +222,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -281,6 +286,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
@@ -368,8 +374,9 @@
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.2.0;
|
||||
kind = versionRange;
|
||||
maximumVersion = 3.0.0;
|
||||
minimumVersion = 1.7.2;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
||||
"version" : "1.2.3"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2660"
|
||||
LastUpgradeVersion = "2700"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<!-- Incoming .shoegaze files are read and imported into the rig library (a copy), never
|
||||
edited in place, so the app opens a copy rather than the original document. -->
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<false/>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -32,11 +28,13 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4.0</string>
|
||||
<string>${MARKETING_VERSION}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
|
||||
@@ -31,7 +31,8 @@ struct ShoeGazeBuilderiOSApp: App {
|
||||
library: model.library,
|
||||
hardwareSampleRate: { model.hardwareSampleRate },
|
||||
onEnableLiveInput: { model.enableLiveInput() },
|
||||
midi: model.midi
|
||||
midi: model.midi,
|
||||
undo: model.undo
|
||||
)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.task { await model.startLibrary() }
|
||||
|
||||
@@ -40,6 +40,10 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
/// is rebuilt with an input channel); the `@Observable` change re-binds the hosting view.
|
||||
private(set) var shoeGaze: ShoeGaze
|
||||
|
||||
/// Multi-level undo / redo for structural rig edits, bound to the current `shoeGaze`. Recreated
|
||||
/// when `shoeGaze` is swapped by the live-input rebuild (history resets across that rebuild).
|
||||
private(set) var undo: UndoCoordinator
|
||||
|
||||
private var engine: SynthesisEngine
|
||||
private var iosDriver: iOSAudioDriver
|
||||
|
||||
@@ -70,6 +74,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
self.engine = built.engine
|
||||
self.iosDriver = built.driver
|
||||
self.shoeGaze = shoeGaze
|
||||
self.undo = UndoCoordinator(shoeGaze: shoeGaze)
|
||||
|
||||
// Restore the autosaved working rig if there is one; otherwise seed a default board. Operate
|
||||
// on the local `shoeGaze`, not `self.shoeGaze`: self may not be touched until every stored
|
||||
@@ -197,6 +202,8 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
self.engine = rebuilt.engine
|
||||
self.iosDriver = rebuilt.driver
|
||||
self.shoeGaze = rebuilt.shoeGaze
|
||||
// Bind undo to the new session; history resets across the engine rebuild.
|
||||
self.undo = UndoCoordinator(shoeGaze: rebuilt.shoeGaze)
|
||||
|
||||
do {
|
||||
// Teardown already happened, so a restore failure can only recover by seeding.
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"originHash" : "bc2a61a4b15bd882ede79ecb295b7878eca7ce7b55f4832eaf9bd7e7f557dd4f",
|
||||
"originHash" : "6094cf70541e0593db7264ad9c75576ce239a5a5885ca4b783b5444793b6fee5",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "ea0aa84ca796d9a21667e4b5a7d76a1ac2c280b6",
|
||||
"version" : "1.7.1"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+9
-6
@@ -24,14 +24,16 @@ let package = Package(
|
||||
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.7.1"),
|
||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "2.3.0"),
|
||||
],
|
||||
targets: [
|
||||
// The core target depends on LyrebirdUI as well as the synthesis core:
|
||||
// pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
|
||||
// (the type `ParameterKnob` binds to) lives in LyrebirdUI. Importing
|
||||
// LyrebirdUI here does not pull SwiftUI into ShoeGaze's own sources —
|
||||
// it only makes the `@UIParam` wrapper and `UIParamNode` visible.
|
||||
// Both targets depend on the core `Lyrebird` product AND `LyrebirdUI`.
|
||||
// Pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
|
||||
// lives in the core `LyrebirdSynth` module (the `Lyrebird` product) as of
|
||||
// Lyrebird 2.0 — `LyrebirdUI` no longer re-exports it — so any file using
|
||||
// `@UIParam` / `UIParamNode` needs `import LyrebirdSynth`, which requires
|
||||
// the `Lyrebird` product as a direct dependency. Importing these does not
|
||||
// pull SwiftUI into ShoeGaze's own core sources.
|
||||
.target(
|
||||
name: "LyrebirdShoeGaze",
|
||||
dependencies: [
|
||||
@@ -44,6 +46,7 @@ let package = Package(
|
||||
name: "LyrebirdShoeGazeUI",
|
||||
dependencies: [
|
||||
"LyrebirdShoeGaze",
|
||||
.product(name: "Lyrebird", package: "Lyrebird"),
|
||||
.product(name: "LyrebirdUI", package: "Lyrebird"),
|
||||
],
|
||||
path: "Sources/LyrebirdShoeGazeUI"
|
||||
|
||||
@@ -11,8 +11,13 @@ signal (no hardware needed) or on live guitar through an audio input.
|
||||
|
||||
## Features
|
||||
|
||||
- **36 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, Cabinet |
|
||||
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, 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 |
|
||||
| Gain | Overdrive, Distortion, Fuzz, Sustain Fuzz |
|
||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate, Volume |
|
||||
| EQ & filter | Graphic EQ, Auto-Wah, Wah, Mutant |
|
||||
| Modulation | Tremolo, Phaser, Script Phaser, Modulation, Chorus, Flanger, Vibrato, Vibe, Rotary, Ring Modulator |
|
||||
| Pitch | Bass Octaver, Octave Splitter, Harmonizer, Whammy, Poly Octave |
|
||||
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay, DL4 |
|
||||
| Reverb | Reverb, Shimmer Reverb, Plate Reverb, Room Reverb, Spring Reverb, Reverse Reverb, Granular Reverb, FreezVerb, TunedVerb |
|
||||
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator, Karplus Resonator, Looper, Tape 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
|
||||
|
||||
|
||||
+73
@@ -1,4 +1,77 @@
|
||||
# Releases
|
||||
## ShoeGaze 3.3.0
|
||||
|
||||
Noise-gate and output-level fixes, on Lyrebird 2.2.0.
|
||||
|
||||
### Fixed
|
||||
- **Noise Gate now respects its threshold after loading a rig.** A gate restored from a saved
|
||||
rig could latch open and ignore its Threshold knob — the gate's open level is derived from the
|
||||
threshold, and that value swept up from a default on the first audio block, tripping the gate
|
||||
on the transient. Fixed upstream in Lyrebird 2.2.0 (a live parameter set before the first
|
||||
render is now delivered flat), so the gate reads its real threshold from the first block.
|
||||
- **Mono rigs come out at the level they went in.** A mono board was written through a centre
|
||||
pan that dropped both channels ~3 dB; it now copies the mono signal to both outputs at unity.
|
||||
|
||||
### Changed
|
||||
- **Noise Gate detector: Peak / RMS, defaulting to RMS.** RMS follows perceived loudness, so the
|
||||
gate's threshold decision tracks how loud the note actually is instead of riding the waveform
|
||||
peaks. A gate saved before this switch existed loads on RMS. (Peak remains available.)
|
||||
- Updated to **Lyrebird 2.2.0**.
|
||||
|
||||
## 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" : "f5174c66e77b86ada0723482273f3d43cce9269f39894b2deb371f09e04069ab",
|
||||
"originHash" : "9e278ce69e19f7dabaaaed1b75fb6112a02ece1e30e2aad82c12942c5ddeb192",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "linenoise-swift",
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||
"state" : {
|
||||
"revision" : "ea0aa84ca796d9a21667e4b5a7d76a1ac2c280b6",
|
||||
"version" : "1.7.1"
|
||||
"revision" : "9f244b19394f6352b0a1dcf532cf142b86e41c30",
|
||||
"version" : "2.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -80,10 +80,13 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// bypass source so a bypassed board passes its untouched input straight through.
|
||||
private let dryInputBusIndex: Int
|
||||
|
||||
// MARK: - Constants
|
||||
/// Destination buses for the master's stereo output — hardware 0 / 1 by default. When a
|
||||
/// post-board chain exists, the masters are pointed at a shared **mix bus** instead, and the
|
||||
/// post-chain reads that mix and writes hardware. All boards share the same destination.
|
||||
private let outputLeftBusIndex: Int
|
||||
private let outputRightBusIndex: Int
|
||||
|
||||
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
|
||||
private let stereoPan: Double = 0.0
|
||||
// MARK: - Constants
|
||||
|
||||
/// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed
|
||||
/// transitions to prevent clicks. Matches the per-pedal bypass lag.
|
||||
@@ -102,10 +105,18 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// - boardOutputBusRightIndex: Right board output bus index for a stereo (width-2) board,
|
||||
/// or `nil` for a mono board (the signal is panned to centre instead).
|
||||
/// - dryInputBusIndex: The board's head-bus index, read as the dry bypass source.
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil, dryInputBusIndex: Int) {
|
||||
init(
|
||||
boardOutputBusIndex: Int,
|
||||
boardOutputBusRightIndex: Int? = nil,
|
||||
dryInputBusIndex: Int,
|
||||
outputLeftBusIndex: Int = 0,
|
||||
outputRightBusIndex: Int = 1
|
||||
) {
|
||||
self.boardOutputBusIndex = boardOutputBusIndex
|
||||
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||
self.dryInputBusIndex = dryInputBusIndex
|
||||
self.outputLeftBusIndex = outputLeftBusIndex
|
||||
self.outputRightBusIndex = outputRightBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -134,11 +145,15 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
let switchedRight: any ValidGeneratorInput = applyBypass(wet: boardOutRight, dry: dry)
|
||||
let gainedRight: any ValidGeneratorInput =
|
||||
((switchedRight * smoothedSelect) * $masterGain) * rigOutputGain
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedRight)
|
||||
output(bus: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedRight)
|
||||
} else {
|
||||
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1.
|
||||
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
|
||||
// Mono board: write the mono signal to both hardware buses at unity (0 dB). Using an
|
||||
// equal-power `Pan2` to centre would drop each channel by 3 dB (×0.707) — power-correct
|
||||
// for a true pan, but a mono guitar rig should come out at the same level it went in, so
|
||||
// the signal is copied to left and right directly instead.
|
||||
output(bus: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedLeft)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ 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 peaking-filter gain in dB to its `A` amplitude term.
|
||||
private let cabinetPeakingGainDivisor: Double = 40.0
|
||||
/// 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
|
||||
@@ -37,16 +37,24 @@ public enum CabinetIRFactory {
|
||||
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` at `sampleRate`.
|
||||
/// 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 {
|
||||
@@ -60,6 +68,25 @@ public enum CabinetIRFactory {
|
||||
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
|
||||
@@ -149,7 +176,7 @@ private struct OfflineBiquad {
|
||||
|
||||
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 / cabinetPeakingGainDivisor)
|
||||
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)
|
||||
@@ -161,4 +188,44 @@ private struct OfflineBiquad {
|
||||
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,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,44 @@
|
||||
// FeedPassThrough.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Internal synthesizer that copies one mono bus straight to another — the writer of the shared
|
||||
/// **feed bus** that every board taps.
|
||||
///
|
||||
/// The feed bus sits between the input source and the boards: a `FeedPassThrough` copies either the
|
||||
/// raw input source (when there is no pre-board chain) or the pre-board chain's mono output onto a
|
||||
/// single stable feed bus, and every board's input tap reads that feed bus. Keeping the feed bus
|
||||
/// stable means a pre-board edit only rebuilds the pre-chain + this one node, never the boards.
|
||||
///
|
||||
/// Unlike ``TestLoopTap`` / ``HardwareInputPassThrough`` it carries no input-mute gain: the input
|
||||
/// mute lives on the per-board taps (downstream of the feed), so a tail-producing pedal in the
|
||||
/// pre-board chain is unaffected by it.
|
||||
///
|
||||
/// - Note: Must be removed from the engine before the feed bus it writes is released.
|
||||
final class FeedPassThrough: SynthesizerBase {
|
||||
|
||||
/// Index of the bus to read from — the input source bus, or the pre-board chain's mono output.
|
||||
private let inputBusIndex: Int
|
||||
|
||||
/// Index of the shared feed bus to write to.
|
||||
private let outputBusIndex: Int
|
||||
|
||||
/// Creates a pass-through that copies `inputBusIndex` to `outputBusIndex`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBusIndex: Bus to read from (input source, or pre-board chain output).
|
||||
/// - outputBusIndex: The shared feed bus to write to.
|
||||
init(inputBusIndex: Int, outputBusIndex: Int) {
|
||||
self.inputBusIndex = inputBusIndex
|
||||
self.outputBusIndex = outputBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func build() {
|
||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
||||
}
|
||||
}
|
||||
@@ -417,6 +417,8 @@ public final class MIDIController {
|
||||
(pedal as? LooperPedal)?.cycleSyncMode()
|
||||
case .looperTrack(let index):
|
||||
(pedal as? LooperPedal)?.tapTrack(index)
|
||||
case .pedalPrimaryTransport:
|
||||
(pedal as? MIDITransportPedal)?.toggleMIDITransport()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,10 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
||||
/// Looper: taps track `index` (0 = A) — selects it, or mutes it if already selected and
|
||||
/// recorded (`LooperPedal.tapTrack(_:)`), matching the A/B/C/D dots.
|
||||
case looperTrack(index: Int)
|
||||
|
||||
/// Toggles a pedal's primary transport footswitch — any ``MIDITransportPedal`` (e.g.
|
||||
/// TunedVerb's Capture, FreezVerb's Freeze). Dispatched to `toggleMIDITransport()`.
|
||||
case pedalPrimaryTransport
|
||||
}
|
||||
|
||||
// MARK: - Switch binding
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// MIDITransportPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A pedal with a primary **transport footswitch** — a momentary, latching action beyond generic
|
||||
/// bypass (e.g. TunedVerb's *Capture*, FreezVerb's *Freeze*) — that can be driven by a MIDI
|
||||
/// footswitch.
|
||||
///
|
||||
/// Conforming makes the action appear in the MIDI mapping sheet automatically and lets a mapped
|
||||
/// Program Change fire it: the sheet lists `midiTransportName`, and `MIDIController` calls
|
||||
/// ``toggleMIDITransport()`` for a `PedalActionKind/pedalPrimaryTransport` binding. A pedal with a
|
||||
/// richer transport surface (the looper) is handled by its own dedicated action kinds instead.
|
||||
@MainActor
|
||||
public protocol MIDITransportPedal: AnyObject {
|
||||
|
||||
/// Short display name of the primary transport footswitch (e.g. `"Capture"`, `"Freeze"`), shown
|
||||
/// in the MIDI mapping sheet after the pedal name.
|
||||
var midiTransportName: String { get }
|
||||
|
||||
/// Toggles the primary transport footswitch — called when a mapped MIDI footswitch fires. Same
|
||||
/// effect as pressing the pedal's on-screen footswitch.
|
||||
func toggleMIDITransport()
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import LyrebirdUI
|
||||
/// inputBus → dry → effect(_:) → wet
|
||||
/// ↕ mix (equal-power crossfade)
|
||||
/// blended
|
||||
/// ↕ bypass (lagged equal-power crossfade with dry)
|
||||
/// ↕ bypass (linear equal-power crossfade with dry)
|
||||
/// switched → × level → outputBus
|
||||
/// ```
|
||||
///
|
||||
@@ -32,7 +32,7 @@ import LyrebirdUI
|
||||
///
|
||||
/// - `mix`: Wet/dry blend in `[0, 1]`. `0` = fully dry, `1` = fully wet.
|
||||
/// - `bypass`: Bypass state. `0` = engaged (effect active), `1` = bypassed (pure dry).
|
||||
/// Transitions are smoothed with a 20 ms lag to avoid clicks.
|
||||
/// Transitions are smoothed with a linear crossfade (see ``bypassFadeTime``) to avoid clicks.
|
||||
/// - `level`: Output gain as a linear multiplier. `1.0` = unity gain.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -47,7 +47,7 @@ open class Pedal: SynthesizerBase {
|
||||
@UIParam public var mix: Double = 1.0
|
||||
|
||||
/// Bypass state. `0` = engaged (effect active), `1` = bypassed (dry signal only).
|
||||
/// Transitions are smoothed by `bypassLagTime` seconds to prevent clicks.
|
||||
/// Transitions are smoothed by a linear crossfade over ``bypassFadeTime`` seconds to prevent clicks.
|
||||
@UIParam public var bypass: Double = 0.0
|
||||
|
||||
/// Output gain as a linear multiplier. `1.0` = unity gain.
|
||||
@@ -143,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.
|
||||
@@ -152,9 +156,22 @@ open class Pedal: SynthesizerBase {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Lag time constant in seconds (60 dB convergence) for the bypass crossfade.
|
||||
/// Smooths engaged ↔ bypassed transitions to prevent audible clicks.
|
||||
private let bypassLagTime: Double = 0.02
|
||||
/// Duration in seconds of the engaged ↔ bypassed crossfade. The bypass control is slewed
|
||||
/// **linearly** and at **audio rate** from `0` to `1` (or back) over this time, so the
|
||||
/// equal-power crossfade sweeps smoothly, one step per sample. Two earlier approaches clicked
|
||||
/// here when the crossfade legs are decorrelated and full-scale (a wet-only pitch shifter such as
|
||||
/// the Whammy swapping against the dry note; masked when wet ≈ dry): a one-pole `Lag`, whose
|
||||
/// exponential curve is front-loaded (steepest slope at the very start); and a block-rate slew,
|
||||
/// which steps only once per audio block — at the engine's 512-sample block a short fade is just
|
||||
/// a few coarse jumps, each its own click. An audio-rate linear slew has neither flaw.
|
||||
/// Overridable for pedals needing a gentler fade.
|
||||
open var bypassFadeTime: Double { 0.03 }
|
||||
|
||||
/// Lower bound the effective fade time is clamped to before taking its reciprocal for the slew
|
||||
/// rate. Guards against an override returning `0` (reciprocal `.infinity` → instantaneous slew,
|
||||
/// which reintroduces the click this fade removes) or a negative value (which would invert the
|
||||
/// slew). One sample at 48 kHz, so a legitimate small fade is left untouched.
|
||||
private let minBypassFadeTime: Double = 1.0 / 48_000.0
|
||||
|
||||
// Bipolar-span constant used to remap a [0, 1] value to [-1, +1]
|
||||
// for CrossFade's equal-power pan parameter.
|
||||
@@ -237,6 +254,17 @@ 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
|
||||
@@ -283,11 +311,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)
|
||||
@@ -295,7 +325,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
|
||||
@@ -401,7 +434,7 @@ open class Pedal: SynthesizerBase {
|
||||
/// Builds the signal graph for one channel: dry → wet/dry blend → bypass switch → × level.
|
||||
///
|
||||
/// Returns the final post-`level` source for the channel. The `mix`, `bypass`, and `level`
|
||||
/// `@UIParam` nodes are shared across channels; each channel gets its own `Lag.Control`
|
||||
/// `@UIParam` nodes are shared across channels; each channel gets its own `Slew.Audio`
|
||||
/// for the bypass crossfade so smoothing is per-channel state driven by the same target.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -422,14 +455,25 @@ open class Pedal: SynthesizerBase {
|
||||
pan: mixPan
|
||||
)
|
||||
|
||||
// Smooth bypass transitions with a 20 ms lag to prevent clicks.
|
||||
let bypassLagged: Lag.Control = Lag.Control(
|
||||
// Smooth bypass transitions with a linear crossfade to prevent clicks. The slew runs at
|
||||
// AUDIO rate, not control rate: a block-rate smoother takes one step per audio block, so at
|
||||
// the engine's 512-sample block a short fade is only a handful of coarse steps — each a
|
||||
// click of its own. `Slew.Audio` ramps per sample, so the fade is smooth regardless of
|
||||
// block size. Linear slope (not a front-loaded one-pole lag) keeps it click-free even when
|
||||
// the two legs are decorrelated and full-scale, as for a wet-only pitch shifter.
|
||||
// Rate is in bypass-units per second: 0 → 1 traverses in exactly `bypassFadeTime` seconds.
|
||||
// Clamp to a positive floor first — a subclass override returning 0 or negative would
|
||||
// otherwise yield an infinite or inverted slew rate (see `minBypassFadeTime`).
|
||||
let effectiveFadeTime: Double = max(bypassFadeTime, minBypassFadeTime)
|
||||
let bypassFadeRate: Double = 1.0 / effectiveFadeTime
|
||||
let bypassSlewed: Slew.Audio = Slew.Audio(
|
||||
input: $bypass,
|
||||
time: bypassLagTime
|
||||
up: bypassFadeRate,
|
||||
dn: bypassFadeRate
|
||||
)
|
||||
|
||||
// Map bypass [0, 1] → pan [-1, +1]: −1 = blended (engaged), +1 = dry (bypassed).
|
||||
let bypassPan: any ValidGeneratorInput = (bypassLagged * bipolarSpan) - bipolarOffset
|
||||
let bypassPan: any ValidGeneratorInput = (bypassSlewed * bipolarSpan) - bipolarOffset
|
||||
|
||||
// Equal-power crossfade: engaged → blended; bypassed → dry.
|
||||
let switched: CrossFade.Audio = CrossFade.Audio(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one pedal button — a momentary action trigger or a
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A continuous pedal control that can be driven by a MIDI Control Change — the common shape of a
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one controllable pedal knob.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of a knob that snaps to a fixed set of labelled stops.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one continuous vertical pedal fader.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A UI-agnostic description of one multi-position pedal switch.
|
||||
|
||||
@@ -51,13 +51,22 @@ public extension PedalType {
|
||||
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 Princeton")
|
||||
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")
|
||||
@@ -65,6 +74,7 @@ public extension PedalType {
|
||||
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")
|
||||
@@ -83,12 +93,15 @@ 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 scriptPhaser = PedalType("Script Phaser")
|
||||
static let diffuser = PedalType("Diffuser")
|
||||
static let bitcrusher = PedalType("Bitcrusher")
|
||||
static let granulator = PedalType("Granulator")
|
||||
static let autoGranulator = PedalType("Auto Granulator")
|
||||
static let karplusResonator = PedalType("Karplus Resonator")
|
||||
|
||||
// Dynamics (additional)
|
||||
static let sustainer = PedalType("Sustainer")
|
||||
@@ -102,17 +115,25 @@ public extension PedalType {
|
||||
static let multiTapDelay = PedalType("Multi-Tap Delay")
|
||||
static let pingPong = PedalType("Ping-Pong")
|
||||
static let reverseDelay = PedalType("Reverse Delay")
|
||||
static let dl4 = PedalType("DL4")
|
||||
static let reverb = PedalType("Reverb")
|
||||
static let shimmerReverb = PedalType("Shimmer Reverb")
|
||||
static let plateReverb = PedalType("Plate Reverb")
|
||||
static let roomReverb = PedalType("Room Reverb")
|
||||
static let springReverb = PedalType("Spring Reverb")
|
||||
static let reverseReverb = PedalType("Reverse Reverb")
|
||||
static let granularReverb = PedalType("Granular Reverb")
|
||||
static let freezVerb = PedalType("FreezVerb")
|
||||
static let tunedVerb = PedalType("TunedVerb")
|
||||
|
||||
// Pitch & octave
|
||||
static let octaveSplitter = PedalType("Octave Splitter")
|
||||
static let bassOctaver = PedalType("Bass Octaver")
|
||||
static let harmonizer = PedalType("Harmonizer")
|
||||
static let whammy = PedalType("Whammy")
|
||||
static let polyOctave = PedalType("Poly Octave")
|
||||
|
||||
// Looper
|
||||
static let looper = PedalType("Looper")
|
||||
static let tapeLooper = PedalType("Tape Looper")
|
||||
}
|
||||
|
||||
@@ -17,10 +17,13 @@ import LyrebirdUI
|
||||
/// → TriodeStage(drive: gain) (preamp)
|
||||
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
|
||||
/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity)
|
||||
/// → TriodeStage(power-amp drive) (power-amp warmth)
|
||||
/// → powerAmpStage(_:) (power amp — two TriodeStage halves blended by
|
||||
/// Bias X; single-stage tone at biasX = 0)
|
||||
/// → shapeVoice(_:) (subclass signature filter)
|
||||
/// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, rebuild on change)
|
||||
/// → TriodeStage(bias: 0) → Clip(±1) (output soft-limit + hard safety ceiling)
|
||||
/// → 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.
|
||||
///
|
||||
@@ -38,8 +41,10 @@ open class AmpVoicePedal: Pedal {
|
||||
|
||||
// MARK: - Common parameters
|
||||
|
||||
/// Preamp drive into the first tube stage. Range [1, 30].
|
||||
@UIParam public var gain: Double = 6.0
|
||||
/// 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].
|
||||
@@ -48,6 +53,20 @@ open class AmpVoicePedal: Pedal {
|
||||
@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
|
||||
|
||||
@@ -135,7 +154,19 @@ open class AmpVoicePedal: Pedal {
|
||||
/// - 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: $gain, bias: preampBias, oversample: preampOversample)
|
||||
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
|
||||
@@ -153,6 +184,61 @@ open class AmpVoicePedal: Pedal {
|
||||
/// 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
|
||||
@@ -160,9 +246,41 @@ open class AmpVoicePedal: Pedal {
|
||||
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
|
||||
/// Fixed power-amp stage drive/bias (gentler than the preamp).
|
||||
/// 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
|
||||
private let powerAmpBias: Double = 0.0
|
||||
/// 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
|
||||
@@ -177,23 +295,29 @@ open class AmpVoicePedal: Pedal {
|
||||
/// 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 ... 30.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 }
|
||||
|
||||
/// Amp-head-style double-width card.
|
||||
/// 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 }
|
||||
@@ -237,23 +361,33 @@ open class AmpVoicePedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// 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 → output soft-limit.
|
||||
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet (or None) → output
|
||||
/// soft-limit.
|
||||
///
|
||||
/// > Note: only the voice named by the live `cab` selector is instantiated, so exactly one
|
||||
/// > `ConvolutionReverb` runs. The `cab` selector is `rebuildsOnChange`, so switching cabs
|
||||
/// > rebuilds the board (re-entering `effect(_:)` with the new voice) rather than running every
|
||||
/// > voice at once.
|
||||
/// > 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 closing `TriodeStage(bias: 0)` is a symmetric `tanh` output limiter: the cab convolution
|
||||
/// and signature shelves can push peaks past ±1, which a real analog output would soft-compress
|
||||
/// rather than hard-clip. Unit small-signal gain keeps clean tones intact; peaks soft-limit
|
||||
/// toward ±1. The trailing `Clip(±1)` is a hard safety clamp for the sub-percent overshoot the
|
||||
/// `tanh`'s DC-blocker and the halfband filters can leave — so no sample can clip the DAC.
|
||||
/// 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, cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
/// - Returns: The amped, (optionally) cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
cabinetAndLimit(preCabinetCore(dry))
|
||||
}
|
||||
@@ -270,32 +404,69 @@ open class AmpVoicePedal: Pedal {
|
||||
let toned: ToneStack = ToneStack(
|
||||
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
|
||||
let processed: any ValidGeneratorInput = onboardEffects(toned)
|
||||
let powerAmp: TriodeStage = TriodeStage(
|
||||
input: processed, drive: powerAmpDriveInput, bias: powerAmpBias, oversample: powerAmpOversample)
|
||||
return shapeVoice(powerAmp)
|
||||
let powerAmp: any ValidGeneratorInput = powerAmpStage(processed)
|
||||
return applySag(shapeVoice(powerAmp))
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: the selected `CabinetVoice` convolver → `tanh`
|
||||
/// soft-limit → `Clip(±1)` safety clamp. Applied once in mono, or once per channel by a
|
||||
/// widener amp.
|
||||
/// 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 cab-convolved, soft-limited, ceiling-clamped signal.
|
||||
/// - 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)
|
||||
let cabinet: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
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: cabinet,
|
||||
input: signal,
|
||||
drive: outputStageDrive,
|
||||
bias: outputStageBias,
|
||||
oversample: outputStageOversample
|
||||
)
|
||||
// Hard safety clamp: the tanh keeps the signal near ±1, but its DC-blocker and the halfband
|
||||
// filters can leave a sub-percent transient overshoot — clamp it so no sample can clip the DAC.
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public final class BritishAmpPedal: AmpVoicePedal {
|
||||
/// - 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 = 10.0 // crunch-leaning default
|
||||
gain = 7.77 // crunch-leaning default
|
||||
cab = 1.0 // default to the British 4×12 cab
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the extra tremolo knobs plus the Bright and Tremolo switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// The base Bright switch plus a Tremolo footswitch (compose `super` so Bright stays in sync).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
@@ -60,7 +57,7 @@ public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
/// - 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.0
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12 voice (combo 2×12 tonally close enough among our cabs)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,6 @@ open class BritishComboAmpPedal: AmpVoicePedal {
|
||||
private let brightFreqHz: Double = 3500.0
|
||||
private let brightMaxGainDb: Double = 6.0
|
||||
private let brightSlope: Double = 0.7
|
||||
let switchOffValue: Double = 0.0
|
||||
let switchOnValue: Double = 1.0
|
||||
/// Grid bias of a cascaded lead/drive `TriodeStage` — a little asymmetry for even-harmonic
|
||||
/// grind. Shared by the master-volume subclasses' cascaded ``preampStage(_:)``.
|
||||
let leadBias: Double = 0.15
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
|
||||
@@ -18,8 +18,8 @@ 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). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.0
|
||||
/// 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).
|
||||
@@ -29,7 +29,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
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 ... 30.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
@@ -63,9 +63,6 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Wider card for the extra Master/Drive/Reverb knobs plus the Bright and Channel switches.
|
||||
public override var widthUnits: Int { 4 }
|
||||
|
||||
/// Creates a British Dual amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -73,7 +70,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
/// - 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.0
|
||||
gain = 5.73
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
@@ -82,7 +79,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
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: $drive, bias: leadBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class BritishJTMAmpPedal: BritishComboAmpPedal {
|
||||
/// - 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.0 // warmer, lower-gain than the plexi
|
||||
gain = 5.73 // warmer, lower-gain than the plexi
|
||||
treble = 0.5 // a shade rounder on top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Wider card for the Presence/Master knobs plus the Bright switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// Creates a British Master amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -44,13 +41,13 @@ public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
/// - 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.0 // cascaded, so already a hot lead at moderate Gain
|
||||
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: $gain, bias: leadBias, oversample: preampOversample)
|
||||
return TriodeStage(input: stage1, drive: taperedDrive($gain), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class BritishPlexiAmpPedal: BritishComboAmpPedal {
|
||||
/// - 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 = 7.0 // clean-ish until pushed
|
||||
gain = 6.72 // clean-ish until pushed
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,12 @@ import LyrebirdUI
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → ConvolutionReverb(ir: selectedVoice) → mono out
|
||||
/// 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.
|
||||
@@ -32,6 +37,13 @@ import LyrebirdUI
|
||||
/// 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.
|
||||
@@ -39,12 +51,42 @@ public final class CabinetPedal: Pedal {
|
||||
"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
|
||||
|
||||
@@ -54,6 +96,33 @@ public final class CabinetPedal: Pedal {
|
||||
/// 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()
|
||||
@@ -61,6 +130,13 @@ public final class CabinetPedal: Pedal {
|
||||
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.
|
||||
@@ -86,28 +162,119 @@ public final class CabinetPedal: Pedal {
|
||||
[
|
||||
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 IR.
|
||||
/// Convolves the dry signal against the single selected cabinet + mic IR, then soft-limits.
|
||||
///
|
||||
/// Only the voice named by the live `cabinet` selector is instantiated, so exactly one
|
||||
/// partitioned-FFT convolver runs. Changing the selector triggers a board rebuild (the selector
|
||||
/// is `rebuildsOnChange`), which re-enters `effect(_:)` with the new voice — so switching cabs
|
||||
/// costs a brief rebuild rather than running every voice at once. Synthesizing the short IR
|
||||
/// happens off the RT thread in `build()`.
|
||||
/// 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 mono output.
|
||||
/// - 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)
|
||||
return ConvolutionReverb.Audio(
|
||||
let micVoice: MicVoice = MicVoice.voice(atSelectorValue: mic)
|
||||
let convolved: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
input: dry,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public final class CaliforniaAmpPedal: AmpVoicePedal {
|
||||
/// - 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 = 4.0 // clean-leaning default
|
||||
gain = 5.08 // clean-leaning default
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
|
||||
@@ -10,8 +10,8 @@ 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 Vox-voiced family — the
|
||||
/// AC-style variants (Chime 15 / Chime Normal / Chime Baby) subclass it and differ by gain, cab,
|
||||
/// 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 {
|
||||
|
||||
@@ -41,7 +41,7 @@ open class ChimeAmpPedal: AmpVoicePedal {
|
||||
/// - 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.0
|
||||
gain = 5.73
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Vox-voiced **practice combo** — the tiny AC4/AC10-style amp: low headroom, a small boxy
|
||||
/// 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.
|
||||
@@ -17,7 +17,7 @@ public final class ChimeBabyAmpPedal: ChimeAmpPedal {
|
||||
private let babyPowerDrive: Double = 2.5
|
||||
|
||||
public override var summaryText: String {
|
||||
"Vox practice combo — tiny, boxy, earliest-breakup chime with a Cut control."
|
||||
"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.
|
||||
@@ -31,7 +31,7 @@ public final class ChimeBabyAmpPedal: ChimeAmpPedal {
|
||||
/// - 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.0
|
||||
gain = 6.27
|
||||
bass = 0.4 // small speaker, less low end
|
||||
cab = 7.0 // Lo-Fi 1×8 — the small, boxy voice
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Vox-voiced **1×12 EL84 combo** — the lower-powered, earlier-breakup sibling of the AC top-boost
|
||||
/// 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.
|
||||
@@ -17,7 +17,7 @@ public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
|
||||
private let fifteenPowerDrive: Double = 2.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"Vox 1×12 EL84 combo — chimey but earlier-breakup, with a Cut control."
|
||||
"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.
|
||||
@@ -31,7 +31,7 @@ public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
|
||||
/// - 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.0 // grittier starting point than the big AC voice
|
||||
gain = 6.27 // grittier starting point than the big AC voice
|
||||
cab = 5.0 // Bright 1×12
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Vox-voiced **Normal channel** — the AC30's non-top-boost side: warmer and rounder than the
|
||||
/// bright top-boost voice, with the same high clean headroom.
|
||||
/// 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 {
|
||||
"Vox Normal channel — warm, round, high-headroom chime with a Cut control."
|
||||
"Chime Normal channel — warm, round, high-headroom chime with a Cut control."
|
||||
}
|
||||
|
||||
/// Creates a Chime Normal amp.
|
||||
@@ -25,7 +25,7 @@ public final class ChimeNormalAmpPedal: ChimeAmpPedal {
|
||||
/// - 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.0
|
||||
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
|
||||
|
||||
@@ -50,8 +50,6 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
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
|
||||
private let switchOffValue: Double = 0.0
|
||||
private let switchOnValue: Double = 1.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
@@ -67,9 +65,6 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the extra Cut/tremolo knobs plus the Brilliant and Tremolo switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Chime Top Boost amp.
|
||||
@@ -79,7 +74,7 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
/// - 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.0
|
||||
gain = 5.73
|
||||
cab = 5.0 // Bright 1×12 — the chimey, top-end-forward cab voice
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
// DL4Pedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// An umbrella multi-model delay in the mould of the classic green four-knob delay modeller: one
|
||||
/// pedal, a **Model** selector, and four shared controls (**Time**, **Repeats**, **Tone**, **Mod**)
|
||||
/// whose character changes with the chosen model. This is the delay-models side only — no looper.
|
||||
///
|
||||
/// Each model is a distinct delay recipe built from Lyrebird primitives:
|
||||
/// - **Tube** — a driven, warm echo (soft-clipped input into a filtered delay).
|
||||
/// - **Tape** — a tape echo with slow wow modulating the delay time and a tape-style HF rolloff.
|
||||
/// - **Analog** — a dark bucket-brigade voice (heavily low-passed, gently saturated repeats).
|
||||
/// - **Analog Mod** — the analog voice with a chorus-rate wobble on the delay time.
|
||||
/// - **Multi-Head** — three fixed delay taps plus a feedback repeat, à la a multi-head tape unit.
|
||||
/// - **Sweep** — a delay fed through a sweeping all-pass for a phased, resonant echo.
|
||||
/// - **Lo-Res** — a down-sampled, gritty lo-fi delay.
|
||||
/// - **Reverse** — backward echo segments (the ``ReverseDelay`` generator).
|
||||
///
|
||||
/// `effect` returns the pure wet signal; the base `Pedal` `mix` sets the wet/dry blend.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `time`: Delay time in seconds. Range `[0.02, 2.0]`. Tempo-syncable.
|
||||
/// - `repeats`: Feedback, as the decay time in seconds for echoes to fall to −60 dB. Range `[0.05, 8.0]`.
|
||||
/// - `tone`: Repeat brightness — a low-pass cutoff in Hz. Range `[500, 12000]`.
|
||||
/// - `mod`: Modulation amount in `[0, 1]` for the models that modulate — delay-time wow depth for
|
||||
/// Tape and Analog Mod, and the sweep rate for Sweep; inert for the others.
|
||||
///
|
||||
/// ## Selectors
|
||||
/// - `model`: The delay model (rebuilds on change).
|
||||
public final class DL4Pedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Multi-model delay: tube, tape, analog, multi-head, sweep, lo-res, and reverse voices."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Delay time in seconds. Range `[0.02, 2.0]`.
|
||||
@UIParam public var time: Double = 0.4
|
||||
|
||||
/// Feedback as decay time in seconds (−60 dB). Range `[0.05, 8.0]`.
|
||||
@UIParam public var repeats: Double = 1.5
|
||||
|
||||
/// Repeat brightness — low-pass cutoff in Hz. Range `[500, 12000]`.
|
||||
@UIParam public var tone: Double = 6000.0
|
||||
|
||||
/// Modulation amount in `[0, 1]` — Tape wow depth, Analog Mod wobble depth, or Sweep rate.
|
||||
@UIParam public var mod: Double = 0.3
|
||||
|
||||
/// Selected model index into ``models``. A knob-picker selector; rebuilds on change.
|
||||
@UIParam public var model: Double = 0.0
|
||||
|
||||
// MARK: - Models
|
||||
|
||||
/// The ordered model list. The index is written to ``model`` by the selector and read at build
|
||||
/// time by ``effect(_:)`` to pick the recipe.
|
||||
private static let models: [String] = [
|
||||
"Tube", "Tape", "Analog", "Analog Mod", "Multi-Head", "Sweep", "Lo-Res", "Reverse",
|
||||
]
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — a partial mix so dry and echoes coexist.
|
||||
private static let defaultMix: Double = 0.35
|
||||
|
||||
/// Maximum delay time in seconds. Sizes every delay line; kept above `timeRange.upperBound` so
|
||||
/// the modulated models can push the delay time a little past the knob maximum without wrapping.
|
||||
private let maxDelayTime: Double = 2.2
|
||||
|
||||
/// Amplitude target for the feedback `decayTime` calculation (−60 dB).
|
||||
private let targetAmp: Double = 0.001
|
||||
|
||||
/// Butterworth Q (no resonant peak) for the tone low-pass.
|
||||
private let filterQ: Double = 0.707
|
||||
|
||||
// Tube
|
||||
private let tubeDrive: Double = 2.0
|
||||
|
||||
// Tape
|
||||
private let tapeWowRate: Double = 0.7 // Hz
|
||||
private let tapeWowDepth: Double = 0.003 // seconds at mod = 1
|
||||
private let tapeToneScale: Double = 0.8 // tape HF rolloff
|
||||
|
||||
// Analog
|
||||
private let analogToneScale: Double = 0.5 // dark BBD voice
|
||||
private let analogDrive: Double = 1.3
|
||||
|
||||
// Analog Mod
|
||||
private let analogModRate: Double = 1.6 // Hz
|
||||
private let analogModDepth: Double = 0.0025 // seconds at mod = 1
|
||||
|
||||
// Multi-Head
|
||||
private let headBFraction: Double = 0.5 // second tap at half the time
|
||||
private let headCFraction: Double = 0.75 // third tap at three-quarters
|
||||
private let headGain: Double = 0.2 // per-tap level (3 taps → 0.6)
|
||||
private let repeatGain: Double = 0.4 // feedback-repeat level (sum 3·0.2 + 0.4 = 1.0)
|
||||
|
||||
// Sweep
|
||||
private let sweepRateMin: Double = 0.05 // Hz at mod = 0
|
||||
private let sweepRateSpan: Double = 1.45 // + span at mod = 1 → up to 1.5 Hz
|
||||
private let sweepDepth: Double = 0.8
|
||||
private let sweepCenterFreq: Double = 900.0
|
||||
private let sweepFeedback: Double = 0.3
|
||||
private let sweepStages: Int = 4
|
||||
private let sweepInternalMix: Double = 1.0
|
||||
|
||||
// Lo-Res
|
||||
private let loResDownsample: Double = 4.0 // hold length in samples
|
||||
private let loResToneScale: Double = 0.6
|
||||
|
||||
// Reverse
|
||||
private let reverseFeedbackScale: Double = 0.95 / 8.0 // maps repeats (≤ 8 s) → [0, 0.95]
|
||||
private let reverseFeedbackMax: Double = 0.95
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let timeRange: ClosedRange<Double> = 0.02 ... 2.0
|
||||
private let repeatsRange: ClosedRange<Double> = 0.05 ... 8.0
|
||||
private let toneRange: ClosedRange<Double> = 500.0 ... 12000.0
|
||||
private let modRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||
PedalKnob(label: "Repeats", node: $repeats, range: repeatsRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
PedalKnob(label: "Mod", node: $mod, range: modRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[
|
||||
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Selectors
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
let stops: [PedalSelectorKnob.Stop] = DL4Pedal.models.enumerated().map { index, name in
|
||||
PedalSelectorKnob.Stop(title: name, value: Double(index))
|
||||
}
|
||||
return [
|
||||
// Each model is a different delay topology read at build time, so switching rebuilds.
|
||||
PedalSelectorKnob(label: "Model", node: $model, stops: stops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a multi-model delay 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: "DL4",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: DL4Pedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// `model` is read as a plain value at build time; the board rebuilds when it changes (each
|
||||
// model is a different delay topology). Time / Repeats / Tone / Mod stay live.
|
||||
let index: Int = min(max(0, Int(model.rounded())), DL4Pedal.models.count - 1)
|
||||
switch index {
|
||||
case 0: return makeTube(dry: dry)
|
||||
case 1: return makeTape(dry: dry)
|
||||
case 2: return makeAnalog(dry: dry)
|
||||
case 3: return makeAnalogMod(dry: dry)
|
||||
case 4: return makeMultiHead(dry: dry)
|
||||
case 5: return makeSweep(dry: dry)
|
||||
case 6: return makeLoRes(dry: dry)
|
||||
default: return makeReverse(dry: dry)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Model builders
|
||||
|
||||
/// A feedback delay line on `input` at the current Time / Repeats.
|
||||
private func feedbackDelay(input: any ValidGeneratorInput, delay: any ValidGeneratorInput) -> DelayLineFeedback {
|
||||
DelayLineFeedback(
|
||||
input: input,
|
||||
maxDelay: maxDelayTime,
|
||||
delay: delay,
|
||||
decayTime: $repeats,
|
||||
targetAmp: targetAmp,
|
||||
sampleRate: sampleRate,
|
||||
interpolation: .linear
|
||||
)
|
||||
}
|
||||
|
||||
/// Tone low-pass at the given cutoff.
|
||||
private func toned(_ input: any ValidGeneratorInput, cutoff: any ValidGeneratorInput) -> RBJLowPass.Audio {
|
||||
RBJLowPass.Audio(input: input, freq: cutoff, q: filterQ)
|
||||
}
|
||||
|
||||
/// Tube: soft-clipped input into a filtered feedback delay — a driven, warm echo.
|
||||
private func makeTube(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let driven: SoftClip.Audio = SoftClip.Audio(dry, drive: tubeDrive)
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: driven, delay: $time)
|
||||
return toned(fb, cutoff: $tone)
|
||||
}
|
||||
|
||||
/// Tape: slow wow modulates the delay time, with a tape-style HF rolloff.
|
||||
private func makeTape(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let wow: OscSin.Audio = OscSin.Audio(freq: tapeWowRate, mul: $mod * tapeWowDepth)
|
||||
let delay: any ValidGeneratorInput = $time + wow
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: dry, delay: delay)
|
||||
return toned(fb, cutoff: $tone * tapeToneScale)
|
||||
}
|
||||
|
||||
/// Analog: dark, gently saturated bucket-brigade voice.
|
||||
private func makeAnalog(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: dry, delay: $time)
|
||||
let dark: RBJLowPass.Audio = toned(fb, cutoff: $tone * analogToneScale)
|
||||
return SoftClip.Audio(dark, drive: analogDrive)
|
||||
}
|
||||
|
||||
/// Analog Mod: the analog voice with a chorus-rate wobble on the delay time.
|
||||
private func makeAnalogMod(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let wobble: OscSin.Audio = OscSin.Audio(freq: analogModRate, mul: $mod * analogModDepth)
|
||||
let delay: any ValidGeneratorInput = $time + wobble
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: dry, delay: delay)
|
||||
return toned(fb, cutoff: $tone * analogToneScale)
|
||||
}
|
||||
|
||||
/// Multi-Head: three fixed delay taps plus a feedback repeat, like a multi-head tape unit.
|
||||
private func makeMultiHead(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let tapA: DelayLine = DelayLine(input: dry, maxDelay: maxDelayTime, delay: $time, sampleRate: sampleRate)
|
||||
let tapB: DelayLine = DelayLine(input: dry, maxDelay: maxDelayTime, delay: $time * headBFraction, sampleRate: sampleRate)
|
||||
let tapC: DelayLine = DelayLine(input: dry, maxDelay: maxDelayTime, delay: $time * headCFraction, sampleRate: sampleRate)
|
||||
let repeatsTap: DelayLineFeedback = feedbackDelay(input: dry, delay: $time)
|
||||
let sum: any ValidGeneratorInput =
|
||||
(tapA * headGain) + (tapB * headGain) + (tapC * headGain) + (repeatsTap * repeatGain)
|
||||
return toned(sum, cutoff: $tone)
|
||||
}
|
||||
|
||||
/// Sweep: a filtered delay fed through a sweeping all-pass for a phased, resonant echo.
|
||||
private func makeSweep(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: dry, delay: $time)
|
||||
let base: RBJLowPass.Audio = toned(fb, cutoff: $tone)
|
||||
let sweepRate: any ValidGeneratorInput = ($mod * sweepRateSpan) + sweepRateMin
|
||||
return Phaser.Audio(
|
||||
input: base,
|
||||
rate: sweepRate,
|
||||
depth: sweepDepth,
|
||||
centerFreq: sweepCenterFreq,
|
||||
feedback: sweepFeedback,
|
||||
stages: sweepStages,
|
||||
mix: sweepInternalMix,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
}
|
||||
|
||||
/// Lo-Res: a down-sampled, gritty lo-fi delay.
|
||||
private func makeLoRes(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let fb: DelayLineFeedback = feedbackDelay(input: dry, delay: $time)
|
||||
let crushed: SampleRateDecimate = SampleRateDecimate(input: fb, downsample: loResDownsample)
|
||||
return toned(crushed, cutoff: $tone * loResToneScale)
|
||||
}
|
||||
|
||||
/// Reverse: backward echo segments at the current Time, with Repeats mapped to the reverse-trail
|
||||
/// feedback factor.
|
||||
private func makeReverse(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let revFeedback: Clip.Audio = Clip.Audio(
|
||||
$repeats * reverseFeedbackScale,
|
||||
lo: 0.0,
|
||||
hi: reverseFeedbackMax
|
||||
)
|
||||
let rev: ReverseDelay = ReverseDelay(
|
||||
input: dry,
|
||||
maxDelay: maxDelayTime,
|
||||
delay: $time,
|
||||
feedback: revFeedback,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
return toned(rev, cutoff: $tone)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
// FreezVerbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A true freeze-and-hold — press **Freeze** and the sound playing at that instant is
|
||||
/// captured and held as an infinite, smoothly-sustaining pad while you keep playing over it.
|
||||
///
|
||||
/// Unlike a feedback-tank "infinite reverb" (which just pushes a reverb's decay toward forever and
|
||||
/// smears everything you play into the wash), this takes a genuine **spectral snapshot**: a
|
||||
/// phase-vocoder (`SpectralFreeze`) locks the magnitude spectrum of the moment you engage it and
|
||||
/// keeps each partial rotating at its own frequency, so the held chord sounds natural and glassy
|
||||
/// rather than a static loop or a metallic ring. That frozen spectrum is then wrapped in a `FreeVerb`
|
||||
/// tank for a diffuse, blooming space — the "reverb" half of the name.
|
||||
///
|
||||
/// The dry signal always passes straight through, so you solo or comp over the held pad; the frozen
|
||||
/// wash is layered on top (the wet/dry Mix knob is hidden and the base `mix` stays fully wet). Press
|
||||
/// Freeze again to release it — the pad fades out over **Rise** and live analysis resumes, ready for
|
||||
/// the next snapshot.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `verb`: Size of the reverb space wrapped around the frozen pad. Range `[0, 1]`: bigger = washier.
|
||||
/// - `tone`: Brightness of the pad. Range `[0, 1]`: `0` = dark, `1` = bright.
|
||||
/// - `rise`: Fade time in seconds as the freeze blooms in and releases out. Range `[0.02, 4.0]`.
|
||||
///
|
||||
/// ## Transport
|
||||
/// - `Freeze`: latching footswitch — press to snapshot and hold, press again to release.
|
||||
public final class FreezVerbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Snapshot the moment and hold it forever — a spectral freeze wrapped in a blooming wash."
|
||||
}
|
||||
|
||||
/// The pad is layered over the untouched dry signal, so a wet/dry Mix knob is meaningless — hide
|
||||
/// it and keep the base `mix` fully wet.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Size of the reverb space wrapped around the frozen pad. Range `[0, 1]`: bigger = washier.
|
||||
@UIParam public var verb: Double = 0.7
|
||||
|
||||
/// Brightness of the pad. Range `[0, 1]`: `0` = dark, `1` = bright.
|
||||
@UIParam public var tone: Double = 0.5
|
||||
|
||||
/// Fade time in seconds as the freeze blooms in and releases out. Range `[0.02, 4.0]`.
|
||||
@UIParam public var rise: Double = 0.4
|
||||
|
||||
// MARK: - Internal live state (read by the audio graph)
|
||||
|
||||
/// `1` while a snapshot is held, else `0`. Drives the pad's fade gate and the Freeze footswitch
|
||||
/// LED. Transport state, not a preset control — captured neither by `captureState` nor restored.
|
||||
@UIParam public var frozen: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// FFT frame size for the phase-vocoder freeze. Larger = finer frequency resolution (smoother
|
||||
/// held chords) at the cost of more latency on the wet path; the dry path is never delayed.
|
||||
private static let fftSize: Int = 2048
|
||||
|
||||
/// Samples between FFT hops (75% overlap at `fftSize` 2048) — fine enough for a clean, artifact-
|
||||
/// free resynthesis of the held spectrum.
|
||||
private static let hopSize: Int = 512
|
||||
|
||||
/// FreeVerb is run fully wet on the pad; the pedal's own dry/wet balance is the `frozen` gate plus
|
||||
/// the base `mix`, so the tank should contribute none of its own dry path.
|
||||
private let verbMix: Double = 1.0
|
||||
|
||||
/// Gain folding FreeVerb's two decorrelated channels to mono — a conservative trim (the channels
|
||||
/// are not identical) that leaves output headroom.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
/// Floor on the release-fade delay, in seconds. On release the gate ramps down over `rise`, but we
|
||||
/// keep the snapshot playing until the fade has essentially finished; this ensures even the
|
||||
/// shortest `rise` still defers the return-to-live by a sensible minimum.
|
||||
private static let minReleaseDefer: Double = 0.05
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let unitRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let riseRange: ClosedRange<Double> = 0.02 ... 4.0
|
||||
|
||||
// MARK: - Live generator references (rebuilt each `effect(_:)`)
|
||||
|
||||
/// The live spectral-freeze processor the Freeze footswitch drives. Recreated on every graph
|
||||
/// rebuild, so the button always acts on the current instance.
|
||||
private var freezeProcessor: SpectralFreeze?
|
||||
|
||||
/// Mirror of the held state, so a toggle knows which way to go and the LED survives a rebuild.
|
||||
private var isFrozen: Bool = false
|
||||
|
||||
/// Bumped on every freeze, release, rebuild, and teardown. A pending deferred return-to-live
|
||||
/// (``completeRelease(generation:)``) only acts when its captured generation still matches, so a
|
||||
/// re-freeze (or any state change) during the release fade cancels it.
|
||||
private var releaseGeneration: Int = 0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Verb", node: $verb, range: unitRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: unitRange),
|
||||
PedalKnob(label: "Rise", node: $rise, range: riseRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Transport
|
||||
|
||||
public override var effectTransportButtons: [PedalButton] {
|
||||
[
|
||||
PedalButton(
|
||||
label: "Freeze",
|
||||
indicator: $frozen,
|
||||
dynamicLabel: { [weak self] in (self?.isFrozen ?? false) ? "Release" : "Freeze" }
|
||||
) { [weak self] in self?.toggleFreeze() }
|
||||
]
|
||||
}
|
||||
|
||||
/// `true` while a snapshot is held. Exposed for UI / tests.
|
||||
public var holding: Bool { isFrozen }
|
||||
|
||||
/// Snapshot-and-hold, or release a held snapshot. Latched by the Freeze footswitch.
|
||||
public func toggleFreeze() {
|
||||
if isFrozen {
|
||||
// Release: drop the gate (the pad fades over `rise`) but keep the snapshot *playing*, and
|
||||
// only return the processor to live analysis once the fade has finished. If we unfroze now,
|
||||
// the still-open fade would carry a live, FFT-delayed copy of the dry signal — combing
|
||||
// against the undelayed dry. Deferring the unfreeze fades the actual held spectrum instead.
|
||||
isFrozen = false
|
||||
frozen = 0.0
|
||||
releaseGeneration += 1
|
||||
let generation: Int = releaseGeneration
|
||||
let fadeSeconds: Double = max(rise, FreezVerbPedal.minReleaseDefer)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + fadeSeconds) { [weak self] in
|
||||
self?.completeRelease(generation: generation)
|
||||
}
|
||||
} else {
|
||||
releaseGeneration += 1 // cancel any pending deferred release
|
||||
freezeProcessor?.freeze()
|
||||
isFrozen = true
|
||||
frozen = 1.0 // bloom the pad in over `rise`
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the processor to live analysis after a release fade, unless a newer freeze/release (or a
|
||||
/// rebuild/teardown) has superseded this one.
|
||||
private func completeRelease(generation: Int) {
|
||||
guard generation == releaseGeneration, !isFrozen else { return }
|
||||
freezeProcessor?.unfreeze()
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a freeze-and-hold 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: "FreezVerb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: 1.0
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// `effect()` re-runs on every add/rebuild. Start from a clean, released state so the button
|
||||
// never holds a reference to a discarded freeze processor.
|
||||
resetForRebuild()
|
||||
|
||||
// Phase-vocoder spectral freeze: live analysis until `freeze()` captures the current spectrum,
|
||||
// then an infinite, naturally-rotating held pad regardless of further input.
|
||||
let freeze: SpectralFreeze = SpectralFreeze(fftSize: FreezVerbPedal.fftSize)
|
||||
freezeProcessor = freeze
|
||||
let pad: SpectralChain.Audio = SpectralChain.Audio(
|
||||
input: dry,
|
||||
fftSize: FreezVerbPedal.fftSize,
|
||||
hopSize: FreezVerbPedal.hopSize,
|
||||
stages: [.mono(freeze)]
|
||||
)
|
||||
|
||||
// Wrap the held spectrum in a diffuse reverb space. Tone brightens by *reducing* FreeVerb's
|
||||
// damping (`damping = 1 − tone`): tone 1 = bright (little damping), tone 0 = dark.
|
||||
let damping: any ValidGeneratorInput = 1.0 - $tone
|
||||
let stereoVerb: FreeVerb.Audio = FreeVerb.Audio(
|
||||
source: pad,
|
||||
roomSize: $verb,
|
||||
damping: damping,
|
||||
mix: verbMix,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
let monoVerb: SumChannels.Audio = SumChannels.Audio(input: stereoVerb, mul: stereoSumGain)
|
||||
|
||||
// The pad is audible only while a snapshot is held; the gate ramps over `rise` so engaging or
|
||||
// releasing the freeze blooms rather than clicks. Live analysis (gate 0) stays silent.
|
||||
let gate: Lag.Control = Lag.Control(input: $frozen, time: $rise)
|
||||
|
||||
// Dry always passes through; the frozen wash is layered on top.
|
||||
return dry + (monoVerb * gate)
|
||||
}
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
/// Releases any held snapshot when the engine stops — a halted engine can't keep a pad rotating.
|
||||
public override func engineDidStop() {
|
||||
releaseHold()
|
||||
}
|
||||
|
||||
/// Releases before this instance is discarded on a rig teardown.
|
||||
public override func rigWillTeardown() {
|
||||
releaseHold()
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
/// Drops any held snapshot and returns the pad to silence.
|
||||
private func releaseHold() {
|
||||
releaseGeneration += 1 // cancel any pending deferred release
|
||||
freezeProcessor?.unfreeze()
|
||||
isFrozen = false
|
||||
frozen = 0.0
|
||||
}
|
||||
|
||||
/// Clears the live generator reference and the held state so a graph rebuild starts fresh.
|
||||
/// Called at the top of ``effect(_:)``.
|
||||
private func resetForRebuild() {
|
||||
releaseGeneration += 1 // cancel any pending deferred release against the old processor
|
||||
freezeProcessor = nil
|
||||
isFrozen = false
|
||||
frozen = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MIDI transport
|
||||
|
||||
extension FreezVerbPedal: MIDITransportPedal {
|
||||
/// The Freeze footswitch is the mappable transport action.
|
||||
public var midiTransportName: String { "Freeze" }
|
||||
|
||||
public func toggleMIDITransport() { toggleFreeze() }
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public final class FullertonDeluxeAmpPedal: FullertonReverbAmpPedal {
|
||||
/// - 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 = 4.5 // slightly hotter starting point than the Twin
|
||||
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
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ 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). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.0
|
||||
/// 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).
|
||||
@@ -35,9 +35,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
private let switchOffValue: Double = 0.0
|
||||
private let switchOnValue: Double = 1.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
@@ -50,9 +48,6 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the Reverb/Drive knobs plus the Bright and Channel switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
@@ -82,7 +77,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
/// - 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 = 4.0
|
||||
gain = 5.08
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
@@ -99,7 +94,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
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: $drive, bias: driveBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
|
||||
@@ -26,14 +26,14 @@ public final class FullertonPrincetonAmpPedal: FullertonReverbAmpPedal {
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { princetonPowerDrive }
|
||||
|
||||
/// Creates a Fullerton Princeton amp.
|
||||
/// 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 Princeton", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0 // hotter still — the small combo grits up soonest
|
||||
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
|
||||
|
||||
@@ -53,8 +53,6 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
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
|
||||
private let switchOffValue: Double = 0.0
|
||||
private let switchOnValue: Double = 1.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
@@ -70,9 +68,6 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card to hold the extra reverb/tremolo knobs plus the Bright switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Fullerton Reverb amp.
|
||||
@@ -85,7 +80,7 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
/// 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 = 4.0 // headroom-rich clean default
|
||||
gain = 5.08 // headroom-rich clean default
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
// GranularReverbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Granular-cloud reverb — a diffuse, blooming wash built from a cloud of pitch-scattered grains,
|
||||
/// then reverberated.
|
||||
///
|
||||
/// The dry signal feeds an `InputGrain` cloud: short grains are sprayed from a rolling capture of
|
||||
/// the input at a chosen `density`, each smeared slightly in time and given a random pitch offset
|
||||
/// (`scatter`) around a center `pitch`. That cloud then drives a `GVerb` room tank, folded
|
||||
/// stereo→mono, so the grains bloom into a reverberant pad.
|
||||
///
|
||||
/// This is deliberately **unlike** the ``ShimmerReverbPedal``: Shimmer is a tuned feedback tank
|
||||
/// regenerating a clean, coherent octave-up tail; this is an incoherent grain cloud whose defining
|
||||
/// control is the **random** per-grain pitch `scatter`. At `pitch = 0, scatter = 0` the cloud
|
||||
/// tracks the input's pitch; raising `scatter` smears it into a broadband haze — a grain cloud, not
|
||||
/// an ascending shimmer. Set `pitch` for a tuned (e.g. octave-up) cloud, or leave it at `0` for an
|
||||
/// untuned ambient bloom.
|
||||
///
|
||||
/// The base `Pedal` `mix` sets the wet/dry blend.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `decay`: GVerb reverb time (T60) in seconds. Range `[0.2, 12.0]`.
|
||||
/// - `density`: Grain cloud density in grains per second. Range `[5, 80]`.
|
||||
/// - `grain`: Grain duration in seconds. Range `[0.02, 0.3]`.
|
||||
/// - `pitch`: Cloud center pitch in semitones. Range `[-24, 24]`; `0` = unpitched (tracks input).
|
||||
/// - `scatter`: Random per-grain pitch spread (± ratio around center). Range `[0, 0.5]`.
|
||||
/// - `damp`: High-frequency damping `[0, 1]` (0 = bright, 1 = dark).
|
||||
public final class GranularReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"A cloud of pitch-scattered grains blooming into reverb — a diffuse, incoherent wash."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// GVerb reverb time (T60) in seconds. Range [0.2, 12.0].
|
||||
@UIParam public var decay: Double = 4.0
|
||||
|
||||
/// Grain cloud density in grains per second. Range [5, 80].
|
||||
@UIParam public var density: Double = 25.0
|
||||
|
||||
/// Grain duration in seconds. Range [0.02, 0.3].
|
||||
@UIParam public var grain: Double = 0.12
|
||||
|
||||
/// Cloud center pitch in semitones. Range [-24, 24]; 0 = unpitched (tracks input).
|
||||
@UIParam public var pitch: Double = 0.0
|
||||
|
||||
/// Random per-grain pitch spread, as a fraction of the center ratio (`0.5` = ±50% of the shifted
|
||||
/// speed), added bipolar per grain. Range [0, 0.5]. Scaling by the center keeps the spread
|
||||
/// proportional, so a down-shifted cloud doesn't send grains to a negative (reverse) ratio. The
|
||||
/// defining control — higher = more smeared and incoherent.
|
||||
@UIParam public var scatter: Double = 0.15
|
||||
|
||||
/// High-frequency damping in [0, 1]. Higher = darker tail.
|
||||
@UIParam public var damp: Double = 0.5
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — the cloud wash sits under the dry note.
|
||||
private static let defaultMix: Double = 0.4
|
||||
|
||||
/// `semitones → ratio` exponent scale: `2^(s/12) = e^(s · ln2/12)`, fed to `Exp.Audio` to turn
|
||||
/// the `pitch` knob into a `pitchRatio` for the grain cloud.
|
||||
private let semitoneToRatioScale: Double = 0.05776226504666215 // ln(2) / 12
|
||||
|
||||
/// Grain read position in the rolling capture, `[0, 1]` (0 = newest). Slightly into the past so
|
||||
/// each grain has recorded material to read even at the lowest density.
|
||||
private let cloudPosition: Double = 0.1
|
||||
|
||||
/// Random spread applied to the read position per grain — a small time smear that keeps the
|
||||
/// cloud diffuse rather than a tight repeat.
|
||||
private let cloudPositionSpread: Double = 0.1
|
||||
|
||||
/// Reference output gain on the grain cloud before the tank, applied after density
|
||||
/// normalisation (see ``effect(_:)``). `InputGrain` sums every active grain, so the raw cloud
|
||||
/// level scales with the grain overlap (`density · grain`); without normalisation the extremes
|
||||
/// of those knobs (and correlated grains at low scatter) could sum to several times the input
|
||||
/// and clip. The cloud is divided by `sqrt(overlap)` (power normalisation), so turning density
|
||||
/// up thickens the texture at a roughly constant level instead of raising the peak toward
|
||||
/// clipping.
|
||||
private let cloudGain: Double = 0.5
|
||||
|
||||
/// Lower bound on the overlap estimate (`density · grain`) before the `sqrt` normalisation, so a
|
||||
/// sparse cloud (overlap < 1) is not boosted by dividing by a fraction.
|
||||
private let minOverlap: Double = 1.0
|
||||
|
||||
/// Fixed PRNG seed for the grain scheduling and pitch scatter, so a given setting renders
|
||||
/// identically every time (reproducible audio and tests).
|
||||
private let cloudSeed: UInt64 = 0x3C6E_F372_FE94_F82B
|
||||
|
||||
/// GVerb room size in metres (fixed; the grain/reverb controls shape the character instead).
|
||||
private let roomSizeMeters: Double = 40.0
|
||||
|
||||
/// GVerb early-reflection level. Low, so the wash favours the diffuse grain tail over discrete
|
||||
/// reflections.
|
||||
private let reverbEarlyLevel: Double = 0.2
|
||||
|
||||
/// GVerb late-reverb (tail) level.
|
||||
private let reverbTailLevel: Double = 0.6
|
||||
|
||||
/// GVerb dry level — how much of the grain cloud passes through the tank's dry path, keeping the
|
||||
/// grain texture itself present under its reverb.
|
||||
private let reverbDryLevel: Double = 0.3
|
||||
|
||||
/// Gain folding a decorrelated stereo pair to mono. A conservative trim leaving output headroom.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let decayRange: ClosedRange<Double> = 0.2 ... 12.0
|
||||
private let densityRange: ClosedRange<Double> = 5.0 ... 80.0
|
||||
private let grainRange: ClosedRange<Double> = 0.02 ... 0.3
|
||||
private let pitchRange: ClosedRange<Double> = -24.0 ... 24.0
|
||||
private let scatterRange: ClosedRange<Double> = 0.0 ... 0.5
|
||||
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Decay", node: $decay, range: decayRange),
|
||||
PedalKnob(label: "Density", node: $density, range: densityRange),
|
||||
PedalKnob(label: "Grain", node: $grain, range: grainRange),
|
||||
PedalKnob(label: "Pitch", node: $pitch, range: pitchRange),
|
||||
PedalKnob(label: "Scatter", node: $scatter, range: scatterRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: normalizedRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a granular-reverb 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: "Granular Reverb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: GranularReverbPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Center pitch (semitones → ratio); per-grain scatter is added bipolar around it inside
|
||||
// InputGrain.
|
||||
let centerRatio: Exp.Audio = Exp.Audio($pitch * semitoneToRatioScale)
|
||||
|
||||
// Density normalisation: divide the cloud by sqrt(grain overlap = density·grain), clamped so
|
||||
// a sparse cloud isn't boosted. Keeps the level roughly constant across the density/grain
|
||||
// knobs and bounds the peak away from clipping even with correlated grains at low scatter.
|
||||
let overlap: any ValidGeneratorInput = Max.Audio($density * $grain, minOverlap)
|
||||
let cloudNormGain: any ValidGeneratorInput = Reciprocal.Audio(Sqrt.Audio(overlap)) * cloudGain
|
||||
|
||||
// Scatter scaled by the center ratio, so the per-grain spread is proportional (±scatter of
|
||||
// the shifted speed). This keeps a down-shifted cloud off a negative/reverse ratio, which an
|
||||
// absolute offset would reach at low pitch + high scatter.
|
||||
let scaledScatter: any ValidGeneratorInput = centerRatio * $scatter
|
||||
|
||||
// The grain cloud (native stereo via per-grain pan).
|
||||
let cloud: InputGrain = InputGrain(
|
||||
input: dry,
|
||||
position: cloudPosition,
|
||||
positionSpread: cloudPositionSpread,
|
||||
duration: $grain,
|
||||
pitchRatio: centerRatio,
|
||||
pitchDispersion: scaledScatter,
|
||||
density: $density,
|
||||
seed: cloudSeed,
|
||||
mul: cloudNormGain
|
||||
)
|
||||
// Fold the cloud to mono for the tank source.
|
||||
let cloudMono: SumChannels.Audio = SumChannels.Audio(
|
||||
input: cloud,
|
||||
mul: stereoSumGain
|
||||
)
|
||||
// Reverberate the cloud (native stereo); `dryLevel` keeps the grain texture present.
|
||||
let stereoVerb: GVerb.Audio = GVerb.Audio(
|
||||
source: cloudMono,
|
||||
roomSize: roomSizeMeters,
|
||||
reverbTime: $decay,
|
||||
damping: $damp,
|
||||
earlyLevel: reverbEarlyLevel,
|
||||
tailLevel: reverbTailLevel,
|
||||
dryLevel: reverbDryLevel,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
// Fold the reverb output stereo → mono.
|
||||
return SumChannels.Audio(
|
||||
input: stereoVerb,
|
||||
mul: stereoSumGain
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
@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). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.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
|
||||
|
||||
@@ -62,9 +62,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
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 ... 30.0
|
||||
private let switchOffValue: Double = 0.0
|
||||
private let switchOnValue: Double = 1.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
@@ -84,9 +82,6 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
|
||||
public override var channelKind: PedalChannelKind { .widener }
|
||||
|
||||
/// Wider card for the reverb/chorus knobs plus the Bright and Chorus switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Jazz Clean amp.
|
||||
@@ -96,7 +91,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
/// - 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 = 3.0 // clean, low-gain solid-state default
|
||||
gain = 4.23 // clean, low-gain solid-state default
|
||||
cab = 6.0 // Full-Range (FRFR) — the hi-fi, least-coloured voice
|
||||
}
|
||||
|
||||
@@ -138,7 +133,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
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: $drive, bias: driveBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
// MARK: - Hooks
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
// KarplusResonatorPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Sympathetic-string resonator — a bank of tuned Karplus-Strong strings the guitar excites.
|
||||
///
|
||||
/// A sitar's or a sarangi's sympathetic strings are always coupled to the played note: pluck, and
|
||||
/// a fixed set of tuned strings sing along, ringing on after each note. This pedal models that with
|
||||
/// four `KarplusStrong` strings tuned to a chord above a **Tune** root. An amplitude envelope of
|
||||
/// your playing drives a Schmitt gate whose rising edge plucks the whole bank — capturing the loud
|
||||
/// note onset — and the strings then ring on at their own tuned pitches with their own decay: the
|
||||
/// sympathetic shimmer blooming out of the note's tail.
|
||||
///
|
||||
/// Distinct from a reverb or a delay: the tails are **pitched** to the Tune root's chord, not a
|
||||
/// diffuse wash or a repeat of what you played. Distinct from the ``PolyOctavePedal`` (which pitch-
|
||||
/// shifts your note in real time): here the resonators have their own fixed tuning and their own
|
||||
/// decay, so holding a drone root under a moving line is the whole point.
|
||||
///
|
||||
/// Wraps Lyrebird's `KarplusStrong` run fully wet; the base `Pedal` `mix` sets the blend of the
|
||||
/// ringing bank against the dry note (an even mix by default).
|
||||
///
|
||||
/// The root can be set two ways, chosen by the **Tuning** switch: **Free** sweeps the continuous
|
||||
/// **Tune** Hz knob; **Pitched** tunes the root to a musical note chosen with a single **Root**
|
||||
/// selector that steps through every semitone from E1 up to E5 (the top of the treble staff),
|
||||
/// captioned by name and octave (`E1`, `A3`, `E5`) in equal temperament (A4 = 440 Hz, so A3 = 220).
|
||||
/// In **Pitched** the Tune Hz knob is ignored; in **Free** the Root selector is hidden.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `tune`: Root frequency of the string bank in Hz (used in **Free** tuning). Range `[40, 660]`
|
||||
/// (up to E5, the top of the treble staff).
|
||||
/// - `sustain`: Ring length — the string feedback. Range `[0, 1]` → feedback `[0.9, 0.999]`.
|
||||
/// - `tone`: Brightness of the strings. Range `[0, 1]`: `0` = dark/woody, `1` = bright/metallic.
|
||||
/// - `sensitivity`: How readily playing plucks the strings. Range `[0, 1]`: higher = lower trigger
|
||||
/// threshold, so quieter notes still excite the bank.
|
||||
///
|
||||
/// ## Switch
|
||||
/// - `tuning`: Root source — **Free** (the Tune Hz knob) or **Pitched** (the Root selector). Rebuilds.
|
||||
///
|
||||
/// ## Selectors (all rebuild on change)
|
||||
/// - `voicing`: Chord the four strings are tuned to: Drone, Octaves, Shimmer.
|
||||
/// - `pitchedNote`: Root note in **Pitched** tuning — a chromatic stop from E1 to E5 (shown only in
|
||||
/// **Pitched** mode). The value is the MIDI note number; A3 (MIDI 57) = 220 Hz.
|
||||
public final class KarplusResonatorPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"A bank of tuned strings that ring along with your note — sympathetic sitar shimmer."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Root frequency of the string bank in Hz (Free tuning). Range `[40, 660]` — up to E5.
|
||||
@UIParam public var tune: Double = 82.41
|
||||
|
||||
/// Ring length — the string feedback. Range `[0, 1]` → feedback `[0.9, 0.999]`.
|
||||
@UIParam public var sustain: Double = 0.7
|
||||
|
||||
/// Brightness of the strings. Range `[0, 1]`: `0` = dark/woody, `1` = bright/metallic.
|
||||
@UIParam public var tone: Double = 0.4
|
||||
|
||||
/// How readily playing plucks the strings. Range `[0, 1]`: higher = lower trigger threshold.
|
||||
@UIParam public var sensitivity: Double = 0.5
|
||||
|
||||
/// Selected voicing index into ``voicings``. A knob-picker selector; rebuilds on change.
|
||||
@UIParam public var voicing: Double = 0.0
|
||||
|
||||
/// Root-tuning source: `0` = Free (the Tune Hz knob), `1` = Pitched (the Root selector). A
|
||||
/// two-position switch; rebuilds on change.
|
||||
@UIParam public var tuning: Double = 0.0
|
||||
|
||||
/// Root note in Pitched tuning, as a MIDI note number. A chromatic selector stepping E1 (MIDI 28)
|
||||
/// to E5 (MIDI 76); rebuilds on change. Defaults to A3 (MIDI 57) = 220 Hz.
|
||||
@UIParam public var pitchedNote: Double = 57.0 // A3 = 220 Hz by default
|
||||
|
||||
// MARK: - Voicings
|
||||
|
||||
/// A named chord the four strings are tuned to, as frequency ratios of the Tune root.
|
||||
private struct Voicing {
|
||||
let title: String
|
||||
let ratios: [Double]
|
||||
}
|
||||
|
||||
/// Fixed string tunings. Each has exactly ``stringCount`` ratios of the Tune root.
|
||||
/// - Drone: root, fifth, octave, octave+fifth — the classic sympathetic drone.
|
||||
/// - Octaves: two octaves down through two up — a wide octave stack.
|
||||
/// - Shimmer: two octave pairs detuned a few cents apart — slow beating for a chorused ring.
|
||||
private static let voicings: [Voicing] = [
|
||||
Voicing(title: "Drone", ratios: [1.0, 1.5, 2.0, 3.0]),
|
||||
Voicing(title: "Octaves", ratios: [0.5, 1.0, 2.0, 4.0]),
|
||||
Voicing(title: "Shimmer", ratios: [1.0, 1.005, 2.0, 1.99]),
|
||||
]
|
||||
|
||||
/// Number of strings in the bank — fixed, so the delay-line allocation is structural.
|
||||
private static let stringCount: Int = 4
|
||||
|
||||
// MARK: - Note tuning
|
||||
|
||||
/// Tuning-source values written by the ``tuning`` switch.
|
||||
private static let tuningFreeValue: Double = 0.0
|
||||
private static let tuningPitchedValue: Double = 1.0
|
||||
|
||||
/// Pitch-class captions, index `0 … 11` (C … B).
|
||||
private static let pitchClassNames: [String] = [
|
||||
"C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B",
|
||||
]
|
||||
|
||||
/// Equal-temperament reference: A4 = 440 Hz is MIDI note 69, 12 semitones per octave.
|
||||
private static let referenceFrequency: Double = 440.0
|
||||
private static let referenceMidiNote: Int = 69
|
||||
private static let semitonesPerOctave: Int = 12
|
||||
|
||||
/// Lowest Pitched root — E1 (MIDI 28, ≈ 41 Hz), a low bass E mirroring the Free knob's floor.
|
||||
private static let lowestMidiNote: Int = 28
|
||||
/// Highest Pitched root — E5 (MIDI 76, ≈ 659 Hz), the top space of the treble staff.
|
||||
private static let highestMidiNote: Int = 76
|
||||
|
||||
/// Equal-tempered frequency in Hz for a MIDI note number, using A4 = 440 Hz (MIDI 69). A3
|
||||
/// (MIDI 57) → 220 Hz; C4 (middle C, MIDI 60) → 261.63 Hz.
|
||||
///
|
||||
/// - Parameter midi: MIDI note number.
|
||||
/// - Returns: The note's frequency in Hz.
|
||||
static func frequency(forMidiNote midi: Int) -> Double {
|
||||
let semitonesFromReference: Double = Double(midi - referenceMidiNote) / Double(semitonesPerOctave)
|
||||
return referenceFrequency * pow(2.0, semitonesFromReference)
|
||||
}
|
||||
|
||||
/// Name-plus-octave caption for a MIDI note number in scientific-pitch convention (MIDI 60 = C4),
|
||||
/// e.g. MIDI 57 → `"A3"`, MIDI 76 → `"E5"`.
|
||||
///
|
||||
/// - Parameter midi: MIDI note number (expected `lowestMidiNote … highestMidiNote`).
|
||||
/// - Returns: The note's caption.
|
||||
static func caption(forMidiNote midi: Int) -> String {
|
||||
let pitchClass: Int = ((midi % semitonesPerOctave) + semitonesPerOctave) % semitonesPerOctave
|
||||
let octaveNumber: Int = midi / semitonesPerOctave - 1
|
||||
return pitchClassNames[pitchClass] + String(octaveNumber)
|
||||
}
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Pedal returns the bank fully wet; the base `mix` blends it against the dry note. An even mix
|
||||
/// so the sympathetic ring sits under the dry signal rather than replacing it.
|
||||
private static let defaultMix: Double = 0.5
|
||||
|
||||
/// Maximum delay time for each string, in seconds — sizes the Karplus delay line. Covers the
|
||||
/// lowest resonator across both tuning modes: the lowest root is ≈ 40 Hz (Free floor, or the
|
||||
/// Pitched E1 ≈ 41 Hz), and the Octaves voicing drops a string a full octave below that
|
||||
/// (ratio 0.5 → ≈ 20 Hz, a ~0.05 s period), so `0.08 s` leaves margin. `KarplusStrong` clamps any lower
|
||||
/// frequency to the line length anyway.
|
||||
private let maxStringDelayTime: Double = 0.08
|
||||
|
||||
/// Feedback (ring length) mapped from `sustain = 0`: a short, plucky decay.
|
||||
private let feedbackMin: Double = 0.9
|
||||
|
||||
/// Feedback mapped from `sustain = 1`: a very long, near-infinite ring. Kept just under `1.0`
|
||||
/// so the bank always decays rather than running away.
|
||||
private let feedbackMax: Double = 0.999
|
||||
|
||||
/// One-pole coefficient mapped from `tone = 0`: classic Karplus averaging — dark and woody.
|
||||
private let coefDark: Double = 0.5
|
||||
|
||||
/// One-pole coefficient mapped from `tone = 1`: negative, for a bright, metallic sitar-like
|
||||
/// timbre. Kept well inside `|coef| < 1` so the feedback path never grows.
|
||||
private let coefBright: Double = -0.2
|
||||
|
||||
/// Schmitt switch-on threshold on the input envelope at `sensitivity = 0` — the least sensitive
|
||||
/// setting, where only loud notes feed the strings.
|
||||
private let gateHiThresholdLow: Double = 0.25
|
||||
|
||||
/// Schmitt switch-on threshold at `sensitivity = 1` — the most sensitive setting, where even
|
||||
/// quiet notes feed the strings.
|
||||
private let gateHiThresholdHigh: Double = 0.01
|
||||
|
||||
/// Fraction of the switch-on threshold used for the switch-off threshold, giving the gate
|
||||
/// hysteresis so it doesn't chatter around a single level.
|
||||
private let gateLoFactor: Double = 0.5
|
||||
|
||||
/// Envelope-follower attack for the gate detector, in seconds — fast, to catch note onsets.
|
||||
private let envAttackTime: Double = 0.005
|
||||
|
||||
/// Envelope-follower release for the gate detector, in seconds — slow enough that the gate holds
|
||||
/// through a note and only drops once it has genuinely decayed, at which point the bank rings.
|
||||
private let envReleaseTime: Double = 0.08
|
||||
|
||||
/// Output scale on the summed four-string bank — `1/stringCount`, the fully-coherent-sum bound.
|
||||
/// The Octaves and Shimmer voicings share string periods, so a full-scale pluck can momentarily
|
||||
/// align all four; this ceiling keeps the summed bank at or below the dry peak with no limiter.
|
||||
private let bankGain: Double = 0.25
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
/// Free-mode root range in Hz. Upper bound reaches E5 (≈ 659 Hz, the top of the treble staff);
|
||||
/// lower bound sits around a low bass E.
|
||||
private let tuneRange: ClosedRange<Double> = 40.0 ... 660.0
|
||||
private let unitRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Tune", node: $tune, range: tuneRange),
|
||||
PedalKnob(label: "Sustain", node: $sustain, range: unitRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: unitRange),
|
||||
PedalKnob(label: "Sensitivity", node: $sensitivity, range: unitRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Switch
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
// Picks the root source. Rebuilds: it swaps the build-time root (live Tune knob vs a fixed
|
||||
// note Hz) and toggles whether the Root selector is shown.
|
||||
PedalSwitch(
|
||||
label: "Tuning",
|
||||
node: $tuning,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Free", value: KarplusResonatorPedal.tuningFreeValue),
|
||||
PedalSwitch.Option(title: "Pitched", value: KarplusResonatorPedal.tuningPitchedValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Selectors
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
let voicingStops: [PedalSelectorKnob.Stop] = KarplusResonatorPedal.voicings.enumerated().map { index, voicing in
|
||||
PedalSelectorKnob.Stop(title: voicing.title, value: Double(index))
|
||||
}
|
||||
// Voicing always shows and stays at selector index 0 — so a preset's positional selector
|
||||
// values line up regardless of tuning mode. The Root selector is appended only in Pitched
|
||||
// mode (and `tuning` is restored in the switch pass before this one, so the count matches).
|
||||
var selectors: [PedalSelectorKnob] = [
|
||||
// Voicing ratios size each string's delay line, so it is a build-time structural choice.
|
||||
PedalSelectorKnob(label: "Voicing", node: $voicing, stops: voicingStops, rebuildsOnChange: true),
|
||||
]
|
||||
if Int(tuning.rounded()) == Int(KarplusResonatorPedal.tuningPitchedValue) {
|
||||
let rootStops: [PedalSelectorKnob.Stop] =
|
||||
(KarplusResonatorPedal.lowestMidiNote ... KarplusResonatorPedal.highestMidiNote).map { midi in
|
||||
PedalSelectorKnob.Stop(title: KarplusResonatorPedal.caption(forMidiNote: midi), value: Double(midi))
|
||||
}
|
||||
// The chosen note sets a fixed root Hz folded into the graph at build time, so it rebuilds.
|
||||
selectors.append(
|
||||
PedalSelectorKnob(label: "Root", node: $pitchedNote, stops: rootStops, rebuildsOnChange: true)
|
||||
)
|
||||
}
|
||||
return selectors
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Karplus-Strong sympathetic-resonator 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: "Karplus Resonator",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: KarplusResonatorPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// `voicing` is read as a plain value at build time; the board rebuilds when it changes (the
|
||||
// ratios size each string's delay line). All other controls stay live.
|
||||
let index: Int = min(max(0, Int(voicing.rounded())), KarplusResonatorPedal.voicings.count - 1)
|
||||
let ratios: [Double] = KarplusResonatorPedal.voicings[index].ratios
|
||||
|
||||
// Root source (read at build time, so switching rebuilds). Free: the live Tune Hz knob.
|
||||
// Pitched: a fixed equal-tempered frequency from the Root note selector.
|
||||
let rootFreq: any ValidGeneratorInput
|
||||
if Int(tuning.rounded()) == Int(KarplusResonatorPedal.tuningPitchedValue) {
|
||||
let midiNote: Int = min(
|
||||
max(KarplusResonatorPedal.lowestMidiNote, Int(pitchedNote.rounded())),
|
||||
KarplusResonatorPedal.highestMidiNote
|
||||
)
|
||||
rootFreq = KarplusResonatorPedal.frequency(forMidiNote: midiNote)
|
||||
} else {
|
||||
rootFreq = $tune
|
||||
}
|
||||
|
||||
// Pluck trigger: track the input envelope, then a Schmitt trigger turns it into a 0/1 play
|
||||
// detector. Its rising edge (you start a note) plucks the whole bank — Karplus fills each
|
||||
// delay line from the loud onset — and the strings then ring on at their tuned pitches. The
|
||||
// hysteresis means the gate must fall back below the off-threshold before the next note can
|
||||
// re-pluck, so a single sustained note plucks once rather than chattering.
|
||||
let env: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: dry,
|
||||
attackTime: envAttackTime,
|
||||
releaseTime: envReleaseTime
|
||||
)
|
||||
// sensitivity [0, 1] → switch-on threshold [gateHiThresholdLow, gateHiThresholdHigh]
|
||||
// (higher sensitivity = lower threshold); switch-off threshold is a fixed fraction below it.
|
||||
let hiSpan: Double = gateHiThresholdHigh - gateHiThresholdLow
|
||||
let hiThreshold: any ValidGeneratorInput = ($sensitivity * hiSpan) + gateHiThresholdLow
|
||||
let loThreshold: any ValidGeneratorInput = hiThreshold * gateLoFactor
|
||||
let trigger: Schmidt.Audio = Schmidt.Audio(input: env, lo: loThreshold, hi: hiThreshold)
|
||||
|
||||
// sustain [0, 1] → feedback [feedbackMin, feedbackMax]; tone [0, 1] → coef [coefDark, coefBright].
|
||||
let feedbackSpan: Double = feedbackMax - feedbackMin
|
||||
let voicedFeedback: any ValidGeneratorInput = ($sustain * feedbackSpan) + feedbackMin
|
||||
let coefSpan: Double = coefBright - coefDark
|
||||
let voicedCoef: any ValidGeneratorInput = ($tone * coefSpan) + coefDark
|
||||
|
||||
// Four tuned strings, each a KarplusStrong plucked by the shared trigger from the dry onset.
|
||||
var bank: any ValidGeneratorInput = KarplusStrong.Audio(
|
||||
exciter: dry,
|
||||
trigger: trigger,
|
||||
freq: rootFreq * ratios[0],
|
||||
feedback: voicedFeedback,
|
||||
coef: voicedCoef,
|
||||
sampleRate: sampleRate,
|
||||
maxDelayTime: maxStringDelayTime
|
||||
)
|
||||
for stringIndex: Int in 1 ..< KarplusResonatorPedal.stringCount {
|
||||
let string: KarplusStrong.Audio = KarplusStrong.Audio(
|
||||
exciter: dry,
|
||||
trigger: trigger,
|
||||
freq: rootFreq * ratios[stringIndex],
|
||||
feedback: voicedFeedback,
|
||||
coef: voicedCoef,
|
||||
sampleRate: sampleRate,
|
||||
maxDelayTime: maxStringDelayTime
|
||||
)
|
||||
bank = bank + string
|
||||
}
|
||||
|
||||
return bank * bankGain
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -31,10 +44,6 @@ public final class MutantPedal: Pedal {
|
||||
"Envelope-following auto-wah / funk filter that opens with your picking."
|
||||
}
|
||||
|
||||
/// Double-width so the two switches — Sweep (2-way) and the 3-way Mode — sit side by side
|
||||
/// without cramping now that switches lay out horizontally.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
|
||||
@@ -49,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.
|
||||
@@ -73,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
|
||||
|
||||
@@ -88,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),
|
||||
@@ -109,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) {
|
||||
@@ -126,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),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -157,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,
|
||||
@@ -167,8 +221,8 @@ public final class MutantPedal: Pedal {
|
||||
peak: $resonance,
|
||||
freqLo: freqLo,
|
||||
freqHi: freqHi,
|
||||
attackTime: attackTime,
|
||||
releaseTime: releaseTime
|
||||
attackTime: $attack,
|
||||
releaseTime: $release
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,18 +11,19 @@ import LyrebirdUI
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry ─┬─────────────────────────────────────────────────────────┐
|
||||
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │
|
||||
/// → LinLin(0…1 → floor…1) │
|
||||
/// → Lag(smooth) ───────────── × ──┴→ mono out
|
||||
/// detector(dry) → Schmidt(lo: thr, hi: thr×ratio) → LinLin(0…1 → floor…1) → LagUpDown(open/close)
|
||||
/// Peak: AmplitudeFollower(|x|)
|
||||
/// RMS: √Lag(x²) out = dry × smoothed-gain
|
||||
/// ```
|
||||
///
|
||||
/// 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.
|
||||
/// The **detector** tracks the dry signal level — either peak (`|x|`) or RMS (√mean-square). 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 **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 +36,10 @@ 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`.
|
||||
/// - detector: Level-detection mode (switch). `0` = Peak (`|x|`), `1` = RMS (√mean-square).
|
||||
/// Defaults to RMS (`1`).
|
||||
public final class NoiseGatePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -50,23 +55,51 @@ 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
|
||||
|
||||
/// Detector mode: `0` = **Peak** (tracks `|x|`), `1` = **RMS** (tracks √mean-square). RMS follows
|
||||
/// perceived loudness, so the threshold decision — and the level at which the gate closes — lines
|
||||
/// up with how loud the note actually is, instead of riding the waveform's peaks. Defaults to RMS.
|
||||
@UIParam public var detector: Double = 1.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the gate sits in-line.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// `detector` value selecting the peak follower.
|
||||
private let detectorPeakValue: Double = 0.0
|
||||
|
||||
/// `detector` value selecting the RMS follower.
|
||||
private let detectorRMSValue: Double = 1.0
|
||||
|
||||
/// Envelope-follower attack time, in seconds — fast so the gate opens promptly on a note.
|
||||
private let detectAttack: Double = 0.002
|
||||
|
||||
/// Envelope-follower release time, in seconds — slower so the gate holds through decay.
|
||||
private let detectRelease: Double = 0.05
|
||||
|
||||
/// RMS integration window (one-pole averaging time, in seconds) for the RMS detector. Long enough
|
||||
/// to average out the waveform's per-cycle ripple so the envelope reflects mean-square level, not
|
||||
/// instantaneous peaks.
|
||||
private let rmsWindow: Double = 0.02
|
||||
|
||||
/// Open-threshold multiplier. The gate opens above `threshold × openRatio` and closes
|
||||
/// 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 +116,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 +129,33 @@ 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),
|
||||
]
|
||||
}
|
||||
|
||||
/// Detector-mode switch (Peak / RMS). Appended as the gate's only switch, so a gate saved before
|
||||
/// it existed (empty `switchValues`) loads with the RMS default — no migration.
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Detector",
|
||||
node: $detector,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Peak", value: detectorPeakValue),
|
||||
PedalSwitch.Option(title: "RMS", value: detectorRMSValue),
|
||||
],
|
||||
// Switching detector changes which follower is instantiated, so rebuild the board.
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a noise-gate pedal.
|
||||
@@ -118,12 +184,26 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Gated mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Track the dry signal's amplitude envelope.
|
||||
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: dry,
|
||||
attackTime: detectAttack,
|
||||
releaseTime: detectRelease
|
||||
)
|
||||
// Build the chosen detector only. `detector` is a `rebuildsOnChange` switch, so it is read
|
||||
// here as a plain value at build time (the board rebuilds when it is toggled) — no live
|
||||
// node-select in the graph.
|
||||
let envelope: any ValidGeneratorInput
|
||||
if detector >= detectorRMSValue {
|
||||
// RMS detector: √(symmetric one-pole average of x²). The averaging window must be
|
||||
// symmetric — a fast attack would track the *squared peaks* and collapse back to peak
|
||||
// detection — so a plain `Lag` over `rmsWindow` recovers the mean square, giving a
|
||||
// loudness-tracking envelope roughly 3 dB below the peak for a steady tone.
|
||||
let squared: any ValidGeneratorInput = dry * dry
|
||||
let meanSquare: Lag.Audio = Lag.Audio(input: squared, time: rmsWindow)
|
||||
envelope = Sqrt.Audio(meanSquare)
|
||||
} else {
|
||||
// Peak detector: a one-pole follower of |x| (fast attack, slower release).
|
||||
envelope = AmplitudeFollower.Audio(
|
||||
in: dry,
|
||||
attackTime: detectAttack,
|
||||
releaseTime: detectRelease
|
||||
)
|
||||
}
|
||||
|
||||
// Hysteretic open/closed gate: opens above threshold×openRatio, closes below threshold.
|
||||
let gate: Schmidt.Audio = Schmidt.Audio(
|
||||
@@ -141,10 +221,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
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
// PolyOctavePedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Polyphonic octave generator in the EHX POG mould.
|
||||
///
|
||||
/// Stacks four fixed pitch-shifted voices — two octaves down, one octave down, one octave up, two
|
||||
/// octaves up — under the dry note, each with its own level, so a single note becomes an
|
||||
/// organ-like chord of octaves. Unlike the ``WhammyPedal`` (one voice swept by an expression
|
||||
/// pedal), every voice sounds at once at a **fixed** interval, and because the ratios are exact
|
||||
/// powers of two the shifter needs no pitch tracking — chords shift as cleanly as single notes.
|
||||
///
|
||||
/// Each voice is a `PitchShift` — Lyrebird's four-head SOLA shifter, whose `pitchRatio` clamps to
|
||||
/// `[0.25, 4.0]`, i.e. exactly ±2 octaves, so every voice here is a single stage (no cascade).
|
||||
///
|
||||
/// The five voice levels sum without an internal limiter (as with the OC-2-style
|
||||
/// ``BassOctaverPedal``), so driving several to full can push the sum above unity; the pedal's
|
||||
/// `level` knob and the board output master set the final gain, like a real mixer's channel sum.
|
||||
///
|
||||
/// A low-pass **Tone** control tames the shifted voices (the dry stays untouched), and an
|
||||
/// **Attack** control adds the POG's signature volume **swell**: turned up, the octave voices fade
|
||||
/// in after each note instead of sounding instantly, for a bowed / synth-pad bloom. The swell is a
|
||||
/// "slow-gear" gain — the ratio of a slow envelope follower to a fast one — so at `Attack = 0` the
|
||||
/// two followers are identical and the gain is unity (voices respond instantly), and the swell
|
||||
/// never depends on how loud you play.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `subTwo`: −2 octave voice level in `[0, 1]`.
|
||||
/// - `subOne`: −1 octave voice level in `[0, 1]`.
|
||||
/// - `upOne`: +1 octave voice level in `[0, 1]`.
|
||||
/// - `upTwo`: +2 octave voice level in `[0, 1]`.
|
||||
/// - `dry`: Dry (direct) signal level in `[0, 1]`.
|
||||
/// - `attack`: Octave-voice swell in `[0, 1]`. `0` = instant; higher = slower volume bloom.
|
||||
/// - `tone`: Octave-voice low-pass cutoff in Hz. Range `[500, 12000]`.
|
||||
public final class PolyOctavePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Stacks fixed octave voices under your note — organ-like, with a volume swell."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// −2 octave voice level in `[0, 1]`.
|
||||
@UIParam public var subTwo: Double = 0.0
|
||||
|
||||
/// −1 octave voice level in `[0, 1]`.
|
||||
@UIParam public var subOne: Double = 0.0
|
||||
|
||||
/// +1 octave voice level in `[0, 1]`.
|
||||
@UIParam public var upOne: Double = 0.5
|
||||
|
||||
/// +2 octave voice level in `[0, 1]`.
|
||||
@UIParam public var upTwo: Double = 0.0
|
||||
|
||||
/// Dry (direct) signal level in `[0, 1]`.
|
||||
@UIParam public var dry: Double = 1.0
|
||||
|
||||
/// Octave-voice swell in `[0, 1]`. `0` = instant; higher = slower volume bloom after each note.
|
||||
@UIParam public var attack: Double = 0.0
|
||||
|
||||
/// Octave-voice low-pass cutoff in Hz. Range `[500, 12000]`.
|
||||
@UIParam public var tone: Double = 8000.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Pedal blends everything internally via the level knobs, so the base wet/dry stays fully wet.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Fixed `PitchShift` playback ratios for the four voices (exact powers of two).
|
||||
private let subTwoRatio: Double = 0.25 // −2 octaves
|
||||
private let subOneRatio: Double = 0.5 // −1 octave
|
||||
private let upOneRatio: Double = 2.0 // +1 octave
|
||||
private let upTwoRatio: Double = 4.0 // +2 octaves
|
||||
|
||||
/// Grain window for each `PitchShift`, in seconds. A touch over the shifter's `0.1` default to
|
||||
/// soften the periodic four-head comb without adding audible lag.
|
||||
private let voiceWindowSize: Double = 0.11
|
||||
|
||||
/// Per-head timing jitter for each `PitchShift`, in seconds. Breaks the fixed-grid comb; kept
|
||||
/// small so the voices stay tight.
|
||||
private let voiceTimeDispersion: Double = 0.02
|
||||
|
||||
/// Fixed PRNG seeds, one per voice, so a given setting renders identically every time
|
||||
/// (reproducible audio and exact-pitch tests). Distinct per voice so their grain dispersion
|
||||
/// sequences decorrelate instead of jittering in lockstep.
|
||||
private let subTwoSeed: UInt64 = 0x9E37_79B9_7F4A_7C15
|
||||
private let subOneSeed: UInt64 = 0xC2B2_AE3D_27D4_EB4F
|
||||
private let upOneSeed: UInt64 = 0x1656_67B1_9E37_79F9
|
||||
private let upTwoSeed: UInt64 = 0x2545_F491_4F6C_DD1D
|
||||
|
||||
/// Fast envelope-follower attack for the swell's denominator, in seconds — near-instant, so it
|
||||
/// tracks note onsets tightly. Also the floor of the mapped slow attack, so `attack = 0` makes
|
||||
/// the two followers identical and the swell gain unity (neutral).
|
||||
private let swellFastAttack: Double = 0.005
|
||||
|
||||
/// Slowest envelope-follower attack the `attack` knob maps to, in seconds (at `attack = 1`).
|
||||
private let swellMaxAttack: Double = 1.5
|
||||
|
||||
/// Shared release time for both swell followers, in seconds. Equal on both so only the attack
|
||||
/// differs between them.
|
||||
private let swellRelease: Double = 0.15
|
||||
|
||||
/// Floor added to the swell denominator before the reciprocal, so a silent input (both
|
||||
/// followers near zero) cannot divide by zero. Kept well below any real signal level
|
||||
/// (`1e-6` ≈ −120 dB) so the neutral gain stays ~1 across the whole playing range — a larger
|
||||
/// floor would pull the `attack = 0` gain toward `0.5` for quiet input.
|
||||
private let swellDenomFloor: Double = 1.0e-6
|
||||
|
||||
/// Clamp bounds for the swell gain. With equal release times the two followers track in
|
||||
/// lockstep once settled, so the ratio stays `≤ 1` in normal use (it dips below `1` only during
|
||||
/// the attack ramp, when the slow follower lags); the ceiling is a defensive guard against a
|
||||
/// transient overshoot from the reciprocal, and the floor keeps the gain non-negative.
|
||||
private let swellGainFloor: Double = 0.0
|
||||
private let swellGainCeil: Double = 1.0
|
||||
|
||||
/// Butterworth Q (no resonant peak) for the tone low-pass.
|
||||
private let toneQ: Double = 0.707
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let levelRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let attackRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let toneRange: ClosedRange<Double> = 500.0 ... 12000.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "-2 Oct", node: $subTwo, range: levelRange),
|
||||
PedalKnob(label: "-1 Oct", node: $subOne, range: levelRange),
|
||||
PedalKnob(label: "+1 Oct", node: $upOne, range: levelRange),
|
||||
PedalKnob(label: "+2 Oct", node: $upTwo, range: levelRange),
|
||||
PedalKnob(label: "Dry", node: $dry, range: levelRange),
|
||||
PedalKnob(label: "Attack", node: $attack, range: attackRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a polyphonic octave pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Poly Octave",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: PolyOctavePedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Four fixed-ratio voices. Each ratio is within PitchShift's ±2-octave clamp, so a single
|
||||
// stage suffices (no cascade, unlike the Whammy's 3-octave Dive Bomb).
|
||||
let subTwoVoice: PitchShift.Audio = makeVoice(dry: dry, ratio: subTwoRatio, seed: subTwoSeed)
|
||||
let subOneVoice: PitchShift.Audio = makeVoice(dry: dry, ratio: subOneRatio, seed: subOneSeed)
|
||||
let upOneVoice: PitchShift.Audio = makeVoice(dry: dry, ratio: upOneRatio, seed: upOneSeed)
|
||||
let upTwoVoice: PitchShift.Audio = makeVoice(dry: dry, ratio: upTwoRatio, seed: upTwoSeed)
|
||||
|
||||
// Octave bus: each voice scaled by its level knob.
|
||||
let octaveBus: any ValidGeneratorInput =
|
||||
(subTwoVoice * $subTwo)
|
||||
+ (subOneVoice * $subOne)
|
||||
+ (upOneVoice * $upOne)
|
||||
+ (upTwoVoice * $upTwo)
|
||||
|
||||
// Swell: a "slow-gear" gain applied to the octave bus only (the dry stays immediate).
|
||||
let swelled: any ValidGeneratorInput = octaveBus * swellGain(dry: dry)
|
||||
|
||||
// Tone shapes the shifted voices, not the dry.
|
||||
let octaveToned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||
input: swelled,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
|
||||
return (dry * $dry) + octaveToned
|
||||
}
|
||||
|
||||
/// Builds one fixed-ratio octave voice.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - dry: Dry input to shift.
|
||||
/// - ratio: Fixed playback ratio (power of two) within PitchShift's `[0.25, 4.0]` clamp.
|
||||
/// - seed: Per-voice PRNG seed for reproducible grain dispersion.
|
||||
/// - Returns: The pitch-shifted voice (pre-level).
|
||||
private func makeVoice(
|
||||
dry: any ValidGeneratorInput,
|
||||
ratio: Double,
|
||||
seed: UInt64
|
||||
) -> PitchShift.Audio {
|
||||
PitchShift.Audio(
|
||||
input: dry,
|
||||
pitchRatio: ratio,
|
||||
windowSize: voiceWindowSize,
|
||||
timeDispersion: voiceTimeDispersion,
|
||||
seed: seed
|
||||
)
|
||||
}
|
||||
|
||||
/// Builds the octave-voice swell gain: the ratio of a slow envelope follower to a fast one,
|
||||
/// clamped to `[0, 1]`. Unity when `attack = 0` (both followers identical), dipping and then
|
||||
/// recovering as `attack` rises, so the voices bloom in after each onset independent of level.
|
||||
///
|
||||
/// - Parameter dry: Dry input the swell tracks.
|
||||
/// - Returns: A `[0, 1]` gain to multiply the octave bus by.
|
||||
private func swellGain(dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// attack [0, 1] → slow-follower attack [swellFastAttack, swellMaxAttack] seconds.
|
||||
let attackSpan: Double = swellMaxAttack - swellFastAttack
|
||||
let slowAttackTime: any ValidGeneratorInput = ($attack * attackSpan) + swellFastAttack
|
||||
|
||||
let fastEnv: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: dry,
|
||||
attackTime: swellFastAttack,
|
||||
releaseTime: swellRelease
|
||||
)
|
||||
let slowEnv: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: dry,
|
||||
attackTime: slowAttackTime,
|
||||
releaseTime: swellRelease
|
||||
)
|
||||
|
||||
// gain = slowEnv / (fastEnv + floor), clamped to [0, 1].
|
||||
let denom: any ValidGeneratorInput = fastEnv + swellDenomFloor
|
||||
let ratio: any ValidGeneratorInput = slowEnv * Reciprocal.Audio(denom)
|
||||
return Clip.Audio(ratio, lo: swellGainFloor, hi: swellGainCeil)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// ReverseReverbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Reverse reverb — a backwards-swelling ambience, the "sucked-in" pre-verb of ambient and
|
||||
/// shoegaze records.
|
||||
///
|
||||
/// The dry signal is first run through a segmented ``ReverseDelay``: it is captured in fixed-length
|
||||
/// segments and each is played back reversed, so a note's natural decay becomes a swell that rises
|
||||
/// *into* the note. That reversed signal then feeds a `GVerb` room tank, so the backwards swell
|
||||
/// arrives wrapped in a diffuse reverberant wash rather than as a dry backwards note. The result is
|
||||
/// distinct from the plain ``ReverseDelayPedal`` (no reverb) and from a forward ``RoomReverbPedal``
|
||||
/// (energy that follows the note instead of swelling up to it).
|
||||
///
|
||||
/// `Time` sets the reverse segment length (and so the pre-delay before each swell); `Decay`, `Size`,
|
||||
/// and `Damp` shape the GVerb tail. The tank runs natively in stereo and is folded to mono. The
|
||||
/// base `Pedal` `mix` sets the wet/dry blend, so your live note stays up front while the reversed
|
||||
/// wash sits under it. Latency is one segment — a note's reversed swell appears up to `Time` seconds
|
||||
/// after you play it.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `time`: Reverse segment length in seconds. Range `[0.1, 2.0]`. Also the swell pre-delay.
|
||||
/// - `decay`: GVerb reverb time (T60) in seconds. Range `[0.2, 12.0]`.
|
||||
/// - `size`: GVerb room size in metres. Range `[1, 100]`.
|
||||
/// - `damp`: High-frequency damping `[0, 1]` (0 = bright, 1 = dark).
|
||||
public final class ReverseReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Backwards-swelling reverb — notes bloom in reverse, wrapped in a diffuse wash."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Reverse segment length in seconds (also the swell pre-delay). Range [0.1, 2.0].
|
||||
@UIParam public var time: Double = 0.5
|
||||
|
||||
/// GVerb reverb time (T60) in seconds. Range [0.2, 12.0].
|
||||
@UIParam public var decay: Double = 3.0
|
||||
|
||||
/// GVerb room size in metres. Range [1, 100].
|
||||
@UIParam public var size: Double = 30.0
|
||||
|
||||
/// High-frequency damping in [0, 1]. Higher = darker tail.
|
||||
@UIParam public var damp: Double = 0.5
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — the reversed wash sits under the dry note.
|
||||
private static let defaultMix: Double = 0.4
|
||||
|
||||
/// Maximum reverse segment length the `ReverseDelay` buffers are allocated for, in seconds.
|
||||
/// Matches the top of the `time` range so a full-length segment never clamps.
|
||||
private let maxReverseTime: Double = 2.0
|
||||
|
||||
/// Reverse-trail feedback. Kept at `0` so each swell is a single clean pass (the GVerb tail,
|
||||
/// not recirculated reverse segments, provides the sustain).
|
||||
private let reverseFeedback: Double = 0.0
|
||||
|
||||
/// GVerb dry level — how much of the GVerb *source* passes through the tank's dry path. The
|
||||
/// source here is the already-reversed signal (not the raw input), so this keeps the backwards
|
||||
/// swell itself audible under its reverb rather than being fully smeared. The pedal's own `mix`
|
||||
/// then blends this whole wet result against the true dry note. Kept at `0.5` (with the tail and
|
||||
/// early levels below) so the summed wet path keeps headroom below clipping on a loud input.
|
||||
private let reverseSwellLevel: Double = 0.5
|
||||
|
||||
/// GVerb late-reverb (tail) level.
|
||||
private let reverbTailLevel: Double = 0.5
|
||||
|
||||
/// GVerb early-reflection level. Lowered from the generator's `0.4` default: early reflections
|
||||
/// fire forward (not reversed), so a high level would fight the backwards-swell character; a
|
||||
/// smaller amount keeps some room sense while favouring the reversed tail, and trims the sum.
|
||||
private let reverbEarlyLevel: Double = 0.3
|
||||
|
||||
/// Gain folding GVerb's two decorrelated reverb channels to mono. A conservative trim (not a
|
||||
/// strict doubling correction — the channels are not identical), leaving output headroom.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let timeRange: ClosedRange<Double> = 0.1 ... 2.0
|
||||
private let decayRange: ClosedRange<Double> = 0.2 ... 12.0
|
||||
private let sizeRange: ClosedRange<Double> = 1.0 ... 100.0
|
||||
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[
|
||||
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||
PedalKnob(label: "Decay", node: $decay, range: decayRange),
|
||||
PedalKnob(label: "Size", node: $size, range: sizeRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: normalizedRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a reverse-reverb 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: "Reverse Reverb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: ReverseReverbPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Reverse the dry in fixed segments: a note's decay becomes a swell rising into it.
|
||||
let reversed: ReverseDelay = ReverseDelay(
|
||||
input: dry,
|
||||
maxDelay: maxReverseTime,
|
||||
delay: $time,
|
||||
feedback: reverseFeedback,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
// Wrap the reversed swell in a GVerb room tank (native stereo). `dryLevel` keeps the swell
|
||||
// itself present under the reverb.
|
||||
let stereoVerb: GVerb.Audio = GVerb.Audio(
|
||||
source: reversed,
|
||||
roomSize: $size,
|
||||
reverbTime: $decay,
|
||||
damping: $damp,
|
||||
earlyLevel: reverbEarlyLevel,
|
||||
tailLevel: reverbTailLevel,
|
||||
dryLevel: reverseSwellLevel,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
// Sum stereo → mono with ×0.5 to avoid level doubling.
|
||||
return SumChannels.Audio(
|
||||
input: stereoVerb,
|
||||
mul: stereoSumGain
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// ScriptPhaserPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Script phaser — the classic one-knob, four-stage orange phaser (the script-logo voicing).
|
||||
///
|
||||
/// A single **Speed** knob sweeps a fixed four-stage all-pass cascade; there is no depth or
|
||||
/// feedback knob, just the signature liquid whoosh. A **Voicing** switch picks the character: the
|
||||
/// smoother *Script* voicing (lower feedback, gentler notch) or the more resonant *Block* voicing
|
||||
/// (more feedback, sharper notch) — the two eras of the hardware.
|
||||
///
|
||||
/// Distinct from the general-purpose ``PhaserPedal`` (six stages, with rate **and** feedback knobs):
|
||||
/// this is deliberately the fixed, four-stage, one-knob classic. Wraps the shared `Phaser.Audio`
|
||||
/// generator run fully wet; the base `Pedal` `mix` sets the wet/dry blend.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `speed`: LFO sweep rate in Hz. Range `[0.05, 5.0]`.
|
||||
///
|
||||
/// ## Switches
|
||||
/// - `voicing` (two-state): `0` = Script (smoother), `1` = Block (more resonant).
|
||||
public final class ScriptPhaserPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"The one-knob four-stage orange phaser — liquid whoosh, script or block voicing."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO sweep rate in Hz. Range [0.05, 5.0].
|
||||
@UIParam public var speed: Double = 0.5
|
||||
|
||||
/// Voicing selector. `0` = Script (smoother, lower feedback), `1` = Block (more resonant).
|
||||
@UIParam public var voicing: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — an even mix for the classic comb-filter sweep.
|
||||
private static let defaultMix: Double = 0.5
|
||||
|
||||
/// Internal `Phaser.Audio` mix — `1.0` so the base `Pedal` handles dry/wet.
|
||||
private let phaserInternalMix: Double = 1.0
|
||||
|
||||
/// LFO depth fraction — sweeps the all-pass coefficient across its range.
|
||||
private let phaserDepth: Double = 0.9
|
||||
|
||||
/// Center frequency in Hz for the all-pass coefficient sweep.
|
||||
private let phaserCenterFreq: Double = 800.0
|
||||
|
||||
/// Four cascaded all-pass stages — the defining topology of this phaser (`Phaser.Audio`
|
||||
/// requires 4, 6, or 8).
|
||||
private let phaserStages: Int = 4
|
||||
|
||||
/// Feedback for the Script voicing — low, for a smooth gentle notch.
|
||||
private let scriptFeedbackValue: Double = 0.2
|
||||
|
||||
/// Feedback for the Block voicing — higher, for a sharper, more resonant notch.
|
||||
private let blockFeedbackValue: Double = 0.45
|
||||
|
||||
// MARK: - Switch values
|
||||
|
||||
private let voicingScriptValue: Double = 0.0
|
||||
private let voicingBlockValue: Double = 1.0
|
||||
|
||||
/// Smoothing time in seconds for the voicing→feedback change, so flipping Script↔Block glides
|
||||
/// the feedback coefficient instead of stepping it (which could tick on a live toggle).
|
||||
private let voicingSmoothTime: Double = 0.03
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let speedRange: ClosedRange<Double> = 0.05 ... 5.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
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),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Voicing",
|
||||
node: $voicing,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Script", value: voicingScriptValue),
|
||||
PedalSwitch.Option(title: "Block", value: voicingBlockValue),
|
||||
]
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a script-phaser 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: "Script Phaser",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: ScriptPhaserPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Voicing (0 = Script, 1 = Block) selects the feedback amount live — a linear map between the
|
||||
// two fixed values, no rebuild needed since feedback is a live Phaser parameter. A short Lag
|
||||
// glides the coefficient on a Script↔Block toggle so it doesn't step audibly.
|
||||
let feedbackSpan: Double = blockFeedbackValue - scriptFeedbackValue
|
||||
let voicedFeedback: any ValidGeneratorInput = ($voicing * feedbackSpan) + scriptFeedbackValue
|
||||
let smoothedFeedback: Lag.Audio = Lag.Audio(input: voicedFeedback, time: voicingSmoothTime)
|
||||
|
||||
return Phaser.Audio(
|
||||
input: dry,
|
||||
rate: $speed,
|
||||
depth: phaserDepth,
|
||||
centerFreq: phaserCenterFreq,
|
||||
feedback: smoothedFeedback,
|
||||
stages: phaserStages,
|
||||
mix: phaserInternalMix,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
// TapeLooperPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A simple one-loop tape-style looper with the two classic tape tricks: **half-speed** (an octave
|
||||
/// down, the loop twice as long) and **reverse**. Where the full ``LooperPedal`` is a synchronized
|
||||
/// four-track overdub station, this is the single-knob stompbox: record a phrase, play it back, and
|
||||
/// layer overdubs onto the one loop — then drop it to half speed or flip it backwards for the dubby,
|
||||
/// Frippertronics-style wash.
|
||||
///
|
||||
/// Both speed tricks are **live** playback controls — flipping Reverse or Half-Speed re-reads the
|
||||
/// same recorded loop at a new rate, with no rebuild. Recording and overdubbing always run at normal
|
||||
/// forward speed (the write head can't stay aligned with a backward or slowed play-head), so
|
||||
/// engaging overdub is ignored while Reverse or Half-Speed is on.
|
||||
///
|
||||
/// ## Transport (the Record footswitch, by state)
|
||||
/// - **Empty**: press → record the loop.
|
||||
/// - **Recording**: press → close the loop at its current length and start playing.
|
||||
/// - **Playing**: press → toggle overdub onto the loop (forward normal speed only).
|
||||
/// - **Stopped**: press → resume playback. Clear returns to empty.
|
||||
///
|
||||
/// The dry signal always passes through; the loop is added on top (so the wet/dry Mix knob is hidden
|
||||
/// and the base `mix` stays fully wet).
|
||||
public final class TapeLooperPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"A one-loop tape looper — record, overdub, then play it back half-speed or reversed."
|
||||
}
|
||||
|
||||
/// Double-width card so the transport row and loop controls fit without scrolling.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
/// The looper passes the clean signal through and adds the loop on top, so the wet/dry Mix knob
|
||||
/// is meaningless — hide it and keep `mix` fully wet.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
/// Loop playback gain, in dB.
|
||||
@UIParam public var playbackLevel: Double = 0.0
|
||||
|
||||
/// Retained level of existing loop content on each overdub pass, `[0, 1]`. `1.0` keeps prior
|
||||
/// layers indefinitely; lower values fade them for a decaying tape-echo loop.
|
||||
@UIParam public var feedback: Double = 1.0
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
/// Playback direction. `0` = forward, `1` = reverse.
|
||||
@UIParam public var reverse: Double = 0.0
|
||||
|
||||
/// Playback speed. `0` = normal, `1` = half speed (an octave down, loop twice as long).
|
||||
@UIParam public var halfSpeed: Double = 0.0
|
||||
|
||||
// MARK: - Internal live state (read by the audio graph)
|
||||
|
||||
/// `1` while the loop is playing, else `0`. Gates the player sum and the overdub recorder's run.
|
||||
@UIParam public var isPlaying: Double = 0.0
|
||||
|
||||
/// Play-head reset trigger. Pulsed `0 → 1` at play-start so the loop starts from frame 0.
|
||||
@UIParam public var playTrigger: Double = 0.0
|
||||
|
||||
/// LED state for the Record footswitch: `1` while recording or overdubbing.
|
||||
@UIParam public var recordIndicator: Double = 0.0
|
||||
|
||||
/// LED state for the Stop footswitch: `1` while stopped.
|
||||
@UIParam public var stoppedIndicator: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Maximum recordable loop length, in seconds. The buffer allocates this long (roughly
|
||||
/// `maxDurationSeconds × sampleRate × 8 bytes` per instance).
|
||||
private static let maxDurationSeconds: Double = 30.0
|
||||
|
||||
/// Fade time constant, in seconds, for the play/stop mute — smooths the loop in and out so a
|
||||
/// stop or resume doesn't click.
|
||||
private let playFadeTime: Double = 0.02
|
||||
|
||||
/// Forward playback rate.
|
||||
private let forwardRate: Double = 1.0
|
||||
|
||||
/// Amount subtracted from the rate per unit of `reverse` — `2.0` flips `+1` to `−1`.
|
||||
private let reverseRateSpan: Double = 2.0
|
||||
|
||||
/// Fraction the rate is reduced by at full `halfSpeed` — `0.5` turns `×1` into `×0.5`.
|
||||
private let halfSpeedDrop: Double = 0.5
|
||||
|
||||
/// Smallest loop length in frames, so a zero-length take can't produce a degenerate buffer.
|
||||
private static let minimumLoopFrames: Int = 1
|
||||
|
||||
private let levelRangeDb: ClosedRange<Double> = -24.0 ... 12.0
|
||||
private let feedbackRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Buffers + generators
|
||||
|
||||
private var buffer: LyrebirdBuffer?
|
||||
private var player: PlayBuffer.Audio?
|
||||
private var masterRecorder: RecordBuffer.Audio?
|
||||
private var overdubRecorder: RecordBuffer.Audio?
|
||||
|
||||
/// Overdub record gate (`1` = layering new input, `0` = passing existing content through).
|
||||
private var overdubGate: ParameterNode = ParameterNode(0.0)
|
||||
|
||||
// MARK: - Transport state
|
||||
|
||||
private enum Phase {
|
||||
case empty
|
||||
case recording
|
||||
case playing
|
||||
case stopped
|
||||
}
|
||||
|
||||
private var phase: Phase = .empty
|
||||
private var overdubbing: Bool = false
|
||||
|
||||
/// Recorded loop length in frames (`0` until a loop is closed).
|
||||
private var masterLength: Int = 0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a tape-looper 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: "Tape Looper", inputBus: inputBus, outputBus: outputBus, initialMix: 1.0)
|
||||
}
|
||||
|
||||
// MARK: - Knobs / switches / buttons
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Playback", node: $playbackLevel, range: levelRangeDb),
|
||||
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Direction",
|
||||
node: $reverse,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Fwd", value: 0.0),
|
||||
PedalSwitch.Option(title: "Rev", value: 1.0),
|
||||
]
|
||||
),
|
||||
PedalSwitch(
|
||||
label: "Speed",
|
||||
node: $halfSpeed,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Normal", value: 0.0),
|
||||
PedalSwitch.Option(title: "Half", value: 1.0),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectTransportButtons: [PedalButton] {
|
||||
[
|
||||
PedalButton(label: "Record", indicator: $recordIndicator,
|
||||
dynamicLabel: { [weak self] in self?.recordButtonCaption ?? "Record" }) { [weak self] in self?.pressRecord() },
|
||||
PedalButton(label: "Stop", indicator: $stoppedIndicator) { [weak self] in self?.stopPlayback() },
|
||||
PedalButton(label: "Clear") { [weak self] in self?.clearLoop() },
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - UI read-outs
|
||||
|
||||
/// Caption for the Record footswitch describing what the *next* press does.
|
||||
public var recordButtonCaption: String {
|
||||
switch phase {
|
||||
case .empty: return "Record"
|
||||
case .recording: return "Play"
|
||||
case .stopped: return "Play"
|
||||
case .playing: return overdubbing ? "Overdub Off" : "Overdub"
|
||||
}
|
||||
}
|
||||
|
||||
/// `true` once a loop has been recorded.
|
||||
public var hasLoop: Bool { masterLength > 0 }
|
||||
|
||||
/// Recorded loop length in frames (`0` until a loop is closed).
|
||||
public var loopFrameCount: Int { masterLength }
|
||||
|
||||
/// Recorded loop length in seconds.
|
||||
public var loopLengthSeconds: Double { Double(masterLength) / sampleRate }
|
||||
|
||||
/// `true` while the loop is being overdubbed.
|
||||
public var isOverdubbing: Bool { overdubbing }
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// `effect()` runs from `build()`, which the engine re-invokes on every add (including the
|
||||
// re-adds a board edit performs on this same instance). Start clean so nothing references a
|
||||
// discarded buffer and the transport returns to empty.
|
||||
resetForRebuild()
|
||||
|
||||
let maxFrames: Int = Int(TapeLooperPedal.maxDurationSeconds * sampleRate)
|
||||
let loopBuffer: LyrebirdBuffer = LyrebirdBuffer(count: maxFrames, channelCount: 1)
|
||||
buffer = loopBuffer
|
||||
|
||||
// Playback rate: direction × speed, both live. reverse 0→+1 / 1→−1; halfSpeed 0→×1 / 1→×0.5.
|
||||
let directionRate: any ValidGeneratorInput = forwardRate - reverseRateSpan * $reverse
|
||||
let speedScale: any ValidGeneratorInput = forwardRate - halfSpeedDrop * $halfSpeed
|
||||
let playbackRate: any ValidGeneratorInput = directionRate * speedScale
|
||||
|
||||
// Non-looping master recorder for the length-defining first take.
|
||||
let master: RecordBuffer.Audio = RecordBuffer.Audio(
|
||||
input: dry,
|
||||
buffer: loopBuffer,
|
||||
loop: false,
|
||||
doneAction: .nothing
|
||||
)
|
||||
master.run = 0.0
|
||||
masterRecorder = master
|
||||
|
||||
// Always-running overdub recorder (gated by play): layers new input only while the overdub
|
||||
// gate is open, otherwise it passes existing content through (`preLevel = 1`). While
|
||||
// overdubbing, prior content is retained at `feedback`.
|
||||
let unity: Double = 1.0
|
||||
let overdub: RecordBuffer.Audio = RecordBuffer.Audio(
|
||||
input: dry,
|
||||
buffer: loopBuffer,
|
||||
loop: true,
|
||||
doneAction: .nothing
|
||||
)
|
||||
// The effective record-enable also closes if Reverse or Half-Speed is engaged *after* an
|
||||
// overdub is toggled on — the write head runs forward 1× and can't stay aligned with a
|
||||
// backward or slowed play-head. `(1 − reverse)·(1 − halfSpeed)` is `1` only at forward normal
|
||||
// speed; when it drops to `0`, `recLevel` is `0` and `preLevel` is `1` (existing content
|
||||
// preserved), so the layers never misalign.
|
||||
overdub.$run.source = $isPlaying
|
||||
let forwardNormal: BinaryOpGenerator = (unity - $reverse) * (unity - $halfSpeed)
|
||||
let effectiveGate: BinaryOpGenerator = overdubGate * forwardNormal
|
||||
overdub.$recLevel.source = effectiveGate
|
||||
overdub.$preLevel.source = (unity - effectiveGate) + effectiveGate * $feedback
|
||||
overdubRecorder = overdub
|
||||
|
||||
let loopPlayer: PlayBuffer.Audio = PlayBuffer.Audio(
|
||||
buffer: loopBuffer,
|
||||
loop: true,
|
||||
interpolation: .cubic,
|
||||
rate: playbackRate,
|
||||
trigger: $playTrigger,
|
||||
mul: DbAmp.Control($playbackLevel)
|
||||
)
|
||||
player = loopPlayer
|
||||
|
||||
// Loop audible only while playing; smoothed to avoid clicks on stop/resume.
|
||||
let smoothedGate: Lag.Control = Lag.Control(input: $isPlaying, time: playFadeTime)
|
||||
|
||||
// Dry always passes through; the loop is added on top, gated by play.
|
||||
return dry + (loopPlayer * smoothedGate)
|
||||
}
|
||||
|
||||
// MARK: - Transport
|
||||
|
||||
/// The smart Record press. Behaviour depends on the current phase.
|
||||
public func pressRecord() {
|
||||
switch phase {
|
||||
case .empty: beginRecording()
|
||||
case .recording: closeAndPlay()
|
||||
case .playing: toggleOverdub()
|
||||
case .stopped: resumePlayback()
|
||||
}
|
||||
}
|
||||
|
||||
private func beginRecording() {
|
||||
guard let master: RecordBuffer.Audio = masterRecorder else { return }
|
||||
master.requestReset()
|
||||
master.run = 1.0
|
||||
recordIndicator = 1.0
|
||||
stoppedIndicator = 0.0
|
||||
phase = .recording
|
||||
}
|
||||
|
||||
private func closeAndPlay() {
|
||||
guard phase == .recording, let master: RecordBuffer.Audio = masterRecorder,
|
||||
let loopBuffer: LyrebirdBuffer = buffer else { return }
|
||||
master.run = 0.0
|
||||
// Nothing actually recorded (e.g. a double-press with no time between) — don't close a
|
||||
// degenerate one-frame loop that would play as a DC buzz; drop back to empty.
|
||||
let recorded: Int = master.recordedFrameCount
|
||||
guard recorded > 0 else {
|
||||
clearLoop()
|
||||
return
|
||||
}
|
||||
masterLength = max(TapeLooperPedal.minimumLoopFrames, recorded)
|
||||
loopBuffer.setLoopLength(masterLength)
|
||||
recordIndicator = 0.0
|
||||
startPlayback()
|
||||
}
|
||||
|
||||
/// Toggles overdub onto the loop. Overdub records forward at normal speed, so it is blocked while
|
||||
/// Reverse or Half-Speed is engaged (the write head can't follow a backward or slowed play-head).
|
||||
private func toggleOverdub() {
|
||||
guard phase == .playing else { return }
|
||||
if overdubbing {
|
||||
overdubbing = false
|
||||
} else {
|
||||
guard reverse < 0.5, halfSpeed < 0.5 else { return }
|
||||
overdubbing = true
|
||||
}
|
||||
updateOverdubGate()
|
||||
}
|
||||
|
||||
private func startPlayback() {
|
||||
overdubRecorder?.requestReset() // realign the write head to the top
|
||||
isPlaying = 1.0
|
||||
stoppedIndicator = 0.0
|
||||
overdubbing = false
|
||||
phase = .playing // set before updateOverdubGate so the LED reads "playing"
|
||||
updateOverdubGate()
|
||||
playTrigger = 1.0 // rising edge resets the play-head to frame 0
|
||||
}
|
||||
|
||||
/// Resumes playback from the stopped state.
|
||||
private func resumePlayback() {
|
||||
guard phase == .stopped, masterLength > 0 else { return }
|
||||
startPlayback()
|
||||
}
|
||||
|
||||
/// Halts playback; recorded content is retained (resume via Record).
|
||||
public func stopPlayback() {
|
||||
guard phase == .playing else { return }
|
||||
overdubbing = false
|
||||
updateOverdubGate()
|
||||
isPlaying = 0.0
|
||||
playTrigger = 0.0 // rearm the play-head reset edge
|
||||
recordIndicator = 0.0
|
||||
stoppedIndicator = 1.0
|
||||
phase = .stopped
|
||||
}
|
||||
|
||||
/// Clears the recorded loop and returns to the empty state.
|
||||
public func clearLoop() {
|
||||
masterRecorder?.run = 0.0
|
||||
masterRecorder?.requestReset()
|
||||
overdubRecorder?.requestReset()
|
||||
isPlaying = 0.0
|
||||
if let loopBuffer: LyrebirdBuffer = buffer {
|
||||
loopBuffer.clear()
|
||||
loopBuffer.setLoopLength(loopBuffer.count)
|
||||
}
|
||||
masterLength = 0
|
||||
overdubbing = false
|
||||
playTrigger = 0.0
|
||||
recordIndicator = 0.0
|
||||
stoppedIndicator = 0.0
|
||||
updateOverdubGate()
|
||||
phase = .empty
|
||||
}
|
||||
|
||||
/// Resets to the empty state when the engine stops — a stopped engine can't keep a loop running.
|
||||
public override func engineDidStop() {
|
||||
clearLoop()
|
||||
}
|
||||
|
||||
/// Resets before this instance is discarded on a rig teardown.
|
||||
public override func rigWillTeardown() {
|
||||
clearLoop()
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func updateOverdubGate() {
|
||||
overdubGate.value = overdubbing ? 1.0 : 0.0
|
||||
recordIndicator = (phase == .recording || overdubbing) ? 1.0 : 0.0
|
||||
}
|
||||
|
||||
/// Clears the generator references and returns the transport to empty, so a graph rebuild
|
||||
/// (`build()` re-run) starts fresh. Called at the top of ``effect(_:)``.
|
||||
private func resetForRebuild() {
|
||||
buffer = nil
|
||||
player = nil
|
||||
masterRecorder = nil
|
||||
overdubRecorder = nil
|
||||
overdubGate = ParameterNode(0.0)
|
||||
phase = .empty
|
||||
overdubbing = false
|
||||
masterLength = 0
|
||||
isPlaying = 0.0
|
||||
playTrigger = 0.0
|
||||
recordIndicator = 0.0
|
||||
stoppedIndicator = 0.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
// TunedVerbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// A spectral *filter-from-the-current-moment* reverb — press **Capture** and the spectrum playing
|
||||
/// at that instant is locked in as a fixed filter, and everything you play afterwards is poured
|
||||
/// through that frozen spectral shape into a big reverb.
|
||||
///
|
||||
/// Where ``FreezVerbPedal`` holds a snapshot as a *sounding* pad, this holds a snapshot as a
|
||||
/// *filter*. A `SpectralCrossMap` masks the live spectrum bin-by-bin against a template taken from a
|
||||
/// side-chain analysis of the input: while live, the template tracks what you play; press Capture and
|
||||
/// the template freezes, so the captured moment becomes a fixed formant mask on your ongoing signal.
|
||||
/// The masked result feeds a large `GVerb` room (fixed 120 m) for a cavernous tail, and a **Pan**
|
||||
/// knob places the stereo wash anywhere across the field.
|
||||
///
|
||||
/// Ported from the composer's `FilterFromCurrentMoment` process: the original drew its filter from a
|
||||
/// random pointer into a time-stretched buffer and spatialised with ambisonics; here the filter is
|
||||
/// captured straight off the live input by the footswitch, and the output is plain stereo via the
|
||||
/// Pan knob.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `time`: Reverb tail length (GVerb T60) in seconds. Range `[0.5, 12.0]`.
|
||||
/// - `damp`: High-frequency damping of the tail. Range `[0, 1]`: `0` = bright, `1` = dark.
|
||||
/// - `pan`: Stereo position of the wash. Range `[-1, +1]`: `-1` = hard left, `+1` = hard right.
|
||||
///
|
||||
/// ## Transport
|
||||
/// - `Capture`: latching footswitch — press to lock the current-moment spectrum as the filter, press
|
||||
/// again to return to live tracking.
|
||||
public final class TunedVerbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Capture a moment's spectrum as a filter and pour your playing through it into a vast room."
|
||||
}
|
||||
|
||||
/// Mono in, stereo out: the reverb wash is panned across the field by the ``pan`` knob.
|
||||
public override var channelKind: PedalChannelKind { .widener }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Reverb tail length (GVerb T60) in seconds. Range `[0.5, 12.0]`.
|
||||
@UIParam public var time: Double = 6.0
|
||||
|
||||
/// High-frequency damping of the tail. Range `[0, 1]`: `0` = bright, `1` = dark.
|
||||
@UIParam public var damp: Double = 0.5
|
||||
|
||||
/// Stereo position of the wash. Range `[-1, +1]`: `-1` = hard left, `+1` = hard right.
|
||||
@UIParam public var pan: Double = 0.0
|
||||
|
||||
// MARK: - Internal live state (read by the audio graph)
|
||||
|
||||
/// `1` while the filter is locked to a captured moment, else `0`. Drives the Capture footswitch
|
||||
/// LED. Transport state — not a preset control, so neither captured nor restored.
|
||||
@UIParam public var captured: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// FFT frame size for the spectral cross-map. Matches the composer's original process — large
|
||||
/// enough for a finely-resolved formant filter at the cost of latency on the wet path (the dry
|
||||
/// path is never delayed).
|
||||
private static let fftSize: Int = 4096
|
||||
|
||||
/// Samples between FFT hops (75% overlap at `fftSize` 4096).
|
||||
private static let hopSize: Int = 1024
|
||||
|
||||
/// GVerb room size in metres — fixed, as in the original process. Large, for a cavernous tail.
|
||||
private let roomSize: Double = 120.0
|
||||
|
||||
/// Cross-map blend: `1.0` = full spectral bandpass mask (loud template bins pass, quiet bins are
|
||||
/// attenuated). Matches the original process.
|
||||
private let crossMapMode: Double = 1.0
|
||||
|
||||
/// GVerb dry level — kept at `0` so the wet path is pure reverb; the base `mix` provides the
|
||||
/// dry/wet blend.
|
||||
private let verbDryLevel: Double = 0.0
|
||||
|
||||
/// Gain folding GVerb's two decorrelated channels to mono before the pan — a conservative trim
|
||||
/// (the channels are not identical) that leaves output headroom.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let timeRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||
private let dampRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let panRange: ClosedRange<Double> = -1.0 ... 1.0
|
||||
|
||||
// MARK: - Live generator references (rebuilt each `wideEffect(_:)`)
|
||||
|
||||
/// The spectral cross-map the Capture footswitch locks. Recreated on every rebuild so the button
|
||||
/// always acts on the current instance.
|
||||
private var crossMap: SpectralCrossMap?
|
||||
|
||||
/// Mirror of the locked state, so a toggle knows which way to go and the LED survives a rebuild.
|
||||
private var isCaptured: Bool = false
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[
|
||||
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: dampRange),
|
||||
PedalKnob(label: "Pan", node: $pan, range: panRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Transport
|
||||
|
||||
public override var effectTransportButtons: [PedalButton] {
|
||||
[
|
||||
PedalButton(
|
||||
label: "Capture",
|
||||
indicator: $captured,
|
||||
dynamicLabel: { [weak self] in (self?.isCaptured ?? false) ? "Live" : "Capture" }
|
||||
) { [weak self] in self?.toggleCapture() }
|
||||
]
|
||||
}
|
||||
|
||||
/// `true` while a moment's spectrum is locked as the filter. Exposed for UI / tests.
|
||||
public var holding: Bool { isCaptured }
|
||||
|
||||
/// Lock the current-moment spectrum as the filter, or return to live tracking. Latched by the
|
||||
/// Capture footswitch. Before the graph is built `crossMap` is nil and only the latch/LED state
|
||||
/// moves; `resetForRebuild()` then clears it on the next build so the two never drift apart.
|
||||
public func toggleCapture() {
|
||||
if isCaptured {
|
||||
crossMap?.freeze = false
|
||||
isCaptured = false
|
||||
captured = 0.0
|
||||
} else {
|
||||
crossMap?.freeze = true
|
||||
isCaptured = true
|
||||
captured = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a filter-from-the-current-moment TunedVerb.
|
||||
///
|
||||
/// - 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: "TunedVerb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: 0.4
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func wideEffect(
|
||||
_ dry: any ValidGeneratorInput
|
||||
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||
// `wideEffect()` re-runs on every add/rebuild. Start from a clean, live-tracking state so the
|
||||
// button never holds a reference to a discarded cross-map.
|
||||
resetForRebuild()
|
||||
|
||||
// Side-chain: a continuous analysis of the live input. While the cross-map is live it captures
|
||||
// its filter template from this each hop; once the footswitch sets `freeze`, the last template
|
||||
// is held and this side-chain is ignored — the captured moment becomes the fixed filter.
|
||||
let sideChain: SpectralChain.Audio = SpectralChain.Audio(
|
||||
input: dry,
|
||||
fftSize: TunedVerbPedal.fftSize,
|
||||
hopSize: TunedVerbPedal.hopSize,
|
||||
analyzeOnly: true
|
||||
)
|
||||
let map: SpectralCrossMap = SpectralCrossMap(
|
||||
fftSize: TunedVerbPedal.fftSize,
|
||||
normalization: .maxMagnitude
|
||||
)
|
||||
map.mode = crossMapMode
|
||||
crossMap = map
|
||||
|
||||
// Main chain: the live input masked by the (tracking or captured) template.
|
||||
let masked: SpectralChain.Audio = SpectralChain.Audio(
|
||||
input: dry,
|
||||
fftSize: TunedVerbPedal.fftSize,
|
||||
hopSize: TunedVerbPedal.hopSize,
|
||||
stages: [.dual(map, sideChain: sideChain)]
|
||||
)
|
||||
|
||||
// Gate the wash by the Capture latch. Until a moment is captured there is no filter template,
|
||||
// so the reverb must be fed silence rather than the live pass-through — otherwise an
|
||||
// uncaptured TunedVerb pours the dry signal straight into the tail. `captured` is `0` until the
|
||||
// footswitch fires and is reset to `0` on every rebuild and on engine stop (`resetForRebuild`
|
||||
// / `releaseHold`), so a fresh app launch or an engine restart comes up silent with no stale
|
||||
// capture. The analysis side-chain inside `masked` keeps tracking while gated, so pressing
|
||||
// Capture still freezes the current-moment spectrum.
|
||||
let gatedIntoVerb: any ValidGeneratorInput = masked * $captured
|
||||
|
||||
// A large room for a cavernous tail; `time` sets the T60, `damp` the brightness.
|
||||
let reverb: GVerb.Audio = GVerb.Audio(
|
||||
source: gatedIntoVerb,
|
||||
roomSize: roomSize,
|
||||
reverbTime: $time,
|
||||
damping: $damp,
|
||||
dryLevel: verbDryLevel,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
|
||||
// GVerb is natively stereo (two decorrelated channels); fold to mono, then pan the wash across
|
||||
// the field with the Pan knob.
|
||||
let monoWet: SumChannels.Audio = SumChannels.Audio(input: reverb, mul: stereoSumGain)
|
||||
let panned: Pan2 = Pan2(input: monoWet, pan: $pan)
|
||||
return (panned.left, panned.right)
|
||||
}
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
/// Returns to live tracking when the engine stops.
|
||||
public override func engineDidStop() {
|
||||
releaseHold()
|
||||
}
|
||||
|
||||
/// Returns to live tracking before this instance is discarded on a rig teardown.
|
||||
public override func rigWillTeardown() {
|
||||
releaseHold()
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
/// Unlocks any captured filter and returns to live tracking.
|
||||
private func releaseHold() {
|
||||
crossMap?.freeze = false
|
||||
isCaptured = false
|
||||
captured = 0.0
|
||||
}
|
||||
|
||||
/// Clears the live generator reference and the locked state so a graph rebuild starts fresh.
|
||||
/// Called at the top of ``wideEffect(_:)``.
|
||||
private func resetForRebuild() {
|
||||
crossMap = nil
|
||||
isCaptured = false
|
||||
captured = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MIDI transport
|
||||
|
||||
extension TunedVerbPedal: MIDITransportPedal {
|
||||
/// The Capture footswitch is the mappable transport action.
|
||||
public var midiTransportName: String { "Capture" }
|
||||
|
||||
public func toggleMIDITransport() { toggleCapture() }
|
||||
}
|
||||
@@ -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,237 @@
|
||||
// WhammyPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Expression-pedal pitch shifter in the DigiTech Whammy mould.
|
||||
///
|
||||
/// A rocking **expression pedal** (`position`, heel `0` → toe `1`) sweeps the pitch between two
|
||||
/// endpoints set by the selected `mode`. Modes fall into the three families the hardware groups
|
||||
/// them into:
|
||||
///
|
||||
/// - **Whammy** (pitch-bend, wet only): the pedal bends the note itself from unison at the heel to
|
||||
/// the mode's interval at the toe — octave/two-octave up, octave/two-octave down, the three-octave
|
||||
/// "dive bomb", or a fixed whole-step "drop tune". No dry signal; you hear only the bent pitch.
|
||||
/// - **Harmony** (dry + bent voice): a pitch-shifted voice is layered under the dry note, and the
|
||||
/// pedal morphs that voice's interval between the mode's two stops (e.g. a 5th down at the heel to
|
||||
/// a 4th down at the toe) while the dry note stays put.
|
||||
/// - **Detune** (dry + near-unison voice): a voice a few cents off unison beats against the dry
|
||||
/// note; the pedal sweeps the detune depth from none (heel) to shallow or deep (toe).
|
||||
///
|
||||
/// Each voice is a `PitchShift` — Lyrebird's SC-faithful four-head SOLA shifter, the same
|
||||
/// windowed time-domain overlap-add family the real Whammy used (IVL Technologies' patented
|
||||
/// pitch-synchronous time-domain method, US 5,567,901). The characteristic warble/flutter of large
|
||||
/// bends is inherent to that method and is the Whammy's signature, not a defect. Ratio is
|
||||
/// `2^(semitones/12)`, with `semitones` interpolated live from `position`.
|
||||
///
|
||||
/// The shifter's four heads re-trigger on a fixed grid, which colours the output with a static
|
||||
/// comb filter. A small per-head time dispersion (see `timeDispersion`) plus a window a touch
|
||||
/// over the default (see `windowSize`) break that regularity to reduce the combing while leaving
|
||||
/// the Whammy's grit intact.
|
||||
///
|
||||
/// A single SOLA stage clamps at the engine's `±2`-octave `pitchRatio` range. The three-octave
|
||||
/// **Dive Bomb** reaches `-36` semitones by cascading two stages, each doing half the shift.
|
||||
///
|
||||
/// `position` is an ordinary live parameter, so it can be mapped to a MIDI expression pedal or
|
||||
/// automated like any other knob.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `position`: Expression-pedal position in `[0, 1]`. Heel `0` = no bend, toe `1` = full bend.
|
||||
///
|
||||
/// ## Selectors (knob picker)
|
||||
/// - `mode`: Pitch program (snaps to the fixed Whammy / Harmony / Detune list). Changing it
|
||||
/// rebuilds the voice, so it is read as a plain value at build time.
|
||||
public final class WhammyPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Expression-pedal pitch bend — octave dives and climbs, a morphing harmony, or a detune."
|
||||
}
|
||||
|
||||
// MARK: - Mode table
|
||||
|
||||
/// One Whammy program: the pedal interpolates `semitones` from `heel` (pedal up) to `toe`
|
||||
/// (pedal down). `harmony` keeps the dry note under the shifted voice (Harmony/Detune families);
|
||||
/// `twoStage` cascades two SOLA stages to reach shifts beyond a single stage's ±2-octave clamp.
|
||||
private struct Program {
|
||||
let title: String
|
||||
let heel: Double
|
||||
let toe: Double
|
||||
let harmony: Bool
|
||||
let twoStage: Bool
|
||||
}
|
||||
|
||||
/// The selectable programs, grouped Whammy → Harmony → Detune as on the hardware. Whammy
|
||||
/// programs bend a wet-only voice; Harmony/Detune programs layer a voice under the dry note.
|
||||
/// Intervals mirror the DigiTech Whammy preset chart.
|
||||
private static let programs: [Program] = [
|
||||
// Whammy — wet only, bend from unison to the interval.
|
||||
Program(title: "2 Oct Up", heel: 0.0, toe: 24.0, harmony: false, twoStage: false),
|
||||
Program(title: "Oct Up", heel: 0.0, toe: 12.0, harmony: false, twoStage: false),
|
||||
Program(title: "Oct Down", heel: 0.0, toe: -12.0, harmony: false, twoStage: false),
|
||||
Program(title: "2 Oct Down", heel: 0.0, toe: -24.0, harmony: false, twoStage: false),
|
||||
// Dive Bomb drops three octaves; a single SOLA stage clamps at two, so cascade two.
|
||||
Program(title: "Dive Bomb", heel: 0.0, toe: -36.0, harmony: false, twoStage: true),
|
||||
// Drop Tune is a fixed whole-step down — the pedal does not move it.
|
||||
Program(title: "Drop Tune", heel: -2.0, toe: -2.0, harmony: false, twoStage: false),
|
||||
// Harmony — dry note kept, layered voice morphs heel → toe.
|
||||
Program(title: "Oct Up/Dn", heel: 12.0, toe: -12.0, harmony: true, twoStage: false),
|
||||
Program(title: "5Dn/4Dn", heel: -7.0, toe: -5.0, harmony: true, twoStage: false),
|
||||
Program(title: "4Dn/3Dn", heel: -5.0, toe: -4.0, harmony: true, twoStage: false),
|
||||
Program(title: "5Up/7Up", heel: 7.0, toe: 11.0, harmony: true, twoStage: false),
|
||||
Program(title: "5Up/6Up", heel: 7.0, toe: 9.0, harmony: true, twoStage: false),
|
||||
Program(title: "4Up/5Up", heel: 5.0, toe: 7.0, harmony: true, twoStage: false),
|
||||
Program(title: "3Up/4Up", heel: 4.0, toe: 5.0, harmony: true, twoStage: false),
|
||||
Program(title: "m3Up/3Up", heel: 3.0, toe: 4.0, harmony: true, twoStage: false),
|
||||
Program(title: "2Up/3Up", heel: 2.0, toe: 4.0, harmony: true, twoStage: false),
|
||||
// Detune — dry note kept, near-unison voice beats against it; pedal sweeps the depth.
|
||||
Program(title: "Detune Shallow", heel: 0.0, toe: 0.07, harmony: true, twoStage: false),
|
||||
Program(title: "Detune Deep", heel: 0.0, toe: 0.20, harmony: true, twoStage: false),
|
||||
]
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Expression-pedal position in `[0, 1]`. Heel (`0`) = no bend, toe (`1`) = the mode's full
|
||||
/// interval. Live, so it can be driven by a mapped expression pedal or automation.
|
||||
@UIParam public var position: Double = 0.0
|
||||
|
||||
/// Selected program index into ``programs``. A knob-picker selector; rebuilds on change.
|
||||
@UIParam public var mode: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Pedal manages its own dry/wet internally (per mode), so the base stays fully wet.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// `semitones → ratio` exponent scale: `2^(s/12) = e^(s · ln2/12)`, fed to `Exp.Audio`.
|
||||
private let semitoneToRatioScale: Double = 0.05776226504666215 // ln(2) / 12
|
||||
|
||||
/// Granular pitch-shift window in seconds. Larger = smoother but more latency and sweep lag;
|
||||
/// smaller tracks faster with more grit. Tuned slightly above the SOLA shifter's `0.1` default
|
||||
/// to soften the periodic comb without adding audible lag.
|
||||
private let windowSize: Double = 0.11
|
||||
|
||||
/// Per-head random timing jitter in seconds fed to each `PitchShift` stage. The four SOLA heads
|
||||
/// re-trigger on a fixed grid, and that periodicity colours the shift with a static comb filter;
|
||||
/// dispersing each head's read position breaks the regularity and reduces the combing. Kept
|
||||
/// small so the voice stays tight. Clamped internally to `[0, windowSize]`.
|
||||
private let timeDispersion: Double = 0.02
|
||||
|
||||
/// Fixed PRNG seed for the grain dispersion. With `timeDispersion > 0` the shifter draws random
|
||||
/// per-head jitter; passing an explicit seed (rather than letting `PitchShift` derive one from
|
||||
/// the clock) makes a given pedal setting render identically every time — reproducible audio,
|
||||
/// and tests that can assert exact pitch instead of just "something changed".
|
||||
private let pitchShiftSeed: UInt64 = 0x7A11_90D5_0C7A_1BEE
|
||||
|
||||
/// Seed for the Dive Bomb cascade's second stage. Distinct from ``pitchShiftSeed`` so the two
|
||||
/// stages' dispersion sequences decorrelate instead of jittering in lockstep.
|
||||
private let pitchShiftSeedStage2: UInt64 = 0x51A6_2B0F_3D44_9C17
|
||||
|
||||
/// Per-voice gain in harmony/detune modes, where the dry note and the shifted voice are summed.
|
||||
/// At the heel the shifted voice is near-unison and correlated with the dry note, so the two sum
|
||||
/// coherently — `0.5` per leg caps that worst case at unity, rather than the `1.4×` peak two
|
||||
/// near-full-scale correlated voices would otherwise reach.
|
||||
private let harmonyVoiceGain: Double = 0.5
|
||||
|
||||
/// Factor splitting a cascaded two-stage shift evenly between its stages.
|
||||
private let twoStageSplit: Double = 0.5
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let positionRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Pedal", node: $position, range: positionRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Selectors
|
||||
|
||||
public override var effectSelectors: [PedalSelectorKnob] {
|
||||
let stops: [PedalSelectorKnob.Stop] = WhammyPedal.programs.enumerated().map { index, program in
|
||||
PedalSelectorKnob.Stop(title: program.title, value: Double(index))
|
||||
}
|
||||
return [
|
||||
// Each program is a different voice topology (interval span + dry blend + stage count),
|
||||
// read at build time — so switching it must rebuild the board, not just write the node.
|
||||
PedalSelectorKnob(label: "Mode", node: $mode, stops: stops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Whammy pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Whammy",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: WhammyPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// `mode` is read as a plain value at build time; the board rebuilds when it changes (the
|
||||
// voice topology — interval span, dry blend, stage count — is fixed per program).
|
||||
// `position` stays live and sweeps the bend within the program.
|
||||
let index: Int = min(max(0, Int(mode.rounded())), WhammyPedal.programs.count - 1)
|
||||
let program: Program = WhammyPedal.programs[index]
|
||||
|
||||
// semitones = heel + position · (toe − heel), interpolated live from the pedal position.
|
||||
let span: Double = program.toe - program.heel
|
||||
let semitones: any ValidGeneratorInput = ($position * span) + program.heel
|
||||
|
||||
if program.twoStage {
|
||||
// Beyond one SOLA stage's ±2-octave ratio clamp (the 3-octave Dive Bomb): cascade two
|
||||
// stages, each shifting half, so the net shift reaches the full interval.
|
||||
let half: any ValidGeneratorInput = semitones * twoStageSplit
|
||||
let stage1: PitchShift.Audio = PitchShift.Audio(
|
||||
input: dry,
|
||||
pitchRatio: Exp.Audio(half * semitoneToRatioScale),
|
||||
windowSize: windowSize,
|
||||
timeDispersion: timeDispersion,
|
||||
seed: pitchShiftSeed
|
||||
)
|
||||
let stage2: PitchShift.Audio = PitchShift.Audio(
|
||||
input: stage1,
|
||||
pitchRatio: Exp.Audio(half * semitoneToRatioScale),
|
||||
windowSize: windowSize,
|
||||
timeDispersion: timeDispersion,
|
||||
seed: pitchShiftSeedStage2
|
||||
)
|
||||
return stage2
|
||||
}
|
||||
|
||||
let shifted: PitchShift.Audio = PitchShift.Audio(
|
||||
input: dry,
|
||||
pitchRatio: Exp.Audio(semitones * semitoneToRatioScale),
|
||||
windowSize: windowSize,
|
||||
timeDispersion: timeDispersion,
|
||||
seed: pitchShiftSeed
|
||||
)
|
||||
|
||||
if program.harmony {
|
||||
// Harmony/Detune: dry note stays, shifted voice layered under it. Both legs attenuated
|
||||
// so the sum of two near-full-scale voices stays near unity rather than peaking toward 2.
|
||||
return (dry * harmonyVoiceGain) + (shifted * harmonyVoiceGain)
|
||||
}
|
||||
// Whammy: the bent pitch replaces the dry note entirely.
|
||||
return shifted
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// PostChain.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// The shared **post-board chain**: a linear chain of pedals that processes the summed board mix
|
||||
/// once, after the board split, before the hardware output — for global reverb, a bus limiter, a
|
||||
/// final EQ, and the like.
|
||||
///
|
||||
/// Signal flow: every board master writes a shared stereo **mix bus**; this chain reads that mix,
|
||||
/// runs its pedals in order, and copies the processed tail to the hardware outputs (via
|
||||
/// ``PostChainOutput``). The chain is **always stereo-headed** — the mix carries two channels even
|
||||
/// for a mono rig (dual-mono) — so a mono pedal auto-stereoizes per channel while a stereo-native
|
||||
/// pedal cross-couples, exactly as in a ``PedalBoard``'s stereo region. It is a *linear* stage:
|
||||
/// no split / parallel / stereo regions, which a post-master bus doesn't need.
|
||||
///
|
||||
/// `PostChain` is deliberately a dedicated type (not a `PedalBoard`): it owns only its inter-node
|
||||
/// buses — the mix buses and the hardware outputs are owned elsewhere — and has post-specific
|
||||
/// routing (mix in, hardware out). Its pedal buses are wired like `PedalBoard.add`'s width-2 arms.
|
||||
///
|
||||
/// - Note: Rig-wide volume / mute live on the board masters, *upstream* of this chain, so a panic
|
||||
/// mute can let a post-chain reverb tail ring out briefly. Acceptable for a setup-time stage.
|
||||
@MainActor
|
||||
final class PostChain {
|
||||
|
||||
private let engine: SynthesisEngine
|
||||
private let clock: LyrebirdClock?
|
||||
|
||||
/// The shared mix bus this chain reads (externally owned — never released here).
|
||||
private let mixLeftBus: Int
|
||||
private let mixRightBus: Int
|
||||
|
||||
/// Hardware output buses the processed tail is copied to.
|
||||
private let outputLeftBus: Int
|
||||
private let outputRightBus: Int
|
||||
|
||||
/// Inter-node buses this chain allocates and owns (released on ``teardown()``).
|
||||
private var allocatedBuses: [AudioBus] = []
|
||||
|
||||
/// The chain's pedals, in signal-flow order.
|
||||
private(set) var pedals: [Pedal] = []
|
||||
|
||||
/// The current stereo tail — starts at the mix, advances with each pedal.
|
||||
private var tailLeft: Int
|
||||
private var tailRight: Int
|
||||
|
||||
/// The last node inserted (for `.after` ordering of the next node).
|
||||
private var lastNode: (any Synthesizer)?
|
||||
|
||||
/// The final node copying the tail to the hardware outputs.
|
||||
private var outputNode: PostChainOutput?
|
||||
|
||||
/// Creates a post-board chain reading `mixLeftBus` / `mixRightBus` and writing the hardware
|
||||
/// outputs. The mix and hardware buses are owned by the caller.
|
||||
init(
|
||||
engine: SynthesisEngine,
|
||||
clock: LyrebirdClock?,
|
||||
mixLeftBus: Int,
|
||||
mixRightBus: Int,
|
||||
outputLeftBus: Int = 0,
|
||||
outputRightBus: Int = 1
|
||||
) {
|
||||
self.engine = engine
|
||||
self.clock = clock
|
||||
self.mixLeftBus = mixLeftBus
|
||||
self.mixRightBus = mixRightBus
|
||||
self.outputLeftBus = outputLeftBus
|
||||
self.outputRightBus = outputRightBus
|
||||
self.tailLeft = mixLeftBus
|
||||
self.tailRight = mixRightBus
|
||||
}
|
||||
|
||||
/// Appends a pedal to the chain. The first pedal is inserted at the **tail of the main group** so
|
||||
/// it evaluates after every board master regardless of board add order; later calls chain after
|
||||
/// the previous node automatically.
|
||||
///
|
||||
/// The pedal is wired at stereo width: both input channels read the current tail, both output
|
||||
/// channels write fresh buses. The pedal's `channelKind` decides how its `build()` uses them (a
|
||||
/// mono pedal runs `effect(_:)` per channel; a stereo-native pedal cross-couples).
|
||||
func add(_ pedal: Pedal) throws {
|
||||
pedal.sampleRate = engine.sampleRate
|
||||
pedal.hostEngine = engine
|
||||
pedal.clock = clock
|
||||
|
||||
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||
let outRight: AudioBus = try allocateInterNodeBus()
|
||||
pedal.inputBus = tailLeft
|
||||
pedal.inputBusRight = tailRight
|
||||
pedal.outputBus = outLeft.index
|
||||
pedal.outputBusRight = outRight.index
|
||||
try insertNode(pedal)
|
||||
tailLeft = outLeft.index
|
||||
tailRight = outRight.index
|
||||
pedals.append(pedal)
|
||||
}
|
||||
|
||||
/// Adds the output node that copies the chain tail to the hardware outputs. Call once, after all
|
||||
/// pedals have been added.
|
||||
func finalize() throws {
|
||||
let output: PostChainOutput = PostChainOutput(
|
||||
leftInputBus: tailLeft,
|
||||
rightInputBus: tailRight,
|
||||
leftOutputBus: outputLeftBus,
|
||||
rightOutputBus: outputRightBus
|
||||
)
|
||||
try insertNode(output)
|
||||
outputNode = output
|
||||
}
|
||||
|
||||
/// Removes every node this chain added and releases its inter-node buses. Call before the mix /
|
||||
/// hardware buses it references are released.
|
||||
func teardown() {
|
||||
if let output: PostChainOutput = outputNode { engine.remove(output) }
|
||||
outputNode = nil
|
||||
for pedal: Pedal in pedals { engine.remove(pedal) }
|
||||
pedals.removeAll()
|
||||
for bus: AudioBus in allocatedBuses { engine.busAllocator.releaseAudioBus(bus) }
|
||||
allocatedBuses.removeAll()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func allocateInterNodeBus() throws -> AudioBus {
|
||||
let bus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
allocatedBuses.append(bus)
|
||||
return bus
|
||||
}
|
||||
|
||||
private func insertNode(_ node: any Synthesizer) throws {
|
||||
if let previous: any Synthesizer = lastNode {
|
||||
try engine.add(node, position: .after(previous))
|
||||
} else {
|
||||
// Head node: tail of the main group → after every board master already there, and
|
||||
// order-independent, so a board added later (spliced near the group head) still
|
||||
// evaluates before this chain. No re-order needed on board add.
|
||||
try engine.add(node, position: .tail(of: engine.mainGroup))
|
||||
}
|
||||
lastNode = node
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// PostChainOutput.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Internal synthesizer that copies the post-board chain's stereo tail onto the hardware output
|
||||
/// buses — the final node of the ``PostChain``.
|
||||
///
|
||||
/// The board masters write the shared mix bus, the post-chain's pedals process it, and this node
|
||||
/// copies the processed tail (left / right) to the hardware outputs. It carries no gain: the
|
||||
/// rig-wide volume / mute live on the board masters, upstream of the post-chain.
|
||||
///
|
||||
/// - Note: Must be removed from the engine before the tail / hardware buses it reads are released.
|
||||
final class PostChainOutput: SynthesizerBase {
|
||||
|
||||
private let leftInputBus: Int
|
||||
private let rightInputBus: Int
|
||||
private let leftOutputBus: Int
|
||||
private let rightOutputBus: Int
|
||||
|
||||
/// Creates a stereo copy from the chain tail to the hardware outputs.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - leftInputBus: Chain-tail left bus to read.
|
||||
/// - rightInputBus: Chain-tail right bus to read.
|
||||
/// - leftOutputBus: Hardware output for the left channel (default `0`).
|
||||
/// - rightOutputBus: Hardware output for the right channel (default `1`).
|
||||
init(leftInputBus: Int, rightInputBus: Int, leftOutputBus: Int = 0, rightOutputBus: Int = 1) {
|
||||
self.leftInputBus = leftInputBus
|
||||
self.rightInputBus = rightInputBus
|
||||
self.leftOutputBus = leftOutputBus
|
||||
self.rightOutputBus = rightOutputBus
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func build() {
|
||||
output(bus: leftOutputBus, source: input(bus: leftInputBus))
|
||||
output(bus: rightOutputBus, source: input(bus: rightInputBus))
|
||||
}
|
||||
}
|
||||
@@ -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,26 +28,80 @@ extension Pedal {
|
||||
switchValues: switchValues,
|
||||
sliderValues: sliderValues,
|
||||
selectorValues: selectorValues,
|
||||
advancedValues: advancedValues,
|
||||
bypass: bypass,
|
||||
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) {
|
||||
/// **Pass order is contractual: switches are restored before selectors.** A pedal whose selector
|
||||
/// *set* depends on a switch value (e.g. ``KarplusResonatorPedal``, whose Root note selector
|
||||
/// appears only in the Pitched tuning mode) relies on `tuning` being written in the switch pass
|
||||
/// before `effectSelectors` is re-read in the selector pass, so the mode-dependent selector exists
|
||||
/// to receive its value. Do not reorder these passes without revisiting such pedals.
|
||||
///
|
||||
/// - 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
|
||||
@@ -62,6 +117,9 @@ 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.
|
||||
|
||||
@@ -38,25 +38,38 @@ public enum PedalRegistry {
|
||||
"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 Princeton": { FullertonPrincetonAmpPedal() },
|
||||
"Fullerton Ivy League": { FullertonPrincetonAmpPedal() },
|
||||
"Fullerton Drive": { FullertonDriveAmpPedal() },
|
||||
"Jazz Clean": { JazzCleanAmpPedal() },
|
||||
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
|
||||
"Neural Amp": { NeuralAmpPedal() },
|
||||
// "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() },
|
||||
"Script Phaser": { ScriptPhaserPedal() },
|
||||
"Compressor": { CompressorPedal() },
|
||||
"Mutant": { MutantPedal() },
|
||||
"Auto-Wah": { AutoWahPedal() },
|
||||
@@ -67,12 +80,19 @@ public enum PedalRegistry {
|
||||
"Octave Splitter": { OctaveUpSplitterPedal() },
|
||||
"Bass Octaver": { BassOctaverPedal() },
|
||||
"Harmonizer": { HarmonizerPedal() },
|
||||
"Whammy": { WhammyPedal() },
|
||||
"Poly Octave": { PolyOctavePedal() },
|
||||
"Ping-Pong": { PingPongDelayPedal() },
|
||||
"Reverse Delay": { ReverseDelayPedal() },
|
||||
"DL4": { DL4Pedal() },
|
||||
"Shimmer Reverb": { ShimmerReverbPedal() },
|
||||
"Plate Reverb": { PlateReverbPedal() },
|
||||
"Room Reverb": { RoomReverbPedal() },
|
||||
"Spring Reverb": { SpringReverbPedal() },
|
||||
"Reverse Reverb": { ReverseReverbPedal() },
|
||||
"Granular Reverb": { GranularReverbPedal() },
|
||||
"FreezVerb": { FreezVerbPedal() },
|
||||
"TunedVerb": { TunedVerbPedal() },
|
||||
"Limiter": { LimiterPedal() },
|
||||
"Cabinet": { CabinetPedal() },
|
||||
"Noise Gate": { NoiseGatePedal() },
|
||||
@@ -80,6 +100,7 @@ public enum PedalRegistry {
|
||||
"Chorus": { ChorusPedal() },
|
||||
"Flanger": { FlangerPedal() },
|
||||
"Vibrato": { VibratoPedal() },
|
||||
"Vibe": { VibePedal() },
|
||||
"Rotary": { RotaryPedal() },
|
||||
"Sustainer": { SustainerPedal() },
|
||||
"Ring Modulator": { RingModulatorPedal() },
|
||||
@@ -87,7 +108,18 @@ public enum PedalRegistry {
|
||||
"Bitcrusher": { BitcrusherPedal() },
|
||||
"Granulator": { GranulatorPedal() },
|
||||
"Auto Granulator": { AutoGranulatorPedal() },
|
||||
"Karplus Resonator": { KarplusResonatorPedal() },
|
||||
"Looper": { LooperPedal() },
|
||||
"Tape Looper": { TapeLooperPedal() },
|
||||
]
|
||||
|
||||
/// 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
|
||||
@@ -97,11 +129,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
|
||||
|
||||
@@ -62,6 +66,7 @@ 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
|
||||
@@ -73,6 +78,7 @@ public struct PedalState: Codable, Equatable {
|
||||
switchValues: [Double] = [],
|
||||
sliderValues: [Double] = [],
|
||||
selectorValues: [Double] = [],
|
||||
advancedValues: [Double] = [],
|
||||
bypass: Double,
|
||||
tempoSync: [String: TempoSync]? = nil,
|
||||
resourcePath: String? = nil
|
||||
@@ -83,6 +89,7 @@ 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
|
||||
@@ -95,13 +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()
|
||||
@@ -110,6 +118,7 @@ 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)
|
||||
|
||||
@@ -56,7 +56,7 @@ extension ShoeGaze {
|
||||
branch.append(newState)
|
||||
}
|
||||
}
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Inserts a pedal of the given type at `index` within a lane, shifting later pedals along.
|
||||
@@ -117,7 +117,7 @@ extension ShoeGaze {
|
||||
branch.insert(newState, at: index)
|
||||
}
|
||||
}
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Removes the pedal at `index` within a lane.
|
||||
@@ -149,7 +149,7 @@ extension ShoeGaze {
|
||||
branch.remove(at: index)
|
||||
}
|
||||
}
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Moves the pedal at `sourceIndex` to `destinationIndex` within a lane.
|
||||
@@ -175,7 +175,7 @@ extension ShoeGaze {
|
||||
try Self.moveWithinArray(&branch, from: sourceIndex, to: destinationIndex)
|
||||
}
|
||||
}
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Moves a pedal from one lane to another (e.g. the main chain into a stereo-unzip lane, or
|
||||
@@ -252,7 +252,7 @@ extension ShoeGaze {
|
||||
}
|
||||
}
|
||||
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
// MARK: - Branch regions
|
||||
@@ -270,7 +270,7 @@ extension ShoeGaze {
|
||||
guard board.width == 1 else { throw ShoeGazeError.cannotSplitStereoChain }
|
||||
var segments: [BoardSegmentState] = board.captureState().segments
|
||||
segments.append(.stereoSplit(StereoSplitState(left: [], right: [], route: .stereo)))
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Inserts an empty stereo-unzip region immediately after the segment at `topLevelIndex`,
|
||||
@@ -297,7 +297,7 @@ extension ShoeGaze {
|
||||
.stereoUnzip(StereoUnzipState(left: [], right: [], route: .stereo)),
|
||||
at: topLevelIndex + 1
|
||||
)
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Returns `true` when the segment immediately after `topLevelIndex` is a stereo-unzip region —
|
||||
@@ -318,7 +318,7 @@ extension ShoeGaze {
|
||||
public func appendParallelSplit(to board: PedalBoard) throws -> PedalBoard {
|
||||
var segments: [BoardSegmentState] = board.captureState().segments
|
||||
segments.append(.parallel(ParallelSectionState(branchA: [], branchB: [], mode: .both)))
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Appends a merge-to-mono node, collapsing a stereo tail back to mono.
|
||||
@@ -330,7 +330,7 @@ extension ShoeGaze {
|
||||
guard board.width == 2 else { throw ShoeGazeError.cannotMergeMonoChain }
|
||||
var segments: [BoardSegmentState] = board.captureState().segments
|
||||
segments.append(.mergeToMono)
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
/// Removes the top-level segment (a linear pedal, a split region, or a merge node) at
|
||||
@@ -345,7 +345,7 @@ extension ShoeGaze {
|
||||
throw ShoeGazeError.pedalIndexOutOfRange(index: topLevelIndex, count: segments.count)
|
||||
}
|
||||
segments.remove(at: topLevelIndex)
|
||||
return try rebuildBoard(board, from: BoardState(label: board.label, segments: segments))
|
||||
return try rebuildBoard(board, from: BoardState(id: board.id, label: board.label, segments: segments))
|
||||
}
|
||||
|
||||
// MARK: - Input source switching
|
||||
@@ -481,4 +481,148 @@ extension ShoeGaze {
|
||||
let insertionIndex: Int = destinationIndex > sourceIndex ? destinationIndex - 1 : destinationIndex
|
||||
array.insert(element, at: insertionIndex)
|
||||
}
|
||||
|
||||
// MARK: - Pre-board chain editing
|
||||
|
||||
/// Appends a pedal to the end of the pre-board chain — the shared stage that processes the input
|
||||
/// once, before the board split, and feeds every board.
|
||||
///
|
||||
/// - Important: A pre-board edit reshapes the shared feed every board taps, so the whole rig is
|
||||
/// torn down and rebuilt (ordering-safe). Like ``setInputSource(_:)``, this resets transient
|
||||
/// live state (solo / bypass) and stateful pedals (looper buffers) — it is a setup-time edit.
|
||||
/// - Note: The pre-board chain feeds the **main boards** only. Chain-router branches read the
|
||||
/// input source directly and are not fed by the pre-board chain.
|
||||
public func appendPrePedal(_ kind: PedalType) throws {
|
||||
let type: String = kind.rawValue
|
||||
guard PedalRegistry.builtIn[type] != nil else { throw ShoeGazeError.unknownPedalType(type) }
|
||||
var updated: [PedalState] = capturePreBoardStates() // fold in live knob tweaks first
|
||||
updated.append(PedalState(type: type, knobValues: [], switchValues: [], bypass: 0.0))
|
||||
try setPreBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Inserts a pedal at `index` in the pre-board chain (insert-before; `index == count` appends).
|
||||
public func insertPrePedal(_ kind: PedalType, at index: Int) throws {
|
||||
let type: String = kind.rawValue
|
||||
guard PedalRegistry.builtIn[type] != nil else { throw ShoeGazeError.unknownPedalType(type) }
|
||||
var updated: [PedalState] = capturePreBoardStates()
|
||||
guard index >= 0 && index <= updated.count else {
|
||||
throw ShoeGazeError.pedalIndexOutOfRange(index: index, count: updated.count)
|
||||
}
|
||||
updated.insert(PedalState(type: type, knobValues: [], switchValues: [], bypass: 0.0), at: index)
|
||||
try setPreBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Removes the pre-board pedal at `index`.
|
||||
public func removePrePedal(at index: Int) throws {
|
||||
var updated: [PedalState] = capturePreBoardStates()
|
||||
guard index >= 0 && index < updated.count else {
|
||||
throw ShoeGazeError.pedalIndexOutOfRange(index: index, count: updated.count)
|
||||
}
|
||||
updated.remove(at: index)
|
||||
try setPreBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Moves the pre-board pedal at `sourceIndex` to `destinationIndex` (SwiftUI `onMove` semantics).
|
||||
public func movePrePedal(from sourceIndex: Int, to destinationIndex: Int) throws {
|
||||
var updated: [PedalState] = capturePreBoardStates()
|
||||
try Self.moveWithinArray(&updated, from: sourceIndex, to: destinationIndex)
|
||||
try setPreBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Replaces the pre-board chain with `newStates` and rebuilds the rig. The pre-chain reshapes the
|
||||
/// shared feed that every board taps, so the whole rig is torn down and rebuilt (ordering-safe);
|
||||
/// mirrors ``setInputSource(_:)``, resetting transient / looper state like it does. On failure the
|
||||
/// previous pre-board states are restored so a later capture never persists a half-applied edit.
|
||||
private func setPreBoardChain(_ newStates: [PedalState]) throws {
|
||||
let previous: [PedalState] = preBoardStates
|
||||
preBoardStates = newStates
|
||||
let wasRunning: Bool = engine.isRunning
|
||||
if wasRunning { engine.stop() }
|
||||
let snapshot: ShoeGazeState = captureState().withPreChain(newStates.isEmpty ? nil : newStates)
|
||||
teardown()
|
||||
do {
|
||||
try rebuildAllBoards(from: snapshot)
|
||||
} catch {
|
||||
preBoardStates = previous
|
||||
if wasRunning {
|
||||
do { try engine.start() } catch { print("[ShoeGaze] engine restart after failed pre-board edit failed: \(error)") }
|
||||
}
|
||||
throw error
|
||||
}
|
||||
if wasRunning {
|
||||
do { try engine.start() } catch { print("[ShoeGaze] engine restart after pre-board edit failed: \(error)") }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Post-board chain editing
|
||||
|
||||
/// Appends a pedal to the end of the post-board chain — the shared stage that processes the
|
||||
/// summed board mix, after the split, before the hardware output (global reverb, bus limiter).
|
||||
///
|
||||
/// - Important: Reshapes the shared mix path, so the whole rig is torn down and rebuilt
|
||||
/// (ordering-safe); resets transient / looper state like ``setInputSource(_:)``.
|
||||
public func appendPostPedal(_ kind: PedalType) throws {
|
||||
let type: String = kind.rawValue
|
||||
guard PedalRegistry.builtIn[type] != nil else { throw ShoeGazeError.unknownPedalType(type) }
|
||||
var updated: [PedalState] = capturePostBoardStates()
|
||||
updated.append(PedalState(type: type, knobValues: [], switchValues: [], bypass: 0.0))
|
||||
try setPostBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Inserts a pedal at `index` in the post-board chain (insert-before; `index == count` appends).
|
||||
public func insertPostPedal(_ kind: PedalType, at index: Int) throws {
|
||||
let type: String = kind.rawValue
|
||||
guard PedalRegistry.builtIn[type] != nil else { throw ShoeGazeError.unknownPedalType(type) }
|
||||
var updated: [PedalState] = capturePostBoardStates()
|
||||
guard index >= 0 && index <= updated.count else {
|
||||
throw ShoeGazeError.pedalIndexOutOfRange(index: index, count: updated.count)
|
||||
}
|
||||
updated.insert(PedalState(type: type, knobValues: [], switchValues: [], bypass: 0.0), at: index)
|
||||
try setPostBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Removes the post-board pedal at `index`.
|
||||
public func removePostPedal(at index: Int) throws {
|
||||
var updated: [PedalState] = capturePostBoardStates()
|
||||
guard index >= 0 && index < updated.count else {
|
||||
throw ShoeGazeError.pedalIndexOutOfRange(index: index, count: updated.count)
|
||||
}
|
||||
updated.remove(at: index)
|
||||
try setPostBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Moves the post-board pedal at `sourceIndex` to `destinationIndex` (SwiftUI `onMove` semantics).
|
||||
public func movePostPedal(from sourceIndex: Int, to destinationIndex: Int) throws {
|
||||
var updated: [PedalState] = capturePostBoardStates()
|
||||
try Self.moveWithinArray(&updated, from: sourceIndex, to: destinationIndex)
|
||||
try setPostBoardChain(updated)
|
||||
}
|
||||
|
||||
/// Replaces the post-board chain with `newStates` and rebuilds the rig (ordering-safe). The
|
||||
/// masters' output target (mix bus vs hardware) depends on whether a post-chain exists, so the
|
||||
/// whole rig is rebuilt; mirrors ``setInputSource(_:)``.
|
||||
///
|
||||
/// - Note: On a rebuild failure the `postBoardStates` are restored and the engine is restarted,
|
||||
/// but the graph was already torn down and is left empty — the rig runs silent until the next
|
||||
/// successful edit. A setup-time edit, so this is acceptable (same contract as the pre-board edit).
|
||||
private func setPostBoardChain(_ newStates: [PedalState]) throws {
|
||||
let previous: [PedalState] = postBoardStates
|
||||
postBoardStates = newStates
|
||||
let wasRunning: Bool = engine.isRunning
|
||||
if wasRunning { engine.stop() }
|
||||
let snapshot: ShoeGazeState = captureState().withPostChain(newStates.isEmpty ? nil : newStates)
|
||||
teardown()
|
||||
do {
|
||||
try rebuildAllBoards(from: snapshot)
|
||||
} catch {
|
||||
postBoardStates = previous
|
||||
if wasRunning {
|
||||
do { try engine.start() } catch { print("[ShoeGaze] engine restart after failed post-board edit failed: \(error)") }
|
||||
}
|
||||
throw error
|
||||
}
|
||||
if wasRunning {
|
||||
do { try engine.start() } catch { print("[ShoeGaze] engine restart after post-board edit failed: \(error)") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,15 @@ 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,
|
||||
// Captured from the LIVE pre-pedals (so knob tweaks are saved); `nil` rather than `[]`
|
||||
// when empty, so a rig without a pre-board chain stays byte-identical to the old format.
|
||||
preChain: { let s: [PedalState] = capturePreBoardStates(); return s.isEmpty ? nil : s }(),
|
||||
// Likewise for the post-board chain, captured from the live post-pedals.
|
||||
postChain: { let s: [PedalState] = capturePostBoardStates(); return s.isEmpty ? nil : s }()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -94,9 +112,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 +134,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
|
||||
@@ -155,6 +183,11 @@ extension ShoeGaze {
|
||||
/// - Throws: `BusAllocatorError`, `EngineAddError`, or `ShoeGazeError` from board construction.
|
||||
func rebuildAllBoards(from snapshot: ShoeGazeState) throws {
|
||||
do {
|
||||
// Set the pre- and post-board chains before building any board: a board's input tap wires
|
||||
// through the feed bus (`ensureFeed()` from `preBoardStates`), and its master targets the
|
||||
// mix bus (`ensurePostMix()` from `postBoardStates`), both decided per board.
|
||||
preBoardStates = snapshot.preChain ?? []
|
||||
postBoardStates = snapshot.postChain ?? []
|
||||
for boardState: BoardState in snapshot.boards {
|
||||
let board: PedalBoard = try addBoard()
|
||||
board.id = boardState.id
|
||||
@@ -162,6 +195,17 @@ extension ShoeGaze {
|
||||
try rebuildSegments(boardState.segments, into: board)
|
||||
try finalizeBoard(board)
|
||||
}
|
||||
for routerState: ChainRouterState in snapshot.routers ?? [] {
|
||||
try rebuildRouter(routerState)
|
||||
}
|
||||
// With no boards to pull the feed into being, build the pre-chain anyway so it isn't an
|
||||
// invisible accumulation of states (`preBoardPedals` reflects it; a later board taps it).
|
||||
if boards.isEmpty && !preBoardStates.isEmpty {
|
||||
_ = try ensureFeed()
|
||||
}
|
||||
// Build the post-board chain after every board master exists (it reads the mix those
|
||||
// masters write and must evaluate after them).
|
||||
try buildPostChain()
|
||||
} catch {
|
||||
// Leave no partial rig behind: tear down whatever was built, then rethrow.
|
||||
teardown()
|
||||
@@ -169,6 +213,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:
|
||||
@@ -368,6 +438,19 @@ extension ShoeGaze {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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 —
|
||||
// mirroring the full `loadRig(from:)` path.
|
||||
@@ -376,6 +459,15 @@ 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).
|
||||
|
||||
@@ -57,6 +57,21 @@ 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]?
|
||||
|
||||
/// The rig's pre-board chain — pedals that process the input once, before the board split, and
|
||||
/// feed every board — or `nil` for a rig saved before the pre-board stage existed. Additive:
|
||||
/// decoded with `decodeIfPresent`, so older rigs decode cleanly to `nil` without a format bump.
|
||||
public let preChain: [PedalState]?
|
||||
|
||||
/// The rig's post-board chain — pedals that process the summed board mix, after the split, before
|
||||
/// the hardware output (global reverb, bus limiter, …) — or `nil` for a rig saved before the
|
||||
/// post-board stage existed. Additive: decoded with `decodeIfPresent`.
|
||||
public let postChain: [PedalState]?
|
||||
|
||||
/// Creates a rig state snapshot.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -68,6 +83,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 +92,10 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
tempoEnabled: Bool? = nil,
|
||||
inputSource: InputSource? = nil,
|
||||
numInputChannels: Int? = nil,
|
||||
numOutputChannels: Int? = nil
|
||||
numOutputChannels: Int? = nil,
|
||||
routers: [ChainRouterState]? = nil,
|
||||
preChain: [PedalState]? = nil,
|
||||
postChain: [PedalState]? = nil
|
||||
) {
|
||||
self.version = version
|
||||
self.boards = boards
|
||||
@@ -86,6 +105,9 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
self.inputSource = inputSource
|
||||
self.numInputChannels = numInputChannels
|
||||
self.numOutputChannels = numOutputChannels
|
||||
self.routers = routers
|
||||
self.preChain = preChain
|
||||
self.postChain = postChain
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -97,6 +119,9 @@ public struct ShoeGazeState: Codable, Equatable {
|
||||
case inputSource
|
||||
case numInputChannels
|
||||
case numOutputChannels
|
||||
case routers
|
||||
case preChain
|
||||
case postChain
|
||||
}
|
||||
|
||||
/// Decodes a rig snapshot, tolerating an absent, malformed, OR legacy-format `midiMap`.
|
||||
@@ -129,5 +154,45 @@ 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)
|
||||
self.preChain = try container.decodeIfPresent([PedalState].self, forKey: .preChain)
|
||||
self.postChain = try container.decodeIfPresent([PedalState].self, forKey: .postChain)
|
||||
}
|
||||
|
||||
/// 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
|
||||
&& preChain == other.preChain
|
||||
&& postChain == other.postChain
|
||||
}
|
||||
|
||||
/// Returns a copy of this snapshot with its `preChain` replaced. Used by the pre-board edit path
|
||||
/// to force the just-mutated intended chain (rather than a re-read of the still-live pre-pedals).
|
||||
public func withPreChain(_ preChain: [PedalState]?) -> ShoeGazeState {
|
||||
ShoeGazeState(
|
||||
version: version, boards: boards, midiMap: midiMap, bpm: bpm, tempoEnabled: tempoEnabled,
|
||||
inputSource: inputSource, numInputChannels: numInputChannels,
|
||||
numOutputChannels: numOutputChannels, routers: routers, preChain: preChain, postChain: postChain
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns a copy with its `postChain` replaced. Post-board edit counterpart of ``withPreChain(_:)``.
|
||||
public func withPostChain(_ postChain: [PedalState]?) -> ShoeGazeState {
|
||||
ShoeGazeState(
|
||||
version: version, boards: boards, midiMap: midiMap, bpm: bpm, tempoEnabled: tempoEnabled,
|
||||
inputSource: inputSource, numInputChannels: numInputChannels,
|
||||
numOutputChannels: numOutputChannels, routers: routers, preChain: preChain, postChain: postChain
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,14 +192,123 @@ public final class ShoeGaze {
|
||||
private var globalTestSource: TestLoopSource?
|
||||
private var globalTestBus: AudioBus?
|
||||
|
||||
/// Per-board taps copying the global test bus into each board's head bus.
|
||||
/// Per-board taps copying the shared feed bus into each board's head bus.
|
||||
private var testLoopTaps: [TestLoopTap] = []
|
||||
private var inputPassThroughs: [HardwareInputPassThrough] = []
|
||||
private var outputMasters: [BoardOutputMaster] = []
|
||||
|
||||
// MARK: - Pre-board chain
|
||||
|
||||
/// The shared **feed bus** every board taps. It carries the input source directly, or — when a
|
||||
/// pre-board chain exists — that chain's mono output. Allocated lazily by ``ensureFeed()`` when
|
||||
/// the first board is wired, and rebuilt with the rig on a pre-board edit (which reshapes it).
|
||||
private var feedBus: AudioBus?
|
||||
|
||||
/// The node that writes ``feedBus``: copies the input source, or the pre-board chain's mono
|
||||
/// output, onto the feed bus. Board taps read the feed bus and so must evaluate after this node.
|
||||
private var feedWriter: FeedPassThrough?
|
||||
|
||||
/// The live pre-board processing chain (a ``PedalBoard`` whose mono output feeds every board),
|
||||
/// or `nil` when there is no pre-board processing. Rebuilt from ``preBoardStates``.
|
||||
private var preChainBoard: PedalBoard?
|
||||
|
||||
/// The tap that feeds the pre-board chain's head bus from the input source. `nil` when there is
|
||||
/// no pre-board chain.
|
||||
private var preChainFeedTap: FeedPassThrough?
|
||||
|
||||
/// Persisted pre-board pedal states — the serialization source of truth. The live
|
||||
/// ``preChainBoard`` is rebuilt from these. Empty when there is no pre-board processing.
|
||||
/// Set via the pre-board edit API and on rig load; read by ``ensureFeed()`` when wiring the feed.
|
||||
public internal(set) var preBoardStates: [PedalState] = []
|
||||
|
||||
/// The live pedals currently in the pre-board chain, in signal-flow order; empty when there is no
|
||||
/// pre-board processing. For UI rendering + inspection (the persisted truth is ``preBoardStates``).
|
||||
public var preBoardPedals: [Pedal] { preChainBoard?.pedals ?? [] }
|
||||
|
||||
/// The pre-board states captured from the **live** pre-pedals (so knob / switch tweaks are
|
||||
/// included), or the stored ``preBoardStates`` when there is no live chain. Use this — never the
|
||||
/// raw ``preBoardStates`` — wherever the pre-chain is saved or rebuilt, so live edits aren't lost.
|
||||
func capturePreBoardStates() -> [PedalState] {
|
||||
guard let pre: PedalBoard = preChainBoard else { return preBoardStates }
|
||||
return pre.pedals.map { $0.captureState() }
|
||||
}
|
||||
|
||||
// MARK: - Post-board chain
|
||||
|
||||
/// Shared stereo mix bus the board masters write **into** when a post-board chain exists; `nil`
|
||||
/// otherwise (the masters write the hardware outputs directly). Owned here, released with the
|
||||
/// post-chain. The post-chain reads this mix and writes the hardware outputs.
|
||||
private var postMixLeft: AudioBus?
|
||||
private var postMixRight: AudioBus?
|
||||
|
||||
/// The live post-board chain (reads the mix, writes hardware), or `nil` when there is none.
|
||||
private var postChain: PostChain?
|
||||
|
||||
/// Persisted post-board pedal states — the serialization source of truth; the live ``postChain``
|
||||
/// is rebuilt from these. Empty when there is no post-board processing.
|
||||
public internal(set) var postBoardStates: [PedalState] = []
|
||||
|
||||
/// The live pedals in the post-board chain, in signal-flow order; empty when there is none.
|
||||
public var postBoardPedals: [Pedal] { postChain?.pedals ?? [] }
|
||||
|
||||
/// Post-board states captured from the **live** post-pedals (so knob tweaks are included), or the
|
||||
/// stored ``postBoardStates`` when there is no live chain. Use this wherever the post-chain is
|
||||
/// saved or rebuilt, so live edits aren't lost.
|
||||
func capturePostBoardStates() -> [PedalState] {
|
||||
guard let post: PostChain = postChain else { return postBoardStates }
|
||||
return post.pedals.map { $0.captureState() }
|
||||
}
|
||||
|
||||
/// Ensures the stereo mix bus exists when a post-board chain is present, returning its bus
|
||||
/// indices — or `nil` when there is none (the masters then write hardware directly).
|
||||
private func ensurePostMix() throws -> (left: Int, right: Int)? {
|
||||
guard !postBoardStates.isEmpty else { return nil }
|
||||
if let left: AudioBus = postMixLeft, let right: AudioBus = postMixRight {
|
||||
return (left.index, right.index)
|
||||
}
|
||||
let left: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let right: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
postMixLeft = left
|
||||
postMixRight = right
|
||||
return (left.index, right.index)
|
||||
}
|
||||
|
||||
/// Builds the post-board chain from ``postBoardStates`` — reading the mix, writing hardware,
|
||||
/// inserted at the tail of the main group so it evaluates after **every** board master (order-
|
||||
/// independent). No-op when empty. Call after all boards are finalized.
|
||||
func buildPostChain() throws {
|
||||
guard !postBoardStates.isEmpty, let mix: (left: Int, right: Int) = try ensurePostMix() else { return }
|
||||
let post: PostChain = PostChain(
|
||||
engine: engine, clock: clock, mixLeftBus: mix.left, mixRightBus: mix.right
|
||||
)
|
||||
// Track the chain before wiring it, so a mid-build throw leaves its partial nodes/buses
|
||||
// reachable for teardown (`tearDownPost` / the rebuild catch) instead of orphaned.
|
||||
postChain = post
|
||||
for state: PedalState in postBoardStates {
|
||||
guard let pedal: Pedal = PedalRegistry.makePedal(type: state.type) else { continue }
|
||||
pedal.applyState(state)
|
||||
try post.add(pedal)
|
||||
}
|
||||
try post.finalize()
|
||||
}
|
||||
|
||||
/// Removes the post-board chain nodes and releases the mix bus. Call from ``teardown()`` after the
|
||||
/// masters that write the mix are removed.
|
||||
private func tearDownPost() {
|
||||
postChain?.teardown()
|
||||
postChain = nil
|
||||
if let left: AudioBus = postMixLeft { engine.busAllocator.releaseAudioBus(left) }
|
||||
postMixLeft = nil
|
||||
if let right: AudioBus = postMixRight { engine.busAllocator.releaseAudioBus(right) }
|
||||
postMixRight = nil
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -235,9 +344,18 @@ public final class ShoeGaze {
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
/// The live pedal with the given `id`, searching every board (main chain + parallel / stereo
|
||||
/// branches) and router branches, or `nil` if none matches. Used by undo to re-resolve a
|
||||
/// control's live node after an edit has rebuilt the board it lives on.
|
||||
func pedal(id: UUID) -> Pedal? {
|
||||
allPedals().first { $0.id == id }
|
||||
}
|
||||
|
||||
/// Every live `Pedal` across all main boards and chain-router branches.
|
||||
private func allPedals() -> [Pedal] {
|
||||
var result: [Pedal] = []
|
||||
result.append(contentsOf: preBoardPedals)
|
||||
result.append(contentsOf: postBoardPedals)
|
||||
for board: PedalBoard in boards {
|
||||
result.append(contentsOf: pedals(in: board))
|
||||
}
|
||||
@@ -300,38 +418,36 @@ public final class ShoeGaze {
|
||||
let board: PedalBoard = try PedalBoard(engine: engine, clock: clock)
|
||||
board.label = "Board \(boards.count + 1)"
|
||||
|
||||
// Route the input source to the board head bus.
|
||||
// Every board taps the shared feed bus — the input source, or (when present) the pre-board
|
||||
// chain's mono output. The tap evaluates after the feed writer so it reads a written bus.
|
||||
let (feedBusIndex, feedNode): (Int, any Synthesizer) = try ensureFeed()
|
||||
switch inputSource {
|
||||
case .testLoop:
|
||||
// All boards share one global test source so they stay phase-locked. Each board
|
||||
// gets a tap copying the shared test bus into its head bus, added `.after(_:)` the
|
||||
// source so it sees the source's output for the current block.
|
||||
let (source, testBus): (TestLoopSource, AudioBus) = try ensureGlobalTestSource()
|
||||
// All boards share one feed (and one global test source upstream of it) so they stay
|
||||
// phase-locked. Each board gets a tap copying the feed bus into its head bus.
|
||||
let tap: TestLoopTap = TestLoopTap(
|
||||
inputBusIndex: testBus.index,
|
||||
inputBusIndex: feedBusIndex,
|
||||
outputBusIndex: board.headBus.index
|
||||
)
|
||||
// Prime the mute gain before splicing the node in, so its very first render block
|
||||
// reflects the current mute state with no ramp (see `primeInputMute`).
|
||||
primeInputMute(tap.inputMuteNode, muted: inputMuted)
|
||||
try engine.add(tap, position: NodePosition.after(source))
|
||||
try engine.add(tap, position: NodePosition.after(feedNode))
|
||||
testLoopTaps.append(tap)
|
||||
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
|
||||
// pedal after it automatically (without needing an explicit `after:`).
|
||||
board.headInputNode = tap
|
||||
|
||||
case .liveInput(let channel):
|
||||
// Hardware input channel `channel` lives at bus numOutputChannels + channel.
|
||||
// A HardwareInputPassThrough copies it to the board's head bus so all pedals
|
||||
// read from a board-owned bus (not the raw hardware input bus).
|
||||
let hardwareInputBusIndex: Int = try liveInputBusIndex(channel: channel, engine: engine)
|
||||
case .liveInput:
|
||||
// Live input flows through the same feed bus (which carries the hardware input, or the
|
||||
// pre-board chain fed from it). The per-board input mute stays on this tap.
|
||||
let passThrough: HardwareInputPassThrough = HardwareInputPassThrough(
|
||||
inputBusIndex: hardwareInputBusIndex,
|
||||
inputBusIndex: feedBusIndex,
|
||||
outputBusIndex: board.headBus.index
|
||||
)
|
||||
// Prime the mute gain before splicing the node in (see `primeInputMute`).
|
||||
primeInputMute(passThrough.inputMuteNode, muted: inputMuted)
|
||||
try engine.add(passThrough)
|
||||
try engine.add(passThrough, position: NodePosition.after(feedNode))
|
||||
inputPassThroughs.append(passThrough)
|
||||
board.headInputNode = passThrough
|
||||
}
|
||||
@@ -373,6 +489,100 @@ public final class ShoeGaze {
|
||||
return (source, testBus)
|
||||
}
|
||||
|
||||
// MARK: - Pre-board feed wiring
|
||||
|
||||
/// Ensures the input source for the current ``inputSource`` exists and returns the bus it writes
|
||||
/// plus the node that writes it (`nil` for live input — the hardware input bus is already
|
||||
/// populated at block start, so nothing need evaluate before a reader).
|
||||
private func ensureInputSourceBus() throws -> (bus: Int, node: (any Synthesizer)?) {
|
||||
switch inputSource {
|
||||
case .testLoop:
|
||||
let (source, testBus): (TestLoopSource, AudioBus) = try ensureGlobalTestSource()
|
||||
return (testBus.index, source)
|
||||
case .liveInput(let channel):
|
||||
let index: Int = try liveInputBusIndex(channel: channel, engine: engine)
|
||||
return (index, nil)
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensures the shared feed bus and its writer exist for the current input source and pre-board
|
||||
/// state, returning the feed bus index and the node a board must order its input tap after.
|
||||
@discardableResult
|
||||
func ensureFeed() throws -> (bus: Int, node: any Synthesizer) {
|
||||
if let feedBus: AudioBus = feedBus, let feedWriter: FeedPassThrough = feedWriter {
|
||||
return (feedBus.index, feedWriter)
|
||||
}
|
||||
return try buildFeed()
|
||||
}
|
||||
|
||||
/// Allocates the feed bus (if needed), builds the pre-board chain when ``preBoardStates`` is
|
||||
/// non-empty (source → pedals → mono output), and creates the feed writer that copies the source
|
||||
/// or the pre-chain output onto the feed bus. Returns the feed bus index + the feed writer node.
|
||||
@discardableResult
|
||||
private func buildFeed() throws -> (bus: Int, node: any Synthesizer) {
|
||||
let (sourceBus, sourceNode): (Int, (any Synthesizer)?) = try ensureInputSourceBus()
|
||||
let feed: AudioBus = try feedBus ?? engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
feedBus = feed
|
||||
|
||||
// What the feed writer reads: the source directly, or the pre-board chain's mono output.
|
||||
var writerInputBus: Int = sourceBus
|
||||
var writerAfter: (any Synthesizer)? = sourceNode
|
||||
|
||||
if !preBoardStates.isEmpty {
|
||||
let pre: PedalBoard = try PedalBoard(engine: engine, clock: clock)
|
||||
// Feed the pre-chain head from the input source.
|
||||
let feedTap: FeedPassThrough = FeedPassThrough(
|
||||
inputBusIndex: sourceBus,
|
||||
outputBusIndex: pre.headBus.index
|
||||
)
|
||||
if let sourceNode: any Synthesizer = sourceNode {
|
||||
try engine.add(feedTap, position: NodePosition.after(sourceNode))
|
||||
} else {
|
||||
try engine.add(feedTap)
|
||||
}
|
||||
pre.headInputNode = feedTap
|
||||
preChainFeedTap = feedTap
|
||||
|
||||
for state: PedalState in preBoardStates {
|
||||
guard let pedal: Pedal = PedalRegistry.makePedal(type: state.type) else { continue }
|
||||
pedal.applyState(state)
|
||||
try pre.add(pedal)
|
||||
}
|
||||
// The feed is mono (board heads are mono); fold any multi-channel pre-chain tail to mono.
|
||||
if pre.width > 1 {
|
||||
try pre.mergeToMono()
|
||||
}
|
||||
preChainBoard = pre
|
||||
writerInputBus = pre.outputBus.index
|
||||
writerAfter = pre.tailNode ?? feedTap
|
||||
}
|
||||
|
||||
let writer: FeedPassThrough = FeedPassThrough(inputBusIndex: writerInputBus, outputBusIndex: feed.index)
|
||||
if let after: any Synthesizer = writerAfter {
|
||||
try engine.add(writer, position: NodePosition.after(after))
|
||||
} else {
|
||||
try engine.add(writer)
|
||||
}
|
||||
feedWriter = writer
|
||||
return (feed.index, writer)
|
||||
}
|
||||
|
||||
/// Removes the feed writer + pre-board chain nodes and releases the feed bus. Called from
|
||||
/// ``teardown()`` (the whole feed is rebuilt from scratch on the next ``ensureFeed()``).
|
||||
private func tearDownFeed() {
|
||||
if let writer: FeedPassThrough = feedWriter { engine.remove(writer) }
|
||||
feedWriter = nil
|
||||
if let feedTap: FeedPassThrough = preChainFeedTap { engine.remove(feedTap) }
|
||||
preChainFeedTap = nil
|
||||
preChainBoard?.teardown()
|
||||
preChainBoard = nil
|
||||
if let feed: AudioBus = feedBus {
|
||||
engine.busAllocator.releaseAudioBus(feed)
|
||||
feedBus = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Connects the output master for a previously prepared board and adds it to the engine.
|
||||
///
|
||||
/// Call this after all pedals have been added to the board via `board.add(_:)`.
|
||||
@@ -386,10 +596,15 @@ public final class ShoeGaze {
|
||||
/// - Parameter board: A `PedalBoard` returned by `addBoard()` with pedals added.
|
||||
/// - Throws: `EngineAddError` if the engine rejects the master node.
|
||||
public func finalizeBoard(_ board: PedalBoard) throws {
|
||||
// When a post-board chain exists, every master writes the shared mix bus (the post-chain
|
||||
// then reads the mix and writes hardware); otherwise the master writes hardware directly.
|
||||
let mix: (left: Int, right: Int)? = try ensurePostMix()
|
||||
let master: BoardOutputMaster = BoardOutputMaster(
|
||||
boardOutputBusIndex: board.outputBus.index,
|
||||
boardOutputBusRightIndex: board.outputBusRight?.index,
|
||||
dryInputBusIndex: board.headBus.index
|
||||
dryInputBusIndex: board.headBus.index,
|
||||
outputLeftBusIndex: mix?.left ?? 0,
|
||||
outputRightBusIndex: mix?.right ?? 1
|
||||
)
|
||||
// The master evaluates after the entire chain (pedals, splitters, mergers).
|
||||
// `board.tailNode` returns the last inserted node (any Synthesizer), which covers
|
||||
@@ -429,6 +644,11 @@ public final class ShoeGaze {
|
||||
// Bring a newly-finalized board up at the current rig volume / mute.
|
||||
master.rigVolumeNode.update(rigVolume)
|
||||
master.rigMuteNode.update(rigMuted ? 1.0 : 0.0)
|
||||
|
||||
// A board finalized while a post-board chain already exists needs no post-chain rebuild: the
|
||||
// post-chain sits at the tail of the main group, so the new master (spliced nearer the group
|
||||
// head) evaluates before it automatically, and the new master already writes the shared mix
|
||||
// (via the `ensurePostMix()` redirect above). The post-chain keeps its live pedal state.
|
||||
}
|
||||
|
||||
// MARK: - Board selection / crossfade
|
||||
@@ -827,9 +1047,17 @@ public final class ShoeGaze {
|
||||
engine.remove(tap)
|
||||
}
|
||||
testLoopTaps.removeAll()
|
||||
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
||||
engine.remove(passThrough)
|
||||
}
|
||||
inputPassThroughs.removeAll()
|
||||
|
||||
// Remove the shared global test source and release its bus (after its taps are removed,
|
||||
// preserving remove-before-release ordering).
|
||||
// Remove the feed writer + pre-board chain (the taps that read the feed bus are now gone)
|
||||
// and release the feed bus, before the source it reads is removed.
|
||||
tearDownFeed()
|
||||
|
||||
// Remove the shared global test source and release its bus (after the taps + feed that read
|
||||
// it are removed, preserving remove-before-release ordering).
|
||||
if let source: TestLoopSource = globalTestSource {
|
||||
engine.remove(source)
|
||||
}
|
||||
@@ -839,16 +1067,15 @@ public final class ShoeGaze {
|
||||
}
|
||||
globalTestBus = nil
|
||||
|
||||
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
||||
engine.remove(passThrough)
|
||||
}
|
||||
inputPassThroughs.removeAll()
|
||||
|
||||
for master: BoardOutputMaster in outputMasters {
|
||||
engine.remove(master)
|
||||
}
|
||||
outputMasters.removeAll()
|
||||
|
||||
// Remove the post-board chain (reader of the mix, writer of hardware) and release the mix
|
||||
// bus, now that the masters that write it are gone.
|
||||
tearDownPost()
|
||||
|
||||
// Step 2: Remove pedals from the engine and release all board-owned buses.
|
||||
// board.teardown() removes pedals from the engine and then releases buses,
|
||||
// so bus release only happens after all writers have been dequeued.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Descriptor for one pedal parameter that can be locked to the tempo.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// PedalControlGroup.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// Identifies which of a pedal's control collections holds a given parameter, so a parameter-undo
|
||||
/// entry can re-resolve the live ``UIParamNode`` by `(pedal id, group, control label)` after an
|
||||
/// edit has rebuilt the pedal.
|
||||
public enum PedalControlGroup: Sendable {
|
||||
|
||||
/// A face knob — ``Pedal/knobs`` (includes the trailing `Mix` / `Level`).
|
||||
case knob
|
||||
|
||||
/// A knob in the pedal's advanced popover — ``Pedal/advancedKnobs``.
|
||||
case advancedKnob
|
||||
|
||||
/// A continuous slider — ``Pedal/effectSliders``.
|
||||
case slider
|
||||
|
||||
/// A segmented switch — ``Pedal/effectSwitches``.
|
||||
case `switch`
|
||||
|
||||
/// A stepped selector knob — ``Pedal/effectSelectors``.
|
||||
case selector
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
// UndoCoordinator.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import Observation
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Multi-level undo / redo for rig edits — both structural topology changes and parameter changes,
|
||||
/// interleaved on one stack.
|
||||
///
|
||||
/// **Structural edits** (add / remove / move a pedal, board, split-merge region) are wrapped in
|
||||
/// ``perform(_:_:)``, which snapshots the whole rig as a ``ShoeGazeState`` before the edit and
|
||||
/// records that pre-edit snapshot if the rig actually changed. ``undo()`` restores it *surgically*
|
||||
/// (see ``restore(_:on:)`` — board-by-board reconciliation, not a whole-rig reload) and moves the
|
||||
/// pre-undo state onto the redo stack; ``redo()`` is the mirror.
|
||||
///
|
||||
/// **Parameter edits** (one knob / slider / switch / selector the user finished changing) are
|
||||
/// recorded by ``recordParameterEdit(label:pedalID:group:controlLabel:oldValue:newValue:)`` as the
|
||||
/// control's identity plus its before/after values — undo sets it back, redo re-applies, re-resolving
|
||||
/// the live node by id each time so it survives an intervening rebuild. Topology-changing
|
||||
/// (`rebuildsOnChange`) controls are deliberately NOT recorded this way (they belong to the
|
||||
/// structural path).
|
||||
///
|
||||
/// Any new edit of either kind clears the redo stack.
|
||||
///
|
||||
/// The coordinator holds the ``ShoeGaze`` instance weakly: it is a companion object the UI owns
|
||||
/// alongside the rig, and the rig never refers back to it. All access is `@MainActor`, matching the
|
||||
/// rig's isolation. It is `@Observable` so SwiftUI menus and toolbar buttons track ``canUndo`` /
|
||||
/// ``canRedo`` and the action labels without manual refresh.
|
||||
@MainActor
|
||||
@Observable
|
||||
public final class UndoCoordinator {
|
||||
|
||||
/// Default maximum number of actions retained on the undo stack. Entries are small
|
||||
/// (a `ShoeGazeState` snapshot is a few KB of value types), so the cap is a UX choice — old
|
||||
/// history past this many actions is dropped oldest-first — rather than a memory limit.
|
||||
public static let defaultDepth: Int = 50
|
||||
|
||||
/// The rig this coordinator records edits for. Weak to avoid any retain cycle; `nil` after the
|
||||
/// rig is torn down, which makes every operation a safe no-op.
|
||||
private weak var shoeGaze: ShoeGaze?
|
||||
|
||||
/// Maximum retained undo (and redo) depth. Always at least `1`.
|
||||
private let depth: Int
|
||||
|
||||
/// Recorded pre-edit snapshots, oldest first. The last element is the next action ``undo()``
|
||||
/// reverts.
|
||||
private var undoStack: [UndoEntry] = []
|
||||
|
||||
/// Snapshots moved aside by ``undo()``, oldest first. The last element is the next action
|
||||
/// ``redo()`` re-applies. Cleared by any new ``perform(_:_:)``.
|
||||
private var redoStack: [UndoEntry] = []
|
||||
|
||||
/// `true` when there is at least one action to undo. Drives the Undo menu item / button enabled
|
||||
/// state.
|
||||
public private(set) var canUndo: Bool = false
|
||||
|
||||
/// `true` when there is at least one action to redo. Drives the Redo menu item / button enabled
|
||||
/// state.
|
||||
public private(set) var canRedo: Bool = false
|
||||
|
||||
/// The label of the next action ``undo()`` would revert (e.g. `"Add Reverb"`), or `nil` when the
|
||||
/// undo stack is empty. Suitable for a `"Undo \(label)"` menu title.
|
||||
public private(set) var undoActionLabel: String?
|
||||
|
||||
/// The label of the next action ``redo()`` would re-apply, or `nil` when the redo stack is empty.
|
||||
public private(set) var redoActionLabel: String?
|
||||
|
||||
/// Creates a coordinator for a rig.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - shoeGaze: The rig to record structural edits for. Held weakly.
|
||||
/// - depth: Maximum retained undo/redo depth. Clamped to at least `1`. Defaults to
|
||||
/// ``defaultDepth``.
|
||||
public init(shoeGaze: ShoeGaze, depth: Int = UndoCoordinator.defaultDepth) {
|
||||
self.shoeGaze = shoeGaze
|
||||
self.depth = max(1, depth)
|
||||
}
|
||||
|
||||
// MARK: - Recording
|
||||
|
||||
/// Runs a structural edit, recording an undo checkpoint when it changes the rig.
|
||||
///
|
||||
/// Captures the rig state, runs `action`, then captures it again. The checkpoint is recorded only
|
||||
/// when the two snapshots differ, so a no-op edit (e.g. a move that lands a pedal back in place)
|
||||
/// adds nothing to the history. A throwing `action` propagates its error and records nothing. On
|
||||
/// a recorded edit the redo stack is cleared, matching standard undo semantics.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: A short, human-readable description of the action (e.g. `"Add Reverb"`).
|
||||
/// - action: The edit to run. Its return value is passed straight back to the caller.
|
||||
/// - Returns: Whatever `action` returns.
|
||||
/// - Throws: Rethrows any error `action` throws.
|
||||
@discardableResult
|
||||
public func perform<T>(_ label: String, _ action: () throws -> T) rethrows -> T {
|
||||
let before: ShoeGazeState? = shoeGaze?.captureState()
|
||||
let result: T = try action()
|
||||
guard let beforeState: ShoeGazeState = before,
|
||||
let afterState: ShoeGazeState = shoeGaze?.captureState(),
|
||||
!beforeState.hasSameRigContent(as: afterState) else {
|
||||
// `hasSameRigContent` compares rig topology / parameters / MIDI / tempo while ignoring the
|
||||
// session's input + channel-count fields, so a no-op edit records no checkpoint even if
|
||||
// the engine's input shifted mid-edit.
|
||||
return result
|
||||
}
|
||||
appendUndo(.structural(label: label, state: beforeState))
|
||||
redoStack.removeAll()
|
||||
refreshState()
|
||||
return result
|
||||
}
|
||||
|
||||
/// Records a single parameter edit (a knob / slider the user finished turning). Does nothing when
|
||||
/// the value is unchanged. Clears the redo stack, matching standard undo semantics.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - label: Short description (typically the control's label, e.g. `"Drive"`).
|
||||
/// - pedalID: The id of the pedal the control belongs to.
|
||||
/// - group: Which of the pedal's control collections holds it.
|
||||
/// - controlLabel: The control's label, used to find it within the group.
|
||||
/// - oldValue: The value when the edit began.
|
||||
/// - newValue: The value when the edit ended.
|
||||
public func recordParameterEdit(
|
||||
label: String,
|
||||
pedalID: UUID,
|
||||
group: PedalControlGroup,
|
||||
controlLabel: String,
|
||||
oldValue: Double,
|
||||
newValue: Double
|
||||
) {
|
||||
guard oldValue != newValue else { return }
|
||||
appendUndo(.parameter(
|
||||
label: label,
|
||||
pedalID: pedalID,
|
||||
group: group,
|
||||
controlLabel: controlLabel,
|
||||
oldValue: oldValue,
|
||||
newValue: newValue
|
||||
))
|
||||
redoStack.removeAll()
|
||||
refreshState()
|
||||
}
|
||||
|
||||
/// Reverts the most recent recorded edit, restoring the rig to its state before that edit, and
|
||||
/// moves the edit onto the redo stack. No-op when there is nothing to undo.
|
||||
public func undo() {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, let entry: UndoEntry = undoStack.popLast() else {
|
||||
return
|
||||
}
|
||||
switch entry {
|
||||
case .structural(let label, let beforeState):
|
||||
let afterState: ShoeGazeState = shoeGaze.captureState()
|
||||
appendRedo(.structural(label: label, state: afterState))
|
||||
restore(beforeState, on: shoeGaze)
|
||||
case .parameter(_, let pedalID, let group, let controlLabel, let oldValue, _):
|
||||
applyParameter(pedalID: pedalID, group: group, controlLabel: controlLabel,
|
||||
value: oldValue, on: shoeGaze)
|
||||
appendRedo(entry)
|
||||
}
|
||||
refreshState()
|
||||
}
|
||||
|
||||
/// Re-applies the most recently undone edit and moves it back onto the undo stack. No-op when
|
||||
/// there is nothing to redo.
|
||||
public func redo() {
|
||||
guard let shoeGaze: ShoeGaze = shoeGaze, let entry: UndoEntry = redoStack.popLast() else {
|
||||
return
|
||||
}
|
||||
switch entry {
|
||||
case .structural(let label, let afterState):
|
||||
let beforeState: ShoeGazeState = shoeGaze.captureState()
|
||||
appendUndo(.structural(label: label, state: beforeState))
|
||||
restore(afterState, on: shoeGaze)
|
||||
case .parameter(_, let pedalID, let group, let controlLabel, _, let newValue):
|
||||
applyParameter(pedalID: pedalID, group: group, controlLabel: controlLabel,
|
||||
value: newValue, on: shoeGaze)
|
||||
appendUndo(entry)
|
||||
}
|
||||
refreshState()
|
||||
}
|
||||
|
||||
/// Discards all undo and redo history. Call when the rig is replaced wholesale (new rig, rig
|
||||
/// switch, library load), where carrying history across would let an undo restore a different
|
||||
/// rig entirely.
|
||||
public func clear() {
|
||||
undoStack.removeAll()
|
||||
redoStack.removeAll()
|
||||
refreshState()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// Restores a rig snapshot **surgically**, so undo is safe to use live.
|
||||
///
|
||||
/// Rather than `loadRig` (which tears the whole rig down — stopping any recording, discarding
|
||||
/// looper buffers, losing every board's reverb/delay tail, and resetting solo/bypass), this
|
||||
/// reconciles board-by-board: it removes boards the undone edit added, re-adds boards it removed,
|
||||
/// rebuilds only the boards whose topology changed, and reorders to match. Each step uses the
|
||||
/// same per-board rebuild path as an ordinary edit (at most one block of glitch on a running
|
||||
/// engine), touching nothing else.
|
||||
///
|
||||
/// Crucially it **preserves live parameter values**: a pedal that still exists keeps its current
|
||||
/// knob/switch values (matched by id), so undoing a topology edit never reverts a knob the player
|
||||
/// turned afterwards. A pedal the edit removed comes back with its snapshot values. Rig-wide MIDI
|
||||
/// bindings are restored from the snapshot (so undoing a Clear brings them back); tempo and
|
||||
/// bypass/solo state are left as they are, being orthogonal to a topology edit.
|
||||
private func restore(_ state: ShoeGazeState, on shoeGaze: ShoeGaze) {
|
||||
// Pre-board TOPOLOGY changed (a pre-pedal added / removed / reordered — compared by id
|
||||
// sequence, so a knob-only change doesn't count) → the shared feed every board taps is
|
||||
// different, which a surgical per-board reconcile can't express; rebuild the whole rig from
|
||||
// the snapshot (ordering-safe), matching the forward edit. (Pre-pedal knob changes are
|
||||
// `.parameter` undo entries, resolved by applyParameter, and never reach here.)
|
||||
let targetPreIDs: [UUID] = (state.preChain ?? []).map { $0.id }
|
||||
let livePreIDs: [UUID] = shoeGaze.capturePreBoardStates().map { $0.id }
|
||||
let targetPostIDs: [UUID] = (state.postChain ?? []).map { $0.id }
|
||||
let livePostIDs: [UUID] = shoeGaze.capturePostBoardStates().map { $0.id }
|
||||
if targetPreIDs != livePreIDs || targetPostIDs != livePostIDs {
|
||||
// A pre- or post-board topology change reshapes the shared feed / mix every board touches,
|
||||
// which a surgical per-board reconcile can't express → rebuild the whole rig (as the
|
||||
// forward edit does). Knob-only pre/post changes are `.parameter` entries, not here.
|
||||
let wasRunning: Bool = shoeGaze.engine.isRunning
|
||||
if wasRunning { shoeGaze.engine.stop() }
|
||||
shoeGaze.teardown()
|
||||
do { try shoeGaze.rebuildAllBoards(from: state) }
|
||||
catch { print("[ShoeGaze] undo/redo pre/post-board rebuild failed: \(error)") }
|
||||
shoeGaze.midiMap = state.midiMap
|
||||
if wasRunning {
|
||||
do { try shoeGaze.engine.start() } catch { print("[ShoeGaze] undo/redo engine restart failed: \(error)") }
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Current per-pedal values, keyed by pedal id, to merge onto the restored topology.
|
||||
let liveValues: [UUID: PedalState] = currentPedalStatesByID(shoeGaze)
|
||||
let targetIDs: Set<UUID> = Set(state.boards.map { $0.id })
|
||||
|
||||
// 1. Remove boards present now but absent from the target (undo of an Add Board).
|
||||
for board: PedalBoard in Array(shoeGaze.boards) where !targetIDs.contains(board.id) {
|
||||
shoeGaze.removeBoard(board)
|
||||
}
|
||||
|
||||
// 2. Ensure each target board exists with the target topology + current parameter values.
|
||||
for targetBoard: BoardState in state.boards {
|
||||
let merged: BoardState = mergingLiveValues(into: targetBoard, liveValues: liveValues)
|
||||
if let existing: PedalBoard = shoeGaze.boards.first(where: { $0.id == merged.id }) {
|
||||
// Rebuild only when something actually differs, to avoid a needless audio glitch.
|
||||
if existing.captureState() != merged {
|
||||
do { _ = try shoeGaze.rebuildBoard(existing, from: merged) }
|
||||
catch { print("[ShoeGaze] undo/redo rebuild failed: \(error)") }
|
||||
}
|
||||
} else {
|
||||
// The undone edit had removed this board — bring it back (repositioned in step 3).
|
||||
// `rebuildBoard` is the proven rebuild path; it transiently holds the fresh board's
|
||||
// buses plus the rebuilt board's, which is immaterial at the default bus budget.
|
||||
do {
|
||||
let fresh: PedalBoard = try shoeGaze.addBoard()
|
||||
_ = try shoeGaze.rebuildBoard(fresh, from: merged)
|
||||
} catch {
|
||||
print("[ShoeGaze] undo/redo board re-add failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Reorder the boards to match the target order.
|
||||
for (index, targetBoard): (Int, BoardState) in state.boards.enumerated() {
|
||||
if let board: PedalBoard = shoeGaze.boards.first(where: { $0.id == targetBoard.id }) {
|
||||
shoeGaze.moveBoard(board, to: index)
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Restore the rig's MIDI bindings from the snapshot (they address pedals/boards by id,
|
||||
// which the rebuild preserved). This re-arms the bindings a Clear had wiped. (It also
|
||||
// reverts a binding edit made after the checkpoint — a rare edge, accepted for simplicity.)
|
||||
shoeGaze.midiMap = state.midiMap
|
||||
|
||||
// Chain routers are intentionally NOT reconciled: no undoable (`perform`-wrapped) edit
|
||||
// creates, deletes, or modifies a router, so a router is never part of an undo delta. Any
|
||||
// routers currently present are left exactly as they are.
|
||||
}
|
||||
|
||||
/// Sets a parameter back to `value` by re-resolving the control's live node from the current rig
|
||||
/// (by pedal id, group, and label), so a parameter undo/redo lands on the right control even when
|
||||
/// an earlier structural edit has since rebuilt the pedal. A missing pedal or control is a no-op.
|
||||
private func applyParameter(
|
||||
pedalID: UUID,
|
||||
group: PedalControlGroup,
|
||||
controlLabel: String,
|
||||
value: Double,
|
||||
on shoeGaze: ShoeGaze
|
||||
) {
|
||||
guard let pedal: Pedal = shoeGaze.pedal(id: pedalID) else { return }
|
||||
let node: UIParamNode?
|
||||
switch group {
|
||||
case .knob:
|
||||
node = pedal.knobs.first { $0.label == controlLabel }?.node
|
||||
case .advancedKnob:
|
||||
node = pedal.advancedKnobs.first { $0.label == controlLabel }?.node
|
||||
case .slider:
|
||||
node = pedal.effectSliders.first { $0.label == controlLabel }?.node
|
||||
case .switch:
|
||||
node = pedal.effectSwitches.first { $0.label == controlLabel }?.node
|
||||
case .selector:
|
||||
node = pedal.effectSelectors.first { $0.label == controlLabel }?.node
|
||||
}
|
||||
node?.update(value)
|
||||
}
|
||||
|
||||
/// Flattens every pedal in the current rig into an `id → PedalState` map, descending into
|
||||
/// parallel / stereo-split / stereo-unzip branches.
|
||||
private func currentPedalStatesByID(_ shoeGaze: ShoeGaze) -> [UUID: PedalState] {
|
||||
var map: [UUID: PedalState] = [:]
|
||||
for board: BoardState in shoeGaze.captureState().boards {
|
||||
for segment: BoardSegmentState in board.segments {
|
||||
collectPedalStates(segment, into: &map)
|
||||
}
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
/// Adds every `PedalState` reachable from a segment (including branch lanes) to `map`, keyed by id.
|
||||
private func collectPedalStates(_ segment: BoardSegmentState, into map: inout [UUID: PedalState]) {
|
||||
switch segment {
|
||||
case .pedal(let state):
|
||||
map[state.id] = state
|
||||
case .parallel(let state):
|
||||
for pedal: PedalState in state.branchA + state.branchB { map[pedal.id] = pedal }
|
||||
case .stereoSplit(let state):
|
||||
for pedal: PedalState in state.left + state.right { map[pedal.id] = pedal }
|
||||
case .stereoUnzip(let state):
|
||||
for pedal: PedalState in state.left + state.right { map[pedal.id] = pedal }
|
||||
case .mergeToMono:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `board` with every pedal that still exists live (matched by id) swapped for its
|
||||
/// current `PedalState`, so restoring a topology never reverts a parameter changed since. Pedals
|
||||
/// absent from `liveValues` (ones the undone edit had removed) keep their snapshot values.
|
||||
private func mergingLiveValues(into board: BoardState, liveValues: [UUID: PedalState]) -> BoardState {
|
||||
let segments: [BoardSegmentState] = board.segments.map {
|
||||
mergingLiveValues(into: $0, liveValues: liveValues)
|
||||
}
|
||||
return BoardState(id: board.id, label: board.label, segments: segments)
|
||||
}
|
||||
|
||||
/// Per-segment counterpart of ``mergingLiveValues(into:liveValues:)`` for a single segment.
|
||||
private func mergingLiveValues(
|
||||
into segment: BoardSegmentState,
|
||||
liveValues: [UUID: PedalState]
|
||||
) -> BoardSegmentState {
|
||||
switch segment {
|
||||
case .pedal(let state):
|
||||
return .pedal(liveValues[state.id] ?? state)
|
||||
case .parallel(let state):
|
||||
return .parallel(ParallelSectionState(
|
||||
branchA: state.branchA.map { liveValues[$0.id] ?? $0 },
|
||||
branchB: state.branchB.map { liveValues[$0.id] ?? $0 },
|
||||
mode: state.mode
|
||||
))
|
||||
case .stereoSplit(let state):
|
||||
return .stereoSplit(StereoSplitState(
|
||||
left: state.left.map { liveValues[$0.id] ?? $0 },
|
||||
right: state.right.map { liveValues[$0.id] ?? $0 },
|
||||
route: state.route
|
||||
))
|
||||
case .stereoUnzip(let state):
|
||||
return .stereoUnzip(StereoUnzipState(
|
||||
left: state.left.map { liveValues[$0.id] ?? $0 },
|
||||
right: state.right.map { liveValues[$0.id] ?? $0 },
|
||||
route: state.route
|
||||
))
|
||||
case .mergeToMono:
|
||||
return .mergeToMono
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends to the undo stack, trimming the oldest entries past ``depth``.
|
||||
private func appendUndo(_ entry: UndoEntry) {
|
||||
undoStack.append(entry)
|
||||
if undoStack.count > depth {
|
||||
undoStack.removeFirst(undoStack.count - depth)
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends to the redo stack, trimming the oldest entries past ``depth``.
|
||||
private func appendRedo(_ entry: UndoEntry) {
|
||||
redoStack.append(entry)
|
||||
if redoStack.count > depth {
|
||||
redoStack.removeFirst(redoStack.count - depth)
|
||||
}
|
||||
}
|
||||
|
||||
/// Recomputes the published availability flags and action labels from the current stacks.
|
||||
private func refreshState() {
|
||||
canUndo = !undoStack.isEmpty
|
||||
canRedo = !redoStack.isEmpty
|
||||
undoActionLabel = undoStack.last?.label
|
||||
redoActionLabel = redoStack.last?.label
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// UndoEntry.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// One entry on an ``UndoCoordinator`` undo or redo stack.
|
||||
///
|
||||
/// Two kinds of edit are recorded:
|
||||
/// - **Structural** topology changes (adding, removing, moving, or re-routing pedals and boards) are
|
||||
/// captured as a whole-rig ``ShoeGazeState`` snapshot, restored surgically on undo.
|
||||
/// - **Parameter** changes (a single knob / slider turn) are captured as the control's identity plus
|
||||
/// its before/after values, so undo sets it back without disturbing anything else.
|
||||
///
|
||||
/// Both undo and redo are a symmetric swap: a structural entry restores its snapshot; a parameter
|
||||
/// entry sets its control to the old value on undo and the new value on redo. Either way the applied
|
||||
/// entry moves to the opposite stack.
|
||||
enum UndoEntry {
|
||||
|
||||
/// A whole-rig topology change — adding, removing, or moving a pedal, board, split/merge region,
|
||||
/// or router. The associated ``ShoeGazeState`` is the snapshot to restore when this entry is
|
||||
/// applied: the rig state *before* the change for an undo entry, or *after* it for the matching
|
||||
/// redo entry.
|
||||
case structural(label: String, state: ShoeGazeState)
|
||||
|
||||
/// A single parameter change on one pedal control. The control is addressed by its pedal's id,
|
||||
/// its group, and its label (re-resolved live so it survives an intervening rebuild); `oldValue`
|
||||
/// is restored on undo and `newValue` on redo.
|
||||
case parameter(
|
||||
label: String,
|
||||
pedalID: UUID,
|
||||
group: PedalControlGroup,
|
||||
controlLabel: String,
|
||||
oldValue: Double,
|
||||
newValue: Double
|
||||
)
|
||||
|
||||
/// A human-readable description of the action (e.g. `"Add Reverb"`, `"Drive"`), shown next to the
|
||||
/// Undo / Redo menu items and toolbar buttons.
|
||||
var label: String {
|
||||
switch self {
|
||||
case .structural(let label, _):
|
||||
return label
|
||||
case .parameter(let label, _, _, _, _, _):
|
||||
return label
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A horizontal board-mixer strip for switching between, or blending, multiple `PedalBoard`s.
|
||||
///
|
||||
@@ -78,6 +79,9 @@ public struct BoardBarView: View {
|
||||
private let onAddBoard: () -> Void
|
||||
private let onClearBoards: (() -> Void)?
|
||||
|
||||
/// Undo coordinator injected by the host; `nil` outside the builder (edits run directly).
|
||||
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
|
||||
|
||||
@State private var mode: PlayMode = .solo
|
||||
|
||||
// MARK: - Init
|
||||
@@ -247,7 +251,11 @@ public struct BoardBarView: View {
|
||||
}
|
||||
Divider()
|
||||
Button("Delete Board", role: .destructive) {
|
||||
shoeGaze.removeBoard(board)
|
||||
if let undo: UndoCoordinator = undo {
|
||||
undo.perform("Remove Board") { shoeGaze.removeBoard(board) }
|
||||
} else {
|
||||
shoeGaze.removeBoard(board)
|
||||
}
|
||||
clampEditingIndex()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,16 @@ public struct BoardFlowView: View {
|
||||
private let shoeGaze: ShoeGaze
|
||||
private let boardIndex: Int
|
||||
|
||||
/// When `true`, the view sizes to its content height and scrolls only horizontally, so it can sit
|
||||
/// inside an outer vertical scroller (the pre-board → board → post-board page) without a nested
|
||||
/// vertical scroll. When `false` (the default), it fills the available height and centres the
|
||||
/// chain, adding a vertical scroll only for tall parallel splits.
|
||||
private let sizesToContent: Bool
|
||||
|
||||
/// Undo coordinator injected by ``ShoeGazeBuilderView``; `nil` in lightweight hosts (previews),
|
||||
/// where edits run directly without recording history.
|
||||
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
|
||||
|
||||
/// Identifier of the lane/card currently hovered as a drop target, for highlight.
|
||||
@State private var dropTarget: String?
|
||||
|
||||
@@ -70,9 +80,10 @@ public struct BoardFlowView: View {
|
||||
/// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal.
|
||||
@State private var contentHeight: CGFloat = 0
|
||||
|
||||
public init(shoeGaze: ShoeGaze, boardIndex: Int) {
|
||||
public init(shoeGaze: ShoeGaze, boardIndex: Int, sizesToContent: Bool = false) {
|
||||
self.shoeGaze = shoeGaze
|
||||
self.boardIndex = boardIndex
|
||||
self.sizesToContent = sizesToContent
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
@@ -87,31 +98,45 @@ public struct BoardFlowView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func flow(board: PedalBoard) -> some View {
|
||||
let stages: [StageModel] = stageModels(board: board)
|
||||
return GeometryReader { proxy in
|
||||
let viewportHeight: CGFloat = proxy.size.height
|
||||
// Lock to horizontal, adding the vertical axis only when the chain is taller than the
|
||||
// viewport (deep parallel splits) so it can be reached instead of clipped.
|
||||
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
|
||||
? [.horizontal, .vertical]
|
||||
: .horizontal
|
||||
ScrollView(axes, showsIndicators: true) {
|
||||
// The spacers centre the chain vertically when it is shorter than the viewport; when
|
||||
// it overflows, the min-height floor is already exceeded so they collapse to zero and
|
||||
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
|
||||
// longer stretches them.
|
||||
VStack(spacing: 0) {
|
||||
Spacer(minLength: 0)
|
||||
chainRow(board: board, stages: stages)
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.frame(minHeight: viewportHeight)
|
||||
if sizesToContent {
|
||||
// One-scroller mode: the board is only as tall as its chain and scrolls horizontally,
|
||||
// so the outer vertical scroller flows pre-board → board → post-board as one page with
|
||||
// no nested vertical scroll. A tall parallel split simply makes the page taller.
|
||||
ScrollView(.horizontal, showsIndicators: true) {
|
||||
chainRow(board: board, stages: stages)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.frame(height: contentHeight > 0 ? contentHeight : nil)
|
||||
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
||||
contentHeight = height
|
||||
}
|
||||
} else {
|
||||
GeometryReader { proxy in
|
||||
let viewportHeight: CGFloat = proxy.size.height
|
||||
// Lock to horizontal, adding the vertical axis only when the chain is taller than the
|
||||
// viewport (deep parallel splits) so it can be reached instead of clipped.
|
||||
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
|
||||
? [.horizontal, .vertical]
|
||||
: .horizontal
|
||||
ScrollView(axes, showsIndicators: true) {
|
||||
// The spacers centre the chain vertically when it is shorter than the viewport; when
|
||||
// it overflows, the min-height floor is already exceeded so they collapse to zero and
|
||||
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
|
||||
// longer stretches them.
|
||||
VStack(spacing: 0) {
|
||||
Spacer(minLength: 0)
|
||||
chainRow(board: board, stages: stages)
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.frame(minHeight: viewportHeight)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
||||
contentHeight = height
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,12 +318,12 @@ public struct BoardFlowView: View {
|
||||
do {
|
||||
if split {
|
||||
guard !shoeGaze.isStereoUnzip(afterSegment: segmentIndex, in: board) else { return }
|
||||
_ = try shoeGaze.insertStereoUnzip(afterSegment: segmentIndex, in: board)
|
||||
try editing("Split L/R") { _ = try shoeGaze.insertStereoUnzip(afterSegment: segmentIndex, in: board) }
|
||||
} else {
|
||||
// Only remove the next segment if it is in fact this pedal's unzip region —
|
||||
// it may have been removed via the region's own trash button.
|
||||
guard shoeGaze.isStereoUnzip(afterSegment: segmentIndex, in: board) else { return }
|
||||
_ = try shoeGaze.removeSegment(at: segmentIndex + 1, from: board)
|
||||
try editing("Merge L/R") { _ = try shoeGaze.removeSegment(at: segmentIndex + 1, from: board) }
|
||||
}
|
||||
} catch {
|
||||
print("[BoardFlowView] split toggle failed: \(error)")
|
||||
@@ -507,7 +532,7 @@ public struct BoardFlowView: View {
|
||||
sourceIndex = index
|
||||
}
|
||||
do {
|
||||
_ = try shoeGaze.movePedal(from: sourceLane, at: sourceIndex, to: destination, in: board)
|
||||
try editing("Move Pedal") { _ = try shoeGaze.movePedal(from: sourceLane, at: sourceIndex, to: destination, in: board) }
|
||||
return true
|
||||
} catch {
|
||||
print("[BoardFlowView] cross-lane move failed: \(error)")
|
||||
@@ -522,15 +547,25 @@ public struct BoardFlowView: View {
|
||||
return shoeGaze.boards[boardIndex]
|
||||
}
|
||||
|
||||
/// Runs a structural edit through the undo coordinator (recording a checkpoint when it changes
|
||||
/// the rig), or directly when no coordinator is present.
|
||||
@discardableResult
|
||||
private func editing<T>(_ label: String, _ action: () throws -> T) rethrows -> T {
|
||||
if let undo: UndoCoordinator = undo {
|
||||
return try undo.perform(label, action)
|
||||
}
|
||||
return try action()
|
||||
}
|
||||
|
||||
private func append(type: String, lane: PedalLane) {
|
||||
guard let board: PedalBoard = board else { return }
|
||||
do { _ = try shoeGaze.appendPedal(PedalType(type), to: board, lane: lane) }
|
||||
do { try editing("Add \(type)") { _ = try shoeGaze.appendPedal(PedalType(type), to: board, lane: lane) } }
|
||||
catch { print("[BoardFlowView] appendPedal failed: \(error)") }
|
||||
}
|
||||
|
||||
private func insert(type: String, at index: Int, lane: PedalLane) {
|
||||
guard let board: PedalBoard = board else { return }
|
||||
do { _ = try shoeGaze.insertPedal(PedalType(type), at: index, to: board, lane: lane) }
|
||||
do { try editing("Add \(type)") { _ = try shoeGaze.insertPedal(PedalType(type), at: index, to: board, lane: lane) } }
|
||||
catch { print("[BoardFlowView] insertPedal failed: \(error)") }
|
||||
}
|
||||
|
||||
@@ -539,20 +574,20 @@ public struct BoardFlowView: View {
|
||||
// Convert "dropped ONTO the card at `target`" into movePedal's insert-before `toOffset`:
|
||||
// a forward move lands after the target (target + 1); a backward move lands before it.
|
||||
let destination: Int = source < target ? target + 1 : target
|
||||
do { _ = try shoeGaze.movePedal(from: source, to: destination, in: board, lane: .main) }
|
||||
do { try editing("Move Pedal") { _ = try shoeGaze.movePedal(from: source, to: destination, in: board, lane: .main) } }
|
||||
catch { print("[BoardFlowView] movePedal(main) failed: \(error)") }
|
||||
}
|
||||
|
||||
private func reorderBranch(from source: Int, onto target: Int, lane: PedalLane) {
|
||||
guard source != target, let board: PedalBoard = board else { return }
|
||||
let destination: Int = source < target ? target + 1 : target
|
||||
do { _ = try shoeGaze.movePedal(from: source, to: destination, in: board, lane: lane) }
|
||||
do { try editing("Move Pedal") { _ = try shoeGaze.movePedal(from: source, to: destination, in: board, lane: lane) } }
|
||||
catch { print("[BoardFlowView] movePedal(branch) failed: \(error)") }
|
||||
}
|
||||
|
||||
private func removePedal(at index: Int, lane: PedalLane) {
|
||||
guard let board: PedalBoard = board else { return }
|
||||
do { _ = try shoeGaze.removePedal(at: index, from: board, lane: lane) }
|
||||
do { try editing("Remove Pedal") { _ = try shoeGaze.removePedal(at: index, from: board, lane: lane) } }
|
||||
catch { print("[BoardFlowView] removePedal failed: \(error)") }
|
||||
}
|
||||
|
||||
@@ -563,7 +598,7 @@ public struct BoardFlowView: View {
|
||||
|
||||
private func removeSegment(at segmentIndex: Int) {
|
||||
guard let board: PedalBoard = board else { return }
|
||||
do { _ = try shoeGaze.removeSegment(at: segmentIndex, from: board) }
|
||||
do { try editing("Remove Section") { _ = try shoeGaze.removeSegment(at: segmentIndex, from: board) } }
|
||||
catch { print("[BoardFlowView] removeSegment failed: \(error)") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A full board manager presented as a sheet — the richer companion to the inline
|
||||
/// ``BoardBarView``.
|
||||
@@ -47,6 +48,9 @@ public struct BoardsSheetView: View {
|
||||
private let onAddBoard: () -> Void
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
/// Undo coordinator; re-injected onto this sheet by the builder so board moves/removals here
|
||||
/// record history. `nil` outside the builder (edits run directly).
|
||||
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
|
||||
@State private var mode: PlayMode = .solo
|
||||
|
||||
// MARK: - Init
|
||||
@@ -218,13 +222,24 @@ public struct BoardsSheetView: View {
|
||||
// SwiftUI's destination is the insertion point in the pre-move list; moveBoard
|
||||
// removes first, so shift down by one when moving forward.
|
||||
let target: Int = destination > sourceIndex ? destination - 1 : destination
|
||||
shoeGaze.moveBoard(board, to: target)
|
||||
if let undo: UndoCoordinator = undo {
|
||||
undo.perform("Move Board") { shoeGaze.moveBoard(board, to: target) }
|
||||
} else {
|
||||
shoeGaze.moveBoard(board, to: target)
|
||||
}
|
||||
clampEditingIndex()
|
||||
}
|
||||
|
||||
private func deleteBoards(_ offsets: IndexSet) {
|
||||
for index: Int in offsets.sorted(by: >) where index < shoeGaze.boards.count {
|
||||
shoeGaze.removeBoard(shoeGaze.boards[index])
|
||||
let remove: () -> Void = {
|
||||
for index: Int in offsets.sorted(by: >) where index < shoeGaze.boards.count {
|
||||
shoeGaze.removeBoard(shoeGaze.boards[index])
|
||||
}
|
||||
}
|
||||
if let undo: UndoCoordinator = undo {
|
||||
undo.perform("Remove Board", remove)
|
||||
} else {
|
||||
remove()
|
||||
}
|
||||
clampEditingIndex()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Renders a ``ChainRouter`` as a vertical stack with transport controls, two labelled
|
||||
/// board rows, and a merger + optional master-gain output stage.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user