6 Commits

Author SHA1 Message Date
josh 3edd64e782 feat(whammy): DigiTech Whammy expression-pedal pitch shifter
Add WhammyPedal: a rocking expression pedal (position, heel 0 → toe 1)
that sweeps pitch between two endpoints set by the selected mode, in the
three families the hardware groups — Whammy (wet-only pitch bend),
Harmony (dry note + morphing bent voice), and Detune (dry + near-unison
beating voice).

Each voice is a PitchShift SOLA stage; the three-octave Dive Bomb
cascades two stages (each -18 st) to clear a single stage's ±2-octave
ratio clamp. Harmony/Detune legs are attenuated 0.5 so the summed
dry+shifted output stays within the input peak. A fixed PRNG seed per
stage makes a given setting render identically (reproducible audio and
exact-pitch tests), with a distinct stage-2 seed so the cascade's grain
dispersion decorrelates.

Wire it into PedalType, the registry, and the pitch category; add it to
the README pitch catalog. Tests cover pitch at heel/toe, the Dive Bomb
cascade, harmony dry presence, seeded determinism, preset round-trip,
mode rebuild, registry presence, and a click-free bypass flip at the
real 512-sample block (guarding the audio-rate bypass fix).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-15 12:11:16 -08:00
josh 53b506adeb fix(pedal): audio-rate linear bypass crossfade to kill on/off click
The engaged↔bypassed crossfade smoother was a one-pole Lag.Control,
whose exponential curve is front-loaded (steepest slope at the very
start). That clicked when the two crossfade legs are decorrelated and
full-scale — e.g. a wet-only pitch shifter swapping against the dry
note — and was only masked when wet ≈ dry.

A block-rate smoother does not fix it: at the engine's 512-sample block
a short fade is just a few coarse steps, each its own click.

Switch to an audio-rate linear Slew.Audio, which ramps one step per
sample regardless of block size, driving an equal-power crossfade. The
old `private let bypassLagTime` becomes an overridable `open var
bypassFadeTime`, clamped to a positive floor before taking its
reciprocal so a subclass override of 0 or negative cannot reintroduce
an instantaneous (clicking) or inverted slew. Affects every pedal's
on/off transition.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-15 12:11:06 -08:00
josh 4e8f6e280c release: ShoeGaze 3.3.0 — noise-gate threshold + mono-output fixes on Lyrebird 2.2.0
Bump to Lyrebird 2.2.0 (both Package.resolved pins → 2.2.0 / 24ea32e) and cut
ShoeGaze 3.3.0. This release surfaces the upstream ramp-origin fix plus the two
local fixes already on main:

- Noise Gate respects its threshold after loading a rig: the gate's open level is
  derived from the threshold, which previously swept up from a default on the first
  audio block and tripped the gate on the transient (latching it open). Lyrebird
  2.2.0 delivers a pre-first-render parameter value flat, so the gate reads its real
  threshold from block one.
- Mono rigs output at unity (were ~3 dB down through a centre pan).
- Noise Gate detector Peak/RMS switch, defaulting to RMS.

NoiseGatePedal doc comment tidied (signal-chain diagram + detector parameter).
App build track: MARKETING_VERSION 3.3, CURRENT_PROJECT_VERSION 23.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-03 13:09:48 -08:00
josh a434b14f4b fix(output,gate): unity mono output + RMS noise-gate detector
Two fixes from the guitar-input analysis:

- Mono board output no longer loses 3 dB. BoardOutputMaster panned a mono
  board to stereo centre with an equal-power Pan2 (×0.707 per channel). A
  mono rig should come out at the level it went in, so the signal is now
  written to both hardware buses directly at unity.

- Noise Gate gains a Peak/RMS detector switch (defaults to RMS). The peak
  follower (|x|) rides the waveform's peaks, so the gate's threshold decision
  tracked instantaneous peaks rather than loudness; the RMS detector
  (√ symmetric-average of x²) follows perceived level, so the gate opens and
  closes where the note actually is. Implemented as a rebuildsOnChange switch
  that builds only the chosen follower. Serialization-safe: a gate saved
  before the switch (empty switchValues) loads with the RMS default.

Tests cover the detector switch, RMS default (incl. legacy load), state
round-trip, and RMS closing earlier than Peak on a sustained tail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-03 08:49:16 -08:00
josh 0ddf350f1f Migrate to Lyrebird 2.0.0; app version bump
Lyrebird 2.0 moved `@UIParam` / `UIParamNode` out of `LyrebirdUI` into the
core `LyrebirdSynth` module (the `Lyrebird` product); `LyrebirdUI` no longer
re-exports them. Migrate:
- add `import LyrebirdSynth` to every file that uses `@UIParam`/`UIParamNode`
  (the pedal controls, tempo-syncable params, and the SwiftUI views).
- Package.swift: the `LyrebirdShoeGazeUI` target now also depends on the
  `Lyrebird` product (previously only `LyrebirdUI`), so `import LyrebirdSynth`
  resolves there under explicit module maps.
- Package.resolved (SwiftPM + both Xcode projects) pinned to Lyrebird 2.0.0.

Also: app marketing/project version bumps, Xcode upgrade-check, and a
CHANGELOG wording tweak carried in the same working tree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-23 21:17:30 -07:00
josh f8926ecfb8 fix(mutant): double-width pedal so switch captions don't wrap — 3.1.1
The Mutant envelope filter's three segmented switches (Direction / Mode /
Range — seven segments total) were crammed into a single-width pedal, so the
"Down" caption wrapped to "Do wn". Mutant is now double-width, like the
Cabinet and amp pedals, giving the switch row room for its captions.

