Compare commits
65 Commits
v2.0.0
...
31fa1b9cd3
| Author | SHA1 | Date | |
|---|---|---|---|
| 31fa1b9cd3 | |||
| 9c0f89bae6 | |||
| 651706126c | |||
| cda596b9d5 | |||
| a7534a29db | |||
| e88db04686 | |||
| da4d5e23ea | |||
| 8cd77ad984 | |||
| 818478ce1b | |||
| 415e99dd62 | |||
| 71d9b44809 | |||
| 4de8379cb8 | |||
| 690030a4c5 | |||
| 8a08264fb4 | |||
| e5deb8f94a | |||
| 9abc613fc3 | |||
| 48dce06f5a | |||
| b9a63eeaf5 | |||
| 9588d77137 | |||
| 5d8e655dab | |||
| 17a0845225 | |||
| 29b1747533 | |||
| 102715ded1 | |||
| 27fb6e6898 | |||
| a9e91ef08c | |||
| c9795f7305 | |||
| 6718914ee0 | |||
| 544a07d569 | |||
| fb50538e84 | |||
| e1ed4e348c | |||
| 3fe6b8a50a | |||
| 59370ee5dd | |||
| 8a266a33dc | |||
| ec4e7dc5a4 | |||
| 733e979c1b | |||
| 1b247cf766 | |||
| 23d607b9fc | |||
| 40fa590196 | |||
| fe31eb6d7d | |||
| 77df1675cb | |||
| 4a5d4009f6 | |||
| 791fbd1b2c | |||
| 323988af7b | |||
| ed3283f645 | |||
| 8983e8829e | |||
| e697789bd7 | |||
| 09fa4e8d4b | |||
| 37777826d1 | |||
| a1a7683bc9 | |||
| 3d67c7b450 | |||
| 551b650d45 | |||
| 7720fbec7b | |||
| 3228614071 | |||
| e207728a12 | |||
| e36074e9d3 | |||
| b29c8848ef | |||
| be0e3d118b | |||
| 5542ee5b5a | |||
| b0294612f8 | |||
| cc3a986cde | |||
| 5987ec7b78 | |||
| f61961b90b | |||
| 7e39842eb2 | |||
| 2772abdc56 | |||
| a33d5488c9 |
@@ -20,3 +20,6 @@ DerivedData/
|
|||||||
# Note: Package.resolved is intentionally tracked to pin the Lyrebird dependency.
|
# Note: Package.resolved is intentionally tracked to pin the Lyrebird dependency.
|
||||||
icon-source.png
|
icon-source.png
|
||||||
review.diff
|
review.diff
|
||||||
|
|
||||||
|
# Local working plan (not shared)
|
||||||
|
docs/plans/amp-expansion-plan.md
|
||||||
|
|||||||
@@ -4,6 +4,97 @@ 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
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
||||||
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.1.3] — 2026-07-13
|
||||||
|
|
||||||
|
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output —
|
||||||
|
even with "Mute while tuning" on — until a steady note was detected.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Tuner no longer leaks into the audio output.** The tuner's pitch-detection stage
|
||||||
|
was mistakenly written to an audio output bus instead of its internal analysis bus,
|
||||||
|
so the tracked frequency was summed onto an output channel — bypassing the rig mute
|
||||||
|
and crackling while the pitch was still unstable (it stopped once a note locked). The
|
||||||
|
tuner now writes only to its analysis bus; engaging it leaves the output untouched.
|
||||||
|
|
||||||
|
## [2.1.1] — 2026-07-12
|
||||||
|
|
||||||
|
A quieter, more predictable startup. The input feeding the pedals now has its own
|
||||||
|
mute — separate from the rig-output mute — that arms every time you start the engine,
|
||||||
|
so nothing squeals the instant it spins up. New rigs open listening to In 0 instead of
|
||||||
|
the test-loop phrase, and your input choice and I/O channel counts now travel with the
|
||||||
|
rig (and iCloud) instead of a separate local setting.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Input mute.** A hard kill-switch on the incoming guitar / mic signal, distinct from
|
||||||
|
the rig-output mute. It arms automatically every time you press Start (so a fresh
|
||||||
|
engine is silent until you're ready), sits next to the Start/Stop transport with a
|
||||||
|
pulsing red glow while active, and is MIDI-mappable (footswitch or key), like Rig Mute.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **New rigs open on In 0** (live input) instead of the built-in test-loop phrase.
|
||||||
|
- **Input & I/O persist with the rig.** The input selection and the engine's input /
|
||||||
|
output channel counts are stored in the rig (and sync via iCloud), and are reapplied
|
||||||
|
on launch — so a multi-channel setup and a chosen input channel survive a restart
|
||||||
|
instead of reverting to the defaults. Replaces the previous local-only input setting.
|
||||||
|
- The docked (macOS) transport shows the Bypass / Mute / Input toggles as icons so the
|
||||||
|
row no longer crowds the sample-rate and channel controls.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A muted input is now **exactly** silent from the first sample — no brief start-up
|
||||||
|
transient when the engine begins rendering.
|
||||||
|
- iOS: the app declares in-place document support, clearing a launch-time console warning.
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
|
||||||
|
Additive: rigs saved before this release load unchanged (input defaults to In 0, or the
|
||||||
|
test loop when no live input is available), and 2.1.1 rigs still open in older builds —
|
||||||
|
the input-mute state isn't persisted and the extra I/O fields are ignored there.
|
||||||
|
|
||||||
|
## [2.1.0] — 2026-07-10
|
||||||
|
|
||||||
|
Tempo comes to the pedals. Delay times and modulation rates can lock to a note
|
||||||
|
division of the live tempo — a quarter-note delay, a dotted-eighth, an eighth-triplet
|
||||||
|
LFO — shown with real music-notation glyphs and following the tempo as it changes.
|
||||||
|
Delays reach further, the BPM is directly editable, and every mappable control shows
|
||||||
|
its MIDI / key binding right on the pedal.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Tempo-synced pedal parameters.** Lock a delay time or a modulation rate to a note
|
||||||
|
division — whole down to sixteenth, including dotted and triplet values — and it is
|
||||||
|
derived from the shared tempo, following tap tempo, the stepper, the BPM field, and
|
||||||
|
MIDI. Delay time on Delay, Feedback Delay, Ping-Pong, Reverse Delay, and each of
|
||||||
|
Multi-Tap's three taps; LFO rate on Tremolo, Vibrato, Chorus, Flanger, Phaser, and
|
||||||
|
Modulation. A MIDI CC bound to a synced parameter is ignored while it stays synced
|
||||||
|
(the tempo drives the value) and resumes control once the parameter is set to Free.
|
||||||
|
- **Note-value glyphs.** The division picker uses drawn music-notation glyphs —
|
||||||
|
noteheads, stems, flags, an augmentation dot for dotted values, and a bracketed "3"
|
||||||
|
over triplets — instead of text labels.
|
||||||
|
- **Editable BPM.** The tempo readout is now a text field: type a tempo directly
|
||||||
|
(integer only, clamped to 30–300 BPM). The stepper and tap tempo still work, and a
|
||||||
|
synced pedal follows a typed change immediately.
|
||||||
|
- **In-context control mapping.** Each pedal draws a small badge on every mappable
|
||||||
|
control showing its binding source — Program Change footswitch (PC), Control Change
|
||||||
|
expression (CC), or letter Key (KEY) — with a legend above the board. Completes the
|
||||||
|
computer-keyboard control mapping.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Longer delays.** Maximum delay time raised to 5 seconds across the delay pedals
|
||||||
|
(previously 1–2 s), so tempo-synced values at slow tempos (whole and half notes) fit.
|
||||||
|
- Note divisions that would exceed a parameter's range at the current tempo are shown
|
||||||
|
disabled in the picker, and an active sync that has to clamp shows a warning marker.
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
|
||||||
|
Additive: rigs saved before this release load unchanged (every parameter defaults to
|
||||||
|
"free"), and 2.1 rigs still open in older builds — the tempo-sync state is simply
|
||||||
|
ignored there.
|
||||||
|
|
||||||
## [2.0.0] — 2026-07-05
|
## [2.0.0] — 2026-07-05
|
||||||
|
|
||||||
Major release. Performance-focused: a visual metronome, a real rig mute with
|
Major release. Performance-focused: a visual metronome, a real rig mute with
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = 1;
|
BuildIndependentTargetsInParallel = 1;
|
||||||
LastSwiftUpdateCheck = 1600;
|
LastSwiftUpdateCheck = 1600;
|
||||||
LastUpgradeCheck = 2620;
|
LastUpgradeCheck = 2660;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
C3B100000000000000000014 = {
|
C3B100000000000000000014 = {
|
||||||
CreatedOnToolsVersion = 16.0;
|
CreatedOnToolsVersion = 16.0;
|
||||||
@@ -163,10 +163,9 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 8;
|
CURRENT_PROJECT_VERSION = 14;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
@@ -176,7 +175,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 2.0.0;
|
MARKETING_VERSION = 2.1.6;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -194,9 +193,8 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 8;
|
CURRENT_PROJECT_VERSION = 14;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
@@ -206,7 +204,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 2.0.0;
|
MARKETING_VERSION = 2.1.6;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -249,6 +247,7 @@
|
|||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
@@ -311,6 +310,7 @@
|
|||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
||||||
"version" : "1.2.0"
|
"version" : "1.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2620"
|
LastUpgradeVersion = "2660"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
||||||
|
// The engine is built with the default layout; the autosaved rig's saved I/O layout (if any)
|
||||||
|
// is applied by `RigStore.restore` below, so a multi-channel setup survives relaunch.
|
||||||
let engine: SynthesisEngine = SynthesisEngine(
|
let engine: SynthesisEngine = SynthesisEngine(
|
||||||
blockSize: AppDelegate.blockSize,
|
blockSize: AppDelegate.blockSize,
|
||||||
sampleRate: AppDelegate.sampleRate,
|
sampleRate: AppDelegate.sampleRate,
|
||||||
@@ -127,6 +129,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
|||||||
|
|
||||||
/// Seeds one board with a single pedal so the builder opens with an audible starting point.
|
/// Seeds one board with a single pedal so the builder opens with an audible starting point.
|
||||||
private static func seedInitialBoard(into shoeGaze: ShoeGaze) {
|
private static func seedInitialBoard(into shoeGaze: ShoeGaze) {
|
||||||
|
// Fresh launch (no autosaved rig): default to live In 0 rather than the test-loop arpeggio,
|
||||||
|
// so the app comes up listening to the instrument. A restored rig keeps its own saved input.
|
||||||
|
if shoeGaze.engine.numInputChannels > 0 {
|
||||||
|
shoeGaze.inputSource = .liveInput(channel: 0)
|
||||||
|
}
|
||||||
var created: PedalBoard?
|
var created: PedalBoard?
|
||||||
do {
|
do {
|
||||||
let board: PedalBoard = try shoeGaze.addBoard()
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 200 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 643 KiB |
@@ -28,9 +28,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.0.0</string>
|
<string>${MARKETING_VERSION}</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>7</string>
|
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.music</string>
|
<string>public.app-category.music</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
C3C10000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001C /* LyrebirdUI */; };
|
C3C10000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001C /* LyrebirdUI */; };
|
||||||
C3C10000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001E /* Lyrebird */; };
|
C3C10000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001E /* Lyrebird */; };
|
||||||
C3C100000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000030 /* Assets.xcassets */; };
|
C3C100000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000030 /* Assets.xcassets */; };
|
||||||
|
C3C1000000000000000000B1 /* SplashView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C1000000000000000000B0 /* SplashView.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSApp.swift; sourceTree = "<group>"; };
|
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSApp.swift; sourceTree = "<group>"; };
|
||||||
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSAppModel.swift; sourceTree = "<group>"; };
|
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSAppModel.swift; sourceTree = "<group>"; };
|
||||||
C3C100000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
C3C100000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
C3C1000000000000000000B0 /* SplashView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashView.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -60,6 +62,7 @@
|
|||||||
children = (
|
children = (
|
||||||
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */,
|
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */,
|
||||||
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */,
|
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */,
|
||||||
|
C3C1000000000000000000B0 /* SplashView.swift */,
|
||||||
C3C100000000000000000030 /* Assets.xcassets */,
|
C3C100000000000000000030 /* Assets.xcassets */,
|
||||||
C3C100000000000000000006 /* Info.plist */,
|
C3C100000000000000000006 /* Info.plist */,
|
||||||
);
|
);
|
||||||
@@ -100,7 +103,7 @@
|
|||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = 1;
|
BuildIndependentTargetsInParallel = 1;
|
||||||
LastSwiftUpdateCheck = 1600;
|
LastSwiftUpdateCheck = 1600;
|
||||||
LastUpgradeCheck = 2620;
|
LastUpgradeCheck = 2660;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
C3C100000000000000000011 = {
|
C3C100000000000000000011 = {
|
||||||
CreatedOnToolsVersion = 16.0;
|
CreatedOnToolsVersion = 16.0;
|
||||||
@@ -147,6 +150,7 @@
|
|||||||
files = (
|
files = (
|
||||||
C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */,
|
C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */,
|
||||||
C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */,
|
C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */,
|
||||||
|
C3C1000000000000000000B1 /* SplashView.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -163,7 +167,6 @@
|
|||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 7;
|
CURRENT_PROJECT_VERSION = 7;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
|
||||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
@@ -192,7 +195,6 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 7;
|
CURRENT_PROJECT_VERSION = 7;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
|
||||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
@@ -246,6 +248,7 @@
|
|||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
@@ -308,6 +311,7 @@
|
|||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
||||||
"version" : "1.2.0"
|
"version" : "1.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2620"
|
LastUpgradeVersion = "2660"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 402 KiB After Width: | Height: | Size: 643 KiB |
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : { "red" : "0.080", "green" : "0.070", "blue" : "0.060", "alpha" : "1.000" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : { "author" : "xcode", "version" : 1 }
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{ "idiom" : "universal", "filename" : "splashlogo.png", "scale" : "1x" },
|
||||||
|
{ "idiom" : "universal", "filename" : "splashlogo@2x.png", "scale" : "2x" },
|
||||||
|
{ "idiom" : "universal", "filename" : "splashlogo@3x.png", "scale" : "3x" }
|
||||||
|
],
|
||||||
|
"info" : { "author" : "xcode", "version" : 1 }
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 420 KiB |
@@ -17,6 +17,10 @@
|
|||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</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>
|
<key>CFBundleExecutable</key>
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
@@ -55,7 +59,10 @@
|
|||||||
<false/>
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>UILaunchScreen</key>
|
<key>UILaunchScreen</key>
|
||||||
<dict/>
|
<dict>
|
||||||
|
<key>UIColorName</key>
|
||||||
|
<string>LaunchBackground</string>
|
||||||
|
</dict>
|
||||||
<key>UIRequiresFullScreen</key>
|
<key>UIRequiresFullScreen</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
|||||||
@@ -20,21 +20,30 @@ import LyrebirdShoeGazeUI
|
|||||||
struct ShoeGazeBuilderiOSApp: App {
|
struct ShoeGazeBuilderiOSApp: App {
|
||||||
|
|
||||||
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
||||||
|
@State private var showSplash: Bool = true
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
ShoeGazeBuilderView(
|
ZStack {
|
||||||
shoeGaze: model.shoeGaze,
|
ShoeGazeBuilderView(
|
||||||
library: model.library,
|
shoeGaze: model.shoeGaze,
|
||||||
hardwareSampleRate: { model.hardwareSampleRate },
|
library: model.library,
|
||||||
onEnableLiveInput: { model.enableLiveInput() },
|
hardwareSampleRate: { model.hardwareSampleRate },
|
||||||
midi: model.midi
|
onEnableLiveInput: { model.enableLiveInput() },
|
||||||
)
|
midi: model.midi
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
)
|
||||||
.task { await model.startLibrary() }
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||||
.onDisappear { model.stop() }
|
.task { await model.startLibrary() }
|
||||||
.onOpenURL { url in model.importDocument(at: url) }
|
.onDisappear { model.stop() }
|
||||||
|
.onOpenURL { url in model.importDocument(at: url) }
|
||||||
|
|
||||||
|
if showSplash {
|
||||||
|
SplashView(isActive: $showSplash)
|
||||||
|
.transition(.opacity)
|
||||||
|
.zIndex(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: scenePhase) { _, phase in
|
.onChange(of: scenePhase) { _, phase in
|
||||||
// Persist the rig whenever the app leaves the foreground.
|
// Persist the rig whenever the app leaves the foreground.
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
private static let numAudioBuses: Int = 256
|
private static let numAudioBuses: Int = 256
|
||||||
private static let seedPedalType: PedalType = .overdrive
|
private static let seedPedalType: PedalType = .overdrive
|
||||||
|
|
||||||
/// UserDefaults key persisting the input selection. Must match the key written by the
|
|
||||||
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
|
||||||
private static let inputSelectionDefaultsKey: String = "ShoeGaze.inputSelection"
|
|
||||||
/// Persisted value meaning "live input, channel 0".
|
|
||||||
private static let liveInputChannelZeroTag: Int = 0
|
|
||||||
|
|
||||||
// MARK: - Owned objects
|
// MARK: - Owned objects
|
||||||
|
|
||||||
/// The active ShoeGaze builder session. Swapped out when live input is enabled (the engine
|
/// The active ShoeGaze builder session. Swapped out when live input is enabled (the engine
|
||||||
@@ -144,6 +138,8 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
) -> (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) {
|
) -> (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) {
|
||||||
let sampleRate: Double = AVAudioSession.sharedInstance().sampleRate
|
let sampleRate: Double = AVAudioSession.sharedInstance().sampleRate
|
||||||
let driver: iOSAudioDriver = iOSAudioDriver()
|
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||||
|
// The engine is built with the default layout; the autosaved rig's saved I/O (if any) is
|
||||||
|
// applied by `RigStore.restore`, so an output change survives relaunch.
|
||||||
let engine: SynthesisEngine = SynthesisEngine(
|
let engine: SynthesisEngine = SynthesisEngine(
|
||||||
blockSize: ShoeGazeBuilderiOSAppModel.blockSize,
|
blockSize: ShoeGazeBuilderiOSAppModel.blockSize,
|
||||||
sampleRate: sampleRate,
|
sampleRate: sampleRate,
|
||||||
@@ -222,14 +218,12 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
if wasRunning { try? engine.start() }
|
if wasRunning { try? engine.start() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Selects live input on channel 0 and persists the choice for restore-on-relaunch.
|
/// Selects live input on channel 0 and autosaves so the rig (the source of truth for the input
|
||||||
|
/// selection) records it for restore-on-relaunch.
|
||||||
private func selectLiveInputAndPersist() {
|
private func selectLiveInputAndPersist() {
|
||||||
do {
|
do {
|
||||||
try shoeGaze.setInputSource(.liveInput(channel: 0))
|
try shoeGaze.setInputSource(.liveInput(channel: 0))
|
||||||
UserDefaults.standard.set(
|
save()
|
||||||
ShoeGazeBuilderiOSAppModel.liveInputChannelZeroTag,
|
|
||||||
forKey: ShoeGazeBuilderiOSAppModel.inputSelectionDefaultsKey
|
|
||||||
)
|
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderiOS] selecting live input failed: \(error)")
|
print("[ShoeGazeBuilderiOS] selecting live input failed: \(error)")
|
||||||
}
|
}
|
||||||
@@ -237,6 +231,11 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
|
|
||||||
/// Seeds a single default board so the rig is never empty after a failed restore.
|
/// Seeds a single default board so the rig is never empty after a failed restore.
|
||||||
private static func seedFallbackBoard(into shoeGaze: ShoeGaze) {
|
private static func seedFallbackBoard(into shoeGaze: ShoeGaze) {
|
||||||
|
// Fresh launch (no autosaved rig): default to live In 0 rather than the test-loop arpeggio.
|
||||||
|
// A restored rig keeps its own saved input selection.
|
||||||
|
if shoeGaze.engine.numInputChannels > 0 {
|
||||||
|
shoeGaze.inputSource = .liveInput(channel: 0)
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
let board: PedalBoard = try shoeGaze.addBoard()
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
board.label = "Board 1"
|
board.label = "Board 1"
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// SplashView.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// Animated launch splash shown over the app on cold start.
|
||||||
|
///
|
||||||
|
/// The native launch screen (`UILaunchScreen` → `LaunchBackground`) paints an instant dark
|
||||||
|
/// backdrop with no visible jump; this view then fades and scales the ShoeGaze pedal logo in,
|
||||||
|
/// holds briefly, and fades the whole overlay away to reveal ``ShoeGazeBuilderView``. Colors match
|
||||||
|
/// the app background so the hand-off is seamless. Respects Reduce Motion by skipping the scale.
|
||||||
|
struct SplashView: View {
|
||||||
|
|
||||||
|
/// Background matching the builder's app background (`0.08, 0.07, 0.06`).
|
||||||
|
private static let backgroundColor: Color = Color(red: 0.08, green: 0.07, blue: 0.06)
|
||||||
|
|
||||||
|
private static let logoSize: CGFloat = 200
|
||||||
|
private static let logoCornerRadius: CGFloat = 44
|
||||||
|
private static let logoStartScale: CGFloat = 0.86
|
||||||
|
private static let wordmarkKerning: CGFloat = 4
|
||||||
|
|
||||||
|
private static let logoFadeInDuration: Double = 0.55
|
||||||
|
private static let wordmarkFadeInDelay: Double = 0.30
|
||||||
|
private static let wordmarkFadeInDuration: Double = 0.45
|
||||||
|
private static let holdDuration: Double = 0.85
|
||||||
|
private static let fadeOutDuration: Double = 0.45
|
||||||
|
|
||||||
|
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
||||||
|
|
||||||
|
/// Set false to fade the overlay out; parent removes it when the fade completes.
|
||||||
|
@Binding var isActive: Bool
|
||||||
|
|
||||||
|
@State private var logoOpacity: Double = 0
|
||||||
|
@State private var logoScale: CGFloat = SplashView.logoStartScale
|
||||||
|
@State private var wordmarkOpacity: Double = 0
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
SplashView.backgroundColor
|
||||||
|
.ignoresSafeArea()
|
||||||
|
|
||||||
|
VStack(spacing: 22) {
|
||||||
|
Image("SplashLogo")
|
||||||
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
.frame(width: SplashView.logoSize, height: SplashView.logoSize)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: SplashView.logoCornerRadius,
|
||||||
|
style: .continuous))
|
||||||
|
.opacity(logoOpacity)
|
||||||
|
.scaleEffect(logoScale)
|
||||||
|
|
||||||
|
Text("ShoeGaze")
|
||||||
|
.font(.system(size: 34, weight: .semibold, design: .rounded))
|
||||||
|
.kerning(SplashView.wordmarkKerning)
|
||||||
|
.foregroundStyle(.white)
|
||||||
|
.opacity(wordmarkOpacity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onAppear { runSequence() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private func runSequence() {
|
||||||
|
withAnimation(.easeOut(duration: SplashView.logoFadeInDuration)) {
|
||||||
|
logoOpacity = 1
|
||||||
|
if !reduceMotion { logoScale = 1 }
|
||||||
|
}
|
||||||
|
withAnimation(.easeOut(duration: SplashView.wordmarkFadeInDuration)
|
||||||
|
.delay(SplashView.wordmarkFadeInDelay)) {
|
||||||
|
wordmarkOpacity = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
let holdUntil: Double = SplashView.logoFadeInDuration + SplashView.holdDuration
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + holdUntil) {
|
||||||
|
withAnimation(.easeIn(duration: SplashView.fadeOutDuration)) {
|
||||||
|
isActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "8bbfcc5441e68d57cefd08aed960cbac3875af1e0f8b1d2d3fbdd4dadc0ac18c",
|
"originHash" : "bc2a61a4b15bd882ede79ecb295b7878eca7ce7b55f4832eaf9bd7e7f557dd4f",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "linenoise-swift",
|
"identity" : "linenoise-swift",
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
"revision" : "ea0aa84ca796d9a21667e4b5a7d76a1ac2c280b6",
|
||||||
"version" : "1.2.3"
|
"version" : "1.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ let package = Package(
|
|||||||
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
|
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.2.3"),
|
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.7.1"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
// The core target depends on LyrebirdUI as well as the synthesis core:
|
// The core target depends on LyrebirdUI as well as the synthesis core:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ signal (no hardware needed) or on live guitar through an audio input.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **35 modeled pedals** across gain, dynamics, EQ/filter, modulation, pitch, delay, reverb, and
|
- **36 modeled pedals** across gain, dynamics, EQ/filter, modulation, pitch, delay, reverb, and
|
||||||
texture — see the catalog below.
|
texture — see the catalog below.
|
||||||
- **Multi-board rigs** — build several boards and a board-mixer bar to **Solo** one (amp-channel
|
- **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
|
style) or **Blend** any subset, each with its own level and a click-free crossfade, plus a
|
||||||
@@ -39,7 +39,7 @@ signal (no hardware needed) or on live guitar through an audio input.
|
|||||||
|---|---|
|
|---|---|
|
||||||
| Gain | Overdrive, Distortion, Fuzz |
|
| Gain | Overdrive, Distortion, Fuzz |
|
||||||
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate |
|
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate |
|
||||||
| EQ & filter | Graphic EQ, Auto-Wah, Mutant |
|
| EQ & filter | Graphic EQ, Auto-Wah, Mutant, Cabinet |
|
||||||
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Rotary, Ring Modulator |
|
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Rotary, Ring Modulator |
|
||||||
| Pitch | Bass Octaver, Octave Splitter, Harmonizer |
|
| Pitch | Bass Octaver, Octave Splitter, Harmonizer |
|
||||||
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay |
|
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay |
|
||||||
|
|||||||
@@ -1,4 +1,64 @@
|
|||||||
# Releases
|
# Releases
|
||||||
|
## ShoeGaze 2.1.3
|
||||||
|
|
||||||
|
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output — even
|
||||||
|
with "Mute while tuning" on — until you played a steady note.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Tuner no longer leaks into the output.** The pitch-detection stage was written to an
|
||||||
|
audio output bus instead of its internal analysis bus, so the tracked frequency was
|
||||||
|
summed onto an output channel — bypassing the rig mute and crackling while the pitch was
|
||||||
|
unstable (it stopped once a note locked). The tuner now writes only to its analysis bus.
|
||||||
|
|
||||||
|
## ShoeGaze 2.1.1
|
||||||
|
|
||||||
|
A quieter, more predictable startup. The signal feeding the pedals now has its own mute
|
||||||
|
that arms every time you start the engine, new rigs open listening to your instrument,
|
||||||
|
and your input and I/O settings travel with the rig instead of a local-only setting.
|
||||||
|
|
||||||
|
### Highlights
|
||||||
|
- **Input mute** — a hard kill-switch on the incoming guitar / mic signal, separate from
|
||||||
|
the rig-output mute. Arms automatically on every Start (silent until you're ready),
|
||||||
|
sits by the Start/Stop transport with a pulsing red glow while active, and is
|
||||||
|
MIDI-mappable like Rig Mute. A muted input is exactly silent from the first sample.
|
||||||
|
- **Opens on In 0** — new rigs listen to live input instead of the test-loop phrase.
|
||||||
|
- **Input & I/O persist with the rig** — the input selection and engine input/output
|
||||||
|
channel counts are stored in the rig (and iCloud) and reapplied on launch, so a
|
||||||
|
multi-channel setup and a chosen input survive a restart. Replaces the old local-only
|
||||||
|
input setting.
|
||||||
|
- **Tidier transport** — the docked macOS Bypass / Mute / Input toggles are icons so the
|
||||||
|
row no longer crowds the rate and channel controls.
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
Additive: rigs saved before this release load unchanged, and 2.1.1 rigs still open in
|
||||||
|
older builds (input-mute state isn't persisted; the extra I/O fields are ignored there).
|
||||||
|
|
||||||
|
## ShoeGaze 2.1.0
|
||||||
|
|
||||||
|
Tempo comes to the pedals. Delay times and LFO rates can lock to note divisions of the
|
||||||
|
live tempo — shown with real music-notation glyphs and following the tempo as it
|
||||||
|
changes — plus a directly-editable BPM, longer delays, and per-control MIDI/key mapping
|
||||||
|
badges on every pedal.
|
||||||
|
|
||||||
|
### Highlights
|
||||||
|
- **Tempo-synced parameters** — lock a delay time or a modulation rate to a note value
|
||||||
|
(whole → sixteenth, dotted, triplet); it follows tap tempo, the stepper, the BPM
|
||||||
|
field, and MIDI. Delay, Feedback Delay, Ping-Pong, Reverse, and Multi-Tap (per tap);
|
||||||
|
Tremolo, Vibrato, Chorus, Flanger, Phaser, Modulation.
|
||||||
|
- **Notation glyphs** — the picker draws real note glyphs (augmentation dot for dotted
|
||||||
|
values, a bracketed "3" over triplets) instead of text.
|
||||||
|
- **Editable BPM** — type a tempo directly (integer, 30–300); the stepper and tap still
|
||||||
|
work, and synced pedals follow immediately.
|
||||||
|
- **Longer delays** — maximum delay time raised to 5 s so slow synced values fit.
|
||||||
|
- **Control mapping badges** — every pedal shows the PC (footswitch), CC (expression),
|
||||||
|
or KEY (letter key) binding on each control, with a legend above the board.
|
||||||
|
- **CC respects tempo sync** — a CC bound to a synced parameter is ignored while synced
|
||||||
|
(the tempo drives it) and resumes control once the parameter is set back to Free.
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
Additive persistence — older rigs load unchanged (every parameter defaults to free),
|
||||||
|
and 2.1 rigs open in older builds with the tempo-sync state ignored.
|
||||||
|
|
||||||
## ShoeGaze 2.0.0
|
## ShoeGaze 2.0.0
|
||||||
|
|
||||||
Major release. Performance-focused: a visual metronome, a real rig mute with
|
Major release. Performance-focused: a visual metronome, a real rig mute with
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "39c6a5f1535f779ef8a83b5ea2ab6f965ee3b28ad8419b94679e422a92f75603",
|
"originHash" : "f5174c66e77b86ada0723482273f3d43cce9269f39894b2deb371f09e04069ab",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "linenoise-swift",
|
"identity" : "linenoise-swift",
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
|
"revision" : "ea0aa84ca796d9a21667e4b5a7d76a1ac2c280b6",
|
||||||
"version" : "1.2.3"
|
"version" : "1.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
// CabinetIRFactory.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import Darwin
|
||||||
|
|
||||||
|
/// Fraction of the sample rate above which a filter centre frequency is clamped, so the RBJ
|
||||||
|
/// coefficients stay well-behaved below Nyquist even at low sample rates.
|
||||||
|
private let cabinetBiquadNyquistFraction: Double = 0.49
|
||||||
|
/// RBJ-cookbook divisor converting a peaking-filter gain in dB to its `A` amplitude term.
|
||||||
|
private let cabinetPeakingGainDivisor: Double = 40.0
|
||||||
|
|
||||||
|
/// Synthesizes a short cabinet impulse response for a ``CabinetVoice`` by running a unit
|
||||||
|
/// impulse through a cascade of RBJ biquads (high-pass → two-stage low-pass → low-mid body
|
||||||
|
/// peak → presence peak → cone-breakup peak → mid notch) and capturing the result into a mono
|
||||||
|
/// ``LyrebirdBuffer``.
|
||||||
|
///
|
||||||
|
/// This runs **off the RT thread** (at pedal build time), so it uses plain `Double` math with
|
||||||
|
/// no allocation constraints. The produced buffer is a normal IR consumed by `ConvolutionReverb`.
|
||||||
|
public enum CabinetIRFactory {
|
||||||
|
|
||||||
|
/// Default IR length in frames. 1024 taps (~21 ms at 48 kHz) is ample for a speaker-cab
|
||||||
|
/// magnitude curve, which has no long tail.
|
||||||
|
public static let defaultFrames: Int = 1024
|
||||||
|
|
||||||
|
/// Butterworth Q for the high-pass (low rolloff) stage.
|
||||||
|
private static let highPassQ: Double = 0.707
|
||||||
|
/// Per-stage Q values for a true 4th-order Butterworth low-pass built as two cascaded
|
||||||
|
/// biquads (maximally flat passband). Q ≈ 0.5412 and 1.3066.
|
||||||
|
private static let lowPassCascadeQ: [Double] = [0.541_196_100_146_197, 1.306_562_964_876_377]
|
||||||
|
/// Q for the resonant body / presence peaks.
|
||||||
|
private static let peakQ: Double = 1.2
|
||||||
|
/// Q for the narrower cone-breakup peak (higher than the body/presence peaks).
|
||||||
|
private static let breakupQ: Double = 2.0
|
||||||
|
/// Q for the mid interference notch (narrow, so it dips without gutting the midrange).
|
||||||
|
private static let notchQ: Double = 2.5
|
||||||
|
|
||||||
|
/// Builds the impulse response for `voice` at `sampleRate`.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - voice: The cabinet voicing to synthesize.
|
||||||
|
/// - 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,
|
||||||
|
sampleRate: Double,
|
||||||
|
frames: Int = CabinetIRFactory.defaultFrames
|
||||||
|
) -> LyrebirdBuffer {
|
||||||
|
var chain: [OfflineBiquad] = [
|
||||||
|
OfflineBiquad.highPass(freq: voice.highPassHz, q: highPassQ, sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[0], sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[1], sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.peaking(freq: voice.bodyHz, q: peakQ, gainDb: voice.bodyGainDb, sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.peaking(freq: voice.presenceHz, q: peakQ, gainDb: voice.presenceGainDb, sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.peaking(freq: voice.breakupHz, q: breakupQ, gainDb: voice.breakupGainDb, sampleRate: sampleRate),
|
||||||
|
OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate),
|
||||||
|
]
|
||||||
|
|
||||||
|
var ir: [Double] = [Double](repeating: 0.0, count: frames)
|
||||||
|
for n: Int in 0..<frames {
|
||||||
|
var sample: Double = n == 0 ? 1.0 : 0.0
|
||||||
|
for i: Int in chain.indices {
|
||||||
|
sample = chain[i].process(sample)
|
||||||
|
}
|
||||||
|
ir[n] = sample
|
||||||
|
}
|
||||||
|
|
||||||
|
// Peak-normalize so the cab contributes unity-ish level regardless of the filter gains.
|
||||||
|
let peak: Double = ir.reduce(0.0) { Swift.max($0, abs($1)) }
|
||||||
|
if peak > 0.0 {
|
||||||
|
let inv: Double = 1.0 / peak
|
||||||
|
for i: Int in ir.indices { ir[i] *= inv }
|
||||||
|
}
|
||||||
|
|
||||||
|
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: frames, channelCount: 1)
|
||||||
|
buffer.fill(using: { (frame: Int, _: Int) -> Double in ir[frame] })
|
||||||
|
buffer.setSampleRate(sampleRate)
|
||||||
|
return buffer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A minimal off-RT RBJ biquad (transposed Direct Form II) used only to render cabinet IRs.
|
||||||
|
private struct OfflineBiquad {
|
||||||
|
private let b0: Double
|
||||||
|
private let b1: Double
|
||||||
|
private let b2: Double
|
||||||
|
private let a1: Double
|
||||||
|
private let a2: Double
|
||||||
|
private var z1: Double = 0.0
|
||||||
|
private var z2: Double = 0.0
|
||||||
|
|
||||||
|
private init(
|
||||||
|
b0: Double,
|
||||||
|
b1: Double,
|
||||||
|
b2: Double,
|
||||||
|
a1: Double,
|
||||||
|
a2: Double
|
||||||
|
) {
|
||||||
|
self.b0 = b0
|
||||||
|
self.b1 = b1
|
||||||
|
self.b2 = b2
|
||||||
|
self.a1 = a1
|
||||||
|
self.a2 = a2
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Centre frequency clamped below Nyquist for the given sample rate.
|
||||||
|
private static func clampedFreq(_ freq: Double, sampleRate: Double) -> Double {
|
||||||
|
Swift.min(freq, sampleRate * cabinetBiquadNyquistFraction)
|
||||||
|
}
|
||||||
|
|
||||||
|
mutating func process(_ x: Double) -> Double {
|
||||||
|
let y: Double = b0 * x + z1
|
||||||
|
z1 = b1 * x - a1 * y + z2
|
||||||
|
z2 = b2 * x - a2 * y
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
|
||||||
|
static func highPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||||
|
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||||
|
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||||
|
let cosW0: Double = cos(w0)
|
||||||
|
let alpha: Double = sin(w0) / (2.0 * q)
|
||||||
|
let a0: Double = 1.0 + alpha
|
||||||
|
let b0: Double = (1.0 + cosW0) / 2.0
|
||||||
|
let b1: Double = -(1.0 + cosW0)
|
||||||
|
let b2: Double = (1.0 + cosW0) / 2.0
|
||||||
|
let a1: Double = -2.0 * cosW0
|
||||||
|
let a2: Double = 1.0 - alpha
|
||||||
|
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func lowPass(freq: Double, q: Double, sampleRate: Double) -> OfflineBiquad {
|
||||||
|
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||||
|
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||||
|
let cosW0: Double = cos(w0)
|
||||||
|
let alpha: Double = sin(w0) / (2.0 * q)
|
||||||
|
let a0: Double = 1.0 + alpha
|
||||||
|
let b0: Double = (1.0 - cosW0) / 2.0
|
||||||
|
let b1: Double = 1.0 - cosW0
|
||||||
|
let b2: Double = (1.0 - cosW0) / 2.0
|
||||||
|
let a1: Double = -2.0 * cosW0
|
||||||
|
let a2: Double = 1.0 - alpha
|
||||||
|
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func peaking(freq: Double, q: Double, gainDb: Double, sampleRate: Double) -> OfflineBiquad {
|
||||||
|
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||||
|
let amplitude: Double = pow(10.0, gainDb / cabinetPeakingGainDivisor)
|
||||||
|
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||||
|
let cosW0: Double = cos(w0)
|
||||||
|
let alpha: Double = sin(w0) / (2.0 * q)
|
||||||
|
let a0: Double = 1.0 + alpha / amplitude
|
||||||
|
let b0: Double = 1.0 + alpha * amplitude
|
||||||
|
let b1: Double = -2.0 * cosW0
|
||||||
|
let b2: Double = 1.0 - alpha * amplitude
|
||||||
|
let a1: Double = -2.0 * cosW0
|
||||||
|
let a2: Double = 1.0 - alpha / amplitude
|
||||||
|
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
// CabinetVoice.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// A built-in guitar-speaker-cabinet voicing.
|
||||||
|
///
|
||||||
|
/// Each voice is a compact set of target-response parameters — low/high rolloff, a low-mid
|
||||||
|
/// "body" bump, an upper-mid "presence" peak, a higher cone-"breakup" peak, and a mid
|
||||||
|
/// interference "notch" — from which ``CabinetIRFactory`` synthesizes a short impulse response
|
||||||
|
/// entirely in code. These IRs are **our own content** (MIT, generated, no third-party capture),
|
||||||
|
/// so they ship with the pedal without licensing concerns. (Loading a user-supplied captured
|
||||||
|
/// `.wav` cab IR is a planned follow-up.)
|
||||||
|
///
|
||||||
|
/// The values are deliberately broad-strokes voicings, not measurements of specific hardware.
|
||||||
|
public enum CabinetVoice: String, CaseIterable, Sendable {
|
||||||
|
case americanCombo
|
||||||
|
case britishStack
|
||||||
|
case vintageDark
|
||||||
|
case modernStack
|
||||||
|
case boutiqueOpen
|
||||||
|
case brightCombo
|
||||||
|
case fullRange
|
||||||
|
case loFiBox
|
||||||
|
|
||||||
|
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||||
|
/// range. Used by the cab selector to pick the single voice to instantiate on a board rebuild.
|
||||||
|
///
|
||||||
|
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||||
|
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||||
|
public static func voice(atSelectorValue selectorValue: Double) -> CabinetVoice {
|
||||||
|
let all: [CabinetVoice] = allCases
|
||||||
|
guard selectorValue.isFinite else { return all[0] }
|
||||||
|
// Clamp in Double space first so a huge/NaN-adjacent value can never trap `Int(_:)`.
|
||||||
|
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||||
|
let index: Int = Int(bounded.rounded())
|
||||||
|
return all[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Human-readable name for pickers.
|
||||||
|
public var displayName: String {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return "American 1×12"
|
||||||
|
case .britishStack: return "British 4×12"
|
||||||
|
case .vintageDark: return "Vintage Dark"
|
||||||
|
case .modernStack: return "Modern 4×12"
|
||||||
|
case .boutiqueOpen: return "Boutique 2×12"
|
||||||
|
case .brightCombo: return "Bright 1×12"
|
||||||
|
case .fullRange: return "Full-Range (FRFR)"
|
||||||
|
case .loFiBox: return "Lo-Fi 1×8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Low-frequency rolloff (high-pass cutoff) in Hz — the speaker's bass limit.
|
||||||
|
var highPassHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 80.0
|
||||||
|
case .britishStack: return 95.0
|
||||||
|
case .vintageDark: return 90.0
|
||||||
|
case .modernStack: return 100.0
|
||||||
|
case .boutiqueOpen: return 70.0
|
||||||
|
case .brightCombo: return 85.0
|
||||||
|
case .fullRange: return 45.0
|
||||||
|
case .loFiBox: return 180.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// High-frequency rolloff (low-pass cutoff) in Hz — the speaker's top-end limit. Applied as a
|
||||||
|
/// two-stage cascade for a steeper, more speaker-like slope.
|
||||||
|
var lowPassHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 5500.0
|
||||||
|
case .britishStack: return 4500.0
|
||||||
|
case .vintageDark: return 3800.0
|
||||||
|
case .modernStack: return 4000.0
|
||||||
|
case .boutiqueOpen: return 6000.0
|
||||||
|
case .brightCombo: return 6500.0
|
||||||
|
case .fullRange: return 9000.0
|
||||||
|
case .loFiBox: return 3000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Low-mid "body" peak centre in Hz.
|
||||||
|
var bodyHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 420.0
|
||||||
|
case .britishStack: return 700.0
|
||||||
|
case .vintageDark: return 500.0
|
||||||
|
case .modernStack: return 900.0
|
||||||
|
case .boutiqueOpen: return 450.0
|
||||||
|
case .brightCombo: return 550.0
|
||||||
|
case .fullRange: return 300.0
|
||||||
|
case .loFiBox: return 900.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Low-mid body peak gain in dB (may be negative for a scoop).
|
||||||
|
var bodyGainDb: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 1.5
|
||||||
|
case .britishStack: return -2.0
|
||||||
|
case .vintageDark: return 2.0
|
||||||
|
case .modernStack: return 2.0
|
||||||
|
case .boutiqueOpen: return -1.0
|
||||||
|
case .brightCombo: return 1.0
|
||||||
|
case .fullRange: return 0.0
|
||||||
|
case .loFiBox: return 4.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Presence peak centre in Hz — the upper-mid "bite".
|
||||||
|
var presenceHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 3000.0
|
||||||
|
case .britishStack: return 2500.0
|
||||||
|
case .vintageDark: return 2200.0
|
||||||
|
case .modernStack: return 3200.0
|
||||||
|
case .boutiqueOpen: return 3500.0
|
||||||
|
case .brightCombo: return 3800.0
|
||||||
|
case .fullRange: return 4000.0
|
||||||
|
case .loFiBox: return 2400.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Presence peak gain in dB.
|
||||||
|
var presenceGainDb: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 3.0
|
||||||
|
case .britishStack: return 4.0
|
||||||
|
case .vintageDark: return 2.0
|
||||||
|
case .modernStack: return 5.0
|
||||||
|
case .boutiqueOpen: return 2.0
|
||||||
|
case .brightCombo: return 4.0
|
||||||
|
case .fullRange: return 1.0
|
||||||
|
case .loFiBox: return 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cone-"breakup" peak centre in Hz — the higher, narrower bite/clank a real driver adds as
|
||||||
|
/// the cone breaks up. Sits above the presence peak.
|
||||||
|
var breakupHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 4200.0
|
||||||
|
case .britishStack: return 3800.0
|
||||||
|
case .vintageDark: return 3500.0
|
||||||
|
case .modernStack: return 3800.0
|
||||||
|
case .boutiqueOpen: return 5000.0
|
||||||
|
case .brightCombo: return 5200.0
|
||||||
|
case .fullRange: return 6000.0
|
||||||
|
case .loFiBox: return 2600.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cone-breakup peak gain in dB. Small; `0` disables the peak (identity).
|
||||||
|
var breakupGainDb: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 2.0
|
||||||
|
case .britishStack: return 3.0
|
||||||
|
case .vintageDark: return 1.5
|
||||||
|
case .modernStack: return 3.0
|
||||||
|
case .boutiqueOpen: return 1.5
|
||||||
|
case .brightCombo: return 3.0
|
||||||
|
case .fullRange: return 0.5
|
||||||
|
case .loFiBox: return 2.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mid interference "notch" centre in Hz — the characteristic dip from cone/mic
|
||||||
|
/// comb-filtering, typically ~1.2–2.5 kHz.
|
||||||
|
var notchHz: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return 1800.0
|
||||||
|
case .britishStack: return 1600.0
|
||||||
|
case .vintageDark: return 1500.0
|
||||||
|
case .modernStack: return 1700.0
|
||||||
|
case .boutiqueOpen: return 2000.0
|
||||||
|
case .brightCombo: return 2100.0
|
||||||
|
case .fullRange: return 2000.0
|
||||||
|
case .loFiBox: return 1200.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Notch depth in dB (negative). `0` disables the notch (identity).
|
||||||
|
var notchGainDb: Double {
|
||||||
|
switch self {
|
||||||
|
case .americanCombo: return -3.0
|
||||||
|
case .britishStack: return -4.0
|
||||||
|
case .vintageDark: return -2.5
|
||||||
|
case .modernStack: return -5.0
|
||||||
|
case .boutiqueOpen: return -2.0
|
||||||
|
case .brightCombo: return -2.0
|
||||||
|
case .fullRange: return 0.0
|
||||||
|
case .loFiBox: return -1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
// OversampledRingModulator.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import Darwin
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||||
|
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||||
|
private let oversampledRingModZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Ring modulator (`input × sine carrier`) evaluated at 2× or 4× the engine sample rate.
|
||||||
|
///
|
||||||
|
/// A ring modulator's product produces sum-and-difference sidebands at `f_in ± f_carrier`. The
|
||||||
|
/// sum sideband can land above the engine Nyquist and fold back as an inharmonic alias —
|
||||||
|
/// worst with a high carrier and bright input. Evaluating the multiply at an oversampled rate
|
||||||
|
/// (the input upsampled through a halfband FIR, the carrier generated directly at the
|
||||||
|
/// oversampled rate) pushes the sum term below the upsampled Nyquist, then the matching
|
||||||
|
/// downsampler filters it out before returning to the engine rate.
|
||||||
|
///
|
||||||
|
/// Output is mono (channel 0 of the input is used).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to modulate.
|
||||||
|
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||||
|
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||||
|
public final class OversampledRingModulator: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||||
|
private let inputSource: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// Resolved carrier-frequency control. Read once per block.
|
||||||
|
private let freqInput: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||||
|
private let oversampleFactor: Int
|
||||||
|
|
||||||
|
/// Carrier phase in radians, advanced at the oversampled rate and wrapped to `[0, 2π)`.
|
||||||
|
private var phase: Double = 0.0
|
||||||
|
|
||||||
|
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||||
|
private var upsampler2x: HalfbandUpsampler2x
|
||||||
|
private var downsampler2x: HalfbandDownsampler2x
|
||||||
|
|
||||||
|
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||||
|
private var upsampler4x: HalfbandUpsampler4x
|
||||||
|
private var downsampler4x: HalfbandDownsampler4x
|
||||||
|
|
||||||
|
private let twoPi: Double = 2.0 * Double.pi
|
||||||
|
|
||||||
|
/// Creates an oversampled ring modulator.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to modulate.
|
||||||
|
/// - freq: Carrier frequency in Hz. Read once per block. Defaults to `220.0`.
|
||||||
|
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||||
|
public init(
|
||||||
|
_ input: any ValidGeneratorInput,
|
||||||
|
freq: any ValidGeneratorInput = 220.0,
|
||||||
|
oversample: Int = 2
|
||||||
|
) {
|
||||||
|
precondition(
|
||||||
|
oversample == 2 || oversample == 4,
|
||||||
|
"OversampledRingModulator: oversample must be 2 or 4"
|
||||||
|
)
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
let resolvedFreq: any ValidGeneratorInput = freq._resolvedInput()
|
||||||
|
inputSource = resolvedInput
|
||||||
|
freqInput = resolvedFreq
|
||||||
|
oversampleFactor = oversample
|
||||||
|
upsampler2x = HalfbandUpsampler2x()
|
||||||
|
downsampler2x = HalfbandDownsampler2x()
|
||||||
|
upsampler4x = HalfbandUpsampler4x()
|
||||||
|
downsampler4x = HalfbandDownsampler4x()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||||
|
?? oversampledRingModZeroBlock
|
||||||
|
let sr: Double = graph.engine.sampleRate
|
||||||
|
// A degenerate sample rate would make phaseInc NaN/Inf and latch NaN into the
|
||||||
|
// persisted phase; zero-fill and bail, matching MoogLadder's guard.
|
||||||
|
guard sr >= 1.0 else {
|
||||||
|
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||||
|
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||||
|
for i: Int in 0..<count { dstP[i] = 0 }
|
||||||
|
}
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
let freq: Double = freqInput.floatValue(graph: graph)
|
||||||
|
let inCount: Int = input.count
|
||||||
|
let useFourX: Bool = oversampleFactor == 4
|
||||||
|
// Phase increment per oversampled sample.
|
||||||
|
let factor: Double = useFourX ? 4.0 : 2.0
|
||||||
|
let phaseInc: Double = twoPi * freq / (sr * factor)
|
||||||
|
|
||||||
|
var localPhase: Double = phase
|
||||||
|
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||||
|
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||||
|
if useFourX {
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = i < inCount ? input[i] : 0
|
||||||
|
let (a, b, c, d) = upsampler4x.process(x)
|
||||||
|
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||||
|
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||||
|
let yc: Double = c * sin(localPhase); localPhase += phaseInc
|
||||||
|
let yd: Double = d * sin(localPhase); localPhase += phaseInc
|
||||||
|
// Wrap both directions — a negative carrier frequency drives phaseInc
|
||||||
|
// negative, so an upward-only wrap would let the phase grow unbounded.
|
||||||
|
if localPhase >= twoPi || localPhase < 0 {
|
||||||
|
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||||
|
if localPhase < 0 { localPhase += twoPi }
|
||||||
|
}
|
||||||
|
dstP[i] = downsampler4x.process(ya, yb, yc, yd)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = i < inCount ? input[i] : 0
|
||||||
|
let (a, b) = upsampler2x.process(x)
|
||||||
|
let ya: Double = a * sin(localPhase); localPhase += phaseInc
|
||||||
|
let yb: Double = b * sin(localPhase); localPhase += phaseInc
|
||||||
|
// Wrap both directions (see 4× branch).
|
||||||
|
if localPhase >= twoPi || localPhase < 0 {
|
||||||
|
localPhase = localPhase.truncatingRemainder(dividingBy: twoPi)
|
||||||
|
if localPhase < 0 { localPhase += twoPi }
|
||||||
|
}
|
||||||
|
dstP[i] = downsampler2x.process(ya, yb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
phase = localPhase
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
// OversampledSaturator.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load. Returned when an upstream
|
||||||
|
/// input yields no channel for a `_computeSamples` call, so the RT path never allocates.
|
||||||
|
private let oversampledSaturatorZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// A waveshaping saturator that evaluates its nonlinearity at 2× or 4× the engine sample
|
||||||
|
/// rate to keep the harmonics it generates from folding back into the audible band as
|
||||||
|
/// aliasing.
|
||||||
|
///
|
||||||
|
/// A hard or steep nonlinearity (`tanh` driven hard, a hard clipper) produces harmonics well
|
||||||
|
/// above the engine Nyquist. Evaluated at the base rate those harmonics alias — an
|
||||||
|
/// inharmonic, buzzy "crackle" that gets worse the louder and brighter the input and the
|
||||||
|
/// harder the drive. This generator upsamples the input, applies the ``SaturationCurve``
|
||||||
|
/// per oversampled sample, then downsamples with the matching halfband FIR, so the aliased
|
||||||
|
/// content is filtered out before returning to the engine rate.
|
||||||
|
///
|
||||||
|
/// Linear stages (DC-block high-pass, tone low-pass, output trim) do **not** alias and should
|
||||||
|
/// stay as ordinary graph nodes around this one — only the nonlinearity needs oversampling.
|
||||||
|
///
|
||||||
|
/// Output is mono (channel 0 of the input is used).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to saturate.
|
||||||
|
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||||
|
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||||
|
/// - oversample: Oversampling factor — `2` or `4`. Use `4` for hard-clipping curves whose
|
||||||
|
/// harmonics extend furthest; `2` is enough for `tanh`-family soft saturation. Defaults to `2`.
|
||||||
|
public final class OversampledSaturator: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||||
|
private let inputSource: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// Resolved drive control. Read once per block.
|
||||||
|
private let driveInput: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// The waveshaping curve applied per oversampled sample.
|
||||||
|
private let curve: SaturationCurve
|
||||||
|
|
||||||
|
/// Oversampling factor — `2` or `4`, fixed at init.
|
||||||
|
private let oversampleFactor: Int
|
||||||
|
|
||||||
|
/// Lower bound on drive so `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||||
|
private let minDrive: Double = 1.0e-4
|
||||||
|
|
||||||
|
/// 2× halfband oversampling state (used when `oversampleFactor == 2`).
|
||||||
|
private var upsampler2x: HalfbandUpsampler2x
|
||||||
|
private var downsampler2x: HalfbandDownsampler2x
|
||||||
|
|
||||||
|
/// 4× halfband oversampling state (used when `oversampleFactor == 4`).
|
||||||
|
private var upsampler4x: HalfbandUpsampler4x
|
||||||
|
private var downsampler4x: HalfbandDownsampler4x
|
||||||
|
|
||||||
|
/// Creates an oversampled saturator.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to saturate.
|
||||||
|
/// - drive: Drive amount fed to the curve. Clamped to a small positive floor. Defaults to `1.0`.
|
||||||
|
/// - curve: The ``SaturationCurve`` to apply per oversampled sample.
|
||||||
|
/// - oversample: Oversampling factor — `2` or `4`. Defaults to `2`.
|
||||||
|
public init(
|
||||||
|
_ input: any ValidGeneratorInput,
|
||||||
|
drive: any ValidGeneratorInput = 1.0,
|
||||||
|
curve: SaturationCurve,
|
||||||
|
oversample: Int = 2
|
||||||
|
) {
|
||||||
|
precondition(
|
||||||
|
oversample == 2 || oversample == 4,
|
||||||
|
"OversampledSaturator: oversample must be 2 or 4"
|
||||||
|
)
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
let resolvedDrive: any ValidGeneratorInput = drive._resolvedInput()
|
||||||
|
inputSource = resolvedInput
|
||||||
|
driveInput = resolvedDrive
|
||||||
|
self.curve = curve
|
||||||
|
oversampleFactor = oversample
|
||||||
|
upsampler2x = HalfbandUpsampler2x()
|
||||||
|
downsampler2x = HalfbandDownsampler2x()
|
||||||
|
upsampler4x = HalfbandUpsampler4x()
|
||||||
|
downsampler4x = HalfbandDownsampler4x()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
let input: [Double] = inputSource.calculatedSamples(graph: graph, count: count).first
|
||||||
|
?? oversampledSaturatorZeroBlock
|
||||||
|
let driveRaw: Double = driveInput.floatValue(graph: graph)
|
||||||
|
let drive: Double = Swift.max(minDrive, driveRaw)
|
||||||
|
let inCount: Int = input.count
|
||||||
|
let useFourX: Bool = oversampleFactor == 4
|
||||||
|
|
||||||
|
_result[0].withUnsafeMutableBufferPointer { (dst: inout UnsafeMutableBufferPointer<Double>) in
|
||||||
|
guard let dstP: UnsafeMutablePointer<Double> = dst.baseAddress else { return }
|
||||||
|
if useFourX {
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = i < inCount ? input[i] : 0
|
||||||
|
let (a, b, c, d) = upsampler4x.process(x)
|
||||||
|
dstP[i] = downsampler4x.process(
|
||||||
|
curve.apply(a, drive: drive),
|
||||||
|
curve.apply(b, drive: drive),
|
||||||
|
curve.apply(c, drive: drive),
|
||||||
|
curve.apply(d, drive: drive)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = i < inCount ? input[i] : 0
|
||||||
|
let (a, b) = upsampler2x.process(x)
|
||||||
|
dstP[i] = downsampler2x.process(
|
||||||
|
curve.apply(a, drive: drive),
|
||||||
|
curve.apply(b, drive: drive)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// SaturationCurve.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Darwin
|
||||||
|
|
||||||
|
/// The waveshaping curve applied per (oversampled) sample by ``OversampledSaturator``.
|
||||||
|
///
|
||||||
|
/// Each case reproduces the nonlinearity a specific drive pedal used to build inline from
|
||||||
|
/// stock generators, so moving that pedal onto the oversampled path is voicing-preserving:
|
||||||
|
///
|
||||||
|
/// - `tanhPreGain` — `tanh(drive · x)`. Symmetric soft saturation with the drive applied
|
||||||
|
/// *before* the `tanh` (the fuzz voicing: hard pre-gain squares the wave off).
|
||||||
|
/// - `softClipNormalized` — `tanh(drive · x) / tanh(drive)`. The same curve normalised so a
|
||||||
|
/// unity-drive signal passes near-linearly (the overdrive voicing).
|
||||||
|
/// - `tanhPostGainHardClip(low:high:)` — `clip(tanh(x) · drive, low, high)`. A gentle `tanh`
|
||||||
|
/// stage, post-gained by drive into a hard clipper (the distortion voicing). The hard clip
|
||||||
|
/// is the dominant harmonic source and the reason this curve wants the highest oversampling
|
||||||
|
/// factor.
|
||||||
|
public enum SaturationCurve: Sendable {
|
||||||
|
case tanhPreGain
|
||||||
|
case softClipNormalized
|
||||||
|
case tanhPostGainHardClip(low: Double, high: Double)
|
||||||
|
|
||||||
|
/// Applies the curve to a single sample.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - x: Input sample (already at the oversampled rate).
|
||||||
|
/// - drive: Drive amount. The caller clamps this to a small positive floor so
|
||||||
|
/// `softClipNormalized`'s `tanh(drive)` denominator is never zero.
|
||||||
|
/// - Returns: The shaped sample.
|
||||||
|
@inline(__always)
|
||||||
|
func apply(_ x: Double, drive: Double) -> Double {
|
||||||
|
switch self {
|
||||||
|
case .tanhPreGain:
|
||||||
|
return tanh(drive * x)
|
||||||
|
case .softClipNormalized:
|
||||||
|
return tanh(drive * x) / tanh(drive)
|
||||||
|
case .tanhPostGainHardClip(let low, let high):
|
||||||
|
let shaped: Double = tanh(x) * drive
|
||||||
|
return Swift.min(high, Swift.max(low, shaped))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import LyrebirdSynth
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
/// Internal synthesizer that copies one hardware input bus to a board head bus.
|
/// Internal synthesizer that copies one hardware input bus to a board head bus.
|
||||||
///
|
///
|
||||||
@@ -18,6 +19,17 @@ import LyrebirdSynth
|
|||||||
/// `teardown()` releases the head bus back to the allocator.
|
/// `teardown()` releases the head bus back to the allocator.
|
||||||
final class HardwareInputPassThrough: SynthesizerBase {
|
final class HardwareInputPassThrough: SynthesizerBase {
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Input mute — `0` = audible, `1` = muted (a hard gate on the incoming signal, distinct from
|
||||||
|
/// the rig-output mute). Driven across every board input node by `ShoeGaze.setInputMuted(_:)`,
|
||||||
|
/// which sets a newly-added node to the session's current mute state. Defaults audible so
|
||||||
|
/// direct users (e.g. `ChainRouter`) that don't drive the mute pass the signal through.
|
||||||
|
@UIParam var inputMute: Double = 0.0
|
||||||
|
|
||||||
|
/// The live `UIParamNode` backing `inputMute`, driven by `ShoeGaze.setInputMuted(_:)`.
|
||||||
|
var inputMuteNode: UIParamNode { $inputMute }
|
||||||
|
|
||||||
// MARK: - Routing
|
// MARK: - Routing
|
||||||
|
|
||||||
/// Index of the hardware input bus to read from (typically `engine.numOutputChannels`).
|
/// Index of the hardware input bus to read from (typically `engine.numOutputChannels`).
|
||||||
@@ -43,6 +55,11 @@ final class HardwareInputPassThrough: SynthesizerBase {
|
|||||||
// MARK: - Build
|
// MARK: - Build
|
||||||
|
|
||||||
override func build() {
|
override func build() {
|
||||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
|
||||||
|
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
|
||||||
|
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
|
||||||
|
// kill-switch mute is expected to be abrupt anyway.
|
||||||
|
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
|
||||||
|
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import LyrebirdSynth
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
/// Internal synthesizer that copies the shared global test-loop bus to a board head bus.
|
/// Internal synthesizer that copies the shared global test-loop bus to a board head bus.
|
||||||
///
|
///
|
||||||
@@ -19,6 +20,16 @@ import LyrebirdSynth
|
|||||||
/// - Note: Must be removed from the engine before the board's `teardown()` releases the head bus.
|
/// - Note: Must be removed from the engine before the board's `teardown()` releases the head bus.
|
||||||
final class TestLoopTap: SynthesizerBase {
|
final class TestLoopTap: SynthesizerBase {
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Input mute — `0` = audible, `1` = muted. Driven across every board input node by
|
||||||
|
/// `ShoeGaze.setInputMuted(_:)`, which sets a newly-added node to the session's current mute
|
||||||
|
/// state. Defaults audible so direct users that don't drive the mute pass the signal through.
|
||||||
|
@UIParam var inputMute: Double = 0.0
|
||||||
|
|
||||||
|
/// The live `UIParamNode` backing `inputMute`, driven by `ShoeGaze.setInputMuted(_:)`.
|
||||||
|
var inputMuteNode: UIParamNode { $inputMute }
|
||||||
|
|
||||||
// MARK: - Routing
|
// MARK: - Routing
|
||||||
|
|
||||||
/// Index of the shared global test-loop bus to read from.
|
/// Index of the shared global test-loop bus to read from.
|
||||||
@@ -44,6 +55,11 @@ final class TestLoopTap: SynthesizerBase {
|
|||||||
// MARK: - Build
|
// MARK: - Build
|
||||||
|
|
||||||
override func build() {
|
override func build() {
|
||||||
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
|
||||||
|
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
|
||||||
|
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
|
||||||
|
// kill-switch mute is expected to be abrupt anyway.
|
||||||
|
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
|
||||||
|
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public final class MIDIController {
|
|||||||
case cc(MIDIMap.CCTarget)
|
case cc(MIDIMap.CCTarget)
|
||||||
/// A toggle action awaiting a Program Change.
|
/// A toggle action awaiting a Program Change.
|
||||||
case action(MIDIMap.Action)
|
case action(MIDIMap.Action)
|
||||||
|
/// A toggle action awaiting a computer key press.
|
||||||
|
case key(MIDIMap.Action)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The control currently armed for Learn, or `nil` when not learning. Observable so the UI can
|
/// The control currently armed for Learn, or `nil` when not learning. Observable so the UI can
|
||||||
@@ -248,6 +250,14 @@ public final class MIDIController {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
guard let resolved: ResolvedCC = resolveCC(binding.target) else { continue }
|
guard let resolved: ResolvedCC = resolveCC(binding.target) else { continue }
|
||||||
|
// A parameter locked to a note division is driven by the tempo; a CC write would be
|
||||||
|
// overwritten on the next tempo change, so ignore it here. The binding stays intact and
|
||||||
|
// resumes control the moment the parameter is set back to Free.
|
||||||
|
if case let .pedalControl(pedalID, _, _, _) = binding.target,
|
||||||
|
let pedal: Pedal = pedal(id: pedalID),
|
||||||
|
pedal.isNodeTempoSynced(resolved.node) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
let mapped: Double = resolved.range.lowerBound
|
let mapped: Double = resolved.range.lowerBound
|
||||||
+ norm * (resolved.range.upperBound - resolved.range.lowerBound)
|
+ norm * (resolved.range.upperBound - resolved.range.lowerBound)
|
||||||
resolved.node.update(mapped)
|
resolved.node.update(mapped)
|
||||||
@@ -350,6 +360,8 @@ public final class MIDIController {
|
|||||||
shoeGaze.toggleRigBypassed()
|
shoeGaze.toggleRigBypassed()
|
||||||
case .rigMute:
|
case .rigMute:
|
||||||
shoeGaze.toggleRigMuted()
|
shoeGaze.toggleRigMuted()
|
||||||
|
case .inputMute:
|
||||||
|
shoeGaze.toggleInputMuted()
|
||||||
case .allBoards:
|
case .allBoards:
|
||||||
// One-shot: cancel any solo and bring every board back up.
|
// One-shot: cancel any solo and bring every board back up.
|
||||||
shoeGaze.selectAllBoards(crossfadeSeconds: boardActionCrossfade)
|
shoeGaze.selectAllBoards(crossfadeSeconds: boardActionCrossfade)
|
||||||
@@ -412,7 +424,7 @@ public final class MIDIController {
|
|||||||
/// Not used for resolution (bindings resolve by UUID) — purely a human-readable snapshot.
|
/// Not used for resolution (bindings resolve by UUID) — purely a human-readable snapshot.
|
||||||
private func hint(for action: MIDIMap.Action) -> String? {
|
private func hint(for action: MIDIMap.Action) -> String? {
|
||||||
switch action {
|
switch action {
|
||||||
case .rigBypass, .rigMute, .allBoards:
|
case .rigBypass, .rigMute, .inputMute, .allBoards:
|
||||||
return nil
|
return nil
|
||||||
case .boardSolo(let boardID), .boardAudible(let boardID), .boardBypass(let boardID):
|
case .boardSolo(let boardID), .boardAudible(let boardID), .boardBypass(let boardID):
|
||||||
return board(id: boardID)?.label
|
return board(id: boardID)?.label
|
||||||
@@ -438,6 +450,89 @@ public final class MIDIController {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Key learn + apply
|
||||||
|
|
||||||
|
/// Arms MIDI Learn for a toggle action awaiting a key: the next ingested key press binds to it.
|
||||||
|
public func armKeyLearn(_ action: MIDIMap.Action) {
|
||||||
|
learnTarget = .key(action)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The key binding currently assigned to an action, or `nil` if unbound.
|
||||||
|
public func keyBinding(for action: MIDIMap.Action) -> MIDIMap.KeyBinding? {
|
||||||
|
shoeGaze?.midiMap?.keys.first { $0.action == action }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes any key binding assigned to an action.
|
||||||
|
public func clearKeyBinding(for action: MIDIMap.Action) {
|
||||||
|
guard let shoeGaze: ShoeGaze = shoeGaze, var map: MIDIMap = shoeGaze.midiMap else { return }
|
||||||
|
let before: Int = map.keys.count
|
||||||
|
map.keys.removeAll { $0.action == action }
|
||||||
|
guard map.keys.count != before else { return }
|
||||||
|
shoeGaze.midiMap = map
|
||||||
|
onMapChanged?()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Normalizes a raw key string to the single lowercased character used for storage and matching,
|
||||||
|
/// or `nil` when the input is not exactly one letter or digit. Restricting to alphanumerics keeps
|
||||||
|
/// non-printing keys (Return, Tab, Escape, arrows — all single `Character`s) from being learned
|
||||||
|
/// and then silently swallowed app-wide.
|
||||||
|
private func normalizedKey(_ raw: String) -> String? {
|
||||||
|
let lowered: String = raw.lowercased()
|
||||||
|
guard lowered.count == 1, let character: Character = lowered.first, character.isASCII,
|
||||||
|
character.isLetter || character.isNumber else { return nil }
|
||||||
|
return lowered
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Routes a computer key press: captures a binding when armed for key Learn, otherwise performs
|
||||||
|
/// every action bound to that key + modifier combination. Returns `true` when the press was
|
||||||
|
/// consumed (learned or matched a binding) so the caller can swallow the event; `false` lets it
|
||||||
|
/// fall through.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - rawKey: The pressed key; normalized to a single lowercased character.
|
||||||
|
/// - modifiers: The modifier keys held with the press. `a` and `⇧a` bind independently.
|
||||||
|
@discardableResult
|
||||||
|
public func ingestKey(_ rawKey: String, modifiers: MIDIMap.KeyModifiers = []) -> Bool {
|
||||||
|
guard let key: String = normalizedKey(rawKey) else { return false }
|
||||||
|
if case .key(let action) = learnTarget {
|
||||||
|
captureKey(key: key, modifiers: modifiers, action: action)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return applyKey(key, modifiers: modifiers)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Captures a learned key binding for the armed action and clears the Learn state. One binding
|
||||||
|
/// per action — re-learning replaces it — but a single key may drive multiple actions (a scene),
|
||||||
|
/// so we do not steal by key.
|
||||||
|
private func captureKey(key: String, modifiers: MIDIMap.KeyModifiers, action: MIDIMap.Action) {
|
||||||
|
learnTarget = nil
|
||||||
|
guard let shoeGaze: ShoeGaze = shoeGaze else { return }
|
||||||
|
let binding: MIDIMap.KeyBinding = MIDIMap.KeyBinding(
|
||||||
|
key: key,
|
||||||
|
modifiers: modifiers,
|
||||||
|
action: action,
|
||||||
|
displayNameHint: hint(for: action)
|
||||||
|
)
|
||||||
|
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
||||||
|
map.keys.removeAll { $0.action == action }
|
||||||
|
map.keys.append(binding)
|
||||||
|
shoeGaze.midiMap = map
|
||||||
|
onMapChanged?()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Performs every action bound to a key + modifier combination. Returns `true` when at least one
|
||||||
|
/// binding matched (key and modifiers both equal).
|
||||||
|
private func applyKey(_ key: String, modifiers: MIDIMap.KeyModifiers) -> Bool {
|
||||||
|
guard let shoeGaze: ShoeGaze = shoeGaze, let map: MIDIMap = shoeGaze.midiMap else { return false }
|
||||||
|
var matched: Bool = false
|
||||||
|
for binding: MIDIMap.KeyBinding in map.keys
|
||||||
|
where binding.key == key && binding.modifiers == modifiers {
|
||||||
|
perform(binding.action)
|
||||||
|
matched = true
|
||||||
|
}
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Device detection
|
// MARK: - Device detection
|
||||||
|
|
||||||
private func refreshDevices() {
|
private func refreshDevices() {
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
|||||||
/// Control-Change → pedal-knob bindings (expression pedals).
|
/// Control-Change → pedal-knob bindings (expression pedals).
|
||||||
public var ccs: [CCBinding]
|
public var ccs: [CCBinding]
|
||||||
|
|
||||||
|
/// Computer letter/digit key → action bindings. Same toggle ``Action`` set as ``switches`` —
|
||||||
|
/// a key press is a software footswitch — but keys never drive continuous CC targets.
|
||||||
|
public var keys: [KeyBinding]
|
||||||
|
|
||||||
/// An empty map (no bindings).
|
/// An empty map (no bindings).
|
||||||
public static let empty: MIDIMap = MIDIMap()
|
public static let empty: MIDIMap = MIDIMap()
|
||||||
|
|
||||||
@@ -32,12 +36,32 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
|||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - switches: Program-Change bindings. Defaults to empty.
|
/// - switches: Program-Change bindings. Defaults to empty.
|
||||||
/// - ccs: Control-Change bindings. Defaults to empty.
|
/// - ccs: Control-Change bindings. Defaults to empty.
|
||||||
|
/// - keys: Letter-key bindings. Defaults to empty.
|
||||||
public init(
|
public init(
|
||||||
switches: [SwitchBinding] = [],
|
switches: [SwitchBinding] = [],
|
||||||
ccs: [CCBinding] = []
|
ccs: [CCBinding] = [],
|
||||||
|
keys: [KeyBinding] = []
|
||||||
) {
|
) {
|
||||||
self.switches = switches
|
self.switches = switches
|
||||||
self.ccs = ccs
|
self.ccs = ccs
|
||||||
|
self.keys = keys
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case switches
|
||||||
|
case ccs
|
||||||
|
case keys
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes a map, tolerating an absent `keys` list so a rig saved before keyboard mapping
|
||||||
|
/// existed still decodes with its `switches` / `ccs` intact (synthesized Codable would fail
|
||||||
|
/// the whole map on the missing key, silently dropping the MIDI bindings too). `encode(to:)`
|
||||||
|
/// stays synthesized and always writes `keys` (empty when there are none).
|
||||||
|
public init(from decoder: Decoder) throws {
|
||||||
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.switches = try container.decode([SwitchBinding].self, forKey: .switches)
|
||||||
|
self.ccs = try container.decode([CCBinding].self, forKey: .ccs)
|
||||||
|
self.keys = try container.decodeIfPresent([KeyBinding].self, forKey: .keys) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Action
|
// MARK: - Action
|
||||||
@@ -48,6 +72,8 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
|||||||
case rigBypass
|
case rigBypass
|
||||||
/// Mutes/unmutes the rig output (a hard silence, not a bypass).
|
/// Mutes/unmutes the rig output (a hard silence, not a bypass).
|
||||||
case rigMute
|
case rigMute
|
||||||
|
/// Mutes/unmutes the input feeding every board (the incoming guitar / mic signal).
|
||||||
|
case inputMute
|
||||||
/// Cancels any solo and makes every board audible again (the "All" button).
|
/// Cancels any solo and makes every board audible again (the "All" button).
|
||||||
case allBoards
|
case allBoards
|
||||||
case boardSolo(boardID: UUID)
|
case boardSolo(boardID: UUID)
|
||||||
@@ -127,6 +153,86 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Key modifiers
|
||||||
|
|
||||||
|
/// The modifier keys that qualify a ``KeyBinding``, so `a` and `⇧a` (and `⌃a`, `⌥a`) are
|
||||||
|
/// distinct triggers. Shift is a modifier here rather than being folded into the key's case,
|
||||||
|
/// which keeps the base key a single lowercased character on every platform. Command is
|
||||||
|
/// deliberately absent — it is reserved for the app's menu keyboard shortcuts.
|
||||||
|
public struct KeyModifiers: OptionSet, Codable, Equatable, Hashable, Sendable {
|
||||||
|
|
||||||
|
public let rawValue: Int
|
||||||
|
|
||||||
|
public init(rawValue: Int) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Shift key (`⇧`).
|
||||||
|
public static let shift: KeyModifiers = KeyModifiers(rawValue: 1 << 0)
|
||||||
|
/// The Control key (`⌃`).
|
||||||
|
public static let control: KeyModifiers = KeyModifiers(rawValue: 1 << 1)
|
||||||
|
/// The Option key (`⌥`).
|
||||||
|
public static let option: KeyModifiers = KeyModifiers(rawValue: 1 << 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Key binding
|
||||||
|
|
||||||
|
/// A computer letter/digit key bound to a toggle ``Action``. Fires on key-down when no text
|
||||||
|
/// field is focused; the same latch semantics as a footswitch (booleans flip in software,
|
||||||
|
/// `boardSolo` is exclusive). `key` is a single lowercased character; ``modifiers`` distinguish
|
||||||
|
/// `a` from `⇧a`, `⌃a`, and `⌥a`.
|
||||||
|
public struct KeyBinding: Codable, Equatable, Sendable {
|
||||||
|
|
||||||
|
/// The bound key as a single lowercased character (e.g. `"b"`, `"3"`).
|
||||||
|
public var key: String
|
||||||
|
|
||||||
|
/// The modifier keys held with ``key``. Empty for an unmodified press.
|
||||||
|
public var modifiers: KeyModifiers
|
||||||
|
|
||||||
|
/// The control to toggle.
|
||||||
|
public var action: Action
|
||||||
|
|
||||||
|
/// The resolved control's display name at learn time, for stale-binding detection.
|
||||||
|
public var displayNameHint: String?
|
||||||
|
|
||||||
|
/// Creates a key binding.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - key: The bound key, normalized to a single lowercased character.
|
||||||
|
/// - modifiers: The qualifying modifier keys. Defaults to none.
|
||||||
|
/// - action: The toggle action to perform.
|
||||||
|
/// - displayNameHint: Resolved control name at learn time. Defaults to `nil`.
|
||||||
|
public init(
|
||||||
|
key: String,
|
||||||
|
modifiers: KeyModifiers = [],
|
||||||
|
action: Action,
|
||||||
|
displayNameHint: String? = nil
|
||||||
|
) {
|
||||||
|
self.key = key
|
||||||
|
self.modifiers = modifiers
|
||||||
|
self.action = action
|
||||||
|
self.displayNameHint = displayNameHint
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case key
|
||||||
|
case modifiers
|
||||||
|
case action
|
||||||
|
case displayNameHint
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decodes a key binding, defaulting `modifiers` to none when absent so a binding saved
|
||||||
|
/// before modifiers existed still decodes (unmodified, as it was learned). `encode(to:)`
|
||||||
|
/// stays synthesized.
|
||||||
|
public init(from decoder: Decoder) throws {
|
||||||
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.key = try container.decode(String.self, forKey: .key)
|
||||||
|
self.modifiers = try container.decodeIfPresent(KeyModifiers.self, forKey: .modifiers) ?? []
|
||||||
|
self.action = try container.decode(Action.self, forKey: .action)
|
||||||
|
self.displayNameHint = try container.decodeIfPresent(String.self, forKey: .displayNameHint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - CC target
|
// MARK: - CC target
|
||||||
|
|
||||||
/// A continuous control an expression pedal can drive — either a specific pedal control (a knob
|
/// A continuous control an expression pedal can drive — either a specific pedal control (a knob
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ open class Pedal: SynthesizerBase {
|
|||||||
/// Output gain as a linear multiplier. `1.0` = unity gain.
|
/// Output gain as a linear multiplier. `1.0` = unity gain.
|
||||||
@UIParam public var level: Double = 1.0
|
@UIParam public var level: Double = 1.0
|
||||||
|
|
||||||
|
/// Optional path to an external resource this pedal references (e.g. a neural-amp model file).
|
||||||
|
/// Not a `@UIParam` — it's a `String`, applied at `build()`, and persisted separately in
|
||||||
|
/// ``PedalState/resourcePath``. Default `nil`. Pedals that don't use an external file ignore it.
|
||||||
|
public var resourcePath: String?
|
||||||
|
|
||||||
// MARK: - Sample rate
|
// MARK: - Sample rate
|
||||||
|
|
||||||
/// Engine sample rate, injected by `PedalBoard.add(_:)` before the pedal is added
|
/// Engine sample rate, injected by `PedalBoard.add(_:)` before the pedal is added
|
||||||
@@ -73,6 +78,16 @@ open class Pedal: SynthesizerBase {
|
|||||||
/// the engine owns the node tree, not the reverse.
|
/// the engine owns the node tree, not the reverse.
|
||||||
public internal(set) weak var hostEngine: SynthesisEngine?
|
public internal(set) weak var hostEngine: SynthesisEngine?
|
||||||
|
|
||||||
|
// MARK: - Tempo sync
|
||||||
|
|
||||||
|
/// Sync state per tempo-syncable parameter, keyed by ``TempoSyncableParam/key``. A missing
|
||||||
|
/// key means ``TempoSync/free``. Persisted in ``PedalState`` and restored on rig load.
|
||||||
|
public internal(set) var tempoSync: [String: TempoSync] = [:]
|
||||||
|
|
||||||
|
/// Observable signal bumped on every ``tempoSync`` change so a SwiftUI badge re-renders when the
|
||||||
|
/// sync state changes through any path (the picker, a preset load, or a lightweight recall).
|
||||||
|
public let tempoSyncRevision: TempoSyncRevision = TempoSyncRevision()
|
||||||
|
|
||||||
// MARK: - Identity / routing
|
// MARK: - Identity / routing
|
||||||
|
|
||||||
/// Stable identity for this pedal instance, persisted in ``PedalState`` and used by MIDI
|
/// Stable identity for this pedal instance, persisted in ``PedalState`` and used by MIDI
|
||||||
@@ -222,6 +237,23 @@ open class Pedal: SynthesizerBase {
|
|||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Current values of every ``effectSelectors`` and ``effectSwitches`` entry flagged
|
||||||
|
/// `rebuildsOnChange` — the controls whose choice changes the graph topology (e.g. a cabinet
|
||||||
|
/// voice or a clean/drive channel). A lightweight recall compares this before/after applying a
|
||||||
|
/// snapshot to decide whether the board must be rebuilt (a plain node write does not re-enter
|
||||||
|
/// `effect(_:)`). Empty for pedals with no such controls.
|
||||||
|
public var rebuildTopologyValues: [Double] {
|
||||||
|
// Sanitize non-finite to a fixed sentinel: the before/after compare in a recall uses `!=`,
|
||||||
|
// and `NaN != NaN` would force a spurious rebuild on every recall.
|
||||||
|
let selectorValues: [Double] = effectSelectors
|
||||||
|
.filter { $0.rebuildsOnChange }
|
||||||
|
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||||
|
let switchValues: [Double] = effectSwitches
|
||||||
|
.filter { $0.rebuildsOnChange }
|
||||||
|
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||||
|
return selectorValues + switchValues
|
||||||
|
}
|
||||||
|
|
||||||
/// Effect-specific transport controls, rendered as a row directly below the knobs — above
|
/// Effect-specific transport controls, rendered as a row directly below the knobs — above
|
||||||
/// ``effectButtons``. Use for the persistent state toggles and transport stops that read as
|
/// ``effectButtons``. Use for the persistent state toggles and transport stops that read as
|
||||||
/// a group distinct from the momentary "do it now" actions (e.g. a looper's Loop / Stop /
|
/// a group distinct from the momentary "do it now" actions (e.g. a looper's Loop / Stop /
|
||||||
@@ -266,6 +298,60 @@ open class Pedal: SynthesizerBase {
|
|||||||
return knobControls + sliderControls
|
return knobControls + sliderControls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Tempo sync
|
||||||
|
|
||||||
|
/// Parameters this pedal exposes to tempo sync (delay times, LFO rates). Empty by default —
|
||||||
|
/// override in subclasses whose time- or rate-based parameters can lock to the tempo.
|
||||||
|
///
|
||||||
|
/// Each descriptor's ``TempoSyncableParam/key`` must be unique within the pedal and stable
|
||||||
|
/// across versions (it is the persistence key). Order is the order the sync controls appear.
|
||||||
|
open var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Recomputes and writes every parameter currently locked to a note division, from the shared
|
||||||
|
/// clock's tempo. Main-thread only — writing a `@UIParam` is the same path as a knob turn.
|
||||||
|
///
|
||||||
|
/// A no-op when no clock is injected. Free parameters are left untouched. A synced value that
|
||||||
|
/// falls outside the parameter's range (a long division past a delay's maximum time) is clamped.
|
||||||
|
/// Called by `ShoeGaze` whenever the tempo changes and whenever a parameter's sync state changes.
|
||||||
|
public func applyTempoSync() {
|
||||||
|
guard let clock: LyrebirdClock = clock else { return }
|
||||||
|
let bpm: Double = clock.bpm
|
||||||
|
guard bpm > 0 else { return }
|
||||||
|
for param: TempoSyncableParam in tempoSyncableParams {
|
||||||
|
guard case .division(let division) = tempoSync[param.key] ?? .free else { continue }
|
||||||
|
param.node.update(param.value(for: division, bpm: bpm).value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets one parameter's sync state and immediately recomputes it. Pass ``TempoSync/free`` to
|
||||||
|
/// return the parameter to knob control (its value stays at the last synced number until the
|
||||||
|
/// knob moves it), or `.division(_:)` to lock it to a note value of the live tempo.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - sync: The new sync state.
|
||||||
|
/// - key: The ``TempoSyncableParam/key`` of the parameter to update.
|
||||||
|
public func setSync(_ sync: TempoSync, for key: String) {
|
||||||
|
tempoSync[key] = sync
|
||||||
|
tempoSyncRevision.bump()
|
||||||
|
applyTempoSync()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `node` backs a tempo-syncable parameter currently locked to a note division.
|
||||||
|
///
|
||||||
|
/// Used by MIDI to leave a synced parameter alone: its value is derived from the tempo, so a CC
|
||||||
|
/// write would be immediately overwritten on the next tempo change. Matches by node identity, so
|
||||||
|
/// it stays correct regardless of control ordering. Returns `false` for a free or non-syncable node.
|
||||||
|
public func isNodeTempoSynced(_ node: UIParamNode) -> Bool {
|
||||||
|
for param: TempoSyncableParam in tempoSyncableParams where param.node === node {
|
||||||
|
if case .division = tempoSync[param.key] ?? .free {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Subclass hook
|
// MARK: - Subclass hook
|
||||||
|
|
||||||
/// Returns the processed (wet) mono signal for this pedal.
|
/// Returns the processed (wet) mono signal for this pedal.
|
||||||
|
|||||||
@@ -49,20 +49,31 @@ public struct PedalSelectorKnob {
|
|||||||
/// contain at least two.
|
/// contain at least two.
|
||||||
public let stops: [Stop]
|
public let stops: [Stop]
|
||||||
|
|
||||||
|
/// When `true`, committing a new stop asks the host to rebuild the board (as the Neural Amp
|
||||||
|
/// model loader does) instead of relying on the live graph to react to the node value. Use for
|
||||||
|
/// selectors whose choice changes the *graph topology* — e.g. a cabinet whose voice picks which
|
||||||
|
/// single convolver is instantiated — rather than a value an always-running node reads live.
|
||||||
|
/// Defaults to `false`.
|
||||||
|
public let rebuildsOnChange: Bool
|
||||||
|
|
||||||
/// Creates a selector-knob descriptor.
|
/// Creates a selector-knob descriptor.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - label: Short label shown beneath the knob.
|
/// - label: Short label shown beneath the knob.
|
||||||
/// - node: The `UIParamNode` projected value of an `@UIParam` property (`pedal.$voice1`, …).
|
/// - node: The `UIParamNode` projected value of an `@UIParam` property (`pedal.$voice1`, …).
|
||||||
/// - stops: Ordered stops, CCW → CW. At least two.
|
/// - stops: Ordered stops, CCW → CW. At least two.
|
||||||
|
/// - rebuildsOnChange: Ask the host to rebuild the board when a new stop is committed. Use for
|
||||||
|
/// selectors that change graph topology. Defaults to `false`.
|
||||||
public init(
|
public init(
|
||||||
label: String,
|
label: String,
|
||||||
node: UIParamNode,
|
node: UIParamNode,
|
||||||
stops: [Stop]
|
stops: [Stop],
|
||||||
|
rebuildsOnChange: Bool = false
|
||||||
) {
|
) {
|
||||||
precondition(stops.count >= 2, "PedalSelectorKnob requires at least two stops")
|
precondition(stops.count >= 2, "PedalSelectorKnob requires at least two stops")
|
||||||
self.label = label
|
self.label = label
|
||||||
self.node = node
|
self.node = node
|
||||||
self.stops = stops
|
self.stops = stops
|
||||||
|
self.rebuildsOnChange = rebuildsOnChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ public struct PedalSwitch {
|
|||||||
/// to their first (off) option — while the tempo indicator is turned off. Defaults to `false`.
|
/// to their first (off) option — while the tempo indicator is turned off. Defaults to `false`.
|
||||||
public let tempoDependent: Bool
|
public let tempoDependent: Bool
|
||||||
|
|
||||||
|
/// When `true`, committing a new position asks the host to rebuild the board — for switches that
|
||||||
|
/// change the *graph topology* (e.g. a clean/drive channel that adds or removes a gain stage),
|
||||||
|
/// the same mechanism as ``PedalSelectorKnob/rebuildsOnChange``. Defaults to `false`.
|
||||||
|
public let rebuildsOnChange: Bool
|
||||||
|
|
||||||
/// Creates a switch descriptor.
|
/// Creates a switch descriptor.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -62,17 +67,21 @@ public struct PedalSwitch {
|
|||||||
/// (`pedal.$mode`, `pedal.$direction`, …).
|
/// (`pedal.$mode`, `pedal.$direction`, …).
|
||||||
/// - options: Ordered switch positions, left to right. At least two.
|
/// - options: Ordered switch positions, left to right. At least two.
|
||||||
/// - tempoDependent: `true` if the switch depends on the tempo/clock. Defaults to `false`.
|
/// - tempoDependent: `true` if the switch depends on the tempo/clock. Defaults to `false`.
|
||||||
|
/// - rebuildsOnChange: Ask the host to rebuild the board when a new position is committed. Use
|
||||||
|
/// for switches that change graph topology (e.g. a channel switch). Defaults to `false`.
|
||||||
public init(
|
public init(
|
||||||
label: String,
|
label: String,
|
||||||
node: UIParamNode,
|
node: UIParamNode,
|
||||||
options: [Option],
|
options: [Option],
|
||||||
tempoDependent: Bool = false
|
tempoDependent: Bool = false,
|
||||||
|
rebuildsOnChange: Bool = false
|
||||||
) {
|
) {
|
||||||
precondition(options.count >= 2, "PedalSwitch requires at least two options")
|
precondition(options.count >= 2, "PedalSwitch requires at least two options")
|
||||||
self.label = label
|
self.label = label
|
||||||
self.node = node
|
self.node = node
|
||||||
self.options = options
|
self.options = options
|
||||||
self.tempoDependent = tempoDependent
|
self.tempoDependent = tempoDependent
|
||||||
|
self.rebuildsOnChange = rebuildsOnChange
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The value of the next option after the one nearest `current`, wrapping to the first — so a
|
/// The value of the next option after the one nearest `current`, wrapping to the first — so a
|
||||||
|
|||||||
@@ -44,12 +44,33 @@ public struct PedalType: RawRepresentable, Hashable, Sendable {
|
|||||||
public extension PedalType {
|
public extension PedalType {
|
||||||
|
|
||||||
// Drive & dynamics
|
// Drive & dynamics
|
||||||
|
static let california = PedalType("California")
|
||||||
|
static let british = PedalType("British")
|
||||||
|
static let britishPlexi = PedalType("British Plexi")
|
||||||
|
static let britishJTM = PedalType("British JTM")
|
||||||
|
static let britishBluesbreaker = PedalType("British Bluesbreaker")
|
||||||
|
static let britishMaster = PedalType("British Master")
|
||||||
|
static let britishDual = PedalType("British Dual")
|
||||||
|
static let boutiqueLead = PedalType("Boutique Lead")
|
||||||
|
static let boutiqueOD = PedalType("Boutique OD")
|
||||||
|
static let 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 fullertonDrive = PedalType("Fullerton Drive")
|
||||||
|
static let jazzClean = PedalType("Jazz Clean")
|
||||||
|
static let chimeTopBoost = PedalType("Chime Top Boost")
|
||||||
|
static let neuralAmp = PedalType("Neural Amp")
|
||||||
static let overdrive = PedalType("Overdrive")
|
static let overdrive = PedalType("Overdrive")
|
||||||
static let distortion = PedalType("Distortion")
|
static let distortion = PedalType("Distortion")
|
||||||
static let fuzz = PedalType("Fuzz")
|
static let fuzz = PedalType("Fuzz")
|
||||||
static let compressor = PedalType("Compressor")
|
static let compressor = PedalType("Compressor")
|
||||||
static let limiter = PedalType("Limiter")
|
static let limiter = PedalType("Limiter")
|
||||||
static let noiseGate = PedalType("Noise Gate")
|
static let noiseGate = PedalType("Noise Gate")
|
||||||
|
static let cabinet = PedalType("Cabinet")
|
||||||
|
|
||||||
// EQ & filter
|
// EQ & filter
|
||||||
static let graphicEQ = PedalType("Graphic EQ")
|
static let graphicEQ = PedalType("Graphic EQ")
|
||||||
|
|||||||
@@ -0,0 +1,301 @@
|
|||||||
|
// AmpVoicePedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Shared base for the tube-amp voice pedals — the fixed-voicing amps and the full-surface amps
|
||||||
|
/// (those adding onboard reverb / tremolo / chorus and switches via the hooks below).
|
||||||
|
///
|
||||||
|
/// Each concrete amp fixes one tone-stack ``ToneStackModel`` and adds one signature control, but
|
||||||
|
/// shares the common chain built here:
|
||||||
|
/// ```
|
||||||
|
/// dry → inputShaping(_:) (subclass hook — e.g. bright switch; default identity)
|
||||||
|
/// → TriodeStage(drive: gain) (preamp)
|
||||||
|
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
|
||||||
|
/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity)
|
||||||
|
/// → TriodeStage(power-amp drive) (power-amp warmth)
|
||||||
|
/// → 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)
|
||||||
|
/// ```
|
||||||
|
/// Fully wet (the amp replaces the dry signal); `Level` is the master. Double-width amp-head card.
|
||||||
|
///
|
||||||
|
/// The `tanh` output stage models output-transformer / speaker compression: a real amp has no
|
||||||
|
/// brickwall, and its analog output can't digital-clip. Small signals pass at ~unit gain (clean
|
||||||
|
/// playing largely intact); peaks soft-limit toward ±1, adding gentle output compression. Because
|
||||||
|
/// that soft-limit sits *after* the cab (the overshoot it guards is a digital convolution /
|
||||||
|
/// oversampling artifact, not literal circuit order) and the `tanh`'s own DC-blocker can leave a
|
||||||
|
/// sub-percent overshoot, a final `Clip(±1)` hard-clamps the residue so the amp stage never emits a
|
||||||
|
/// sample past ±1. At the normal master `Level` (≤ 1) that ceiling carries through to the output.
|
||||||
|
///
|
||||||
|
/// Subclasses override ``toneStackModel``, ``summaryText``, ``signatureKnobs``, and
|
||||||
|
/// ``shapeVoice(_:)``, and may set a voice-appropriate default `gain` in their `init`.
|
||||||
|
open class AmpVoicePedal: Pedal {
|
||||||
|
|
||||||
|
// MARK: - Common parameters
|
||||||
|
|
||||||
|
/// Preamp drive into the first tube stage. Range [1, 30].
|
||||||
|
@UIParam public var gain: Double = 6.0
|
||||||
|
/// Tone-stack bass control in [0, 1].
|
||||||
|
@UIParam public var bass: Double = 0.5
|
||||||
|
/// Tone-stack mid control in [0, 1].
|
||||||
|
@UIParam public var mid: Double = 0.5
|
||||||
|
/// Tone-stack treble control in [0, 1].
|
||||||
|
@UIParam public var treble: Double = 0.6
|
||||||
|
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
|
||||||
|
@UIParam public var cab: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Subclass configuration
|
||||||
|
|
||||||
|
/// The fixed tone-stack model for this amp voice. Subclasses override.
|
||||||
|
open var toneStackModel: ToneStackModel { .fender }
|
||||||
|
/// One-line description. Subclasses override.
|
||||||
|
open var summaryText: String { "Tube amp." }
|
||||||
|
/// The amp's signature knob(s), appended after Gain/Bass/Mid/Treble. Default none.
|
||||||
|
open var signatureKnobs: [PedalKnob] { [] }
|
||||||
|
|
||||||
|
/// Applies the amp's signature post-power-amp shaping (e.g. a bright/presence shelf or a cut
|
||||||
|
/// low-pass). Default: identity. Subclasses override.
|
||||||
|
///
|
||||||
|
/// - Parameter signal: The post-power-amp signal.
|
||||||
|
/// - Returns: The shaped signal fed to the cabinet.
|
||||||
|
open func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
signal
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shaping applied to the dry input *before* the preamp — e.g. a bright-switch treble lift that
|
||||||
|
/// hits the tubes pre-distortion. Default: identity. Subclasses override.
|
||||||
|
///
|
||||||
|
/// - Parameter signal: The dry input signal.
|
||||||
|
/// - Returns: The shaped signal fed into the preamp.
|
||||||
|
open func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
signal
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Onboard effects inserted *after* the tone stack and *before* the power amp — the slot a
|
||||||
|
/// combo amp's built-in reverb and tremolo occupy. Default: identity. Subclasses override.
|
||||||
|
///
|
||||||
|
/// - Parameter signal: The post-tone-stack signal.
|
||||||
|
/// - Returns: The signal fed into the power-amp stage.
|
||||||
|
open func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
signal
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Depth scale for the shared ``tremolo(_:speed:depth:enabled:)`` helper — at full depth the
|
||||||
|
/// unipolar sine swings over half the normalised range, so the peak gain is `1.0` and the trough
|
||||||
|
/// is `1 − depth`.
|
||||||
|
private static let tremoloDepthScale: Double = 0.5
|
||||||
|
|
||||||
|
/// A unipolar-sine tremolo: `signal ×` an LFO over `[1 − depth·enabled, 1]`. Returns a bit-exact
|
||||||
|
/// pass-through (a constant-`1.0` LFO) when `depth·enabled == 0`, so a zeroed depth or a
|
||||||
|
/// footswitch `enabled = 0` is a true identity. Shared by the combo amps' `onboardEffects(_:)`.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - signal: The signal to amplitude-modulate.
|
||||||
|
/// - speed: LFO rate in Hz.
|
||||||
|
/// - depth: Modulation depth in `[0, 1]`.
|
||||||
|
/// - enabled: Footswitch gate (`0` or `1`) multiplied into the depth.
|
||||||
|
/// - Returns: The amplitude-modulated signal.
|
||||||
|
func tremolo(
|
||||||
|
_ signal: any ValidGeneratorInput,
|
||||||
|
speed: any ValidGeneratorInput,
|
||||||
|
depth: any ValidGeneratorInput,
|
||||||
|
enabled: any ValidGeneratorInput
|
||||||
|
) -> any ValidGeneratorInput {
|
||||||
|
let swing: any ValidGeneratorInput = (depth * enabled) * AmpVoicePedal.tremoloDepthScale
|
||||||
|
let lfo: OscSin.Audio = OscSin.Audio(freq: speed, mul: swing, add: 1.0 - swing)
|
||||||
|
return signal * lfo
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Maps a `Master` knob `[0, 1]` to a power-amp drive range — the canonical body of a
|
||||||
|
/// master-volume amp's ``powerAmpDriveInput`` override. Turning Master up drives the power-amp
|
||||||
|
/// stage harder (real master-volume saturation, unlike `level`).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - master: The `Master` knob node (`[0, 1]`).
|
||||||
|
/// - minDrive: Power-amp drive at `master = 0`.
|
||||||
|
/// - maxDrive: Power-amp drive at `master = 1`.
|
||||||
|
/// - Returns: The mapped drive to feed the power-amp stage.
|
||||||
|
func masterDrive(
|
||||||
|
_ master: any ValidGeneratorInput,
|
||||||
|
minDrive: Double,
|
||||||
|
maxDrive: Double
|
||||||
|
) -> any ValidGeneratorInput {
|
||||||
|
LinLin.Audio(master, inLo: 0.0, inHi: 1.0, outLo: minDrive, outHi: maxDrive)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The preamp gain stage — the (post-`inputShaping`) input driven through the first tube stage
|
||||||
|
/// at `Gain`. Default: one `TriodeStage`. A channel-switching amp overrides this to cascade an
|
||||||
|
/// extra stage on its drive channel (call `super.preampStage(_:)` for the clean stage first).
|
||||||
|
///
|
||||||
|
/// - Parameter signal: The post-`inputShaping` input signal.
|
||||||
|
/// - Returns: The preamp output fed into the tone stack.
|
||||||
|
open func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
TriodeStage(input: signal, drive: $gain, bias: preampBias, oversample: preampOversample)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Drive into the power-amp `TriodeStage`. Defaults to the fixed power-amp drive. Two kinds of
|
||||||
|
/// amp override it: a **master-volume** amp returns a live `Master` knob mapped to a drive range
|
||||||
|
/// (turning Master up pushes the power-amp stage into saturation — the real master-volume
|
||||||
|
/// behaviour, unlike `level`, which only attenuates the finished output); a **lower-headroom
|
||||||
|
/// variant** returns a fixed value *higher* than the default to model an amp that breaks up
|
||||||
|
/// earlier. Either way, higher drive = more power-amp saturation.
|
||||||
|
open var powerAmpDriveInput: any ValidGeneratorInput { powerAmpDrive }
|
||||||
|
|
||||||
|
/// Oversampling factor for the power-amp stage — `2` or `4`. Any amp that drives the power amp
|
||||||
|
/// harder than the default fixed value (a `Master` control, or a lower-headroom variant with a
|
||||||
|
/// higher fixed drive) should override to `4` for more anti-alias headroom, since higher drive
|
||||||
|
/// generates more high-order harmonics. Defaults to `2` (ample for the lightly-driven fixed
|
||||||
|
/// power stage of the standard voices).
|
||||||
|
open var powerAmpOversample: Int { 2 }
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
|
||||||
|
private let preampBias: Double = 0.2
|
||||||
|
/// Oversampling factor for the preamp stage (4× — the preamp can be driven hard by `Gain`).
|
||||||
|
let preampOversample: Int = 4
|
||||||
|
/// Fixed power-amp stage drive/bias (gentler than the preamp).
|
||||||
|
private let powerAmpDrive: Double = 1.5
|
||||||
|
private let powerAmpBias: Double = 0.0
|
||||||
|
private let cabinetMix: Double = 1.0
|
||||||
|
/// Output soft-limit drive. `1.0` gives unit small-signal gain (clean playing untouched) with a
|
||||||
|
/// hard `tanh` asymptote at ±1 — models output-transformer / speaker compression and keeps the
|
||||||
|
/// amp from ever digital-clipping the DAC.
|
||||||
|
private let outputStageDrive: Double = 1.0
|
||||||
|
/// Symmetric output stage (no even-harmonic bias) — a pure `tanh` limiter, not a tube colour.
|
||||||
|
private let outputStageBias: Double = 0.0
|
||||||
|
/// 2× is enough: the cab low-pass already band-limits the signal feeding this stage.
|
||||||
|
private let outputStageOversample: Int = 2
|
||||||
|
/// Absolute digital ceiling. The `tanh` stage does the musical soft-limiting; this hard clamp
|
||||||
|
/// only ever catches the sub-percent overshoot the oversampling filters and DC-blocker can leave
|
||||||
|
/// just above ±1, guaranteeing the amp stage never emits a sample the DAC would clip.
|
||||||
|
private let outputCeiling: Double = 1.0
|
||||||
|
|
||||||
|
let gainRange: ClosedRange<Double> = 1.0 ... 30.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
|
||||||
|
|
||||||
|
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||||
|
.enumerated()
|
||||||
|
.map { (index: Int, voice: CabinetVoice) in
|
||||||
|
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
public override var widthUnits: Int { 2 }
|
||||||
|
|
||||||
|
public override var summary: String { summaryText }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates an amp voice pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - name: Display name (the amp voice, e.g. "California").
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
name: String,
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: name,
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: AmpVoicePedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - UI
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Gain", node: $gain, range: gainRange),
|
||||||
|
PedalKnob(label: "Bass", node: $bass, range: toneRange),
|
||||||
|
PedalKnob(label: "Mid", node: $mid, range: toneRange),
|
||||||
|
PedalKnob(label: "Treble", node: $treble, range: toneRange),
|
||||||
|
] + signatureKnobs
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var effectSelectors: [PedalSelectorKnob] {
|
||||||
|
[
|
||||||
|
PedalSelectorKnob(
|
||||||
|
label: "Cab", node: $cab, stops: AmpVoicePedal.cabStops, rebuildsOnChange: true),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet → 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.
|
||||||
|
///
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The amped, cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
cabinetAndLimit(preCabinetCore(dry))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The mono pre-cabinet core: `inputShaping → preamp → tone stack → onboardEffects → power amp →
|
||||||
|
/// shapeVoice`. Factored out of `effect(_:)` so a stereo (widener) amp can split into a stereo
|
||||||
|
/// stage (e.g. a stereo chorus) between the core and a per-channel ``cabinetAndLimit(_:)``.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The post-power-amp, pre-cabinet mono signal.
|
||||||
|
func preCabinetCore(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let preShaped: any ValidGeneratorInput = inputShaping(dry)
|
||||||
|
let preamp: any ValidGeneratorInput = preampStage(preShaped)
|
||||||
|
let toned: ToneStack = ToneStack(
|
||||||
|
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
|
||||||
|
let processed: any ValidGeneratorInput = onboardEffects(toned)
|
||||||
|
let powerAmp: TriodeStage = TriodeStage(
|
||||||
|
input: processed, drive: powerAmpDriveInput, bias: powerAmpBias, oversample: powerAmpOversample)
|
||||||
|
return 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.
|
||||||
|
///
|
||||||
|
/// - Parameter signal: The post-core signal for one channel.
|
||||||
|
/// - Returns: The cab-convolved, soft-limited, ceiling-clamped signal.
|
||||||
|
func cabinetAndLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cab)
|
||||||
|
let cabinet: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||||
|
input: signal,
|
||||||
|
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate),
|
||||||
|
mix: cabinetMix
|
||||||
|
)
|
||||||
|
let softLimited: TriodeStage = TriodeStage(
|
||||||
|
input: cabinet,
|
||||||
|
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,99 @@
|
|||||||
|
// 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). Range [1, 30].
|
||||||
|
@UIParam public var drive: Double = 10.0
|
||||||
|
/// 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
|
||||||
|
/// Grid bias of the cascaded lead stage — a little asymmetry for even-harmonic grind.
|
||||||
|
private let leadBias: Double = 0.15
|
||||||
|
private let channelThreshold: Double = 0.5
|
||||||
|
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||||
|
let switchOffValue: Double = 0.0
|
||||||
|
let switchOnValue: Double = 1.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 }
|
||||||
|
|
||||||
|
/// Wider card for the Presence/Depth/Master/Drive knobs plus the Channel switch.
|
||||||
|
public override var widthUnits: 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: $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 aggressive British tone stack, defaulting to a hot Lead drive.
|
||||||
|
public final class BoutiqueLeadAmpPedal: BoutiqueAmpPedal {
|
||||||
|
|
||||||
|
// toneStackModel inherits the base's .marshall (aggressive British stack).
|
||||||
|
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.0
|
||||||
|
drive = 14.0 // 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.0
|
||||||
|
drive = 10.0
|
||||||
|
cab = 0.0 // American 1×12
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The base Presence/Depth shaping, plus a Mid Boost peak when the switch is engaged (its gain
|
||||||
|
/// scales by the switch value, so Off is a true identity, live, no rebuild).
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
|
||||||
|
let midGainDb: any ValidGeneratorInput = $midBoost * midBoostMaxGainDb
|
||||||
|
return RBJPeakingEQ.Audio(input: shaped, freq: midBoostFreqHz, gain: midGainDb, q: midBoostQ)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// BritishAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British-voiced amp (mid-forward crunch) with a **Presence** lift and a **Master** volume.
|
||||||
|
///
|
||||||
|
/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. The
|
||||||
|
/// Master control drives the power-amp stage (via ``AmpVoicePedal/powerAmpDriveInput``), so raising
|
||||||
|
/// it adds power-amp saturation — turn `Gain` up for preamp grind and use `Master` to set how hard
|
||||||
|
/// that hits the power amp, the classic master-volume interplay.
|
||||||
|
public final class BritishAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||||
|
@UIParam public var presence: Double = 0.4
|
||||||
|
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`]. The
|
||||||
|
/// default maps to ≈1.5 drive — the amp's prior fixed power-amp drive — so the out-of-box tone
|
||||||
|
/// is unchanged; turn it up for power-amp saturation.
|
||||||
|
@UIParam public var master: Double = 0.22
|
||||||
|
|
||||||
|
private let presenceFreqHz: Double = 4500.0
|
||||||
|
private let presenceMaxGainDb: Double = 8.0
|
||||||
|
private let shelfSlope: Double = 0.7
|
||||||
|
/// Power-amp drive at `master = 0` — barely driven (cleanest power stage).
|
||||||
|
private let masterMinDrive: Double = 0.5
|
||||||
|
/// Power-amp drive at `master = 1` — hard into power-amp saturation.
|
||||||
|
private let masterMaxDrive: Double = 5.0
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .marshall }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British crunch — forward mids and bite, with Presence and a Master volume."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||||
|
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`.
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||||
|
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 4× oversampling on the power-amp stage — Master can drive it well past the fixed value used
|
||||||
|
/// by the non-master amps, so the extra anti-alias headroom keeps the added harmonics clean.
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
|
||||||
|
/// Creates a British amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 10.0 // crunch-leaning default
|
||||||
|
cab = 1.0 // default to the British 4×12 cab
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||||
|
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||||
|
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: shelfSlope)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// BritishBluesbreakerAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British non-master **2×12 combo** with onboard **tremolo** — the bluesbreaker voice: lower-power
|
||||||
|
/// Marshall crunch that cleans up with the guitar volume, plus a bias-tremolo.
|
||||||
|
///
|
||||||
|
/// A ``BritishComboAmpPedal`` (Presence + Bright) that overlays a tremolo in the onboard-effects
|
||||||
|
/// slot, with Speed / Intensity knobs and a Tremolo footswitch.
|
||||||
|
public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||||
|
|
||||||
|
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||||
|
@UIParam public var speed: Double = 4.0
|
||||||
|
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||||
|
@UIParam public var intensity: Double = 0.0
|
||||||
|
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||||
|
@UIParam public var tremoloEnabled: Double = 1.0
|
||||||
|
|
||||||
|
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||||
|
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British 2×12 combo — bluesbreaker crunch with tremolo, Presence, and a Bright switch."
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||||||
|
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||||
|
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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 + [
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Tremolo",
|
||||||
|
node: $tremoloEnabled,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a British Bluesbreaker amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British Bluesbreaker", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 6.0
|
||||||
|
cab = 1.0 // British 4×12 voice (combo 2×12 tonally close enough among our cabs)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack.
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// Identity when depth·enabled == 0.
|
||||||
|
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// BritishComboAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Shared base for the British (Marshall-voiced) amps — the `.marshall` tone stack plus a common
|
||||||
|
/// **Presence** lift (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf).
|
||||||
|
///
|
||||||
|
/// The non-master voices (Plexi / JTM / Bluesbreaker) run a fixed power-amp drive — loudness comes
|
||||||
|
/// from cranking `Gain`; the Bluesbreaker additionally overlays tremolo. The master-volume voices
|
||||||
|
/// (British Master / British Dual) subclass this too, adding a `Master` (via
|
||||||
|
/// ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``) and a cascaded lead ``preampStage(_:)``.
|
||||||
|
///
|
||||||
|
/// Distinct from ``BritishAmpPedal``, the standalone master-volume crunch voice.
|
||||||
|
open class BritishComboAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
|
||||||
|
@UIParam public var presence: Double = 0.4
|
||||||
|
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||||
|
@UIParam public var bright: Double = 0.0
|
||||||
|
|
||||||
|
private let presenceFreqHz: Double = 4500.0
|
||||||
|
private let presenceMaxGainDb: Double = 8.0
|
||||||
|
private let presenceSlope: Double = 0.7
|
||||||
|
private let brightFreqHz: Double = 3500.0
|
||||||
|
private let brightMaxGainDb: Double = 6.0
|
||||||
|
private let brightSlope: Double = 0.7
|
||||||
|
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] {
|
||||||
|
[PedalKnob(label: "Presence", node: $presence, range: signatureRange)]
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Bright",
|
||||||
|
node: $bright,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||||
|
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||||
|
return RBJHighShelf.Audio(
|
||||||
|
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Presence: a post-power-amp high-shelf lift, `[0, 1]` → `[0, presenceMaxGainDb]` dB.
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||||
|
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||||||
|
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: presenceSlope)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
// BritishDualAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British **dual-channel master-volume** — the 900/DSL-era Marshall: a footswitchable Clean/Lead
|
||||||
|
/// channel, a Master volume, spring reverb, Presence, and a Bright switch. The modern high-gain
|
||||||
|
/// British workhorse.
|
||||||
|
///
|
||||||
|
/// A ``BritishComboAmpPedal`` (Presence + Bright) that adds a `rebuildsOnChange` **Channel** switch —
|
||||||
|
/// the Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||||
|
/// `Master` (power-amp drive), and spring reverb in the onboard-effects slot.
|
||||||
|
public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||||
|
|
||||||
|
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||||
|
@UIParam public var master: Double = 0.5
|
||||||
|
/// Lead-channel preamp gain (the cascaded stage). Range [1, 30].
|
||||||
|
@UIParam public var drive: Double = 8.0
|
||||||
|
/// Spring-reverb wet mix in [0, 1].
|
||||||
|
@UIParam public var reverb: Double = 0.2
|
||||||
|
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||||
|
@UIParam public var channel: Double = 0.0
|
||||||
|
|
||||||
|
private let masterMinDrive: Double = 0.5
|
||||||
|
private let masterMaxDrive: Double = 5.0
|
||||||
|
/// Channel-select threshold: `>= this` selects the Lead channel.
|
||||||
|
private let channelThreshold: Double = 0.5
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||||
|
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British dual-channel master-volume — Clean/Lead switching, reverb, Presence, and Bright."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
super.signatureKnobs + [
|
||||||
|
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||||
|
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||||
|
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
super.effectSwitches + [
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Channel",
|
||||||
|
node: $channel,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||||
|
],
|
||||||
|
rebuildsOnChange: true
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||||
|
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||||
|
}
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
|
||||||
|
/// 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:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0
|
||||||
|
cab = 1.0 // British 4×12
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||||
|
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||||
|
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||||
|
guard channel >= channelThreshold else { return clean }
|
||||||
|
return TriodeStage(input: clean, drive: $drive, bias: leadBias, oversample: preampOversample)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// BritishJTMAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British non-master **JTM** — the earliest Marshall, Bassman-derived: warmer and lower-gain than
|
||||||
|
/// the plexi Super Lead, a rounder blues-rock crunch.
|
||||||
|
///
|
||||||
|
/// A ``BritishComboAmpPedal`` with lower gain and a slightly darker top end.
|
||||||
|
public final class BritishJTMAmpPedal: BritishComboAmpPedal {
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British non-master combo — warm, lower-gain JTM crunch with Presence and Bright."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a British JTM amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British JTM", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0 // warmer, lower-gain than the plexi
|
||||||
|
treble = 0.5 // a shade rounder on top
|
||||||
|
cab = 1.0 // British 4×12
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
// BritishMasterAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British **master-volume lead** — the 800-series single-channel hot-rodded Marshall: a cascaded
|
||||||
|
/// two-stage preamp for singing lead gain, a Master volume, Presence, and a Bright switch.
|
||||||
|
///
|
||||||
|
/// A ``BritishComboAmpPedal`` (Presence + Bright) whose ``preampStage(_:)`` cascades a second gain
|
||||||
|
/// stage — both driven by `Gain`, so one knob sets the whole preamp grind — and whose `Master`
|
||||||
|
/// drives the power-amp stage (via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``).
|
||||||
|
public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||||
|
|
||||||
|
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||||
|
@UIParam public var master: Double = 0.5
|
||||||
|
|
||||||
|
private let masterMinDrive: Double = 0.5
|
||||||
|
private let masterMaxDrive: Double = 5.0
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British master-volume lead — cascaded 800-series gain with Presence, Master, and Bright."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
super.signatureKnobs + [PedalKnob(label: "Master", node: $master, range: signatureRange)]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||||
|
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||||
|
}
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
|
||||||
|
/// Wider card for the Presence/Master knobs plus the Bright switch.
|
||||||
|
public override var widthUnits: Int { 3 }
|
||||||
|
|
||||||
|
/// Creates a British Master amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British Master", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0 // 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// BritishPlexiAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British non-master **Super Lead** — the classic plexi-panel stack: big, loud, no master volume,
|
||||||
|
/// clean-ish until cranked and then a singing midrange roar.
|
||||||
|
///
|
||||||
|
/// A ``BritishComboAmpPedal`` with higher gain and the 4×12 cab. Presence + Bright; loudness and
|
||||||
|
/// breakup both come from `Gain`.
|
||||||
|
public final class BritishPlexiAmpPedal: BritishComboAmpPedal {
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"British non-master stack — plexi roar with Presence and a Bright switch."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a British Plexi amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "British Plexi", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 7.0 // clean-ish until pushed
|
||||||
|
cab = 1.0 // British 4×12
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
// CabinetPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Speaker-cabinet simulation via impulse-response convolution.
|
||||||
|
///
|
||||||
|
/// Convolves the input against a cabinet impulse response using Lyrebird's partitioned FFT
|
||||||
|
/// convolver (`ConvolutionReverb`). A single convolver is built at `build()` time for the voice the
|
||||||
|
/// ``cabinet`` selector currently names (each voicing's IR is synthesized in code — our own MIT
|
||||||
|
/// content, see ``CabinetIRFactory``). Changing the selector asks the host to rebuild the board so
|
||||||
|
/// only the selected voice's convolver ever runs — one partitioned-FFT convolver, not one per
|
||||||
|
/// voice. The selection round-trips through the rig save format like every other pedal.
|
||||||
|
///
|
||||||
|
/// Signal path (inside `effect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → ConvolutionReverb(ir: selectedVoice) → mono out
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The wet/dry mix and bypass are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// > Note: Loading a user-supplied captured `.wav` cab IR is a planned follow-up (it needs a
|
||||||
|
/// > persisted file-path field the current `PedalState` doesn't carry); this first version ships
|
||||||
|
/// > the built-in voicings only.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - `cabinet`: Selects the built-in cabinet voicing (stepped selector over ``CabinetVoice``).
|
||||||
|
public final class CabinetPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Speaker-cabinet impulse-response convolution with selectable built-in voicings."
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — fully wet; the cabinet sits in-line.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Convolution is taken fully wet here; the `Pedal` base class provides the user wet/dry mix.
|
||||||
|
private let convolutionMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Selector stops, one per ``CabinetVoice`` in `allCases` order (value == index).
|
||||||
|
private static let voiceStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||||
|
.enumerated()
|
||||||
|
.map { (index: Int, voice: CabinetVoice) in
|
||||||
|
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a cabinet pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: "Cabinet",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: CabinetPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - UI
|
||||||
|
|
||||||
|
public override var effectSelectors: [PedalSelectorKnob] {
|
||||||
|
[
|
||||||
|
PedalSelectorKnob(
|
||||||
|
label: "Cab", node: $cabinet, stops: CabinetPedal.voiceStops, rebuildsOnChange: true),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Convolves the dry signal against the single selected cabinet IR.
|
||||||
|
///
|
||||||
|
/// 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()`.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The cabinet-convolved 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(
|
||||||
|
input: dry,
|
||||||
|
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
|
||||||
|
mix: convolutionMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// CaliforniaAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// American-voiced amp (scooped-mid, bright clean) with a **Bright** high-shelf sparkle control.
|
||||||
|
///
|
||||||
|
/// A ``AmpVoicePedal`` fixed to the American tone stack, defaulting to a lower gain for headroom.
|
||||||
|
public final class CaliforniaAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
/// Bright high-shelf amount in [0, 1] → 0…`brightMaxGainDb` of lift above `brightFreqHz`.
|
||||||
|
@UIParam public var bright: Double = 0.3
|
||||||
|
|
||||||
|
private let brightFreqHz: Double = 3200.0
|
||||||
|
private let brightMaxGainDb: Double = 6.0
|
||||||
|
private let shelfSlope: Double = 1.0
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .fender }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"American clean — scooped mids, glassy top, with a Bright sparkle shelf."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[PedalKnob(label: "Bright", node: $bright, range: signatureRange)]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a California amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "California", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 4.0 // clean-leaning default
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let gainDB: LinLin.Audio = LinLin.Audio(
|
||||||
|
$bright, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: brightMaxGainDb)
|
||||||
|
return RBJHighShelf.Audio(input: signal, freq: brightFreqHz, gain: gainDB, slope: shelfSlope)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// ChimeAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Chimey/jangly amp (bell-like top boost) with a **Cut** control that rolls off the high end as
|
||||||
|
/// it's turned up — the classic top-boost "Cut" behavior.
|
||||||
|
///
|
||||||
|
/// A ``AmpVoicePedal`` fixed to the chime tone stack. The base of the Vox-voiced family — the
|
||||||
|
/// AC-style variants (Chime 15 / Chime Normal / Chime Baby) subclass it and differ by gain, cab,
|
||||||
|
/// and tone defaults (and, for the smaller combos, an earlier power-amp breakup).
|
||||||
|
open class ChimeAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest. Maps to a low-pass cutoff
|
||||||
|
/// swept from `cutOpenHz` down to `cutDarkHz`.
|
||||||
|
@UIParam public var cut: Double = 0.2
|
||||||
|
|
||||||
|
private let cutOpenHz: Double = 9000.0
|
||||||
|
private let cutDarkHz: Double = 2500.0
|
||||||
|
private let cutQ: Double = 0.707
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .vox }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"Chimey top-boost jangle with a Cut control that tames the highs."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[PedalKnob(label: "Cut", node: $cut, range: signatureRange)]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a Chime amp.
|
||||||
|
///
|
||||||
|
/// The AC-style variants call the inherited `AmpVoicePedal.init(name:inputBus:outputBus:)` to set
|
||||||
|
/// their own name while inheriting the shared Cut voice.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
self.init(name: "Chime", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// cut 0 → cutOpenHz (bright), cut 1 → cutDarkHz (dark).
|
||||||
|
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||||
|
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
|
||||||
|
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// ChimeBabyAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Vox-voiced **practice combo** — the tiny AC4/AC10-style amp: low headroom, a small boxy
|
||||||
|
/// speaker, and the earliest breakup of the chime family.
|
||||||
|
///
|
||||||
|
/// A ``ChimeAmpPedal`` (Cut voice) driven hardest into the power stage, with the small lo-fi cab.
|
||||||
|
public final class ChimeBabyAmpPedal: ChimeAmpPedal {
|
||||||
|
|
||||||
|
/// Power-amp drive — the highest of the chime family, so it breaks up earliest.
|
||||||
|
private let babyPowerDrive: Double = 2.5
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"Vox practice combo — tiny, boxy, earliest-breakup chime with a Cut control."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Driven hardest of the chime family, so 4× oversampling for anti-alias headroom.
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput { babyPowerDrive }
|
||||||
|
|
||||||
|
/// Creates a Chime Baby amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Chime Baby", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 6.0
|
||||||
|
bass = 0.4 // small speaker, less low end
|
||||||
|
cab = 7.0 // Lo-Fi 1×8 — the small, boxy voice
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// ChimeFifteenAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Vox-voiced **1×12 EL84 combo** — the lower-powered, earlier-breakup sibling of the AC top-boost
|
||||||
|
/// voice. Chimey but grittier: the small power section saturates sooner.
|
||||||
|
///
|
||||||
|
/// A ``ChimeAmpPedal`` (Cut voice) with a higher fixed power-amp drive and a bright cab.
|
||||||
|
public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
|
||||||
|
|
||||||
|
/// Power-amp drive — higher than the base's fixed `1.5` so the EL84 stage breaks up earlier.
|
||||||
|
private let fifteenPowerDrive: Double = 2.0
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"Vox 1×12 EL84 combo — chimey but earlier-breakup, with a Cut control."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Driven harder than the base, so 4× oversampling for anti-alias headroom.
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput { fifteenPowerDrive }
|
||||||
|
|
||||||
|
/// Creates a Chime 15 amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Chime 15", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 6.0 // grittier starting point than the big AC voice
|
||||||
|
cab = 5.0 // Bright 1×12
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// ChimeNormalAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// 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."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a Chime Normal amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Chime Normal", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0
|
||||||
|
treble = 0.5 // rounder top than the top-boost voice
|
||||||
|
cut = 0.3 // a shade darker by default
|
||||||
|
cab = 0.0 // American 1×12 — plainer than the bright cab
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
// ChimeTopBoostAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// British-invasion "top boost" combo with a full control surface: the chimey top-boost EQ, a
|
||||||
|
/// **Cut** control that tames the highs, onboard **tremolo** (Speed / Intensity), and a
|
||||||
|
/// **Brilliant** switch — the jangly clean-to-edge-of-breakup voice.
|
||||||
|
///
|
||||||
|
/// A ``AmpVoicePedal`` fixed to the chime tone stack that fills both subclass hooks:
|
||||||
|
/// - ``inputShaping(_:)`` applies the Brilliant switch as a pre-preamp treble shelf.
|
||||||
|
/// - ``onboardEffects(_:)`` inserts the tremolo between the tone stack and the power amp.
|
||||||
|
///
|
||||||
|
/// Unlike the American blackface combo this amp has no built-in reverb (that was always outboard),
|
||||||
|
/// so the onboard-effects slot holds only the tremolo. Tremolo defaults off (`Intensity = 0`).
|
||||||
|
public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
// MARK: - Signature / onboard-effect parameters
|
||||||
|
|
||||||
|
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest (the top-boost "Cut" control,
|
||||||
|
/// which rolls off the highs as it's turned up).
|
||||||
|
@UIParam public var cut: Double = 0.2
|
||||||
|
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||||
|
@UIParam public var speed: Double = 4.0
|
||||||
|
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
|
||||||
|
@UIParam public var intensity: Double = 0.0
|
||||||
|
/// Brilliant switch: `0` = flat, `1` = treble shelf engaged (the brilliant/top-boost sparkle).
|
||||||
|
@UIParam public var brilliant: Double = 0.0
|
||||||
|
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||||
|
@UIParam public var tremoloEnabled: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Cut low-pass cutoff when fully open (`cut = 0`), in Hz.
|
||||||
|
private let cutOpenHz: Double = 9000.0
|
||||||
|
/// Cut low-pass cutoff when fully dark (`cut = 1`), in Hz.
|
||||||
|
private let cutDarkHz: Double = 2500.0
|
||||||
|
/// Cut low-pass Q (Butterworth).
|
||||||
|
private let cutQ: Double = 0.707
|
||||||
|
/// Brilliant-switch shelf corner in Hz.
|
||||||
|
private let brilliantFreqHz: Double = 4000.0
|
||||||
|
/// Brilliant-switch shelf lift in dB when engaged.
|
||||||
|
private let brilliantMaxGainDb: Double = 6.0
|
||||||
|
/// Brilliant-switch shelf slope.
|
||||||
|
private let brilliantSlope: Double = 0.7
|
||||||
|
private let cutRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||||
|
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let switchOffValue: Double = 0.0
|
||||||
|
private let switchOnValue: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Voice configuration
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .vox }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"Chimey top-boost jangle — Cut control, tremolo, and a Brilliant switch."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Cut", node: $cut, range: cutRange),
|
||||||
|
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||||
|
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Chime Top Boost", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 5.0
|
||||||
|
cab = 5.0 // Bright 1×12 — the chimey, top-end-forward cab voice
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Switches
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Brilliant",
|
||||||
|
node: $brilliant,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Tremolo",
|
||||||
|
node: $tremoloEnabled,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Hooks
|
||||||
|
|
||||||
|
/// Brilliant switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||||
|
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shelfGainDb: any ValidGeneratorInput = $brilliant * brilliantMaxGainDb
|
||||||
|
return RBJHighShelf.Audio(
|
||||||
|
input: signal, freq: brilliantFreqHz, gain: shelfGainDb, slope: brilliantSlope)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack. No onboard reverb.
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// Tremolo gated by the Tremolo footswitch (identity when depth·enabled == 0).
|
||||||
|
tremolo(signal, speed: $speed, depth: $intensity, enabled: $tremoloEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cut control: a low-pass whose cutoff sweeps from `cutOpenHz` (bright) down to `cutDarkHz`
|
||||||
|
/// (dark) as `cut` rises — the top-boost "Cut" behaviour, applied post-power-amp.
|
||||||
|
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||||
|
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
|
||||||
|
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,6 +61,12 @@ public final class ChorusPedal: Pedal {
|
|||||||
private let rateRange: ClosedRange<Double> = 0.05 ... 6.0
|
private let rateRange: ClosedRange<Double> = 0.05 ... 6.0
|
||||||
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.008
|
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.008
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ import LyrebirdUI
|
|||||||
/// compressed. Range `[-40, 0]` dB. Defaults to `-12.0`.
|
/// compressed. Range `[-40, 0]` dB. Defaults to `-12.0`.
|
||||||
/// - ratio: Compression ratio `≥ 1.0`. `1.0` = bypass, `4.0` = 4:1 compression.
|
/// - ratio: Compression ratio `≥ 1.0`. `1.0` = bypass, `4.0` = 4:1 compression.
|
||||||
/// Range `[1, 20]`. Defaults to `4.0`.
|
/// Range `[1, 20]`. Defaults to `4.0`.
|
||||||
|
///
|
||||||
|
/// A feed-forward compressor can overshoot on fast transients (its attack is non-zero),
|
||||||
|
/// so a hot input plus makeup gain can push peaks past full scale and clip the output.
|
||||||
|
/// The **Safety** switch inserts a brick-wall `LookAheadLimiter` after the compressor to
|
||||||
|
/// catch those peaks; it is off by default (leave adding a limiter to the user) and adds
|
||||||
|
/// a short look-ahead output delay when engaged.
|
||||||
public final class CompressorPedal: Pedal {
|
public final class CompressorPedal: Pedal {
|
||||||
|
|
||||||
/// One-line description shown in the picker and info panel.
|
/// One-line description shown in the picker and info panel.
|
||||||
@@ -50,6 +56,10 @@ public final class CompressorPedal: Pedal {
|
|||||||
/// Compression ratio. Range [1, 20].
|
/// Compression ratio. Range [1, 20].
|
||||||
@UIParam public var ratio: Double = 4.0
|
@UIParam public var ratio: Double = 4.0
|
||||||
|
|
||||||
|
/// Safety limiter engage state. `0` = off (compressor may overshoot), `1` = on
|
||||||
|
/// (brick-wall look-ahead limiter catches transient peaks).
|
||||||
|
@UIParam public var safetyLimiter: Double = 0.0
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
|
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
|
||||||
@@ -71,6 +81,20 @@ public final class CompressorPedal: Pedal {
|
|||||||
/// Makeup gain in dB applied after compression to restore perceived loudness.
|
/// Makeup gain in dB applied after compression to restore perceived loudness.
|
||||||
private let makeupGainDB: Double = 4.0
|
private let makeupGainDB: Double = 4.0
|
||||||
|
|
||||||
|
/// Safety-limiter peak ceiling (linear amplitude), just below full scale.
|
||||||
|
private let safetyCeiling: Double = 0.98
|
||||||
|
|
||||||
|
/// Safety-limiter look-ahead / output delay in seconds. Short enough to catch
|
||||||
|
/// transients without smearing attack; only in circuit when Safety is engaged.
|
||||||
|
private let safetyLookAheadTime: Double = 0.005
|
||||||
|
|
||||||
|
/// Safety-limiter gain-release time in seconds.
|
||||||
|
private let safetyReleaseTime: Double = 0.05
|
||||||
|
|
||||||
|
/// Safety switch position values.
|
||||||
|
private let safetyOffValue: Double = 0.0
|
||||||
|
private let safetyOnValue: Double = 1.0
|
||||||
|
|
||||||
// MARK: - UI knobs
|
// MARK: - UI knobs
|
||||||
|
|
||||||
/// Input-gain knob range in dB.
|
/// Input-gain knob range in dB.
|
||||||
@@ -90,6 +114,19 @@ public final class CompressorPedal: Pedal {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Safety",
|
||||||
|
node: $safetyLimiter,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: safetyOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: safetyOnValue),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
/// Creates a compressor pedal.
|
/// Creates a compressor pedal.
|
||||||
@@ -121,7 +158,7 @@ public final class CompressorPedal: Pedal {
|
|||||||
// Convert the input-gain dB to a linear multiplier (10^(dB/20)) and apply before compression.
|
// Convert the input-gain dB to a linear multiplier (10^(dB/20)) and apply before compression.
|
||||||
let inputGainLinear: Exp.Audio = Exp.Audio($inputGain * dbToLinExpScale)
|
let inputGainLinear: Exp.Audio = Exp.Audio($inputGain * dbToLinExpScale)
|
||||||
let boosted: any ValidGeneratorInput = dry * inputGainLinear
|
let boosted: any ValidGeneratorInput = dry * inputGainLinear
|
||||||
return Compressor.Audio(
|
let compressed: Compressor.Audio = Compressor.Audio(
|
||||||
in: boosted,
|
in: boosted,
|
||||||
threshold: $threshold,
|
threshold: $threshold,
|
||||||
ratio: $ratio,
|
ratio: $ratio,
|
||||||
@@ -130,5 +167,18 @@ public final class CompressorPedal: Pedal {
|
|||||||
kneeWidth: kneeWidth,
|
kneeWidth: kneeWidth,
|
||||||
makeupGain: makeupGainDB
|
makeupGain: makeupGainDB
|
||||||
)
|
)
|
||||||
|
// Brick-wall safety limiter after the compressor. Both branches are always built;
|
||||||
|
// `Select` picks per the Safety switch (0 = compressor only, 1 = limited).
|
||||||
|
let limited: LookAheadLimiter = LookAheadLimiter(
|
||||||
|
in: compressed,
|
||||||
|
maxAmplitude: safetyCeiling,
|
||||||
|
lookAheadTime: safetyLookAheadTime,
|
||||||
|
releaseTime: safetyReleaseTime,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
return Select.Audio(
|
||||||
|
which: $safetyLimiter,
|
||||||
|
inputs: [compressed, limited]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import LyrebirdUI
|
|||||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - time: Delay time in seconds. Range `[0.01, 1.5]`. Defaults to `0.25`.
|
/// - time: Delay time in seconds. Range `[0.01, 5.0]`. Defaults to `0.25`.
|
||||||
/// - feedback: Feedback amount expressed as decay time in seconds — the time
|
/// - feedback: Feedback amount expressed as decay time in seconds — the time
|
||||||
/// for echoes to fall to `targetAmp` (−60 dB). Longer values produce more
|
/// for echoes to fall to `targetAmp` (−60 dB). Longer values produce more
|
||||||
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
|
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
|
||||||
@@ -35,7 +35,7 @@ public final class DelayPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Delay time in seconds. Range [0.01, 1.5].
|
/// Delay time in seconds. Range [0.01, 5.0].
|
||||||
@UIParam public var time: Double = 0.25
|
@UIParam public var time: Double = 0.25
|
||||||
|
|
||||||
/// Feedback decay time in seconds (time to reach −60 dB amplitude).
|
/// Feedback decay time in seconds (time to reach −60 dB amplitude).
|
||||||
@@ -44,7 +44,7 @@ public final class DelayPedal: Pedal {
|
|||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Maximum supported delay time in seconds. Sizes the delay line buffer at init.
|
/// Maximum supported delay time in seconds. Sizes the delay line buffer at init.
|
||||||
private let maxDelayTime: Double = 1.5
|
private let maxDelayTime: Double = 5.0
|
||||||
|
|
||||||
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
||||||
private let targetAmp: Double = 0.001
|
private let targetAmp: Double = 0.001
|
||||||
@@ -55,7 +55,7 @@ public final class DelayPedal: Pedal {
|
|||||||
// MARK: - UI knobs
|
// MARK: - UI knobs
|
||||||
|
|
||||||
/// Delay-time knob range in seconds.
|
/// Delay-time knob range in seconds.
|
||||||
private let timeRange: ClosedRange<Double> = 0.01 ... 1.5
|
private let timeRange: ClosedRange<Double> = 0.01 ... 5.0
|
||||||
|
|
||||||
/// Feedback (decay-time) knob range in seconds.
|
/// Feedback (decay-time) knob range in seconds.
|
||||||
private let feedbackRange: ClosedRange<Double> = 0.05 ... 6.0
|
private let feedbackRange: ClosedRange<Double> = 0.05 ... 6.0
|
||||||
@@ -86,6 +86,12 @@ public final class DelayPedal: Pedal {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Effect
|
// MARK: - Effect
|
||||||
|
|
||||||
/// Applies a feedback delay line. Returns the pure wet (delayed) signal.
|
/// Applies a feedback delay line. Returns the pure wet (delayed) signal.
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ import LyrebirdUI
|
|||||||
|
|
||||||
/// Mid-gain distortion — more saturated than `OverdrivePedal`, more controlled than `FuzzPedal`.
|
/// Mid-gain distortion — more saturated than `OverdrivePedal`, more controlled than `FuzzPedal`.
|
||||||
///
|
///
|
||||||
/// A DC-blocking high-pass feeds a `tanh` soft-clipper driven hard by the `Drive` knob; a
|
/// A DC-blocking high-pass feeds a `tanh` stage that is post-gained by the `Drive` knob into a
|
||||||
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip guarantees the
|
/// hard clipper — both evaluated at 4× oversampling so the clipper's harmonics don't alias. A
|
||||||
/// output stays bounded.
|
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip re-bounds the
|
||||||
|
/// output (the tone low-pass can ring slightly past the ceiling on transients).
|
||||||
///
|
///
|
||||||
/// ## Knobs
|
/// ## Knobs
|
||||||
/// - `drive`: Pre-clip gain into the `tanh` stage. Range `[1, 50]`.
|
/// - `drive`: Pre-clip gain into the `tanh` stage. Range `[1, 50]`.
|
||||||
@@ -87,12 +88,24 @@ public final class DistortionPedal: Pedal {
|
|||||||
freq: dcBlockFreq,
|
freq: dcBlockFreq,
|
||||||
q: filterQ
|
q: filterQ
|
||||||
)
|
)
|
||||||
let driven: Tanh.Audio = Tanh.Audio(dcBlocked, mul: $drive)
|
// tanh soft stage → post-gain by drive → hard clip, all evaluated at 4× so the hard
|
||||||
|
// clipper's harmonics settle above the upsampled Nyquist instead of aliasing back.
|
||||||
|
// The tone low-pass now follows the clip (standard clip→tone order), which also
|
||||||
|
// filters any residual high-band content the downsampler leaves.
|
||||||
|
let clipped: OversampledSaturator = OversampledSaturator(
|
||||||
|
dcBlocked,
|
||||||
|
drive: $drive,
|
||||||
|
curve: .tanhPostGainHardClip(low: clipLow, high: clipHigh),
|
||||||
|
oversample: 4
|
||||||
|
)
|
||||||
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||||
input: driven,
|
input: clipped,
|
||||||
freq: $tone,
|
freq: $tone,
|
||||||
q: filterQ
|
q: filterQ
|
||||||
)
|
)
|
||||||
|
// Final hard clip re-establishes the strict output bound: the tone low-pass is linear
|
||||||
|
// and band-limited, so it can overshoot the ceiling slightly on transients, but
|
||||||
|
// clipping its (already band-limited) output adds negligible new aliasing.
|
||||||
return Clip.Audio(toned, lo: clipLow, hi: clipHigh)
|
return Clip.Audio(toned, lo: clipLow, hi: clipHigh)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class FeedbackDelayPedal: Pedal {
|
|||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Maximum supported delay time in seconds. Sizes the delay-line buffer at init.
|
/// Maximum supported delay time in seconds. Sizes the delay-line buffer at init.
|
||||||
private let maxDelayTime: Double = 1.5
|
private let maxDelayTime: Double = 5.0
|
||||||
|
|
||||||
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
||||||
private let targetAmp: Double = 0.001
|
private let targetAmp: Double = 0.001
|
||||||
@@ -58,12 +58,18 @@ public final class FeedbackDelayPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Ranges
|
// MARK: - Ranges
|
||||||
|
|
||||||
private let timeRange: ClosedRange<Double> = 0.02 ... 1.5
|
private let timeRange: ClosedRange<Double> = 0.02 ... 5.0
|
||||||
private let feedbackRange: ClosedRange<Double> = 0.1 ... 8.0
|
private let feedbackRange: ClosedRange<Double> = 0.1 ... 8.0
|
||||||
private let toneRange: ClosedRange<Double> = 500.0 ... 8000.0
|
private let toneRange: ClosedRange<Double> = 500.0 ... 8000.0
|
||||||
|
|
||||||
// MARK: - Knobs
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ public final class FlangerPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Knobs
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// FullertonDeluxeAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// American blackface **lower-headroom combo** — the smaller-powered sibling of
|
||||||
|
/// ``FullertonReverbAmpPedal``.
|
||||||
|
///
|
||||||
|
/// Same reverb + tremolo + Bright control surface and American cab, but with less clean headroom:
|
||||||
|
/// the power-amp stage runs a higher fixed drive than the Twin, so it breaks up earlier and grittier.
|
||||||
|
/// The go-to blackface combo tone.
|
||||||
|
public final class FullertonDeluxeAmpPedal: FullertonReverbAmpPedal {
|
||||||
|
|
||||||
|
/// Power-amp drive — higher than the Twin's fixed `1.5` so it saturates earlier (less headroom).
|
||||||
|
private let deluxePowerDrive: Double = 2.2
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"American combo — earlier-breakup blackface tone with reverb, tremolo, and Bright."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fixed power-amp drive is higher than the Twin's, so 4× oversampling for anti-alias headroom.
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput { deluxePowerDrive }
|
||||||
|
|
||||||
|
/// Creates a Fullerton Deluxe amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Fullerton Deluxe", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 4.5 // slightly hotter starting point than the Twin
|
||||||
|
bass = 0.45 // a touch less low end than the 2×12
|
||||||
|
cab = 0.0 // American 1×12
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
// FullertonDriveAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// American **two-channel combo** — a blackface-style clean plus a hotter overdrive channel, with
|
||||||
|
/// spring reverb and a Bright switch. The modern gigging combo (Hot Rod / Blues Jr. lineage).
|
||||||
|
///
|
||||||
|
/// The **Channel** switch selects Clean or Drive. On the Drive channel a second cascaded
|
||||||
|
/// ``TriodeStage`` (set by the `Drive` knob) is added ahead of the tone stack for preamp overdrive;
|
||||||
|
/// on Clean it is omitted entirely. Because the channel changes the graph topology the switch is
|
||||||
|
/// `rebuildsOnChange` — flipping it rebuilds the board (like the cab selector), so only the selected
|
||||||
|
/// channel's stages are ever built.
|
||||||
|
public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
/// Spring-reverb wet mix in [0, 1].
|
||||||
|
@UIParam public var reverb: Double = 0.25
|
||||||
|
/// Drive-channel preamp gain (the cascaded overdrive stage). Range [1, 30].
|
||||||
|
@UIParam public var drive: Double = 8.0
|
||||||
|
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||||
|
@UIParam public var bright: Double = 0.0
|
||||||
|
/// Channel select: `0` = Clean, `1` = Drive (the cascaded overdrive stage).
|
||||||
|
@UIParam public var channel: Double = 0.0
|
||||||
|
|
||||||
|
private let brightFreqHz: Double = 3200.0
|
||||||
|
private let brightMaxGainDb: Double = 6.0
|
||||||
|
private let brightSlope: Double = 1.0
|
||||||
|
/// Grid bias of the cascaded drive stage — a little asymmetry for even-harmonic grind.
|
||||||
|
private let driveBias: Double = 0.25
|
||||||
|
/// Channel-select threshold: `>= this` selects the Drive channel.
|
||||||
|
private let channelThreshold: Double = 0.5
|
||||||
|
|
||||||
|
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||||
|
private let switchOffValue: Double = 0.0
|
||||||
|
private let switchOnValue: Double = 1.0
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .fender }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"American two-channel combo — blackface clean plus an overdrive channel, with reverb and Bright."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||||
|
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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(
|
||||||
|
label: "Bright",
|
||||||
|
node: $bright,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Channel",
|
||||||
|
node: $channel,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "Drive", value: switchOnValue),
|
||||||
|
],
|
||||||
|
rebuildsOnChange: true
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a Fullerton Drive amp.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Fullerton Drive", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 4.0
|
||||||
|
cab = 0.0 // American 1×12
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||||
|
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||||
|
return RBJHighShelf.Audio(
|
||||||
|
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clean preamp, plus a cascaded overdrive stage on the Drive channel. The `channel` value is
|
||||||
|
/// read at board-build time (the switch is `rebuildsOnChange`), so only the selected channel's
|
||||||
|
/// stages exist in the graph.
|
||||||
|
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||||
|
guard channel >= channelThreshold else { return clean }
|
||||||
|
return TriodeStage(input: clean, drive: $drive, bias: driveBias, oversample: preampOversample)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// FullertonPrincetonAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// American blackface **1×10 combo** — the smallest, darkest blackface voice, below
|
||||||
|
/// ``FullertonDeluxeAmpPedal``.
|
||||||
|
///
|
||||||
|
/// Same reverb + tremolo + Bright control surface, but voiced smaller: a darker cabinet, less low
|
||||||
|
/// end, and the earliest, most compressed breakup of the three — the classic small-studio recording
|
||||||
|
/// combo.
|
||||||
|
public final class FullertonPrincetonAmpPedal: FullertonReverbAmpPedal {
|
||||||
|
|
||||||
|
/// Power-amp drive — the highest of the blackface trio, so it breaks up earliest.
|
||||||
|
private let princetonPowerDrive: Double = 2.6
|
||||||
|
|
||||||
|
public override var summaryText: String {
|
||||||
|
"American 1×10 combo — small, dark, early-breakup blackface with reverb, tremolo, and Bright."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Driven hardest of the blackface trio, so 4× oversampling for anti-alias headroom.
|
||||||
|
public override var powerAmpOversample: Int { 4 }
|
||||||
|
public override var powerAmpDriveInput: any ValidGeneratorInput { princetonPowerDrive }
|
||||||
|
|
||||||
|
/// Creates a Fullerton Princeton 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
|
||||||
|
bass = 0.4 // least low end of the trio
|
||||||
|
treble = 0.55 // a shade darker
|
||||||
|
cab = 2.0 // Vintage Dark — the small, dark 1×10 voice
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
// FullertonReverbAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// American blackface-combo amp with a full onboard control surface: spring **reverb**, **tremolo**
|
||||||
|
/// (Speed / Intensity), and a **Bright** switch — the loud, headroom-rich clean voice.
|
||||||
|
///
|
||||||
|
/// A ``AmpVoicePedal`` fixed to the American tone stack that fills both subclass hooks:
|
||||||
|
/// - ``inputShaping(_:)`` applies the Bright switch as a pre-preamp treble shelf.
|
||||||
|
/// - ``onboardEffects(_:)`` inserts the spring reverb then the tremolo, between the tone stack and
|
||||||
|
/// the power amp — the slot a combo amp's built-in reverb/tremolo occupy.
|
||||||
|
///
|
||||||
|
/// The amp's "vibrato" channel is historically amplitude modulation (tremolo), not pitch vibrato,
|
||||||
|
/// so `Intensity` drives a unipolar-sine gain LFO. Tremolo defaults off (`Intensity = 0`) so the
|
||||||
|
/// amp opens as a clean, reverbed platform.
|
||||||
|
///
|
||||||
|
/// A **Reverb** and a **Vibrato** switch model the amp's two-button footswitch: each bypasses its
|
||||||
|
/// effect (dry pass-through) while preserving the knob positions, so a player can stomp the FX in
|
||||||
|
/// and out without losing their settings.
|
||||||
|
open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
// MARK: - Onboard-effect parameters
|
||||||
|
|
||||||
|
/// Spring-reverb wet mix in [0, 1]. `0` = dry, `1` = fully wet.
|
||||||
|
@UIParam public var reverb: Double = 0.25
|
||||||
|
/// Tremolo LFO rate in Hz. Range [0.5, 12].
|
||||||
|
@UIParam public var speed: Double = 4.0
|
||||||
|
/// Tremolo depth in [0, 1]. `0` = off (clean), `1` = full silence-to-unity swing.
|
||||||
|
@UIParam public var intensity: Double = 0.0
|
||||||
|
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||||
|
@UIParam public var bright: Double = 0.0
|
||||||
|
/// Reverb footswitch: `1` = reverb engaged, `0` = bypassed (dry pass-through, `Reverb` knob
|
||||||
|
/// setting preserved). Models the amp's reverb footswitch.
|
||||||
|
@UIParam public var reverbEnabled: Double = 1.0
|
||||||
|
/// Vibrato footswitch: `1` = tremolo engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
|
||||||
|
/// Models the amp's vibrato footswitch.
|
||||||
|
@UIParam public var vibratoEnabled: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Bright-switch shelf corner in Hz.
|
||||||
|
private let brightFreqHz: Double = 2500.0
|
||||||
|
/// Bright-switch shelf lift in dB when engaged.
|
||||||
|
private let brightMaxGainDb: Double = 6.0
|
||||||
|
/// Bright-switch shelf slope.
|
||||||
|
private let brightSlope: Double = 0.8
|
||||||
|
|
||||||
|
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
|
||||||
|
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let switchOffValue: Double = 0.0
|
||||||
|
private let switchOnValue: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Voice configuration
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .fender }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"American blackface clean — spring reverb, tremolo, and a Bright switch."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||||
|
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||||
|
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
/// The blackface-combo variants (Deluxe / Princeton) call the inherited
|
||||||
|
/// `AmpVoicePedal.init(name:inputBus:outputBus:)` designated init to set their own name while
|
||||||
|
/// inheriting the shared reverb + tremolo + bright control surface.
|
||||||
|
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
self.init(name: "Fullerton Reverb", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 4.0 // headroom-rich clean default
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Switches
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Bright",
|
||||||
|
node: $bright,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Reverb FX", // disambiguated from the "Reverb" level knob
|
||||||
|
node: $reverbEnabled,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Vibrato",
|
||||||
|
node: $vibratoEnabled,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Hooks
|
||||||
|
|
||||||
|
/// Bright switch: a high-shelf lift ahead of the preamp. The switch value (`0`/`1`) scales the
|
||||||
|
/// shelf gain, so "Off" is a true identity and the effect is live (no rebuild).
|
||||||
|
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||||
|
return RBJHighShelf.Audio(
|
||||||
|
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spring reverb → tremolo, inserted after the tone stack and before the power amp.
|
||||||
|
///
|
||||||
|
/// The `reverbEnabled` / `vibratoEnabled` footswitches gate each effect live by scaling its wet
|
||||||
|
/// amount to zero: reverb collapses to a dry pass-through and the tremolo LFO collapses to a
|
||||||
|
/// constant `1.0` (identity), each while preserving its knob positions and needing no rebuild.
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// Footswitch gates the wet mix to 0 → SpringReverb passes the dry signal through.
|
||||||
|
let reverbMix: any ValidGeneratorInput = $reverb * $reverbEnabled
|
||||||
|
let reverbed: SpringReverb.Audio = SpringReverb.Audio(
|
||||||
|
input: signal, mix: reverbMix, sampleRate: sampleRate)
|
||||||
|
// Tremolo gated by the vibrato footswitch (identity when depth·enabled == 0).
|
||||||
|
return tremolo(reverbed, speed: $speed, depth: $intensity, enabled: $vibratoEnabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,11 +105,17 @@ public final class FuzzPedal: Pedal {
|
|||||||
/// - Returns: Fuzzed and tone-shaped mono output.
|
/// - Returns: Fuzzed and tone-shaped mono output.
|
||||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
// Pre-gain the signal hard, then saturate. `tanh` squares the waveform off as the
|
// Pre-gain the signal hard, then saturate. `tanh` squares the waveform off as the
|
||||||
// drive rises while keeping the level bounded — the hallmark of a fuzz.
|
// drive rises while keeping the level bounded — the hallmark of a fuzz. Evaluated at
|
||||||
let driven: any ValidGeneratorInput = dry * $fuzz
|
// 2× so the high harmonics the hard pre-gain generates don't fold back as aliasing.
|
||||||
let saturated: Tanh.Audio = Tanh.Audio(driven, mul: outputTrim)
|
let saturated: OversampledSaturator = OversampledSaturator(
|
||||||
|
dry,
|
||||||
|
drive: $fuzz,
|
||||||
|
curve: .tanhPreGain,
|
||||||
|
oversample: 2
|
||||||
|
)
|
||||||
|
let trimmed: any ValidGeneratorInput = saturated * outputTrim
|
||||||
return RBJLowPass.Audio(
|
return RBJLowPass.Audio(
|
||||||
input: saturated,
|
input: trimmed,
|
||||||
freq: $tone,
|
freq: $tone,
|
||||||
q: toneQ
|
q: toneQ
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
// JazzCleanAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Ultra-clean solid-state combo with its signature lush **stereo chorus**, plus spring reverb and
|
||||||
|
/// a bright switch — the glassy "jazz clean" platform.
|
||||||
|
///
|
||||||
|
/// Unlike the mono amp voices, this amp is a ``PedalChannelKind/widener``: the real amp has two
|
||||||
|
/// power amps and two speakers fed by a stereo chorus, so it takes the mono guitar input and emits a
|
||||||
|
/// genuinely stereo pair. The chorus (mono → stereo) is the stereo splitter — its two taps become
|
||||||
|
/// the left and right channels, each then run through its own cabinet + output stage.
|
||||||
|
///
|
||||||
|
/// Signal path (inside `wideEffect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → preCabinetCore (bright → preamp → tone → spring reverb → power amp) [mono]
|
||||||
|
/// → Chorus (mono → stereo) [stereo split]
|
||||||
|
/// → L: cabinetAndLimit R: cabinetAndLimit [per channel]
|
||||||
|
/// ```
|
||||||
|
/// A **Chorus** switch models the amp's chorus on/off footswitch: off collapses the chorus to a dry
|
||||||
|
/// pass-through (both channels identical), preserving the Rate/Depth settings.
|
||||||
|
public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||||
|
|
||||||
|
// MARK: - Onboard-effect parameters
|
||||||
|
|
||||||
|
/// Spring-reverb wet mix in [0, 1].
|
||||||
|
@UIParam public var reverb: Double = 0.2
|
||||||
|
/// Chorus LFO rate in Hz. Range [0.1, 5.0].
|
||||||
|
@UIParam public var chorusRate: Double = 0.8
|
||||||
|
/// Chorus depth as a fraction of the base delay time. Kept in the classic-chorus band
|
||||||
|
/// (~0.001–0.01) so it adds width without pitch wobble.
|
||||||
|
@UIParam public var chorusDepth: Double = 0.005
|
||||||
|
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||||
|
@UIParam public var bright: Double = 0.0
|
||||||
|
/// Chorus footswitch: `1` = chorus engaged (stereo), `0` = bypassed (dry, mono-equivalent).
|
||||||
|
@UIParam public var chorusEnabled: Double = 1.0
|
||||||
|
/// Drive-channel preamp gain (the onboard distortion). Range [1, 30].
|
||||||
|
@UIParam public var drive: Double = 8.0
|
||||||
|
/// Channel select: `0` = Clean, `1` = Distortion (the cascaded onboard-distortion stage).
|
||||||
|
@UIParam public var channel: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Bright-switch shelf corner in Hz.
|
||||||
|
private let brightFreqHz: Double = 3000.0
|
||||||
|
/// Bright-switch shelf lift in dB when engaged.
|
||||||
|
private let brightMaxGainDb: Double = 5.0
|
||||||
|
/// Bright-switch shelf slope.
|
||||||
|
private let brightSlope: Double = 0.9
|
||||||
|
/// Fixed chorus wet/dry blend when the chorus is engaged (the amp has no chorus-mix knob).
|
||||||
|
private let chorusMixValue: Double = 0.5
|
||||||
|
|
||||||
|
/// Grid bias of the cascaded distortion stage — solid-state-flavoured, near-symmetric.
|
||||||
|
private let driveBias: Double = 0.1
|
||||||
|
/// Channel-select threshold: `>= this` selects the Distortion channel.
|
||||||
|
private let channelThreshold: Double = 0.5
|
||||||
|
|
||||||
|
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let chorusRateRange: ClosedRange<Double> = 0.1 ... 5.0
|
||||||
|
private let chorusDepthRange: ClosedRange<Double> = 0.0005 ... 0.015
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||||
|
private let switchOffValue: Double = 0.0
|
||||||
|
private let switchOnValue: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Voice configuration
|
||||||
|
|
||||||
|
public override var toneStackModel: ToneStackModel { .fender }
|
||||||
|
public override var summaryText: String {
|
||||||
|
"Solid-state clean — lush stereo chorus, spring reverb, a Bright switch, and a Distortion channel."
|
||||||
|
}
|
||||||
|
public override var signatureKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||||
|
PedalKnob(label: "Rate", node: $chorusRate, range: chorusRateRange),
|
||||||
|
PedalKnob(label: "Depth", node: $chorusDepth, range: chorusDepthRange),
|
||||||
|
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
|
super.init(name: "Jazz Clean", inputBus: inputBus, outputBus: outputBus)
|
||||||
|
gain = 3.0 // clean, low-gain solid-state default
|
||||||
|
cab = 6.0 // Full-Range (FRFR) — the hi-fi, least-coloured voice
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Switches
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Bright",
|
||||||
|
node: $bright,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Chorus",
|
||||||
|
node: $chorusEnabled,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Channel",
|
||||||
|
node: $channel,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||||
|
PedalSwitch.Option(title: "Dist", value: switchOnValue),
|
||||||
|
],
|
||||||
|
rebuildsOnChange: true
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clean preamp, plus the onboard-distortion stage on the Distortion channel. The `channel`
|
||||||
|
/// value is read at board-build time (the switch is `rebuildsOnChange`), so only the selected
|
||||||
|
/// channel's stages exist in the graph.
|
||||||
|
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||||
|
guard channel >= channelThreshold else { return clean }
|
||||||
|
return TriodeStage(input: clean, drive: $drive, bias: driveBias, oversample: preampOversample)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Hooks
|
||||||
|
|
||||||
|
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||||||
|
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||||||
|
return RBJHighShelf.Audio(
|
||||||
|
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spring reverb inside the mono core (before the stereo chorus split).
|
||||||
|
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Stereo effect
|
||||||
|
|
||||||
|
/// Mono amp core → stereo chorus split → per-channel cabinet + output stage.
|
||||||
|
///
|
||||||
|
/// The `chorusEnabled` footswitch gates the chorus wet mix to `0` when off, so the chorus passes
|
||||||
|
/// the dry core to both channels (a mono-equivalent output) while preserving Rate/Depth.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The stereo (left, right) amp output.
|
||||||
|
public override func wideEffect(
|
||||||
|
_ dry: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
let core: any ValidGeneratorInput = preCabinetCore(dry)
|
||||||
|
let chorusMix: any ValidGeneratorInput = $chorusEnabled * chorusMixValue
|
||||||
|
let chorus: Chorus.Audio = Chorus.Audio(
|
||||||
|
input: core,
|
||||||
|
depth: $chorusDepth,
|
||||||
|
rate: $chorusRate,
|
||||||
|
mix: chorusMix,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
return (cabinetAndLimit(chorus.left), cabinetAndLimit(chorus.right))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ import LyrebirdUI
|
|||||||
/// drive harder into the limiter. Range `[1, 12]`. Defaults to `1.0`.
|
/// drive harder into the limiter. Range `[1, 12]`. Defaults to `1.0`.
|
||||||
/// - ceiling: Output peak ceiling as a linear amplitude in `[0, 1]`. The limited output
|
/// - ceiling: Output peak ceiling as a linear amplitude in `[0, 1]`. The limited output
|
||||||
/// never exceeds this absolute value. Range `[0.1, 1.0]`. Defaults to `0.95`.
|
/// never exceeds this absolute value. Range `[0.1, 1.0]`. Defaults to `0.95`.
|
||||||
|
/// - release: Gain-release time in seconds. Too short a release modulates the gain
|
||||||
|
/// within a waveform cycle and distorts low notes; longer is cleaner but lets the
|
||||||
|
/// level swell back more slowly. Range `[0.01, 0.5]`. Defaults to `0.05`.
|
||||||
public final class LimiterPedal: Pedal {
|
public final class LimiterPedal: Pedal {
|
||||||
|
|
||||||
/// One-line description shown in the picker and info panel.
|
/// One-line description shown in the picker and info panel.
|
||||||
@@ -44,6 +47,9 @@ public final class LimiterPedal: Pedal {
|
|||||||
/// Output peak ceiling (linear amplitude). Range [0.1, 1.0].
|
/// Output peak ceiling (linear amplitude). Range [0.1, 1.0].
|
||||||
@UIParam public var ceiling: Double = 0.95
|
@UIParam public var ceiling: Double = 0.95
|
||||||
|
|
||||||
|
/// Gain-release time in seconds. Range [0.01, 0.5].
|
||||||
|
@UIParam public var release: Double = 0.05
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Default wet/dry blend — fully wet; the limiter sits in-line.
|
/// Default wet/dry blend — fully wet; the limiter sits in-line.
|
||||||
@@ -61,10 +67,14 @@ public final class LimiterPedal: Pedal {
|
|||||||
/// Ceiling knob range (linear output peak).
|
/// Ceiling knob range (linear output peak).
|
||||||
private let ceilingRange: ClosedRange<Double> = 0.1 ... 1.0
|
private let ceilingRange: ClosedRange<Double> = 0.1 ... 1.0
|
||||||
|
|
||||||
|
/// Release knob range in seconds.
|
||||||
|
private let releaseRange: ClosedRange<Double> = 0.01 ... 0.5
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Boost", node: $boost, range: boostRange),
|
PedalKnob(label: "Boost", node: $boost, range: boostRange),
|
||||||
PedalKnob(label: "Ceiling", node: $ceiling, range: ceilingRange),
|
PedalKnob(label: "Ceiling", node: $ceiling, range: ceilingRange),
|
||||||
|
PedalKnob(label: "Release", node: $release, range: releaseRange),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +111,7 @@ public final class LimiterPedal: Pedal {
|
|||||||
in: boosted,
|
in: boosted,
|
||||||
maxAmplitude: $ceiling,
|
maxAmplitude: $ceiling,
|
||||||
lookAheadTime: lookAheadTime,
|
lookAheadTime: lookAheadTime,
|
||||||
|
releaseTime: $release,
|
||||||
sampleRate: sampleRate
|
sampleRate: sampleRate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ public final class ModulationPedal: Pedal {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -58,18 +58,26 @@ public final class MultiTapDelayPedal: Pedal {
|
|||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Maximum supported per-tap delay time in seconds. Sizes each delay-line buffer at init.
|
/// Maximum supported per-tap delay time in seconds. Sizes each delay-line buffer at init.
|
||||||
private let maxDelayTime: Double = 1.0
|
private let maxDelayTime: Double = 5.0
|
||||||
|
|
||||||
/// Partial wet/dry blend so the dry note and its taps coexist.
|
/// Partial wet/dry blend so the dry note and its taps coexist.
|
||||||
private static let defaultMix: Double = 0.4
|
private static let defaultMix: Double = 0.4
|
||||||
|
|
||||||
// MARK: - Ranges
|
// MARK: - Ranges
|
||||||
|
|
||||||
private let timeRange: ClosedRange<Double> = 0.01 ... 1.0
|
private let timeRange: ClosedRange<Double> = 0.01 ... 5.0
|
||||||
private let volRange: ClosedRange<Double> = 0.0 ... 1.0
|
private let volRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
// MARK: - Knobs
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "time1", label: "Time 1", node: $time1, kind: .time, range: timeRange),
|
||||||
|
TempoSyncableParam(key: "time2", label: "Time 2", node: $time2, kind: .time, range: timeRange),
|
||||||
|
TempoSyncableParam(key: "time3", label: "Time 3", node: $time3, kind: .time, range: timeRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
/// Two rows of three: the three tap times, then the three tap volumes.
|
/// Two rows of three: the three tap times, then the three tap volumes.
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public final class MutantPedal: Pedal {
|
|||||||
"Envelope-following auto-wah / funk filter that opens with your picking."
|
"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
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
|
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
// NeuralAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Neural amp/pedal capture player: runs a GuitarML Proteus / NeuralPi LSTM model on the input.
|
||||||
|
///
|
||||||
|
/// Load a model with ``loadModel(path:)`` (or set ``Pedal/resourcePath``); the file path is
|
||||||
|
/// persisted in the rig, so a saved rig reloads the same capture. With no model loaded the pedal
|
||||||
|
/// passes the signal through clean.
|
||||||
|
///
|
||||||
|
/// Signal chain (inside `effect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → × gain → LSTMAmp(model) → mono out (model loaded)
|
||||||
|
/// dry → mono out (no model)
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The model is read and built at `build()` (off the RT thread); changing it takes effect on the
|
||||||
|
/// next rebuild. Fully wet when a model is loaded; `Level` is the master.
|
||||||
|
///
|
||||||
|
/// > Model files are **user-supplied and not bundled** — GuitarML models are GPL-3.0. Download a
|
||||||
|
/// > capture (e.g. from the GuitarML Tone Library or Tone3000) and point the pedal at it.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `bypass` and `level` (master) from `Pedal`, plus:
|
||||||
|
/// - `gain`: Input drive into the model (linear). Range `[0.25, 4]`.
|
||||||
|
public final class NeuralAmpPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Plays a neural amp/pedal capture (GuitarML Proteus / NeuralPi model)."
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fully wet when a model is loaded; hide the Mix control.
|
||||||
|
public override var showsMixControl: Bool { false }
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Input drive into the model (linear multiplier). Range [0.25, 4].
|
||||||
|
@UIParam public var gain: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
private let gainRange: ClosedRange<Double> = 0.25 ... 4.0
|
||||||
|
|
||||||
|
/// Caches the parsed model per path so a stereo-region build (which calls `effect(_:)` once
|
||||||
|
/// per channel) reads and decodes the file only once. Keyed on the path so a model change
|
||||||
|
/// re-parses. Touched only at `build()` on the main thread.
|
||||||
|
private var loadedModel: (path: String, model: NeuralAmpModel)?
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a neural amp pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: "Neural Amp",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: NeuralAmpPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Points the pedal at a Proteus/NeuralPi model file. Takes effect on the next rebuild.
|
||||||
|
///
|
||||||
|
/// - Parameter path: Filesystem path to the model `.json`.
|
||||||
|
public func loadModel(path: String) {
|
||||||
|
resourcePath = path
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - UI
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Gain", node: $gain, range: gainRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Runs the loaded model on the (gain-trimmed) input; passes through clean if no model is set
|
||||||
|
/// or the file can't be read/parsed.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The model output, or the dry signal when no model is loaded.
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
guard let path: String = resourcePath, let model: NeuralAmpModel = resolveModel(path: path) else {
|
||||||
|
return dry
|
||||||
|
}
|
||||||
|
let driven: any ValidGeneratorInput = dry * $gain
|
||||||
|
return LSTMAmp(input: driven, model: model)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads (and caches) the model at `path`, or returns `nil` if the file is missing/unparsable.
|
||||||
|
private func resolveModel(path: String) -> NeuralAmpModel? {
|
||||||
|
if let cached: (path: String, model: NeuralAmpModel) = loadedModel, cached.path == path {
|
||||||
|
return cached.model
|
||||||
|
}
|
||||||
|
guard let data: Data = try? Data(contentsOf: URL(fileURLWithPath: path)),
|
||||||
|
let model: NeuralAmpModel = try? ProteusModelImporter.model(fromProteusJSON: data)
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
loadedModel = (path, model)
|
||||||
|
return model
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import LyrebirdUI
|
|||||||
///
|
///
|
||||||
/// Signal chain (inside `effect(_:)`):
|
/// Signal chain (inside `effect(_:)`):
|
||||||
/// ```
|
/// ```
|
||||||
/// dry → SoftClip(drive:) → RBJLowPass(freq: tone, q: 0.707) → mono out
|
/// dry → OversampledSaturator(curve: .softClipNormalized, drive:) → RBJLowPass(freq: tone, q: 0.707) → mono out
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||||
@@ -83,7 +83,14 @@ public final class OverdrivePedal: Pedal {
|
|||||||
/// - Parameter dry: Dry mono input signal.
|
/// - Parameter dry: Dry mono input signal.
|
||||||
/// - Returns: Saturated and tone-shaped mono output.
|
/// - Returns: Saturated and tone-shaped mono output.
|
||||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
let saturated: SoftClip.Audio = SoftClip.Audio(dry, drive: $drive)
|
// Same normalised soft-clip curve as before (`tanh(drive·x) / tanh(drive)`), but
|
||||||
|
// evaluated at 2× so high-drive harmonics don't alias.
|
||||||
|
let saturated: OversampledSaturator = OversampledSaturator(
|
||||||
|
dry,
|
||||||
|
drive: $drive,
|
||||||
|
curve: .softClipNormalized,
|
||||||
|
oversample: 2
|
||||||
|
)
|
||||||
return RBJLowPass.Audio(
|
return RBJLowPass.Audio(
|
||||||
input: saturated,
|
input: saturated,
|
||||||
freq: $tone,
|
freq: $tone,
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ public final class PhaserPedal: Pedal {
|
|||||||
/// Feedback knob range (all-pass feedback gain).
|
/// Feedback knob range (all-pass feedback gain).
|
||||||
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.9
|
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.9
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import LyrebirdUI
|
|||||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - time: Delay time per tap in seconds. Range `[0.05, 1.0]`. Defaults to `0.3`.
|
/// - time: Delay time per tap in seconds. Range `[0.05, 5.0]`. Defaults to `0.3`.
|
||||||
/// - feedback: Feedback as decay time in seconds (time for echoes to fall to −60 dB).
|
/// - feedback: Feedback as decay time in seconds (time for echoes to fall to −60 dB).
|
||||||
/// Range `[0.05, 6.0]`. Defaults to `1.2`.
|
/// Range `[0.05, 6.0]`. Defaults to `1.2`.
|
||||||
public final class PingPongDelayPedal: Pedal {
|
public final class PingPongDelayPedal: Pedal {
|
||||||
@@ -44,7 +44,7 @@ public final class PingPongDelayPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Delay time per tap in seconds. Range [0.05, 1.0].
|
/// Delay time per tap in seconds. Range [0.05, 5.0].
|
||||||
@UIParam public var time: Double = 0.3
|
@UIParam public var time: Double = 0.3
|
||||||
|
|
||||||
/// Feedback decay time in seconds (time to reach −60 dB amplitude). Range [0.05, 6.0].
|
/// Feedback decay time in seconds (time to reach −60 dB amplitude). Range [0.05, 6.0].
|
||||||
@@ -53,7 +53,7 @@ public final class PingPongDelayPedal: Pedal {
|
|||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Maximum supported delay time in seconds. Sizes both delay lines at init.
|
/// Maximum supported delay time in seconds. Sizes both delay lines at init.
|
||||||
private let maxDelayTime: Double = 1.0
|
private let maxDelayTime: Double = 5.0
|
||||||
|
|
||||||
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
/// Amplitude target for the `decayTime` calculation (−60 dB).
|
||||||
private let targetAmp: Double = 0.001
|
private let targetAmp: Double = 0.001
|
||||||
@@ -67,7 +67,7 @@ public final class PingPongDelayPedal: Pedal {
|
|||||||
// MARK: - UI knobs
|
// MARK: - UI knobs
|
||||||
|
|
||||||
/// Delay-time knob range in seconds.
|
/// Delay-time knob range in seconds.
|
||||||
private let timeRange: ClosedRange<Double> = 0.05 ... 1.0
|
private let timeRange: ClosedRange<Double> = 0.05 ... 5.0
|
||||||
|
|
||||||
/// Feedback (decay-time) knob range in seconds.
|
/// Feedback (decay-time) knob range in seconds.
|
||||||
private let feedbackRange: ClosedRange<Double> = 0.05 ... 6.0
|
private let feedbackRange: ClosedRange<Double> = 0.05 ... 6.0
|
||||||
@@ -96,6 +96,12 @@ public final class PingPongDelayPedal: Pedal {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import LyrebirdUI
|
|||||||
/// so the pedal's `Mix` knob sets the wet/dry blend.
|
/// so the pedal's `Mix` knob sets the wet/dry blend.
|
||||||
///
|
///
|
||||||
/// ## Knobs
|
/// ## Knobs
|
||||||
/// - `time`: Reverse segment length in seconds. Range `[0.05, 2.0]`.
|
/// - `time`: Reverse segment length in seconds. Range `[0.05, 5.0]`.
|
||||||
/// - `feedback`: Reverse-trail feedback. Range `[0, 0.95]`.
|
/// - `feedback`: Reverse-trail feedback. Range `[0, 0.95]`.
|
||||||
public final class ReverseDelayPedal: Pedal {
|
public final class ReverseDelayPedal: Pedal {
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public final class ReverseDelayPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Reverse segment length in seconds. Range [0.05, 2.0].
|
/// Reverse segment length in seconds. Range [0.05, 5.0].
|
||||||
@UIParam public var time: Double = 0.5
|
@UIParam public var time: Double = 0.5
|
||||||
|
|
||||||
/// Reverse-trail feedback. Range [0, 0.95].
|
/// Reverse-trail feedback. Range [0, 0.95].
|
||||||
@@ -38,15 +38,21 @@ public final class ReverseDelayPedal: Pedal {
|
|||||||
private static let defaultMix: Double = 0.5
|
private static let defaultMix: Double = 0.5
|
||||||
|
|
||||||
/// Maximum segment length the buffers are allocated for, in seconds.
|
/// Maximum segment length the buffers are allocated for, in seconds.
|
||||||
private let maxDelayTime: Double = 2.0
|
private let maxDelayTime: Double = 5.0
|
||||||
|
|
||||||
// MARK: - Ranges
|
// MARK: - Ranges
|
||||||
|
|
||||||
private let timeRange: ClosedRange<Double> = 0.05 ... 2.0
|
private let timeRange: ClosedRange<Double> = 0.05 ... 5.0
|
||||||
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.95
|
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.95
|
||||||
|
|
||||||
// MARK: - Knobs
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "time", label: "Time", node: $time, kind: .time, range: timeRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import LyrebirdUI
|
|||||||
///
|
///
|
||||||
/// Signal path (inside `effect(_:)`):
|
/// Signal path (inside `effect(_:)`):
|
||||||
/// ```
|
/// ```
|
||||||
/// dry × OscSin(frequency) → wet
|
/// dry → OversampledRingModulator(freq: frequency, oversample: 2) → wet
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||||
@@ -78,7 +78,8 @@ public final class RingModulatorPedal: Pedal {
|
|||||||
/// - Parameter dry: Dry mono input signal.
|
/// - Parameter dry: Dry mono input signal.
|
||||||
/// - Returns: The ring-modulated wet signal.
|
/// - Returns: The ring-modulated wet signal.
|
||||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
let carrier: OscSin.Audio = OscSin.Audio(freq: $frequency)
|
// Oversampled multiply: the sum sideband (f_in + f_carrier) can exceed Nyquist and
|
||||||
return dry * carrier
|
// fold back as an inharmonic alias, so do the product at 2× and filter on the way down.
|
||||||
|
return OversampledRingModulator(dry, freq: $frequency, oversample: 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ import LyrebirdUI
|
|||||||
/// - sustain: Amount of sustain/compression. `0` = gentle, `10` = maximum squash and hold.
|
/// - sustain: Amount of sustain/compression. `0` = gentle, `10` = maximum squash and hold.
|
||||||
/// Range `[0, 10]`. Defaults to `5.0`.
|
/// Range `[0, 10]`. Defaults to `5.0`.
|
||||||
/// - tone: Output low-pass cutoff in Hz. Range `[800, 8000]`. Defaults to `6000.0`.
|
/// - tone: Output low-pass cutoff in Hz. Range `[800, 8000]`. Defaults to `6000.0`.
|
||||||
|
///
|
||||||
|
/// At high sustain the compressor applies a low threshold, a high ratio, and up to +18 dB of
|
||||||
|
/// makeup — a feed-forward compressor's non-zero attack lets transients overshoot before the
|
||||||
|
/// gain clamps, so a hot pick can push the output past full scale and clip. The **Safety**
|
||||||
|
/// switch inserts a brick-wall `LookAheadLimiter` after the compressor to catch those peaks;
|
||||||
|
/// it is off by default and adds a short look-ahead output delay when engaged.
|
||||||
public final class SustainerPedal: Pedal {
|
public final class SustainerPedal: Pedal {
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
@@ -39,6 +45,10 @@ public final class SustainerPedal: Pedal {
|
|||||||
/// Output low-pass cutoff in Hz. Range [800, 8000].
|
/// Output low-pass cutoff in Hz. Range [800, 8000].
|
||||||
@UIParam public var tone: Double = 6000.0
|
@UIParam public var tone: Double = 6000.0
|
||||||
|
|
||||||
|
/// Safety limiter engage state. `0` = off (compressor may overshoot), `1` = on
|
||||||
|
/// (brick-wall look-ahead limiter catches transient peaks).
|
||||||
|
@UIParam public var safetyLimiter: Double = 0.0
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
private static let defaultMix: Double = 1.0
|
private static let defaultMix: Double = 1.0
|
||||||
@@ -69,6 +79,19 @@ public final class SustainerPedal: Pedal {
|
|||||||
private let makeupAtMin: Double = 0.0
|
private let makeupAtMin: Double = 0.0
|
||||||
private let makeupAtMax: Double = 18.0
|
private let makeupAtMax: Double = 18.0
|
||||||
|
|
||||||
|
/// Safety-limiter peak ceiling (linear amplitude), just below full scale.
|
||||||
|
private let safetyCeiling: Double = 0.98
|
||||||
|
|
||||||
|
/// Safety-limiter look-ahead / output delay in seconds. Only in circuit when Safety is on.
|
||||||
|
private let safetyLookAheadTime: Double = 0.005
|
||||||
|
|
||||||
|
/// Safety-limiter gain-release time in seconds.
|
||||||
|
private let safetyReleaseTime: Double = 0.05
|
||||||
|
|
||||||
|
/// Safety switch position values.
|
||||||
|
private let safetyOffValue: Double = 0.0
|
||||||
|
private let safetyOnValue: Double = 1.0
|
||||||
|
|
||||||
// MARK: - UI knobs
|
// MARK: - UI knobs
|
||||||
|
|
||||||
private let sustainRange: ClosedRange<Double> = 0.0 ... 10.0
|
private let sustainRange: ClosedRange<Double> = 0.0 ... 10.0
|
||||||
@@ -81,6 +104,19 @@ public final class SustainerPedal: Pedal {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Safety",
|
||||||
|
node: $safetyLimiter,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Off", value: safetyOffValue),
|
||||||
|
PedalSwitch.Option(title: "On", value: safetyOnValue),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
/// Creates a sustainer pedal.
|
/// Creates a sustainer pedal.
|
||||||
@@ -124,8 +160,22 @@ public final class SustainerPedal: Pedal {
|
|||||||
kneeWidth: kneeWidth,
|
kneeWidth: kneeWidth,
|
||||||
makeupGain: makeup
|
makeupGain: makeup
|
||||||
)
|
)
|
||||||
|
// Optional brick-wall safety limiter. Both branches are always built; `Select` picks
|
||||||
|
// per the Safety switch (0 = compressor only, 1 = limited). Engaging it adds the
|
||||||
|
// limiter's short look-ahead delay.
|
||||||
|
let limited: LookAheadLimiter = LookAheadLimiter(
|
||||||
|
in: compressed,
|
||||||
|
maxAmplitude: safetyCeiling,
|
||||||
|
lookAheadTime: safetyLookAheadTime,
|
||||||
|
releaseTime: safetyReleaseTime,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
let guarded: Select.Audio = Select.Audio(
|
||||||
|
which: $safetyLimiter,
|
||||||
|
inputs: [compressed, limited]
|
||||||
|
)
|
||||||
return RBJLowPass.Audio(
|
return RBJLowPass.Audio(
|
||||||
input: compressed,
|
input: guarded,
|
||||||
freq: $tone,
|
freq: $tone,
|
||||||
q: toneQ
|
q: toneQ
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ public final class TremoloPedal: Pedal {
|
|||||||
/// Depth knob range (modulation fraction).
|
/// Depth knob range (modulation fraction).
|
||||||
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
|
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ public final class VibratoPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Knobs
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||||
|
[
|
||||||
|
TempoSyncableParam(key: "rate", label: "Rate", node: $rate, kind: .rate, range: rateRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ extension Pedal {
|
|||||||
switchValues: switchValues,
|
switchValues: switchValues,
|
||||||
sliderValues: sliderValues,
|
sliderValues: sliderValues,
|
||||||
selectorValues: selectorValues,
|
selectorValues: selectorValues,
|
||||||
bypass: bypass
|
bypass: bypass,
|
||||||
|
tempoSync: tempoSync.isEmpty ? nil : tempoSync,
|
||||||
|
resourcePath: resourcePath
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,5 +63,10 @@ extension Pedal {
|
|||||||
selector.node.update(value)
|
selector.node.update(value)
|
||||||
}
|
}
|
||||||
bypass = state.bypass
|
bypass = state.bypass
|
||||||
|
// Restore tempo-sync state. The synced values themselves are recomputed from the rig's
|
||||||
|
// tempo by `ShoeGaze` after the rebuild, so no clock is required here.
|
||||||
|
tempoSync = state.tempoSync ?? [:]
|
||||||
|
tempoSyncRevision.bump()
|
||||||
|
resourcePath = state.resourcePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,26 @@ public enum PedalRegistry {
|
|||||||
/// `ShoeGaze.loadRig(from:)` updates `inputBus`/`outputBus` when adding the pedal
|
/// `ShoeGaze.loadRig(from:)` updates `inputBus`/`outputBus` when adding the pedal
|
||||||
/// to a board via `board.add(_:)`.
|
/// to a board via `board.add(_:)`.
|
||||||
public static let builtIn: [String: @MainActor () -> Pedal] = [
|
public static let builtIn: [String: @MainActor () -> Pedal] = [
|
||||||
|
"California": { CaliforniaAmpPedal() },
|
||||||
|
"British": { BritishAmpPedal() },
|
||||||
|
"British Plexi": { BritishPlexiAmpPedal() },
|
||||||
|
"British JTM": { BritishJTMAmpPedal() },
|
||||||
|
"British Bluesbreaker": { BritishBluesbreakerAmpPedal() },
|
||||||
|
"British Master": { BritishMasterAmpPedal() },
|
||||||
|
"British Dual": { BritishDualAmpPedal() },
|
||||||
|
"Boutique Lead": { BoutiqueLeadAmpPedal() },
|
||||||
|
"Boutique OD": { BoutiqueODAmpPedal() },
|
||||||
|
"Chime": { ChimeAmpPedal() },
|
||||||
|
"Chime 15": { ChimeFifteenAmpPedal() },
|
||||||
|
"Chime Normal": { ChimeNormalAmpPedal() },
|
||||||
|
"Chime Baby": { ChimeBabyAmpPedal() },
|
||||||
|
"Fullerton Reverb": { FullertonReverbAmpPedal() },
|
||||||
|
"Fullerton Deluxe": { FullertonDeluxeAmpPedal() },
|
||||||
|
"Fullerton Princeton": { FullertonPrincetonAmpPedal() },
|
||||||
|
"Fullerton Drive": { FullertonDriveAmpPedal() },
|
||||||
|
"Jazz Clean": { JazzCleanAmpPedal() },
|
||||||
|
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
|
||||||
|
"Neural Amp": { NeuralAmpPedal() },
|
||||||
"Overdrive": { OverdrivePedal() },
|
"Overdrive": { OverdrivePedal() },
|
||||||
"Distortion": { DistortionPedal() },
|
"Distortion": { DistortionPedal() },
|
||||||
"Delay": { DelayPedal() },
|
"Delay": { DelayPedal() },
|
||||||
@@ -56,6 +76,7 @@ public enum PedalRegistry {
|
|||||||
"Room Reverb": { RoomReverbPedal() },
|
"Room Reverb": { RoomReverbPedal() },
|
||||||
"Spring Reverb": { SpringReverbPedal() },
|
"Spring Reverb": { SpringReverbPedal() },
|
||||||
"Limiter": { LimiterPedal() },
|
"Limiter": { LimiterPedal() },
|
||||||
|
"Cabinet": { CabinetPedal() },
|
||||||
"Noise Gate": { NoiseGatePedal() },
|
"Noise Gate": { NoiseGatePedal() },
|
||||||
"Graphic EQ": { GraphicEQPedal() },
|
"Graphic EQ": { GraphicEQPedal() },
|
||||||
"Chorus": { ChorusPedal() },
|
"Chorus": { ChorusPedal() },
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ public struct PedalState: Codable, Equatable {
|
|||||||
/// Bypass parameter value. `0.0` = engaged, `1.0` = bypassed.
|
/// Bypass parameter value. `0.0` = engaged, `1.0` = bypassed.
|
||||||
public let bypass: Double
|
public let bypass: Double
|
||||||
|
|
||||||
|
/// Tempo-sync state per syncable parameter, keyed by ``TempoSyncableParam/key``. `nil` for a
|
||||||
|
/// pedal with no synced parameters, and for presets saved before tempo sync existed — both
|
||||||
|
/// decode to "all parameters free".
|
||||||
|
public let tempoSync: [String: TempoSync]?
|
||||||
|
|
||||||
|
/// Optional path to an external resource the pedal references (e.g. a neural-amp model file).
|
||||||
|
/// `nil` for pedals that use no external file, and for presets saved before this existed.
|
||||||
|
public let resourcePath: String?
|
||||||
|
|
||||||
/// Creates a pedal state snapshot.
|
/// Creates a pedal state snapshot.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -54,6 +63,9 @@ public struct PedalState: Codable, Equatable {
|
|||||||
/// - sliderValues: Current slider values in `Pedal.effectSliders` 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.
|
/// - selectorValues: Current selector values in `Pedal.effectSelectors` order. Defaults to empty.
|
||||||
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
||||||
|
/// - tempoSync: Tempo-sync state per syncable parameter, or `nil` for none. Defaults to `nil`.
|
||||||
|
/// - resourcePath: Path to an external resource the pedal references (e.g. a neural-amp
|
||||||
|
/// model file), or `nil`. Defaults to `nil`.
|
||||||
public init(
|
public init(
|
||||||
id: UUID = UUID(),
|
id: UUID = UUID(),
|
||||||
type: String,
|
type: String,
|
||||||
@@ -61,7 +73,9 @@ public struct PedalState: Codable, Equatable {
|
|||||||
switchValues: [Double] = [],
|
switchValues: [Double] = [],
|
||||||
sliderValues: [Double] = [],
|
sliderValues: [Double] = [],
|
||||||
selectorValues: [Double] = [],
|
selectorValues: [Double] = [],
|
||||||
bypass: Double
|
bypass: Double,
|
||||||
|
tempoSync: [String: TempoSync]? = nil,
|
||||||
|
resourcePath: String? = nil
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.type = type
|
self.type = type
|
||||||
@@ -70,6 +84,8 @@ public struct PedalState: Codable, Equatable {
|
|||||||
self.sliderValues = sliderValues
|
self.sliderValues = sliderValues
|
||||||
self.selectorValues = selectorValues
|
self.selectorValues = selectorValues
|
||||||
self.bypass = bypass
|
self.bypass = bypass
|
||||||
|
self.tempoSync = tempoSync
|
||||||
|
self.resourcePath = resourcePath
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
@@ -80,10 +96,12 @@ public struct PedalState: Codable, Equatable {
|
|||||||
case sliderValues
|
case sliderValues
|
||||||
case selectorValues
|
case selectorValues
|
||||||
case bypass
|
case bypass
|
||||||
|
case tempoSync
|
||||||
|
case resourcePath
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
|
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
|
||||||
/// `selectorValues` existed by defaulting the missing keys to an empty array.
|
/// `selectorValues` / `tempoSync` existed by defaulting the missing keys.
|
||||||
public init(from decoder: any Decoder) throws {
|
public init(from decoder: any Decoder) throws {
|
||||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
self.id = try container.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()
|
self.id = try container.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()
|
||||||
@@ -93,5 +111,7 @@ public struct PedalState: Codable, Equatable {
|
|||||||
self.sliderValues = try container.decodeIfPresent([Double].self, forKey: .sliderValues) ?? []
|
self.sliderValues = try container.decodeIfPresent([Double].self, forKey: .sliderValues) ?? []
|
||||||
self.selectorValues = try container.decodeIfPresent([Double].self, forKey: .selectorValues) ?? []
|
self.selectorValues = try container.decodeIfPresent([Double].self, forKey: .selectorValues) ?? []
|
||||||
self.bypass = try container.decode(Double.self, forKey: .bypass)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,15 +85,29 @@ public enum RigStore {
|
|||||||
do {
|
do {
|
||||||
let data: Data = try Data(contentsOf: url)
|
let data: Data = try Data(contentsOf: url)
|
||||||
let decoder: JSONDecoder = JSONDecoder()
|
let decoder: JSONDecoder = JSONDecoder()
|
||||||
|
let state: ShoeGazeState
|
||||||
|
let rigID: UUID?
|
||||||
if let envelope: AutosaveEnvelope = try? decoder.decode(AutosaveEnvelope.self, from: data) {
|
if let envelope: AutosaveEnvelope = try? decoder.decode(AutosaveEnvelope.self, from: data) {
|
||||||
try shoeGaze.loadRig(from: envelope.state)
|
state = envelope.state
|
||||||
shoeGaze.currentRigID = envelope.currentRigID
|
rigID = envelope.currentRigID
|
||||||
} else {
|
} else {
|
||||||
// Pre-envelope autosave: a bare ShoeGazeState with no recorded source rig.
|
// Pre-envelope autosave: a bare ShoeGazeState with no recorded source rig.
|
||||||
let state: ShoeGazeState = try decoder.decode(ShoeGazeState.self, from: data)
|
state = try decoder.decode(ShoeGazeState.self, from: data)
|
||||||
try shoeGaze.loadRig(from: state)
|
rigID = nil
|
||||||
shoeGaze.currentRigID = nil
|
|
||||||
}
|
}
|
||||||
|
// Unlike a mid-session rig load — where forcing the layout would fight the global engine
|
||||||
|
// config and the iOS enable-live-input flow — a launch restore SHOULD reinstate the
|
||||||
|
// rig's saved I/O layout so a multi-channel setup (and a saved live-input channel)
|
||||||
|
// survives relaunch. Apply it first, while the engine is stopped, so `loadRig`'s
|
||||||
|
// input-channel validation runs against the restored count. A failure here is
|
||||||
|
// non-fatal — fall through to `loadRig`, which still rebuilds the boards.
|
||||||
|
do {
|
||||||
|
try shoeGaze.applyChannelLayout(from: state)
|
||||||
|
} catch {
|
||||||
|
print("[RigStore] channel-layout restore failed (continuing): \(error)")
|
||||||
|
}
|
||||||
|
try shoeGaze.loadRig(from: state)
|
||||||
|
shoeGaze.currentRigID = rigID
|
||||||
return !shoeGaze.boards.isEmpty
|
return !shoeGaze.boards.isEmpty
|
||||||
} catch {
|
} catch {
|
||||||
print("[RigStore] restore failed: \(error)")
|
print("[RigStore] restore failed: \(error)")
|
||||||
|
|||||||
@@ -134,6 +134,12 @@ extension ShoeGaze {
|
|||||||
if let savedTempoEnabled: Bool = state.tempoEnabled {
|
if let savedTempoEnabled: Bool = state.tempoEnabled {
|
||||||
setTempoEnabled(savedTempoEnabled)
|
setTempoEnabled(savedTempoEnabled)
|
||||||
}
|
}
|
||||||
|
// Bring restored tempo-synced parameters in line with the loaded tempo. `setTempoEnabled`
|
||||||
|
// already re-syncs when it runs and is enabled, but an older rig with no saved
|
||||||
|
// `tempoEnabled` skips that path — recompute unconditionally so synced values are correct.
|
||||||
|
if tempoEnabled {
|
||||||
|
applyTempoSyncToAllPedals()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rebuilds every board from a snapshot with all-or-nothing semantics.
|
/// Rebuilds every board from a snapshot with all-or-nothing semantics.
|
||||||
@@ -328,8 +334,8 @@ extension ShoeGaze {
|
|||||||
|
|
||||||
// MARK: - Lightweight recall
|
// MARK: - Lightweight recall
|
||||||
|
|
||||||
/// Applies parameter values from `state` to the current rig topology without
|
/// Applies parameter values from `state` to the current rig topology, rebuilding only the
|
||||||
/// rebuilding the engine graph.
|
/// boards where a graph-topology selector changed.
|
||||||
///
|
///
|
||||||
/// This is a lightweight "recall settings" path intended for topologically identical
|
/// This is a lightweight "recall settings" path intended for topologically identical
|
||||||
/// rigs (same board count, same segment order, same pedal types). Boards, segments, and
|
/// rigs (same board count, same segment order, same pedal types). Boards, segments, and
|
||||||
@@ -339,42 +345,73 @@ extension ShoeGaze {
|
|||||||
/// is thrown and remaining
|
/// is thrown and remaining
|
||||||
/// entries continue to be processed.
|
/// entries continue to be processed.
|
||||||
///
|
///
|
||||||
|
/// Most parameters apply live with no graph change. The exception is a `rebuildsOnChange`
|
||||||
|
/// selector (e.g. a cabinet voice, which picks which convolver is instantiated): if such a
|
||||||
|
/// selector's value differs from the live rig, that board is rebuilt via `rebuildBoard(_:from:)`
|
||||||
|
/// so the new selection takes effect — which carries the same at-most-one-block glitch as any
|
||||||
|
/// rebuild on a running engine. Boards without such a selector stay fully live.
|
||||||
|
///
|
||||||
/// Use `loadRig(from:)` when you need a full topology rebuild.
|
/// Use `loadRig(from:)` when you need a full topology rebuild.
|
||||||
///
|
///
|
||||||
/// - Parameter state: The `ShoeGazeState` whose parameter values should be applied.
|
/// - Parameter state: The `ShoeGazeState` whose parameter values should be applied.
|
||||||
public func applyState(_ state: ShoeGazeState) {
|
public func applyState(_ state: ShoeGazeState) {
|
||||||
for (board, boardState) in zip(boards, state.boards) {
|
for (board, boardState) in zip(boards, state.boards) {
|
||||||
applySegmentParams(boardState.segments, to: board.orderedSegments)
|
let topologyChanged: Bool = applySegmentParams(boardState.segments, to: board.orderedSegments)
|
||||||
|
// A `rebuildsOnChange` selector (e.g. a cabinet voice) picks which nodes exist in the
|
||||||
|
// graph, so a plain node write during recall is invisible until the board is rebuilt.
|
||||||
|
// Rebuild only the boards where such a selector actually changed value.
|
||||||
|
if topologyChanged {
|
||||||
|
do {
|
||||||
|
_ = try rebuildBoard(board, from: board.captureState())
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGaze] board rebuild after recall failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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.
|
||||||
|
if tempoEnabled {
|
||||||
|
applyTempoSyncToAllPedals()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Positionally applies segment parameter snapshots to live board segments, including
|
/// Positionally applies segment parameter snapshots to live board segments, including
|
||||||
/// branch pedals and split routing modes. Type or topology mismatches at any position are
|
/// branch pedals and split routing modes. Type or topology mismatches at any position are
|
||||||
/// skipped silently (lightweight recall is for topologically identical rigs).
|
/// skipped silently (lightweight recall is for topologically identical rigs).
|
||||||
|
/// - Returns: `true` if any pedal's `rebuildsOnChange` selector value changed, meaning the board
|
||||||
|
/// must be rebuilt for the new selection to take effect.
|
||||||
|
@discardableResult
|
||||||
private func applySegmentParams(
|
private func applySegmentParams(
|
||||||
_ states: [BoardSegmentState],
|
_ states: [BoardSegmentState],
|
||||||
to segments: [BoardSegment]
|
to segments: [BoardSegment]
|
||||||
) {
|
) -> Bool {
|
||||||
|
var topologyChanged: Bool = false
|
||||||
for (segment, segmentState) in zip(segments, states) {
|
for (segment, segmentState) in zip(segments, states) {
|
||||||
switch (segment, segmentState) {
|
switch (segment, segmentState) {
|
||||||
case let (.pedal(pedal), .pedal(pedalState)):
|
case let (.pedal(pedal), .pedal(pedalState)):
|
||||||
if pedal.displayName == pedalState.type {
|
if pedal.displayName == pedalState.type {
|
||||||
|
let before: [Double] = pedal.rebuildTopologyValues
|
||||||
pedal.applyState(pedalState)
|
pedal.applyState(pedalState)
|
||||||
|
if pedal.rebuildTopologyValues != before { topologyChanged = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
case let (.parallel(section), .parallel(parallelState)):
|
case let (.parallel(section), .parallel(parallelState)):
|
||||||
applyBranchParams(parallelState.branchA, to: section.branchA.pedals)
|
let a: Bool = applyBranchParams(parallelState.branchA, to: section.branchA.pedals)
|
||||||
applyBranchParams(parallelState.branchB, to: section.branchB.pedals)
|
let b: Bool = applyBranchParams(parallelState.branchB, to: section.branchB.pedals)
|
||||||
|
if a || b { topologyChanged = true }
|
||||||
section.splitter.mode = parallelState.mode
|
section.splitter.mode = parallelState.mode
|
||||||
|
|
||||||
case let (.stereoSplit(section), .stereoSplit(stereoState)):
|
case let (.stereoSplit(section), .stereoSplit(stereoState)):
|
||||||
applyBranchParams(stereoState.left, to: section.left.pedals)
|
let l: Bool = applyBranchParams(stereoState.left, to: section.left.pedals)
|
||||||
applyBranchParams(stereoState.right, to: section.right.pedals)
|
let r: Bool = applyBranchParams(stereoState.right, to: section.right.pedals)
|
||||||
|
if l || r { topologyChanged = true }
|
||||||
section.route = stereoState.route
|
section.route = stereoState.route
|
||||||
|
|
||||||
case let (.stereoUnzip(section), .stereoUnzip(unzipState)):
|
case let (.stereoUnzip(section), .stereoUnzip(unzipState)):
|
||||||
applyBranchParams(unzipState.left, to: section.left.pedals)
|
let l: Bool = applyBranchParams(unzipState.left, to: section.left.pedals)
|
||||||
applyBranchParams(unzipState.right, to: section.right.pedals)
|
let r: Bool = applyBranchParams(unzipState.right, to: section.right.pedals)
|
||||||
|
if l || r { topologyChanged = true }
|
||||||
section.route = unzipState.route
|
section.route = unzipState.route
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -382,12 +419,20 @@ extension ShoeGaze {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return topologyChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Positionally applies branch pedal snapshots to live branch pedals, matching by type.
|
/// Positionally applies branch pedal snapshots to live branch pedals, matching by type.
|
||||||
private func applyBranchParams(_ states: [PedalState], to pedals: [Pedal]) {
|
///
|
||||||
|
/// - Returns: `true` if any branch pedal's `rebuildsOnChange` selector value changed.
|
||||||
|
@discardableResult
|
||||||
|
private func applyBranchParams(_ states: [PedalState], to pedals: [Pedal]) -> Bool {
|
||||||
|
var topologyChanged: Bool = false
|
||||||
for (pedal, pedalState) in zip(pedals, states) where pedal.displayName == pedalState.type {
|
for (pedal, pedalState) in zip(pedals, states) where pedal.displayName == pedalState.type {
|
||||||
|
let before: [Double] = pedal.rebuildTopologyValues
|
||||||
pedal.applyState(pedalState)
|
pedal.applyState(pedalState)
|
||||||
|
if pedal.rebuildTopologyValues != before { topologyChanged = true }
|
||||||
}
|
}
|
||||||
|
return topologyChanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,11 @@ public final class ShoeGaze {
|
|||||||
/// control by forcing each ``PedalSwitch/tempoDependent`` switch to its first option.
|
/// control by forcing each ``PedalSwitch/tempoDependent`` switch to its first option.
|
||||||
public func setTempoEnabled(_ enabled: Bool) {
|
public func setTempoEnabled(_ enabled: Bool) {
|
||||||
tempoEnabled = enabled
|
tempoEnabled = enabled
|
||||||
guard !enabled else { return }
|
guard !enabled else {
|
||||||
|
// Re-enabling: bring every tempo-synced parameter back in line with the current tempo.
|
||||||
|
applyTempoSyncToAllPedals()
|
||||||
|
return
|
||||||
|
}
|
||||||
for pedal: Pedal in allPedals() {
|
for pedal: Pedal in allPedals() {
|
||||||
for pedalSwitch: PedalSwitch in pedal.effectSwitches where pedalSwitch.tempoDependent {
|
for pedalSwitch: PedalSwitch in pedal.effectSwitches where pedalSwitch.tempoDependent {
|
||||||
if let off: PedalSwitch.Option = pedalSwitch.options.first {
|
if let off: PedalSwitch.Option = pedalSwitch.options.first {
|
||||||
@@ -149,6 +153,27 @@ public final class ShoeGaze {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the shared clock's tempo and recomputes every tempo-synced pedal parameter to match.
|
||||||
|
/// Route **all** BPM changes (stepper, tap tempo, MIDI) through here so synced delay times and
|
||||||
|
/// LFO rates follow the tempo. Recompute is skipped while tempo is disabled.
|
||||||
|
///
|
||||||
|
/// - Parameter bpm: The new tempo in beats per minute. A non-positive value is ignored (the
|
||||||
|
/// clock requires a positive tempo); callers that also want an upper bound clamp before calling.
|
||||||
|
public func setBpm(_ bpm: Double) {
|
||||||
|
guard bpm > 0 else { return }
|
||||||
|
clock.bpm = bpm
|
||||||
|
guard tempoEnabled else { return }
|
||||||
|
applyTempoSyncToAllPedals()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Recomputes every tempo-synced parameter on every live pedal from the current tempo.
|
||||||
|
/// `internal` so the preset-restore path (`ShoeGaze+Preset.swift`) can re-sync after a rig load.
|
||||||
|
internal func applyTempoSyncToAllPedals() {
|
||||||
|
for pedal: Pedal in allPedals() {
|
||||||
|
pedal.applyTempoSync()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Scope state
|
// MARK: - Scope state
|
||||||
|
|
||||||
/// Scope tap over the hardware input + output buses, feeding the debug scope view.
|
/// Scope tap over the hardware input + output buses, feeding the debug scope view.
|
||||||
@@ -223,6 +248,16 @@ public final class ShoeGaze {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The top-level board that contains `pedal`, searching the main chain **and** parallel /
|
||||||
|
/// stereo-split branch sections. Returns `nil` if the pedal isn't in a main board (e.g. it
|
||||||
|
/// lives in a chain-router branch, which `rebuildBoard(_:from:)` doesn't operate on).
|
||||||
|
///
|
||||||
|
/// Used by the UI to rebuild the right board after a non-`@UIParam` pedal change (e.g. the
|
||||||
|
/// Neural Amp loading a model file).
|
||||||
|
public func board(containing pedal: Pedal) -> PedalBoard? {
|
||||||
|
boards.first { board in pedals(in: board).contains { $0 === pedal } }
|
||||||
|
}
|
||||||
|
|
||||||
/// Every live `Pedal` in one board, including pedals inside its parallel and stereo-split
|
/// Every live `Pedal` in one board, including pedals inside its parallel and stereo-split
|
||||||
/// branch sections (branch pedals live in their section objects, not as top-level segments).
|
/// branch sections (branch pedals live in their section objects, not as top-level segments).
|
||||||
private func pedals(in board: PedalBoard) -> [Pedal] {
|
private func pedals(in board: PedalBoard) -> [Pedal] {
|
||||||
@@ -276,6 +311,9 @@ public final class ShoeGaze {
|
|||||||
inputBusIndex: testBus.index,
|
inputBusIndex: testBus.index,
|
||||||
outputBusIndex: board.headBus.index
|
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(source))
|
||||||
testLoopTaps.append(tap)
|
testLoopTaps.append(tap)
|
||||||
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
|
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
|
||||||
@@ -291,6 +329,8 @@ public final class ShoeGaze {
|
|||||||
inputBusIndex: hardwareInputBusIndex,
|
inputBusIndex: hardwareInputBusIndex,
|
||||||
outputBusIndex: board.headBus.index
|
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)
|
||||||
inputPassThroughs.append(passThrough)
|
inputPassThroughs.append(passThrough)
|
||||||
board.headInputNode = passThrough
|
board.headInputNode = passThrough
|
||||||
@@ -408,6 +448,13 @@ public final class ShoeGaze {
|
|||||||
/// `true` when the rig output is muted (hard-silenced, not bypassed). Survives a rebuild.
|
/// `true` when the rig output is muted (hard-silenced, not bypassed). Survives a rebuild.
|
||||||
public private(set) var rigMuted: Bool = false
|
public private(set) var rigMuted: Bool = false
|
||||||
|
|
||||||
|
/// `true` when the **input** feeding every board is muted — the incoming guitar / mic signal,
|
||||||
|
/// distinct from ``rigMuted`` (the output). Defaults `false` (audible); the app re-asserts it
|
||||||
|
/// muted on each user engine start (see `EngineConfigView`) so a fresh start is silent until the
|
||||||
|
/// player un-mutes, without forcing silence on headless / offline library use. See
|
||||||
|
/// ``setInputMuted(_:)``.
|
||||||
|
public private(set) var inputMuted: Bool = false
|
||||||
|
|
||||||
/// Identities of boards currently in per-board full bypass. Observable so UI toggles refresh;
|
/// Identities of boards currently in per-board full bypass. Observable so UI toggles refresh;
|
||||||
/// authoritative bypass value lives on each board's `boardBypassNode`. Transient (not persisted).
|
/// authoritative bypass value lives on each board's `boardBypassNode`. Transient (not persisted).
|
||||||
public private(set) var bypassedBoards: Set<ObjectIdentifier> = []
|
public private(set) var bypassedBoards: Set<ObjectIdentifier> = []
|
||||||
@@ -560,6 +607,68 @@ public final class ShoeGaze {
|
|||||||
setRigMuted(!rigMuted)
|
setRigMuted(!rigMuted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mutes or un-mutes the **input** feeding every board — the incoming guitar / mic signal,
|
||||||
|
/// distinct from the rig-output ``setRigMuted(_:)``. Applied to every board's input writer
|
||||||
|
/// (test-loop tap or hardware pass-through) as an abrupt kill-switch gate (unlagged, so a
|
||||||
|
/// muted input is exactly silent — see the note in `HardwareInputPassThrough.build()`).
|
||||||
|
///
|
||||||
|
/// The app re-asserts this muted on each user engine start (see `EngineConfigView`) so a fresh
|
||||||
|
/// start is silent until the player un-mutes — preventing accidental input noise.
|
||||||
|
///
|
||||||
|
/// - Parameter muted: `true` to silence the input, `false` to let it through.
|
||||||
|
public func setInputMuted(_ muted: Bool) {
|
||||||
|
// Seed the ramp start only while the engine is stopped: then the next Start renders the new
|
||||||
|
// mute state from block zero with no audible→muted (or muted→audible) ramp — which is exactly
|
||||||
|
// what "muted on Start" needs. While the engine is running, seeding `previousOutputValue`
|
||||||
|
// would race the RT thread; leaving it lets the one-block ramp act as a click-free toggle.
|
||||||
|
let seedRamp: Bool = !engine.isRunning
|
||||||
|
for tap: TestLoopTap in testLoopTaps {
|
||||||
|
setInputMuteGain(tap.inputMuteNode, muted: muted, seedRamp: seedRamp)
|
||||||
|
}
|
||||||
|
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
||||||
|
setInputMuteGain(passThrough.inputMuteNode, muted: muted, seedRamp: seedRamp)
|
||||||
|
}
|
||||||
|
inputMuted = muted
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primes a freshly-created input-mute node (not yet spliced into the graph) to the given mute
|
||||||
|
/// state so its first render block has no ramp. Race-free because the node is not yet evaluated
|
||||||
|
/// by the RT thread. See ``setInputMuteGain(_:muted:seedRamp:)``.
|
||||||
|
private func primeInputMute(_ node: UIParamNode, muted: Bool) {
|
||||||
|
setInputMuteGain(node, muted: muted, seedRamp: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets an input node's mute gain. `update` stores the atomic target the RT thread ramps toward
|
||||||
|
/// from `previousOutputValue`; that seed is only advanced by RT render, so `update` alone leaves
|
||||||
|
/// a one-block ramp from the node's prior value. When `seedRamp` is `true` (node not yet spliced,
|
||||||
|
/// or engine stopped) we also seed `previousOutputValue` to the target so there is no ramp.
|
||||||
|
private func setInputMuteGain(_ node: UIParamNode, muted: Bool, seedRamp: Bool) {
|
||||||
|
let value: Double = muted ? 1.0 : 0.0
|
||||||
|
node.update(value)
|
||||||
|
if seedRamp { node.previousOutputValue = value }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Toggles the input mute. See ``setInputMuted(_:)``.
|
||||||
|
public func toggleInputMuted() {
|
||||||
|
setInputMuted(!inputMuted)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The live mute-gain values of every board input writer (test-loop taps and hardware
|
||||||
|
/// pass-throughs). `1` = muted, `0` = audible. Exposed for tests to confirm the RT nodes are
|
||||||
|
/// actually driven by ``setInputMuted(_:)``, not just the ``inputMuted`` flag.
|
||||||
|
var inputMuteNodeValues: [Double] {
|
||||||
|
testLoopTaps.map { $0.inputMuteNode.value }
|
||||||
|
+ inputPassThroughs.map { $0.inputMuteNode.value }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `previousOutputValue` (ramp start) of every board input-mute node. Exposed for tests to
|
||||||
|
/// confirm a stopped-engine mute is *primed* — ramp start equal to the target — so the next
|
||||||
|
/// render can't ramp from the prior value and leak a block. See ``setInputMuteGain(_:muted:seedRamp:)``.
|
||||||
|
var inputMutePreviousValues: [Double] {
|
||||||
|
testLoopTaps.map { $0.inputMuteNode.previousOutputValue }
|
||||||
|
+ inputPassThroughs.map { $0.inputMuteNode.previousOutputValue }
|
||||||
|
}
|
||||||
|
|
||||||
/// Removes a single board and its associated input source and output master from
|
/// Removes a single board and its associated input source and output master from
|
||||||
/// the engine, then releases the board's buses. The other boards are unaffected.
|
/// the engine, then releases the board's buses. The other boards are unaffected.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// NoteDivision.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// A rhythmic note value, expressed as a fraction of a bar and measured in quarter-note beats.
|
||||||
|
///
|
||||||
|
/// Used to lock a tempo-syncable pedal parameter (a delay time, an LFO rate) to the shared
|
||||||
|
/// ``ShoeGaze/clock``. The synced period in seconds is `(60 / bpm) * beats`; a delay time uses
|
||||||
|
/// that period directly, an LFO rate uses its inverse (one cycle per division).
|
||||||
|
///
|
||||||
|
/// Cases are ordered longest-first so a stepped selector reads top-to-bottom from slow to fast.
|
||||||
|
public enum NoteDivision: String, Codable, CaseIterable, Sendable {
|
||||||
|
|
||||||
|
/// Whole note — four quarter-note beats.
|
||||||
|
case whole
|
||||||
|
/// Dotted half note — three beats.
|
||||||
|
case dottedHalf
|
||||||
|
/// Half note — two beats.
|
||||||
|
case half
|
||||||
|
/// Dotted quarter note — one and a half beats.
|
||||||
|
case dottedQuarter
|
||||||
|
/// Quarter note — one beat.
|
||||||
|
case quarter
|
||||||
|
/// Dotted eighth note — three-quarters of a beat.
|
||||||
|
case dottedEighth
|
||||||
|
/// Quarter-note triplet — two-thirds of a beat.
|
||||||
|
case quarterTriplet
|
||||||
|
/// Eighth note — half a beat.
|
||||||
|
case eighth
|
||||||
|
/// Eighth-note triplet — one-third of a beat.
|
||||||
|
case eighthTriplet
|
||||||
|
/// Sixteenth note — a quarter of a beat.
|
||||||
|
case sixteenth
|
||||||
|
/// Sixteenth-note triplet — one-sixth of a beat.
|
||||||
|
case sixteenthTriplet
|
||||||
|
|
||||||
|
/// Length of this division in quarter-note beats (a quarter note is `1`).
|
||||||
|
public var beats: Double {
|
||||||
|
switch self {
|
||||||
|
case .whole: return 4.0
|
||||||
|
case .dottedHalf: return 3.0
|
||||||
|
case .half: return 2.0
|
||||||
|
case .dottedQuarter: return 1.5
|
||||||
|
case .quarter: return 1.0
|
||||||
|
case .quarterTriplet: return 2.0 / 3.0
|
||||||
|
case .dottedEighth: return 0.75
|
||||||
|
case .eighth: return 0.5
|
||||||
|
case .eighthTriplet: return 1.0 / 3.0
|
||||||
|
case .sixteenth: return 0.25
|
||||||
|
case .sixteenthTriplet: return 1.0 / 6.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Short label for a selector stop (e.g. `"1/4"`, `"1/8."`, `"1/8T"`).
|
||||||
|
public var label: String {
|
||||||
|
switch self {
|
||||||
|
case .whole: return "1/1"
|
||||||
|
case .dottedHalf: return "1/2."
|
||||||
|
case .half: return "1/2"
|
||||||
|
case .dottedQuarter: return "1/4."
|
||||||
|
case .quarter: return "1/4"
|
||||||
|
case .quarterTriplet: return "1/4T"
|
||||||
|
case .dottedEighth: return "1/8."
|
||||||
|
case .eighth: return "1/8"
|
||||||
|
case .eighthTriplet: return "1/8T"
|
||||||
|
case .sixteenth: return "1/16"
|
||||||
|
case .sixteenthTriplet: return "1/16T"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,6 @@ extension ShoeGaze {
|
|||||||
|
|
||||||
let averageInterval: TimeInterval = intervals.reduce(0, +) / Double(intervals.count)
|
let averageInterval: TimeInterval = intervals.reduce(0, +) / Double(intervals.count)
|
||||||
let secondsPerMinute: Double = 60.0
|
let secondsPerMinute: Double = 60.0
|
||||||
clock.bpm = secondsPerMinute / averageInterval
|
setBpm(secondsPerMinute / averageInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// TempoSync.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Sync state of one tempo-syncable pedal parameter.
|
||||||
|
///
|
||||||
|
/// `.free` leaves the parameter at its stored absolute value (seconds or Hz), controlled by the
|
||||||
|
/// knob as usual. `.division` locks it to a ``NoteDivision`` of the shared ``ShoeGaze/clock`` —
|
||||||
|
/// the value is derived from the current tempo and rewritten whenever the tempo or the division
|
||||||
|
/// changes.
|
||||||
|
public enum TempoSync: Codable, Equatable, Sendable {
|
||||||
|
|
||||||
|
/// Absolute value, knob-controlled. The default for every parameter.
|
||||||
|
case free
|
||||||
|
|
||||||
|
/// Locked to a note division of the live tempo.
|
||||||
|
case division(NoteDivision)
|
||||||
|
}
|
||||||