Bumps both apps to MARKETING_VERSION 3.1.1 and records the fix in
CHANGELOG.md / RELEASES.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-13 20:04:56 -07:00
41 changed files with 989 additions and 76 deletions
+13 -3
View File
@@ -4,6 +4,15 @@ All notable changes to ShoeGaze are recorded here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
[semantic versioning](https://semver.org/spec/v2.0.0.html).
## [3.1.1] — 2026-08-13
### Fixed
- **Mutant switch captions no longer wrap.** The envelope filter's three segmented switches
(Direction / Mode / Range — seven segments in all) were crammed into a single-width pedal,
wrapping the "Down" caption to "Do wn". Mutant is now double-width, like the Cabinet and amp
pedals, so the switch captions have room.
## [3.1.0] — 2026-08-13
Starter rigs and a deeper envelope filter. ShoeGaze now ships a library of ready-to-play
@@ -50,9 +59,10 @@ plus a batch of rig-switching and reverb fixes.
- **No more spurious "Save changes?" prompt when switching rigs.** The unsaved-changes check
compared live session settings (input source, engine channel counts) that legitimately
differ from a rig's saved values; it now compares rig content only.
- **Overwrite guard for starter rigs.** Saving over a loaded starter rig now asks first,
offering **Overwrite**, **Save as New Rig**, or **Cancel**, so a shipped rig isn't replaced
by accident.
- **Starter rigs can't be overwritten by accident.** A built-in starter rig is managed content
(refreshed to the shipped version on updates), so saving over a loaded starter offers **Save
as New Rig** or **Cancel** — your changes are kept as your own rig rather than replacing the
shipped one.
- **Multi-board signal-router rigs now save and load.** Routed A/B rigs were previously lost
on save; their branch chains and blend now persist.
@@ -100,7 +100,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastUpgradeCheck = 2660;
LastUpgradeCheck = 2700;
TargetAttributes = {
C3B100000000000000000014 = {
CreatedOnToolsVersion = 16.0;
@@ -163,7 +163,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 19;
CURRENT_PROJECT_VERSION = 23;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_HARDENED_RUNTIME = YES;
@@ -175,7 +175,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 3.3;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -193,7 +193,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 19;
CURRENT_PROJECT_VERSION = 23;
DEAD_CODE_STRIPPING = YES;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
@@ -204,7 +204,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 3.3;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -216,6 +216,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -279,6 +280,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -366,7 +368,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
requirement = {
kind = upToNextMajorVersion;
kind = versionRange;
maximumVersion = 3.0.0;
minimumVersion = 1.2.0;
};
};
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : {
"revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0",
"version" : "1.2.3"
"revision" : "24ea32e47cecff8efec9720546ed068b4efef2f7",
"version" : "2.2.0"
}
},
{
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2660"
LastUpgradeVersion = "2700"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
@@ -103,7 +103,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastUpgradeCheck = 2660;
LastUpgradeCheck = 2700;
TargetAttributes = {
C3C100000000000000000011 = {
CreatedOnToolsVersion = 16.0;
@@ -165,7 +165,7 @@
CODE_SIGNING_REQUIRED = NO;
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
@@ -175,11 +175,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 2;
@@ -194,7 +196,7 @@
CODE_SIGNING_REQUIRED = NO;
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -203,11 +205,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 2;
@@ -218,6 +222,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -281,6 +286,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -368,8 +374,9 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.2.0;
kind = versionRange;
maximumVersion = 3.0.0;
minimumVersion = 1.7.2;
};
};
/* End XCRemoteSwiftPackageReference section */
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : {
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
"version" : "1.7.2"
"revision" : "b6fdee8bfc7c44d31a0a8cfe6fbd53f352dfad54",
"version" : "2.0.0"
}
},
{
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2660"
LastUpgradeVersion = "2700"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
+4 -6
View File
@@ -17,10 +17,6 @@
</array>
</dict>
</array>
<!-- Incoming .shoegaze files are read and imported into the rig library (a copy), never
edited in place, so the app opens a copy rather than the original document. -->
<key>LSSupportsOpeningDocumentsInPlace</key>
<false/>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -32,11 +28,13 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>${MARKETING_VERSION}</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<false/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
<key>NSMicrophoneUsageDescription</key>
+3 -3
View File
@@ -1,5 +1,5 @@
{
"originHash" : "eed06b1870eecb6b28d2417331f105ea1cc25e9d6fe588c9d2eff8ca3af096f0",
"originHash" : "c8855e41a403b5b1fccd9ccb4b3ef4d75c4307590ae6a0b8e985e71c41011e09",
"pins" : [
{
"identity" : "linenoise-swift",
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : {
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
"version" : "1.7.2"
"revision" : "24ea32e47cecff8efec9720546ed068b4efef2f7",
"version" : "2.2.0"
}
},
{
+9 -6
View File
@@ -24,14 +24,16 @@ let package = Package(
.library(name: "LyrebirdShoeGazeUI", targets: ["LyrebirdShoeGazeUI"]),
],
dependencies: [
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "1.7.2"),
.package(url: "https://realizedsound.mooo.com/josh/Lyrebird", from: "2.0.0"),
],
targets: [
// The core target depends on LyrebirdUI as well as the synthesis core:
// pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
// (the type `ParameterKnob` binds to) lives in LyrebirdUI. Importing
// LyrebirdUI here does not pull SwiftUI into ShoeGaze's own sources —
// it only makes the `@UIParam` wrapper and `UIParamNode` visible.
// Both targets depend on the core `Lyrebird` product AND `LyrebirdUI`.
// Pedals expose their knobs as `@UIParam`, whose projected `UIParamNode`
// lives in the core `LyrebirdSynth` module (the `Lyrebird` product) as of
// Lyrebird 2.0 — `LyrebirdUI` no longer re-exports it — so any file using
// `@UIParam` / `UIParamNode` needs `import LyrebirdSynth`, which requires
// the `Lyrebird` product as a direct dependency. Importing these does not
// pull SwiftUI into ShoeGaze's own core sources.
.target(
name: "LyrebirdShoeGaze",
dependencies: [
@@ -44,6 +46,7 @@ let package = Package(
name: "LyrebirdShoeGazeUI",
dependencies: [
"LyrebirdShoeGaze",
.product(name: "Lyrebird", package: "Lyrebird"),
.product(name: "LyrebirdUI", package: "Lyrebird"),
],
path: "Sources/LyrebirdShoeGazeUI"
+1 -1
View File
@@ -47,7 +47,7 @@ signal (no hardware needed) or on live guitar through an audio input.
| Dynamics | Compressor, Sustainer, Limiter, Noise Gate, Volume |
| EQ & filter | Graphic EQ, Auto-Wah, Wah, Mutant |
| Modulation | Tremolo, Phaser, Modulation, Chorus, Flanger, Vibrato, Vibe, Rotary, Ring Modulator |
| Pitch | Bass Octaver, Octave Splitter, Harmonizer |
| Pitch | Bass Octaver, Octave Splitter, Harmonizer, Whammy |
| Delay | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverse Delay |
| Reverb | Reverb, Shimmer Reverb, Plate Reverb, Room Reverb, Spring Reverb |
| Texture | Diffuser, Bitcrusher, Granulator, Auto Granulator, Looper |
+28
View File
@@ -1,4 +1,32 @@
# Releases
## ShoeGaze 3.3.0
Noise-gate and output-level fixes, on Lyrebird 2.2.0.
### Fixed
- **Noise Gate now respects its threshold after loading a rig.** A gate restored from a saved
rig could latch open and ignore its Threshold knob — the gate's open level is derived from the
threshold, and that value swept up from a default on the first audio block, tripping the gate
on the transient. Fixed upstream in Lyrebird 2.2.0 (a live parameter set before the first
render is now delivered flat), so the gate reads its real threshold from the first block.
- **Mono rigs come out at the level they went in.** A mono board was written through a centre
pan that dropped both channels ~3 dB; it now copies the mono signal to both outputs at unity.
### Changed
- **Noise Gate detector: Peak / RMS, defaulting to RMS.** RMS follows perceived loudness, so the
gate's threshold decision tracks how loud the note actually is instead of riding the waveform
peaks. A gate saved before this switch existed loads on RMS. (Peak remains available.)
- Updated to **Lyrebird 2.2.0**.
## ShoeGaze 3.1.1
A small fix for the Mutant envelope filter's control panel.
### Fixed
- **Mutant switch captions no longer wrap.** Its three segmented switches (Direction / Mode /
Range) were cramped into a single-width pedal, wrapping "Down" to "Do wn". Mutant is now
double-width — like the Cabinet and amp pedals — so the captions fit.
## ShoeGaze 3.1.0
Starter rigs, two new pedals, and a deeper envelope filter — plus smoother rig switching.
@@ -1,5 +1,5 @@
{
"originHash" : "9ce521e7cebf3eed8e20837aba069e3f0c5484a64130b1791e8e6fdb7874b9f0",
"originHash" : "13b4323e9d41dfdff1c6aeac595cff272eb4eee9cc1a3146483bdaf8543bc103",
"pins" : [
{
"identity" : "linenoise-swift",
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
"state" : {
"revision" : "77580ee98e05cb4a94aac367097d27b91d3776c0",
"version" : "1.7.2"
"revision" : "b6fdee8bfc7c44d31a0a8cfe6fbd53f352dfad54",
"version" : "2.0.0"
}
},
{
@@ -82,9 +82,6 @@ final class BoardOutputMaster: SynthesizerBase {
// MARK: - Constants
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
private let stereoPan: Double = 0.0
/// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed
/// transitions to prevent clicks. Matches the per-pedal bypass lag.
private let bypassLagTime: Double = 0.02
@@ -137,8 +134,12 @@ final class BoardOutputMaster: SynthesizerBase {
output(bus: 0, source: gainedLeft)
output(bus: 1, source: gainedRight)
} else {
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1.
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
// Mono board: write the mono signal to both hardware buses at unity (0 dB). Using an
// equal-power `Pan2` to centre would drop each channel by 3 dB (×0.707) — power-correct
// for a true pan, but a mono guitar rig should come out at the same level it went in, so
// the signal is copied to left and right directly instead.
output(bus: 0, source: gainedLeft)
output(bus: 1, source: gainedLeft)
}
}
+35 -11
View File
@@ -19,7 +19,7 @@ import LyrebirdUI
/// inputBus → dry → effect(_:) → wet
/// ↕ mix (equal-power crossfade)
/// blended
/// ↕ bypass (lagged equal-power crossfade with dry)
/// ↕ bypass (linear equal-power crossfade with dry)
/// switched → × level → outputBus
/// ```
///
@@ -32,7 +32,7 @@ import LyrebirdUI
///
/// - `mix`: Wet/dry blend in `[0, 1]`. `0` = fully dry, `1` = fully wet.
/// - `bypass`: Bypass state. `0` = engaged (effect active), `1` = bypassed (pure dry).
/// Transitions are smoothed with a 20 ms lag to avoid clicks.
/// Transitions are smoothed with a linear crossfade (see ``bypassFadeTime``) to avoid clicks.
/// - `level`: Output gain as a linear multiplier. `1.0` = unity gain.
///
/// - Parameters:
@@ -47,7 +47,7 @@ open class Pedal: SynthesizerBase {
@UIParam public var mix: Double = 1.0
/// Bypass state. `0` = engaged (effect active), `1` = bypassed (dry signal only).
/// Transitions are smoothed by `bypassLagTime` seconds to prevent clicks.
/// Transitions are smoothed by a linear crossfade over ``bypassFadeTime`` seconds to prevent clicks.
@UIParam public var bypass: Double = 0.0
/// Output gain as a linear multiplier. `1.0` = unity gain.
@@ -156,9 +156,22 @@ open class Pedal: SynthesizerBase {
// MARK: - Constants
/// Lag time constant in seconds (60 dB convergence) for the bypass crossfade.
/// Smooths engaged ↔ bypassed transitions to prevent audible clicks.
private let bypassLagTime: Double = 0.02
/// Duration in seconds of the engaged ↔ bypassed crossfade. The bypass control is slewed
/// **linearly** and at **audio rate** from `0` to `1` (or back) over this time, so the
/// equal-power crossfade sweeps smoothly, one step per sample. Two earlier approaches clicked
/// here when the crossfade legs are decorrelated and full-scale (a wet-only pitch shifter such as
/// the Whammy swapping against the dry note; masked when wet ≈ dry): a one-pole `Lag`, whose
/// exponential curve is front-loaded (steepest slope at the very start); and a block-rate slew,
/// which steps only once per audio block — at the engine's 512-sample block a short fade is just
/// a few coarse jumps, each its own click. An audio-rate linear slew has neither flaw.
/// Overridable for pedals needing a gentler fade.
open var bypassFadeTime: Double { 0.03 }
/// Lower bound the effective fade time is clamped to before taking its reciprocal for the slew
/// rate. Guards against an override returning `0` (reciprocal `.infinity` → instantaneous slew,
/// which reintroduces the click this fade removes) or a negative value (which would invert the
/// slew). One sample at 48 kHz, so a legitimate small fade is left untouched.
private let minBypassFadeTime: Double = 1.0 / 48_000.0
// Bipolar-span constant used to remap a [0, 1] value to [-1, +1]
// for CrossFade's equal-power pan parameter.
@@ -421,7 +434,7 @@ open class Pedal: SynthesizerBase {
/// Builds the signal graph for one channel: dry → wet/dry blend → bypass switch → × level.
///
/// Returns the final post-`level` source for the channel. The `mix`, `bypass`, and `level`
/// `@UIParam` nodes are shared across channels; each channel gets its own `Lag.Control`
/// `@UIParam` nodes are shared across channels; each channel gets its own `Slew.Audio`
/// for the bypass crossfade so smoothing is per-channel state driven by the same target.
///
/// - Parameters:
@@ -442,14 +455,25 @@ open class Pedal: SynthesizerBase {
pan: mixPan
)
// Smooth bypass transitions with a 20 ms lag to prevent clicks.
let bypassLagged: Lag.Control = Lag.Control(
// Smooth bypass transitions with a linear crossfade to prevent clicks. The slew runs at
// AUDIO rate, not control rate: a block-rate smoother takes one step per audio block, so at
// the engine's 512-sample block a short fade is only a handful of coarse steps — each a
// click of its own. `Slew.Audio` ramps per sample, so the fade is smooth regardless of
// block size. Linear slope (not a front-loaded one-pole lag) keeps it click-free even when
// the two legs are decorrelated and full-scale, as for a wet-only pitch shifter.
// Rate is in bypass-units per second: 0 → 1 traverses in exactly `bypassFadeTime` seconds.
// Clamp to a positive floor first — a subclass override returning 0 or negative would
// otherwise yield an infinite or inverted slew rate (see `minBypassFadeTime`).
let effectiveFadeTime: Double = max(bypassFadeTime, minBypassFadeTime)
let bypassFadeRate: Double = 1.0 / effectiveFadeTime
let bypassSlewed: Slew.Audio = Slew.Audio(
input: $bypass,
time: bypassLagTime
up: bypassFadeRate,
dn: bypassFadeRate
)
// Map bypass [0, 1] → pan [-1, +1]: −1 = blended (engaged), +1 = dry (bypassed).
let bypassPan: any ValidGeneratorInput = (bypassLagged * bipolarSpan) - bipolarOffset
let bypassPan: any ValidGeneratorInput = (bypassSlewed * bipolarSpan) - bipolarOffset
// Equal-power crossfade: engaged → blended; bypassed → dry.
let switched: CrossFade.Audio = CrossFade.Audio(
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A UI-agnostic description of one pedal button — a momentary action trigger or a
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A continuous pedal control that can be driven by a MIDI Control Change — the common shape of a
+1
View File
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A UI-agnostic description of one controllable pedal knob.
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A UI-agnostic description of a knob that snaps to a fixed set of labelled stops.
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A UI-agnostic description of one continuous vertical pedal fader.
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A UI-agnostic description of one multi-position pedal switch.
+1
View File
@@ -123,6 +123,7 @@ public extension PedalType {
static let octaveSplitter = PedalType("Octave Splitter")
static let bassOctaver = PedalType("Bass Octaver")
static let harmonizer = PedalType("Harmonizer")
static let whammy = PedalType("Whammy")
// Looper
static let looper = PedalType("Looper")
@@ -153,6 +153,11 @@ public final class MutantPedal: Pedal {
]
}
/// Double-width so the three segmented switches (Direction / Mode / Range — seven segments in
/// all) have room for their captions instead of wrapping ("Do wn"), the same reason the Cabinet
/// and amp pedals are double-width.
public override var widthUnits: Int { 2 }
// MARK: - Init
public init(inputBus: Int = 0, outputBus: Int = 0) {
@@ -11,20 +11,19 @@ import LyrebirdUI
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry ─┬─────────────────────────────────────────────────────────┐
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │
/// → LinLin(0…1 → floor…1) │
/// → LagUpDown(fast open/slow close) × ─┴→ mono out
/// detector(dry) → Schmidt(lo: thr, hi: thr×ratio) → LinLin(0…1 → floor…1) → LagUpDown(open/close)
/// Peak: AmplitudeFollower(|x|)
/// RMS: √Lag(x²) out = dry × smoothed-gain
/// ```
///
/// An `AmplitudeFollower` tracks the dry signal level. A Schmitt trigger turns that
/// envelope into an open/closed gate with hysteresis (opens above `threshold × openRatio`,
/// closes below `threshold`) so the gate does not chatter around the threshold. The 0/1
/// gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** — opening fast so a
/// note's attack isn't softened, closing slowly so the gate fades shut instead of snapping (a fast
/// close popped audibly when heavy downstream gain amplified the step). When the gate is closed the
/// signal is attenuated to `floor` rather than hard-muted, so `floor` sets how much of the quiet
/// signal/noise tail bleeds through.
/// The **detector** tracks the dry signal level — either peak (`|x|`) or RMS (√mean-square). A
/// Schmitt trigger turns that envelope into an open/closed gate with hysteresis (opens above
/// `threshold × openRatio`, closes below `threshold`) so the gate does not chatter around the
/// threshold. The 0/1 gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** —
/// opening fast so a note's attack isn't softened, closing slowly so the gate fades shut instead of
/// snapping (a fast close popped audibly when heavy downstream gain amplified the step). When the
/// gate is closed the signal is attenuated to `floor` rather than hard-muted, so `floor` sets how
/// much of the quiet signal/noise tail bleeds through.
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
@@ -39,6 +38,8 @@ import LyrebirdUI
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
/// - attack: Gate open time in seconds (advanced pop-over). Range `[0.001, 0.05]`. Defaults to `0.005`.
/// - release: Gate close time in seconds (advanced pop-over). Range `[0.01, 0.5]`. Defaults to `0.08`.
/// - detector: Level-detection mode (switch). `0` = Peak (`|x|`), `1` = RMS (√mean-square).
/// Defaults to RMS (`1`).
public final class NoiseGatePedal: Pedal {
/// One-line description shown in the picker and info panel.
@@ -63,17 +64,33 @@ public final class NoiseGatePedal: Pedal {
/// out chatter at the threshold). Range `[0.01, 0.5]`. Surfaced in the advanced pop-over.
@UIParam public var release: Double = 0.08
/// Detector mode: `0` = **Peak** (tracks `|x|`), `1` = **RMS** (tracks √mean-square). RMS follows
/// perceived loudness, so the threshold decision — and the level at which the gate closes — lines
/// up with how loud the note actually is, instead of riding the waveform's peaks. Defaults to RMS.
@UIParam public var detector: Double = 1.0
// MARK: - Constants
/// Default wet/dry blend — fully wet; the gate sits in-line.
private static let defaultMix: Double = 1.0
/// `detector` value selecting the peak follower.
private let detectorPeakValue: Double = 0.0
/// `detector` value selecting the RMS follower.
private let detectorRMSValue: Double = 1.0
/// Envelope-follower attack time, in seconds — fast so the gate opens promptly on a note.
private let detectAttack: Double = 0.002
/// Envelope-follower release time, in seconds — slower so the gate holds through decay.
private let detectRelease: Double = 0.05
/// RMS integration window (one-pole averaging time, in seconds) for the RMS detector. Long enough
/// to average out the waveform's per-cycle ripple so the envelope reflects mean-square level, not
/// instantaneous peaks.
private let rmsWindow: Double = 0.02
/// Open-threshold multiplier. The gate opens above `threshold × openRatio` and closes
/// below `threshold`, giving hysteresis that prevents chatter near the threshold.
private let openRatio: Double = 2.0
@@ -122,6 +139,23 @@ public final class NoiseGatePedal: Pedal {
]
}
/// Detector-mode switch (Peak / RMS). Appended as the gate's only switch, so a gate saved before
/// it existed (empty `switchValues`) loads with the RMS default — no migration.
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
label: "Detector",
node: $detector,
options: [
PedalSwitch.Option(title: "Peak", value: detectorPeakValue),
PedalSwitch.Option(title: "RMS", value: detectorRMSValue),
],
// Switching detector changes which follower is instantiated, so rebuild the board.
rebuildsOnChange: true
),
]
}
// MARK: - Init
/// Creates a noise-gate pedal.
@@ -150,12 +184,26 @@ public final class NoiseGatePedal: Pedal {
/// - Parameter dry: Dry mono input signal.
/// - Returns: Gated mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Track the dry signal's amplitude envelope.
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
in: dry,
attackTime: detectAttack,
releaseTime: detectRelease
)
// Build the chosen detector only. `detector` is a `rebuildsOnChange` switch, so it is read
// here as a plain value at build time (the board rebuilds when it is toggled) — no live
// node-select in the graph.
let envelope: any ValidGeneratorInput
if detector >= detectorRMSValue {
// RMS detector: √(symmetric one-pole average of x²). The averaging window must be
// symmetric — a fast attack would track the *squared peaks* and collapse back to peak
// detection — so a plain `Lag` over `rmsWindow` recovers the mean square, giving a
// loudness-tracking envelope roughly 3 dB below the peak for a steady tone.
let squared: any ValidGeneratorInput = dry * dry
let meanSquare: Lag.Audio = Lag.Audio(input: squared, time: rmsWindow)
envelope = Sqrt.Audio(meanSquare)
} else {
// Peak detector: a one-pole follower of |x| (fast attack, slower release).
envelope = AmplitudeFollower.Audio(
in: dry,
attackTime: detectAttack,
releaseTime: detectRelease
)
}
// Hysteretic open/closed gate: opens above threshold×openRatio, closes below threshold.
let gate: Schmidt.Audio = Schmidt.Audio(
@@ -0,0 +1,237 @@
// WhammyPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Expression-pedal pitch shifter in the DigiTech Whammy mould.
///
/// A rocking **expression pedal** (`position`, heel `0` → toe `1`) sweeps the pitch between two
/// endpoints set by the selected `mode`. Modes fall into the three families the hardware groups
/// them into:
///
/// - **Whammy** (pitch-bend, wet only): the pedal bends the note itself from unison at the heel to
/// the mode's interval at the toe — octave/two-octave up, octave/two-octave down, the three-octave
/// "dive bomb", or a fixed whole-step "drop tune". No dry signal; you hear only the bent pitch.
/// - **Harmony** (dry + bent voice): a pitch-shifted voice is layered under the dry note, and the
/// pedal morphs that voice's interval between the mode's two stops (e.g. a 5th down at the heel to
/// a 4th down at the toe) while the dry note stays put.
/// - **Detune** (dry + near-unison voice): a voice a few cents off unison beats against the dry
/// note; the pedal sweeps the detune depth from none (heel) to shallow or deep (toe).
///
/// Each voice is a `PitchShift` — Lyrebird's SC-faithful four-head SOLA shifter, the same
/// windowed time-domain overlap-add family the real Whammy used (IVL Technologies' patented
/// pitch-synchronous time-domain method, US 5,567,901). The characteristic warble/flutter of large
/// bends is inherent to that method and is the Whammy's signature, not a defect. Ratio is
/// `2^(semitones/12)`, with `semitones` interpolated live from `position`.
///
/// The shifter's four heads re-trigger on a fixed grid, which colours the output with a static
/// comb filter. A small per-head time dispersion (see `timeDispersion`) plus a window a touch
/// over the default (see `windowSize`) break that regularity to reduce the combing while leaving
/// the Whammy's grit intact.
///
/// A single SOLA stage clamps at the engine's `±2`-octave `pitchRatio` range. The three-octave
/// **Dive Bomb** reaches `-36` semitones by cascading two stages, each doing half the shift.
///
/// `position` is an ordinary live parameter, so it can be mapped to a MIDI expression pedal or
/// automated like any other knob.
///
/// ## Knobs
/// - `position`: Expression-pedal position in `[0, 1]`. Heel `0` = no bend, toe `1` = full bend.
///
/// ## Selectors (knob picker)
/// - `mode`: Pitch program (snaps to the fixed Whammy / Harmony / Detune list). Changing it
/// rebuilds the voice, so it is read as a plain value at build time.
public final class WhammyPedal: Pedal {
/// One-line description shown in the picker and info panel.
public override var summary: String {
"Expression-pedal pitch bend — octave dives and climbs, a morphing harmony, or a detune."
}
// MARK: - Mode table
/// One Whammy program: the pedal interpolates `semitones` from `heel` (pedal up) to `toe`
/// (pedal down). `harmony` keeps the dry note under the shifted voice (Harmony/Detune families);
/// `twoStage` cascades two SOLA stages to reach shifts beyond a single stage's ±2-octave clamp.
private struct Program {
let title: String
let heel: Double
let toe: Double
let harmony: Bool
let twoStage: Bool
}
/// The selectable programs, grouped Whammy → Harmony → Detune as on the hardware. Whammy
/// programs bend a wet-only voice; Harmony/Detune programs layer a voice under the dry note.
/// Intervals mirror the DigiTech Whammy preset chart.
private static let programs: [Program] = [
// Whammy — wet only, bend from unison to the interval.
Program(title: "2 Oct Up", heel: 0.0, toe: 24.0, harmony: false, twoStage: false),
Program(title: "Oct Up", heel: 0.0, toe: 12.0, harmony: false, twoStage: false),
Program(title: "Oct Down", heel: 0.0, toe: -12.0, harmony: false, twoStage: false),
Program(title: "2 Oct Down", heel: 0.0, toe: -24.0, harmony: false, twoStage: false),
// Dive Bomb drops three octaves; a single SOLA stage clamps at two, so cascade two.
Program(title: "Dive Bomb", heel: 0.0, toe: -36.0, harmony: false, twoStage: true),
// Drop Tune is a fixed whole-step down — the pedal does not move it.
Program(title: "Drop Tune", heel: -2.0, toe: -2.0, harmony: false, twoStage: false),
// Harmony — dry note kept, layered voice morphs heel → toe.
Program(title: "Oct Up/Dn", heel: 12.0, toe: -12.0, harmony: true, twoStage: false),
Program(title: "5Dn/4Dn", heel: -7.0, toe: -5.0, harmony: true, twoStage: false),
Program(title: "4Dn/3Dn", heel: -5.0, toe: -4.0, harmony: true, twoStage: false),
Program(title: "5Up/7Up", heel: 7.0, toe: 11.0, harmony: true, twoStage: false),
Program(title: "5Up/6Up", heel: 7.0, toe: 9.0, harmony: true, twoStage: false),
Program(title: "4Up/5Up", heel: 5.0, toe: 7.0, harmony: true, twoStage: false),
Program(title: "3Up/4Up", heel: 4.0, toe: 5.0, harmony: true, twoStage: false),
Program(title: "m3Up/3Up", heel: 3.0, toe: 4.0, harmony: true, twoStage: false),
Program(title: "2Up/3Up", heel: 2.0, toe: 4.0, harmony: true, twoStage: false),
// Detune — dry note kept, near-unison voice beats against it; pedal sweeps the depth.
Program(title: "Detune Shallow", heel: 0.0, toe: 0.07, harmony: true, twoStage: false),
Program(title: "Detune Deep", heel: 0.0, toe: 0.20, harmony: true, twoStage: false),
]
// MARK: - Parameters
/// Expression-pedal position in `[0, 1]`. Heel (`0`) = no bend, toe (`1`) = the mode's full
/// interval. Live, so it can be driven by a mapped expression pedal or automation.
@UIParam public var position: Double = 0.0
/// Selected program index into ``programs``. A knob-picker selector; rebuilds on change.
@UIParam public var mode: Double = 0.0
// MARK: - Constants
/// Pedal manages its own dry/wet internally (per mode), so the base stays fully wet.
private static let defaultMix: Double = 1.0
/// `semitones → ratio` exponent scale: `2^(s/12) = e^(s · ln2/12)`, fed to `Exp.Audio`.
private let semitoneToRatioScale: Double = 0.05776226504666215 // ln(2) / 12
/// Granular pitch-shift window in seconds. Larger = smoother but more latency and sweep lag;
/// smaller tracks faster with more grit. Tuned slightly above the SOLA shifter's `0.1` default
/// to soften the periodic comb without adding audible lag.
private let windowSize: Double = 0.11
/// Per-head random timing jitter in seconds fed to each `PitchShift` stage. The four SOLA heads
/// re-trigger on a fixed grid, and that periodicity colours the shift with a static comb filter;
/// dispersing each head's read position breaks the regularity and reduces the combing. Kept
/// small so the voice stays tight. Clamped internally to `[0, windowSize]`.
private let timeDispersion: Double = 0.02
/// Fixed PRNG seed for the grain dispersion. With `timeDispersion > 0` the shifter draws random
/// per-head jitter; passing an explicit seed (rather than letting `PitchShift` derive one from
/// the clock) makes a given pedal setting render identically every time — reproducible audio,
/// and tests that can assert exact pitch instead of just "something changed".
private let pitchShiftSeed: UInt64 = 0x7A11_90D5_0C7A_1BEE
/// Seed for the Dive Bomb cascade's second stage. Distinct from ``pitchShiftSeed`` so the two
/// stages' dispersion sequences decorrelate instead of jittering in lockstep.
private let pitchShiftSeedStage2: UInt64 = 0x51A6_2B0F_3D44_9C17
/// Per-voice gain in harmony/detune modes, where the dry note and the shifted voice are summed.
/// At the heel the shifted voice is near-unison and correlated with the dry note, so the two sum
/// coherently — `0.5` per leg caps that worst case at unity, rather than the `1.4×` peak two
/// near-full-scale correlated voices would otherwise reach.
private let harmonyVoiceGain: Double = 0.5
/// Factor splitting a cascaded two-stage shift evenly between its stages.
private let twoStageSplit: Double = 0.5
// MARK: - Ranges
private let positionRange: ClosedRange<Double> = 0.0 ... 1.0
// MARK: - Knobs
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Pedal", node: $position, range: positionRange),
]
}
// MARK: - Selectors
public override var effectSelectors: [PedalSelectorKnob] {
let stops: [PedalSelectorKnob.Stop] = WhammyPedal.programs.enumerated().map { index, program in
PedalSelectorKnob.Stop(title: program.title, value: Double(index))
}
return [
// Each program is a different voice topology (interval span + dry blend + stage count),
// read at build time — so switching it must rebuild the board, not just write the node.
PedalSelectorKnob(label: "Mode", node: $mode, stops: stops, rebuildsOnChange: true),
]
}
// MARK: - Init
/// Creates a Whammy pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Whammy",
inputBus: inputBus,
outputBus: outputBus,
initialMix: WhammyPedal.defaultMix
)
}
// MARK: - Effect
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// `mode` is read as a plain value at build time; the board rebuilds when it changes (the
// voice topology — interval span, dry blend, stage count — is fixed per program).
// `position` stays live and sweeps the bend within the program.
let index: Int = min(max(0, Int(mode.rounded())), WhammyPedal.programs.count - 1)
let program: Program = WhammyPedal.programs[index]
// semitones = heel + position · (toe − heel), interpolated live from the pedal position.
let span: Double = program.toe - program.heel
let semitones: any ValidGeneratorInput = ($position * span) + program.heel
if program.twoStage {
// Beyond one SOLA stage's ±2-octave ratio clamp (the 3-octave Dive Bomb): cascade two
// stages, each shifting half, so the net shift reaches the full interval.
let half: any ValidGeneratorInput = semitones * twoStageSplit
let stage1: PitchShift.Audio = PitchShift.Audio(
input: dry,
pitchRatio: Exp.Audio(half * semitoneToRatioScale),
windowSize: windowSize,
timeDispersion: timeDispersion,
seed: pitchShiftSeed
)
let stage2: PitchShift.Audio = PitchShift.Audio(
input: stage1,
pitchRatio: Exp.Audio(half * semitoneToRatioScale),
windowSize: windowSize,
timeDispersion: timeDispersion,
seed: pitchShiftSeedStage2
)
return stage2
}
let shifted: PitchShift.Audio = PitchShift.Audio(
input: dry,
pitchRatio: Exp.Audio(semitones * semitoneToRatioScale),
windowSize: windowSize,
timeDispersion: timeDispersion,
seed: pitchShiftSeed
)
if program.harmony {
// Harmony/Detune: dry note stays, shifted voice layered under it. Both legs attenuated
// so the sum of two near-full-scale voices stays near unity rather than peaking toward 2.
return (dry * harmonyVoiceGain) + (shifted * harmonyVoiceGain)
}
// Whammy: the bent pitch replaces the dry note entirely.
return shifted
}
}
@@ -79,6 +79,7 @@ public enum PedalRegistry {
"Octave Splitter": { OctaveUpSplitterPedal() },
"Bass Octaver": { BassOctaverPedal() },
"Harmonizer": { HarmonizerPedal() },
"Whammy": { WhammyPedal() },
"Ping-Pong": { PingPongDelayPedal() },
"Reverse Delay": { ReverseDelayPedal() },
"Shimmer Reverb": { ShimmerReverbPedal() },
@@ -4,6 +4,7 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Descriptor for one pedal parameter that can be locked to the tempo.
@@ -7,6 +7,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
/// A horizontal board-mixer strip for switching between, or blending, multiple `PedalBoard`s.
///
@@ -7,6 +7,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
/// A full board manager presented as a sheet — the richer companion to the inline
/// ``BoardBarView``.
@@ -7,6 +7,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
/// Renders a ``ChainRouter`` as a vertical stack with transport controls, two labelled
/// board rows, and a merger + optional master-gain output stage.
@@ -5,6 +5,7 @@
// SPDX-License-Identifier: MIT
import SwiftUI
import LyrebirdSynth
import LyrebirdUI
import LyrebirdShoeGaze
@@ -7,6 +7,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
/// A horizontal scrolling strip of ``PedalView`` cards, one per pedal in a `PedalBoard`.
///
@@ -7,6 +7,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
// MARK: - PedalButtonView
@@ -53,7 +53,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
"Cabinet": .cabinet,
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
"Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .modulation,
"Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch,
"Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch, "Whammy": .pitch,
"Delay": .delay, "Feedback Delay": .delay, "Multi-Tap Delay": .delay, "Ping-Pong": .delay,
"Reverse Delay": .delay,
"Reverb": .reverb, "Shimmer Reverb": .reverb,
@@ -5,6 +5,7 @@
// SPDX-License-Identifier: MIT
import SwiftUI
import LyrebirdSynth
import LyrebirdShoeGaze
/// Environment action a leaf pedal control can call to ask the host to rebuild the board that
@@ -5,6 +5,7 @@
// SPDX-License-Identifier: MIT
import SwiftUI
import LyrebirdSynth
import LyrebirdUI
import LyrebirdShoeGaze
@@ -8,6 +8,7 @@ import SwiftUI
import UniformTypeIdentifiers
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdSynth
// MARK: - Accent-color mapping (UI-only, never in the core target)
@@ -5,6 +5,7 @@
// SPDX-License-Identifier: MIT
import SwiftUI
import LyrebirdSynth
import LyrebirdUI
import LyrebirdShoeGaze
@@ -6,6 +6,7 @@
import SwiftUI
import LyrebirdUI
import LyrebirdSynth
/// A vertical fader bound to a single ``UIParamNode``.
///
@@ -170,4 +170,69 @@ struct NoiseGatePedalTests {
#expect(pedal.threshold == 0.03 && pedal.floor == 0.4, "legacy Threshold/Floor mis-mapped")
#expect(pedal.attack == 0.005 && pedal.release == 0.08, "legacy gate should default Attack/Release")
}
@Test func exposesDetectorSwitch() throws {
let switches: [PedalSwitch] = NoiseGatePedal().effectSwitches
#expect(switches.map { $0.label } == ["Detector"])
#expect(switches.first?.options.map { $0.title } == ["Peak", "RMS"])
}
@Test func defaultsToRMSAndLegacyGateGetsRMS() throws {
#expect(NoiseGatePedal().detector == 1.0, "new gate should default to RMS")
// A gate saved before the detector switch (empty switchValues) loads with the RMS default.
let legacy: PedalState = PedalState(
id: UUID(), type: "Noise Gate",
knobValues: [0.03, 0.4, 1.0, 1.0], switchValues: [], advancedValues: [], bypass: 0.0)
let pedal: NoiseGatePedal = NoiseGatePedal()
pedal.applyState(legacy)
#expect(pedal.detector == 1.0, "legacy gate should default to the RMS detector")
}
@Test func detectorRoundTripsThroughState() throws {
let pedal: NoiseGatePedal = NoiseGatePedal()
pedal.detector = 0.0 // Peak
let restored: NoiseGatePedal = NoiseGatePedal()
restored.applyState(pedal.captureState())
#expect(restored.detector == 0.0)
}
@Test func rmsDetectorClosesEarlierThanPeak() throws {
// On a note held just above threshold, the RMS envelope (≈ 3 dB below the peak envelope for a
// steady tone) drops under the close threshold sooner than the peak envelope does — so the
// RMS gate shuts earlier and passes less of the sustained tail than the Peak gate. The source
// steps to a constant 0.03 (peak env ≈ 0.03, RMS env ≈ 0.021); with threshold 0.025 the Peak
// gate stays open on the tail while the RMS gate closes.
func tailEnergy(detector: Double) throws -> Double {
let sr: Double = 48000.0
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.6, sampleRate: sr)
defer { try? FileManager.default.removeItem(at: url) }
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
defer {
engine.busAllocator.releaseAudioBus(srcBus)
engine.busAllocator.releaseAudioBus(dstBus)
}
let source: DecaySineSource = DecaySineSource(bus: srcBus.index)
let gate: NoiseGatePedal = NoiseGatePedal(inputBus: srcBus.index, outputBus: dstBus.index)
gate.sampleRate = sr
gate.threshold = 0.025
gate.floor = 0.0
gate.detector = detector
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
try engine.add(source)
try engine.add(gate, position: NodePosition.after(source))
try engine.add(master, position: NodePosition.after(gate))
try engine.start()
let inter: [Float] = readStereoCAF(url: url, sampleRate: sr)
let mono: [Double] = stride(from: 0, to: inter.count, by: 2).map { Double(inter[$0]) }
let start: Int = Int(0.15 * sr) // the sustained, below-peak-threshold tail
var energy: Double = 0.0
for i: Int in start..<mono.count { energy += mono[i] * mono[i] }
return energy
}
let peakTail: Double = try tailEnergy(detector: 0.0)
let rmsTail: Double = try tailEnergy(detector: 1.0)
#expect(peakTail > rmsTail * 2.0,
"RMS should close earlier than Peak on the sustained tail (peak=\(peakTail) rms=\(rmsTail))")
}
}
@@ -0,0 +1,464 @@
// WhammyPedalTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Testing
import Foundation
import LyrebirdSynth
import LyrebirdUI
@testable import LyrebirdShoeGaze
/// A steady sine source for pitch tests — a known, stable fundamental the shifter can act on so a
/// test can measure the output pitch, which the arpeggiated `TestLoopSource` (pitch changing three
/// times a second) cannot support.
@MainActor
private final class TestSineSource: SynthesizerBase {
private let targetBus: Int
private let freq: Double
private let amp: Double
init(targetBus: Int, freq: Double, amplitude: Double = 0.5) {
self.targetBus = targetBus
self.freq = freq
self.amp = amplitude
super.init()
}
override func build() {
output(bus: targetBus, source: OscSin.Audio(freq: freq, mul: amp))
}
}
@MainActor
@Suite("WhammyPedal")
struct WhammyPedalTests {
// MARK: - Analysis constants
/// Engine sample rate (matches `makeNRTEngine`'s default).
private let sampleRate: Double = 44_100.0
/// Render long enough that the analysis window lands well past the shifter's warm-up.
private let renderDuration: Double = 0.8
/// Test tone fundamental. Mid-range so ±2 octaves stays inside `[20, Nyquist]`.
private let sineHz: Double = 220.0
/// Interleaved-stereo frame offset to start analysis at — clears the shifter's warm-up.
private let analysisSkipFrames: Int = 13_230 // ~0.3 s
/// Analysis window length in frames. ~0.37 s → ≥10 cycles even at the −3-octave Dive Bomb.
private let analysisWindowFrames: Int = 16_384
// MARK: - Render helpers
/// Renders the pedal driven by the arpeggiated `TestLoopSource` (for non-pitch checks).
private func render(
configure: (WhammyPedal) -> Void
) throws -> [Float] {
try renderThroughPedal(source: { bus in TestLoopSource(targetBus: bus) }, configure: configure)
}
/// Renders the pedal driven by a steady sine at `sineHz` (for pitch checks).
private func renderSine(
configure: (WhammyPedal) -> Void
) throws -> [Float] {
try renderThroughPedal(
source: { bus in TestSineSource(targetBus: bus, freq: self.sineHz) },
configure: configure
)
}
/// Renders the steady sine straight to the master with no pedal in the path — a dry reference
/// for correlation tests.
private func renderSineDry() throws -> [Float] {
let numAudioBuses: Int = 64
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
duration: renderDuration,
numAudioBuses: numAudioBuses
)
defer { try? FileManager.default.removeItem(at: url) }
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
defer { engine.busAllocator.releaseAudioBus(srcBus) }
let source: TestSineSource = TestSineSource(targetBus: srcBus.index, freq: sineHz)
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: srcBus.index)
try engine.add(source)
try engine.add(master, position: NodePosition.after(source))
try engine.start()
return readStereoCAF(url: url)
}
/// Shared body: `source` writes the pedal's input bus, the pedal processes it, the master routes
/// the pedal output to the hardware file.
private func renderThroughPedal(
source makeSource: (Int) -> any Synthesizer,
configure: (WhammyPedal) -> Void
) throws -> [Float] {
let numAudioBuses: Int = 64
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
duration: renderDuration,
numAudioBuses: numAudioBuses
)
defer { try? FileManager.default.removeItem(at: url) }
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
defer {
engine.busAllocator.releaseAudioBus(srcBus)
engine.busAllocator.releaseAudioBus(dstBus)
}
let source: any Synthesizer = makeSource(srcBus.index)
let pedal: WhammyPedal = WhammyPedal(
inputBus: srcBus.index,
outputBus: dstBus.index
)
configure(pedal)
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
try engine.add(source)
try engine.add(pedal, position: NodePosition.after(source))
try engine.add(master, position: NodePosition.after(pedal))
try engine.start()
return readStereoCAF(url: url)
}
// MARK: - Signal analysis
/// Estimates the fundamental of the left channel by autocorrelation — robust to the grain-splice
/// glitches a zero-crossing count would miscount. Searches lags in `[20 Hz, maxHz]`; a deep
/// down-shift carries strong grain-rate HF that a wide search would lock onto instead of the
/// intended low fundamental, so callers testing those modes pass a ceiling near the expected Hz.
private func fundamentalHz(_ samples: [Float], maxHz: Double = 1_500.0) -> Double {
let minHz: Double = 20.0
let needed: Int = analysisSkipFrames + analysisWindowFrames
guard samples.count >= 2 * needed else { return 0.0 }
var x: [Double] = []
x.reserveCapacity(analysisWindowFrames)
for i: Int in analysisSkipFrames ..< needed {
x.append(Double(samples[2 * i])) // left channel of the interleaved pair
}
// Remove DC so the autocorrelation peak reflects periodicity, not offset.
let mean: Double = x.reduce(0.0, +) / Double(x.count)
for i: Int in x.indices { x[i] -= mean }
let minLag: Int = Int(sampleRate / maxHz)
let maxLag: Int = min(Int(sampleRate / minHz), x.count - 1)
guard maxLag > minLag else { return 0.0 }
var bestLag: Int = minLag
var bestCorr: Double = -Double.infinity
for lag: Int in minLag ... maxLag {
var c: Double = 0.0
for i: Int in 0 ..< (x.count - lag) {
c += x[i] * x[i + lag]
}
if c > bestCorr {
bestCorr = c
bestLag = lag
}
}
return sampleRate / Double(bestLag)
}
/// Pearson correlation of two renders' left channels over the analysis window. Scale-invariant,
/// so gain differences between the two signals don't matter — only shared waveform shape does.
private func correlation(_ a: [Float], _ b: [Float]) -> Double {
let needed: Int = analysisSkipFrames + analysisWindowFrames
guard a.count >= 2 * needed, b.count >= 2 * needed else { return 0.0 }
var xa: [Double] = []
var xb: [Double] = []
xa.reserveCapacity(analysisWindowFrames)
xb.reserveCapacity(analysisWindowFrames)
for i: Int in analysisSkipFrames ..< needed {
xa.append(Double(a[2 * i]))
xb.append(Double(b[2 * i]))
}
let n: Double = Double(xa.count)
let ma: Double = xa.reduce(0.0, +) / n
let mb: Double = xb.reduce(0.0, +) / n
var num: Double = 0.0
var da: Double = 0.0
var db: Double = 0.0
for i: Int in 0 ..< xa.count {
let u: Double = xa[i] - ma
let v: Double = xb[i] - mb
num += u * v
da += u * u
db += v * v
}
guard da > 0.0, db > 0.0 else { return 0.0 }
return num / (da * db).squareRoot()
}
// MARK: - Pitch behaviour
@Test func pitchShiftsUpTwoOctavesAtToe() throws {
// 2 Oct Up (mode 0): toe = +24 st = ratio 4. A 220 Hz tone should land near 880 Hz, and well
// above the unison it produces at the heel.
let heel: [Float] = try renderSine { pedal in
pedal.mode = 0.0
pedal.position = 0.0
}
let toe: [Float] = try renderSine { pedal in
pedal.mode = 0.0
pedal.position = 1.0
}
let heelHz: Double = fundamentalHz(heel)
let toeHz: Double = fundamentalHz(toe)
#expect(hasNonSilentOutput(toe), "2 Oct Up toe render was silent")
#expect(abs(heelHz - sineHz) < sineHz * 0.3, "heel should be unison (~220 Hz), got \(heelHz)")
#expect(abs(toeHz - sineHz * 4.0) < sineHz * 4.0 * 0.3,
"2 Oct Up toe should be ~880 Hz, got \(toeHz)")
#expect(toeHz > heelHz * 2.0, "toe pitch should be far above the heel")
}
@Test func pitchShiftsDownAnOctaveAtToe() throws {
// Oct Down (mode 2): toe = −12 st = ratio 0.5. 220 Hz should land near 110 Hz, below unison.
let heel: [Float] = try renderSine { pedal in
pedal.mode = 2.0
pedal.position = 0.0
}
let toe: [Float] = try renderSine { pedal in
pedal.mode = 2.0
pedal.position = 1.0
}
let heelHz: Double = fundamentalHz(heel)
let toeHz: Double = fundamentalHz(toe)
#expect(hasNonSilentOutput(toe), "Oct Down toe render was silent")
#expect(abs(toeHz - sineHz * 0.5) < sineHz * 0.5 * 0.3,
"Oct Down toe should be ~110 Hz, got \(toeHz)")
#expect(toeHz < heelHz * 0.7, "toe pitch should be well below the heel")
}
@Test func diveBombCascadeReachesThreeOctaves() throws {
// Dive Bomb (mode 4, cascade) toe = −36 st = ratio 0.125 → ~27.5 Hz. It must drop below the
// single-stage 2 Oct Down (mode 3, −24 st = ~55 Hz), proving the second cascade stage engaged.
// Cap the search near the expected low fundamentals so the deep-shift grain HF can't win.
let deepCeilingHz: Double = 120.0
let twoOctDownHz: Double = fundamentalHz(try renderSine { pedal in
pedal.mode = 3.0
pedal.position = 1.0
}, maxHz: deepCeilingHz)
let diveBomb: [Float] = try renderSine { pedal in
pedal.mode = 4.0
pedal.position = 1.0
}
let diveHz: Double = fundamentalHz(diveBomb, maxHz: deepCeilingHz)
#expect(hasNonSilentOutput(diveBomb), "Dive Bomb render was silent")
#expect(abs(diveHz - sineHz * 0.125) < sineHz * 0.125 * 0.35,
"Dive Bomb toe should be ~27.5 Hz, got \(diveHz)")
#expect(diveHz < twoOctDownHz * 0.75,
"Dive Bomb (\(diveHz) Hz) should dive below 2 Oct Down (\(twoOctDownHz) Hz)")
}
@Test func harmonyKeepsDryVoiceUnderShifted() throws {
// Oct Up/Dn (mode 6) at the toe shifts a voice to −12 st AND keeps the dry note. Its output
// must correlate with the dry signal far more than the wet-only Oct Down (mode 2, also −12 st,
// no dry) does — the only difference between the two is the summed-in dry voice.
let dry: [Float] = try renderSineDry()
let harmony: [Float] = try renderSine { pedal in
pedal.mode = 6.0 // Oct Up/Dn — toe = −12 st, dry + shifted
pedal.position = 1.0
}
let wetOnly: [Float] = try renderSine { pedal in
pedal.mode = 2.0 // Oct Down — toe = −12 st, shifted only
pedal.position = 1.0
}
let harmonyCorr: Double = correlation(harmony, dry)
let wetCorr: Double = correlation(wetOnly, dry)
#expect(hasNonSilentOutput(harmony), "harmony render was silent")
#expect(harmonyCorr > wetCorr + 0.2,
"harmony should correlate with the dry signal far more than the wet-only shift (harmony \(harmonyCorr) vs wet-only \(wetCorr))")
}
@Test func renderIsDeterministic() throws {
// Every PitchShift stage is seeded, and the sine source is RNG-free, so two identical renders
// must be bit-identical. (Guards the seeding that makes the pitch assertions meaningful.)
let a: [Float] = try renderSine { pedal in
pedal.mode = 4.0 // Dive Bomb — exercises both cascade stages' seeds
pedal.position = 0.6
}
let b: [Float] = try renderSine { pedal in
pedal.mode = 4.0
pedal.position = 0.6
}
#expect(a == b, "seeded renders of the same setting should be bit-identical")
}
// MARK: - Bypass transition
/// Renders the Whammy manually block-by-block through a no-op `OfflineDriver`, flipping `bypass`
/// from engaged (`0`) to bypassed (`1`) at `flipFrame`, and returns the left hardware-output
/// channel. Hand-stepping `processBlock` is the only way to change a live `@UIParam` mid-render —
/// `NRTDriver.start()` renders the whole file in one blocking call with no seam to intervene at.
private func renderBypassFlip(
mode: Double,
position: Double,
flipFrame: Int,
totalFrames: Int,
blockSize: Int = 64
) throws -> [Float] {
let numAudioBuses: Int = 64
let numControlBuses: Int = 512
let driver: OfflineDriver = OfflineDriver()
let engine: SynthesisEngine = SynthesisEngine(
blockSize: blockSize,
sampleRate: sampleRate,
numOutputChannels: 2,
numInputChannels: 0,
numAudioBuses: numAudioBuses,
numControlBuses: numControlBuses,
driver: driver
)
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
defer {
engine.busAllocator.releaseAudioBus(srcBus)
engine.busAllocator.releaseAudioBus(dstBus)
}
let source: TestSineSource = TestSineSource(targetBus: srcBus.index, freq: sineHz)
let pedal: WhammyPedal = WhammyPedal(inputBus: srcBus.index, outputBus: dstBus.index)
pedal.mode = mode
pedal.position = position
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
try engine.add(source)
try engine.add(pedal, position: NodePosition.after(source))
try engine.add(master, position: NodePosition.after(pedal))
// OfflineDriver.start() is a no-op, so this allocates buses + builds the node tree without
// rendering; the block loop below drives the render by hand.
try engine.start()
let noInput: [[Float]] = []
var left: [Float] = []
left.reserveCapacity(totalFrames)
var frame: Int = 0
var flipped: Bool = false
while frame < totalFrames {
if !flipped, frame >= flipFrame {
pedal.bypass = 1.0 // engage → bypassed, mid-render
flipped = true
}
engine.processBlock(inputSamples: noInput)
let bus: [Float] = engine.audioBuses[0] // hardware output, left
left.append(contentsOf: bus)
frame += blockSize
}
engine.stop()
return left
}
/// Max absolute first difference (per-sample step) over `[lo, hi)`. An impulsive click shows up
/// here as a step far larger than the signal's own slope.
private func maxStep(_ x: [Float], lo: Int, hi: Int) -> Double {
let a: Int = max(1, lo)
let b: Int = min(hi, x.count)
guard b > a else { return 0.0 }
var m: Double = 0.0
for i: Int in a ..< b {
let d: Double = abs(Double(x[i]) - Double(x[i - 1]))
if d > m { m = d }
}
return m
}
@Test func bypassSwitchIsClickFree() throws {
// Clocking a wet-only pitch voice (Oct Up, +12 at the toe) on/off crossfades the dry note
// against a fully decorrelated shifted voice. The linear-slew equal-power bypass crossfade
// must keep that transition click-free: no impulsive step and no energy dropout at the seam.
// (A naive hard gate, or the old front-loaded one-pole lag, spikes the first difference here.)
// Use the engine's real 512-sample block: a block-rate bypass smoother takes only a few
// coarse steps per short fade at this size, so testing at a small block would hide the click.
let blockSize: Int = 512
let totalFrames: Int = 26_460 // 0.6 s at 44.1 kHz
let flipFrame: Int = 15_435 // ~0.35 s
let left: [Float] = try renderBypassFlip(
mode: 1.0, // Oct Up — wet only, +12 st at the toe
position: 1.0,
flipFrame: flipFrame,
totalFrames: totalFrames,
blockSize: blockSize
)
#expect(hasNonSilentOutput(left), "bypass-flip render was silent")
// Steady engaged region, past the shifter warm-up and before the flip.
let steadyLo: Int = 9_700 // ~0.22 s
let steadyHi: Int = 14_500 // ~0.33 s
// Transition region: the flip plus the fade time and a little settle.
let fadeFrames: Int = Int(0.03 * sampleRate)
let transLo: Int = flipFrame - blockSize
let transHi: Int = flipFrame + fadeFrames + 2_000
let steadyStep: Double = maxStep(left, lo: steadyLo, hi: steadyHi)
let transStep: Double = maxStep(left, lo: transLo, hi: transHi)
// No impulsive click: the biggest per-sample step across the seam stays within a small
// multiple of the signal's own steady-state slope (grain splices included). This is the real
// guard — at the engine's 512-sample block a block-rate smoother (the old one-pole lag, or a
// control-rate slew) leaks a coarse step here; the audio-rate slew ramps per sample.
// (Energy continuity is not asserted: the Oct Up wet voice's inherent SOLA amplitude warble
// swamps any seam-level change, so a short-window RMS is not a usable dropout metric here.)
#expect(transStep <= steadyStep * 4.0,
"bypass transition stepped \(transStep) vs steady \(steadyStep) — a click leaked through")
}
// MARK: - Build / wiring
@Test func buildsAndProducesNonSilentOutput() throws {
let samples: [Float] = try render { pedal in
pedal.mode = 0.0 // 2 Oct Up
pedal.position = 0.5
}
#expect(!samples.isEmpty)
#expect(hasNonSilentOutput(samples), "whammy output was silent")
}
@Test func exposesPedalKnobAndModeSelector() throws {
let pedal: WhammyPedal = WhammyPedal()
#expect(pedal.effectKnobs.map { $0.label } == ["Pedal"])
let selectors: [PedalSelectorKnob] = pedal.effectSelectors
#expect(selectors.map { $0.label } == ["Mode"])
let titles: [String] = selectors.first?.stops.map { $0.title } ?? []
#expect(titles.contains("2 Oct Up"))
#expect(titles.contains("Dive Bomb"))
#expect(titles.contains("Drop Tune"))
#expect(titles.contains("Oct Up/Dn"))
#expect(titles.contains("Detune Deep"))
}
@Test func presetRoundTripPreservesModeAndPosition() throws {
let pedal: WhammyPedal = WhammyPedal()
pedal.position = 0.75
pedal.mode = 2.0 // Oct Down
let state: PedalState = pedal.captureState()
#expect(state.selectorValues == [2.0], "mode should round-trip as the sole selector value")
#expect(state.knobValues.first == 0.75, "position should be the first knob value")
let restored: WhammyPedal = WhammyPedal()
restored.applyState(state)
#expect(restored.position == 0.75)
#expect(restored.mode == 2.0)
}
@Test func modeSwitchRebuildsBoard() throws {
// Each program is a distinct voice topology read at build time, so the Mode selector must
// drive a board rebuild — a plain node write would leave the audible program stuck.
let pedal: WhammyPedal = WhammyPedal()
pedal.mode = 3.0
#expect(pedal.rebuildTopologyValues == [3.0],
"Mode must be a rebuildsOnChange selector so switching programs re-enters effect(_:)")
}
@Test func registeredInBuiltInRegistry() throws {
let pedal: Pedal? = PedalRegistry.makePedal(type: "Whammy")
#expect(pedal is WhammyPedal)
}
}