Compare commits
39 Commits
v2.1.3
...
71d9b44809
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 |
@@ -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
|
||||||
|
|||||||
@@ -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 = 10;
|
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.1.1;
|
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 = 10;
|
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.1.1;
|
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;
|
||||||
|
|||||||
@@ -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: 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.1.2</string>
|
<string>${MARKETING_VERSION}</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>10</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;
|
||||||
|
|||||||
@@ -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 |
@@ -59,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,10 +20,12 @@ 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 {
|
||||||
|
ZStack {
|
||||||
ShoeGazeBuilderView(
|
ShoeGazeBuilderView(
|
||||||
shoeGaze: model.shoeGaze,
|
shoeGaze: model.shoeGaze,
|
||||||
library: model.library,
|
library: model.library,
|
||||||
@@ -35,6 +37,13 @@ struct ShoeGazeBuilderiOSApp: App {
|
|||||||
.task { await model.startLibrary() }
|
.task { await model.startLibrary() }
|
||||||
.onDisappear { model.stop() }
|
.onDisappear { model.stop() }
|
||||||
.onOpenURL { url in model.importDocument(at: url) }
|
.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.
|
||||||
|
|||||||
@@ -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,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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -232,6 +237,18 @@ open class Pedal: SynthesizerBase {
|
|||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Current values of every ``effectSelectors`` entry flagged `rebuildsOnChange` — the selectors
|
||||||
|
/// whose choice changes the graph topology (e.g. a cabinet voice). 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 selectors.
|
||||||
|
public var rebuildSelectorValues: [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.
|
||||||
|
effectSelectors
|
||||||
|
.filter { $0.rebuildsOnChange }
|
||||||
|
.map { $0.node.value.isFinite ? $0.node.value : 0.0 }
|
||||||
|
}
|
||||||
|
|
||||||
/// 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 /
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,25 @@ 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 chime = PedalType("Chime")
|
||||||
|
static let fullertonReverb = PedalType("Fullerton Reverb")
|
||||||
|
static let fullertonDeluxe = PedalType("Fullerton Deluxe")
|
||||||
|
static let fullertonPrinceton = PedalType("Fullerton Princeton")
|
||||||
|
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,246 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
/// 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: TriodeStage = TriodeStage(input: preShaped, drive: $gain, bias: preampBias, oversample: 4)
|
||||||
|
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,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 {
|
||||||
|
LinLin.Audio($master, inLo: 0.0, inHi: 1.0, outLo: masterMinDrive, outHi: 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,80 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
/// Tremolo depth scaling — at full `intensity` the LFO swings over half the normalised range so
|
||||||
|
/// the peak gain is 1.0 and the trough is `1 − intensity`.
|
||||||
|
private let tremoloDepthScale: Double = 0.5
|
||||||
|
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 {
|
||||||
|
// Footswitch gates depth to 0 → LFO is a constant 1.0 (identity). Unipolar sine over
|
||||||
|
// [1 − depth, 1]: peak gain 1.0, trough 1 − depth.
|
||||||
|
let depth: any ValidGeneratorInput = $intensity * $tremoloEnabled
|
||||||
|
let lfoScale: any ValidGeneratorInput = depth * tremoloDepthScale
|
||||||
|
let lfoOffset: any ValidGeneratorInput = 1.0 - (depth * tremoloDepthScale)
|
||||||
|
let lfo: OscSin.Audio = OscSin.Audio(freq: $speed, mul: lfoScale, add: lfoOffset)
|
||||||
|
return signal * lfo
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// BritishComboAmpPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Shared base for the **non-master** British voices (Plexi / JTM / Bluesbreaker) — the earlier
|
||||||
|
/// Marshalls with no master volume, so the power-amp stage runs at a fixed drive and loudness comes
|
||||||
|
/// from cranking `Gain`.
|
||||||
|
///
|
||||||
|
/// Provides the common British control surface: the `.marshall` tone stack, a **Presence** lift
|
||||||
|
/// (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf). Concrete voices
|
||||||
|
/// subclass this and differ by gain/cab/headroom; the Bluesbreaker additionally overlays tremolo.
|
||||||
|
///
|
||||||
|
/// Distinct from ``BritishAmpPedal``, which is the master-volume (JCM-style) 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
|
||||||
|
|
||||||
|
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,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,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,48 @@
|
|||||||
|
// 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.
|
||||||
|
public final 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.
|
||||||
|
///
|
||||||
|
/// - 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", 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,140 @@
|
|||||||
|
// 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
|
||||||
|
/// Tremolo depth scaling — at full `intensity` the LFO swings over half the normalised range so
|
||||||
|
/// the peak gain is 1.0 and the trough is `1 − intensity`.
|
||||||
|
private let tremoloDepthScale: Double = 0.5
|
||||||
|
|
||||||
|
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 {
|
||||||
|
// Footswitch gates depth to 0 → LFO is a constant 1.0 (identity). Unipolar sine over
|
||||||
|
// [1 − depth, 1]: peak gain 1.0, trough 1 − depth.
|
||||||
|
let depth: any ValidGeneratorInput = $intensity * $tremoloEnabled
|
||||||
|
let lfoScale: any ValidGeneratorInput = depth * tremoloDepthScale
|
||||||
|
let lfoOffset: any ValidGeneratorInput = 1.0 - (depth * tremoloDepthScale)
|
||||||
|
let lfo: OscSin.Audio = OscSin.Audio(freq: $speed, mul: lfoScale, add: lfoOffset)
|
||||||
|
return signal * lfo
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,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,153 @@
|
|||||||
|
// 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
|
||||||
|
/// Tremolo depth scaling — at full `intensity` the LFO swings over half the normalised range so
|
||||||
|
/// the peak gain is 1.0 and the trough is `1 − intensity`.
|
||||||
|
private let tremoloDepthScale: Double = 0.5
|
||||||
|
|
||||||
|
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)
|
||||||
|
// Footswitch gates depth to 0 → LFO is a constant 1.0. Unipolar sine over [1 − depth, 1]:
|
||||||
|
// peak gain 1.0, trough 1 − depth.
|
||||||
|
let depth: any ValidGeneratorInput = $intensity * $vibratoEnabled
|
||||||
|
let lfoScale: any ValidGeneratorInput = depth * tremoloDepthScale
|
||||||
|
let lfoOffset: any ValidGeneratorInput = 1.0 - (depth * tremoloDepthScale)
|
||||||
|
let lfo: OscSin.Audio = OscSin.Audio(freq: $speed, mul: lfoScale, add: lfoOffset)
|
||||||
|
return reverbed * lfo
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,152 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
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 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, and a Bright switch."
|
||||||
|
}
|
||||||
|
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),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ extension Pedal {
|
|||||||
sliderValues: sliderValues,
|
sliderValues: sliderValues,
|
||||||
selectorValues: selectorValues,
|
selectorValues: selectorValues,
|
||||||
bypass: bypass,
|
bypass: bypass,
|
||||||
tempoSync: tempoSync.isEmpty ? nil : tempoSync
|
tempoSync: tempoSync.isEmpty ? nil : tempoSync,
|
||||||
|
resourcePath: resourcePath
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,5 +67,6 @@ extension Pedal {
|
|||||||
// tempo by `ShoeGaze` after the rebuild, so no clock is required here.
|
// tempo by `ShoeGaze` after the rebuild, so no clock is required here.
|
||||||
tempoSync = state.tempoSync ?? [:]
|
tempoSync = state.tempoSync ?? [:]
|
||||||
tempoSyncRevision.bump()
|
tempoSyncRevision.bump()
|
||||||
|
resourcePath = state.resourcePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,18 @@ 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() },
|
||||||
|
"Chime": { ChimeAmpPedal() },
|
||||||
|
"Fullerton Reverb": { FullertonReverbAmpPedal() },
|
||||||
|
"Fullerton Deluxe": { FullertonDeluxeAmpPedal() },
|
||||||
|
"Fullerton Princeton": { FullertonPrincetonAmpPedal() },
|
||||||
|
"Jazz Clean": { JazzCleanAmpPedal() },
|
||||||
|
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
|
||||||
|
"Neural Amp": { NeuralAmpPedal() },
|
||||||
"Overdrive": { OverdrivePedal() },
|
"Overdrive": { OverdrivePedal() },
|
||||||
"Distortion": { DistortionPedal() },
|
"Distortion": { DistortionPedal() },
|
||||||
"Delay": { DelayPedal() },
|
"Delay": { DelayPedal() },
|
||||||
@@ -56,6 +68,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() },
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ public struct PedalState: Codable, Equatable {
|
|||||||
/// decode to "all parameters free".
|
/// decode to "all parameters free".
|
||||||
public let tempoSync: [String: TempoSync]?
|
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:
|
||||||
@@ -60,6 +64,8 @@ public struct PedalState: Codable, Equatable {
|
|||||||
/// - 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`.
|
/// - 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,
|
||||||
@@ -68,7 +74,8 @@ public struct PedalState: Codable, Equatable {
|
|||||||
sliderValues: [Double] = [],
|
sliderValues: [Double] = [],
|
||||||
selectorValues: [Double] = [],
|
selectorValues: [Double] = [],
|
||||||
bypass: Double,
|
bypass: Double,
|
||||||
tempoSync: [String: TempoSync]? = nil
|
tempoSync: [String: TempoSync]? = nil,
|
||||||
|
resourcePath: String? = nil
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.type = type
|
self.type = type
|
||||||
@@ -78,6 +85,7 @@ public struct PedalState: Codable, Equatable {
|
|||||||
self.selectorValues = selectorValues
|
self.selectorValues = selectorValues
|
||||||
self.bypass = bypass
|
self.bypass = bypass
|
||||||
self.tempoSync = tempoSync
|
self.tempoSync = tempoSync
|
||||||
|
self.resourcePath = resourcePath
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
@@ -89,6 +97,7 @@ public struct PedalState: Codable, Equatable {
|
|||||||
case selectorValues
|
case selectorValues
|
||||||
case bypass
|
case bypass
|
||||||
case tempoSync
|
case tempoSync
|
||||||
|
case resourcePath
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
|
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
|
||||||
@@ -103,5 +112,6 @@ public struct PedalState: Codable, Equatable {
|
|||||||
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.tempoSync = try container.decodeIfPresent([String: TempoSync].self, forKey: .tempoSync)
|
||||||
|
self.resourcePath = try container.decodeIfPresent(String.self, forKey: .resourcePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,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
|
||||||
@@ -345,12 +345,28 @@ 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
|
// 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 —
|
// consulted in `Pedal.applyState`), so recompute them against the rig's current tempo —
|
||||||
@@ -363,30 +379,39 @@ extension ShoeGaze {
|
|||||||
/// 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.rebuildSelectorValues
|
||||||
pedal.applyState(pedalState)
|
pedal.applyState(pedalState)
|
||||||
|
if pedal.rebuildSelectorValues != 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:
|
||||||
@@ -394,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.rebuildSelectorValues
|
||||||
pedal.applyState(pedalState)
|
pedal.applyState(pedalState)
|
||||||
}
|
if pedal.rebuildSelectorValues != before { topologyChanged = true }
|
||||||
|
}
|
||||||
|
return topologyChanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,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] {
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public struct BoardFlowView: View {
|
|||||||
private static let splitToggleWidth: CGFloat = 200
|
private static let splitToggleWidth: CGFloat = 200
|
||||||
private static let emptyLaneOpacity: Double = 0.4
|
private static let emptyLaneOpacity: Double = 0.4
|
||||||
|
|
||||||
|
/// Extra height the content may exceed the viewport by before vertical scrolling turns on, so a
|
||||||
|
/// sub-pixel rounding difference doesn't flip the axis set on and off.
|
||||||
|
private static let verticalScrollSlack: CGFloat = 1
|
||||||
|
|
||||||
/// Signal-path accent (the pink/magenta connector colour).
|
/// Signal-path accent (the pink/magenta connector colour).
|
||||||
private static let flowColor: Color = Color(red: 0.92, green: 0.32, blue: 0.70)
|
private static let flowColor: Color = Color(red: 0.92, green: 0.32, blue: 0.70)
|
||||||
|
|
||||||
@@ -62,6 +66,10 @@ public struct BoardFlowView: View {
|
|||||||
/// Identifier of the lane/card currently hovered as a drop target, for highlight.
|
/// Identifier of the lane/card currently hovered as a drop target, for highlight.
|
||||||
@State private var dropTarget: String?
|
@State private var dropTarget: String?
|
||||||
|
|
||||||
|
/// Measured height of the flow content, used to enable vertical scrolling only when the stacked
|
||||||
|
/// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal.
|
||||||
|
@State private var contentHeight: CGFloat = 0
|
||||||
|
|
||||||
public init(shoeGaze: ShoeGaze, boardIndex: Int) {
|
public init(shoeGaze: ShoeGaze, boardIndex: Int) {
|
||||||
self.shoeGaze = shoeGaze
|
self.shoeGaze = shoeGaze
|
||||||
self.boardIndex = boardIndex
|
self.boardIndex = boardIndex
|
||||||
@@ -81,7 +89,37 @@ public struct BoardFlowView: View {
|
|||||||
|
|
||||||
private func flow(board: PedalBoard) -> some View {
|
private func flow(board: PedalBoard) -> some View {
|
||||||
let stages: [StageModel] = stageModels(board: board)
|
let stages: [StageModel] = stageModels(board: board)
|
||||||
return ScrollView([.horizontal, .vertical], showsIndicators: true) {
|
return GeometryReader { proxy in
|
||||||
|
let viewportHeight: CGFloat = proxy.size.height
|
||||||
|
// Lock to horizontal, adding the vertical axis only when the chain is taller than the
|
||||||
|
// viewport (deep parallel splits) so it can be reached instead of clipped.
|
||||||
|
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
|
||||||
|
? [.horizontal, .vertical]
|
||||||
|
: .horizontal
|
||||||
|
ScrollView(axes, showsIndicators: true) {
|
||||||
|
// The spacers centre the chain vertically when it is shorter than the viewport; when
|
||||||
|
// it overflows, the min-height floor is already exceeded so they collapse to zero and
|
||||||
|
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
|
||||||
|
// longer stretches them.
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
Spacer(minLength: 0)
|
||||||
|
chainRow(board: board, stages: stages)
|
||||||
|
Spacer(minLength: 0)
|
||||||
|
}
|
||||||
|
.frame(minHeight: viewportHeight)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
||||||
|
contentHeight = height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The left→right chain of endpoints, connectors and stage cards. Reports its own intrinsic
|
||||||
|
/// height through `BoardFlowContentHeightKey` so `flow` can decide whether vertical scrolling is
|
||||||
|
/// needed. Each pedal sizes to its own content, so the row is only as tall as its tallest card —
|
||||||
|
/// a short pedal stays short next to a tall one.
|
||||||
|
private func chainRow(board: PedalBoard, stages: [StageModel]) -> some View {
|
||||||
HStack(alignment: .center, spacing: BoardFlowView.stageSpacing) {
|
HStack(alignment: .center, spacing: BoardFlowView.stageSpacing) {
|
||||||
endpoint("IN")
|
endpoint("IN")
|
||||||
ForEach(stages) { stage in
|
ForEach(stages) { stage in
|
||||||
@@ -92,8 +130,14 @@ public struct BoardFlowView: View {
|
|||||||
endpoint(board.width == 2 ? "OUT ⇒" : "OUT")
|
endpoint(board.width == 2 ? "OUT ⇒" : "OUT")
|
||||||
}
|
}
|
||||||
.padding(.vertical, BoardFlowView.regionPadding)
|
.padding(.vertical, BoardFlowView.regionPadding)
|
||||||
|
.background(
|
||||||
|
GeometryReader { contentProxy in
|
||||||
|
Color.clear.preference(
|
||||||
|
key: BoardFlowContentHeightKey.self,
|
||||||
|
value: contentProxy.size.height
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Stage model
|
// MARK: - Stage model
|
||||||
@@ -531,3 +575,12 @@ private extension String {
|
|||||||
return String(dropFirst(prefix.count))
|
return String(dropFirst(prefix.count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Carries the measured height of the flow content up to `BoardFlowView`, which compares it to the
|
||||||
|
/// viewport height to decide whether the vertical scroll axis is needed.
|
||||||
|
private struct BoardFlowContentHeightKey: PreferenceKey {
|
||||||
|
static let defaultValue: CGFloat = 0
|
||||||
|
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
||||||
|
value = max(value, nextValue())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -165,6 +165,28 @@ public struct HelpView: View {
|
|||||||
+ "CC to two controls and invert one for a crossfade.",
|
+ "CC to two controls and invert one for a crossfade.",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
topicSection(
|
||||||
|
icon: "checkmark.seal",
|
||||||
|
title: "Acknowledgments",
|
||||||
|
intro: "ShoeGaze is built on the Lyrebird audio-synthesis engine. Third-party resources "
|
||||||
|
+ "and techniques used in this app:",
|
||||||
|
steps: [
|
||||||
|
"Lyrebird audio engine (Joshua Parmenter / realizedsound) — MIT licensed.",
|
||||||
|
"Filter design follows the RBJ Audio EQ Cookbook by Robert Bristow-Johnson — the "
|
||||||
|
+ "standard biquad coefficient formulas, used to synthesize the Cabinet pedal's "
|
||||||
|
+ "built-in speaker impulse responses.",
|
||||||
|
"The Cabinet pedal's built-in cab voicings are original impulse responses generated in "
|
||||||
|
+ "code — not captures of any third-party hardware or IR pack.",
|
||||||
|
"The tube-amp voice pedals' tone stacks "
|
||||||
|
+ "follow the Yeh & Smith analysis of the classic passive tone-stack circuit (\"Discretization "
|
||||||
|
+ "of the '59 Fender Bassman Tone Stack\", DAFx-06); their models are original code, not "
|
||||||
|
+ "captures of specific hardware.",
|
||||||
|
"The Neural Amp pedal loads GuitarML Proteus / NeuralPi capture models (the open LSTM "
|
||||||
|
+ "format from github.com/GuitarML). You supply the model file; none are bundled, and "
|
||||||
|
+ "those models are licensed by their respective authors.",
|
||||||
|
]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.navigationTitle("ShoeGaze Help")
|
.navigationTitle("ShoeGaze Help")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import SwiftUI
|
|||||||
/// drive the "filter by type" menu. Purely a UI concern: the mapping from a pedal's `displayName`
|
/// drive the "filter by type" menu. Purely a UI concern: the mapping from a pedal's `displayName`
|
||||||
/// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order.
|
/// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order.
|
||||||
public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||||
|
case amp = "Amp Model"
|
||||||
case gain = "Gain"
|
case gain = "Gain"
|
||||||
case dynamics = "Dynamics"
|
case dynamics = "Dynamics"
|
||||||
case filter = "EQ & Filter"
|
case filter = "EQ & Filter"
|
||||||
@@ -24,6 +25,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
|||||||
/// Accent colour used to tint the palette card and the filter chip.
|
/// Accent colour used to tint the palette card and the filter chip.
|
||||||
var color: Color {
|
var color: Color {
|
||||||
switch self {
|
switch self {
|
||||||
|
case .amp: return Color(red: 0.70, green: 0.45, blue: 0.18) // warm valve-glow copper
|
||||||
case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12)
|
case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12)
|
||||||
case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32)
|
case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32)
|
||||||
case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55)
|
case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55)
|
||||||
@@ -42,9 +44,11 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static let mapping: [String: PedalCategory] = [
|
private static let mapping: [String: PedalCategory] = [
|
||||||
|
"California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "Chime": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Princeton": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp,
|
||||||
"Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain,
|
"Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain,
|
||||||
"Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics,
|
"Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics,
|
||||||
"Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter,
|
"Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter,
|
||||||
|
"Cabinet": .filter,
|
||||||
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
|
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
|
||||||
"Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .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,
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ public struct PedalPaletteView: View {
|
|||||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||||
private static let preferredOrder: [String] = [
|
private static let preferredOrder: [String] = [
|
||||||
"Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "Chime", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Princeton", "Jazz Clean", "Chime Top Boost", "Neural Amp", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||||
"Volume",
|
"Volume",
|
||||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
||||||
"Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
"Auto-Wah", "Wah", "Mutant", "Cabinet", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||||
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
|
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
|
||||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
|
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
|
||||||
"Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb",
|
"Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb",
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// PedalRebuildEnvironment.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
/// Environment action a leaf pedal control can call to ask the host to rebuild the board that
|
||||||
|
/// contains the given pedal — needed when a pedal setting that is *not* a live `@UIParam` (e.g.
|
||||||
|
/// the Neural Amp's model file, stored in ``Pedal/resourcePath``) changes and only takes effect
|
||||||
|
/// after the pedal's graph is rebuilt. Set once near the builder root; defaults to a no-op.
|
||||||
|
private struct PedalRebuildActionKey: EnvironmentKey {
|
||||||
|
static let defaultValue: @MainActor @Sendable (Pedal) -> Void = { _ in }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension EnvironmentValues {
|
||||||
|
/// Rebuilds the board containing the passed pedal. No-op unless the host installs it.
|
||||||
|
var pedalRebuildAction: @MainActor @Sendable (Pedal) -> Void {
|
||||||
|
get { self[PedalRebuildActionKey.self] }
|
||||||
|
set { self[PedalRebuildActionKey.self] = newValue }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ struct PedalSelectorKnobView: View {
|
|||||||
// MARK: - Input
|
// MARK: - Input
|
||||||
|
|
||||||
private let selector: PedalSelectorKnob
|
private let selector: PedalSelectorKnob
|
||||||
|
/// Called once when a drag ends on a different stop than it began — used to trigger a board
|
||||||
|
/// rebuild for `rebuildsOnChange` selectors. `nil` for plain live-value selectors.
|
||||||
|
private let onCommit: (() -> Void)?
|
||||||
|
|
||||||
// MARK: - Drag state
|
// MARK: - Drag state
|
||||||
|
|
||||||
@@ -37,8 +40,9 @@ struct PedalSelectorKnobView: View {
|
|||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
init(_ selector: PedalSelectorKnob) {
|
init(_ selector: PedalSelectorKnob, onCommit: (() -> Void)? = nil) {
|
||||||
self.selector = selector
|
self.selector = selector
|
||||||
|
self.onCommit = onCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Body
|
// MARK: - Body
|
||||||
@@ -100,7 +104,11 @@ struct PedalSelectorKnobView: View {
|
|||||||
selector.node.update(value)
|
selector.node.update(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onEnded { _ in dragInProgress = false }
|
.onEnded { _ in
|
||||||
|
let changed: Bool = currentIndex != dragStartIndex
|
||||||
|
dragInProgress = false
|
||||||
|
if changed { onCommit?() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public struct PedalSwitchView: View {
|
|||||||
Text(inert ? "\(pedalSwitch.label) (tempo off)" : pedalSwitch.label)
|
Text(inert ? "\(pedalSwitch.label) (tempo off)" : pedalSwitch.label)
|
||||||
.font(.system(size: PedalSwitchView.captionFontSize))
|
.font(.system(size: PedalSwitchView.captionFontSize))
|
||||||
.foregroundStyle(Color.white)
|
.foregroundStyle(Color.white)
|
||||||
|
.lineLimit(1)
|
||||||
}
|
}
|
||||||
.disabled(inert)
|
.disabled(inert)
|
||||||
.opacity(inert ? PedalSwitchView.tempoDisabledOpacity : 1.0)
|
.opacity(inert ? PedalSwitchView.tempoDisabledOpacity : 1.0)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import UniformTypeIdentifiers
|
||||||
import LyrebirdUI
|
import LyrebirdUI
|
||||||
import LyrebirdShoeGaze
|
import LyrebirdShoeGaze
|
||||||
|
|
||||||
@@ -16,6 +17,18 @@ import LyrebirdShoeGaze
|
|||||||
/// here in the UI target. Unrecognised names fall through to `.gray`.
|
/// here in the UI target. Unrecognised names fall through to `.gray`.
|
||||||
private func enclosureColor(for displayName: String) -> Color {
|
private func enclosureColor(for displayName: String) -> Color {
|
||||||
switch displayName {
|
switch displayName {
|
||||||
|
case "California": return Color(red: 0.20, green: 0.28, blue: 0.34) // West-Coast steel blue
|
||||||
|
case "British": return Color(red: 0.30, green: 0.16, blue: 0.10) // oxblood tolex
|
||||||
|
case "British Plexi": return Color(red: 0.34, green: 0.20, blue: 0.10) // gold-panel plexi
|
||||||
|
case "British JTM": return Color(red: 0.36, green: 0.24, blue: 0.12) // warm JTM bronze
|
||||||
|
case "British Bluesbreaker": return Color(red: 0.28, green: 0.22, blue: 0.12) // bluesbreaker tan
|
||||||
|
case "Chime": return Color(red: 0.16, green: 0.24, blue: 0.22) // vintage green
|
||||||
|
case "Fullerton Reverb": return Color(red: 0.15, green: 0.22, blue: 0.30) // blackface panel
|
||||||
|
case "Fullerton Deluxe": return Color(red: 0.17, green: 0.20, blue: 0.26) // blackface, warmer
|
||||||
|
case "Fullerton Princeton": return Color(red: 0.19, green: 0.19, blue: 0.23) // small blackface
|
||||||
|
case "Jazz Clean": return Color(red: 0.14, green: 0.30, blue: 0.34) // solid-state silver-teal
|
||||||
|
case "Chime Top Boost": return Color(red: 0.20, green: 0.32, blue: 0.20) // vox-green tolex
|
||||||
|
case "Neural Amp": return Color(red: 0.22, green: 0.16, blue: 0.30) // deep neural violet
|
||||||
case "Overdrive": return Color(red: 0.85, green: 0.42, blue: 0.08) // warm orange
|
case "Overdrive": return Color(red: 0.85, green: 0.42, blue: 0.08) // warm orange
|
||||||
case "Distortion": return Color(red: 0.80, green: 0.26, blue: 0.12) // hot rust
|
case "Distortion": return Color(red: 0.80, green: 0.26, blue: 0.12) // hot rust
|
||||||
case "Delay": return Color(red: 0.10, green: 0.55, blue: 0.55) // teal
|
case "Delay": return Color(red: 0.10, green: 0.55, blue: 0.55) // teal
|
||||||
@@ -39,6 +52,7 @@ private func enclosureColor(for displayName: String) -> Color {
|
|||||||
case "Limiter": return Color(red: 0.62, green: 0.16, blue: 0.20) // brick red
|
case "Limiter": return Color(red: 0.62, green: 0.16, blue: 0.20) // brick red
|
||||||
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
||||||
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
||||||
|
case "Cabinet": return Color(red: 0.50, green: 0.36, blue: 0.18) // tweed / cabinet tan
|
||||||
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
||||||
case "Flanger": return Color(red: 0.28, green: 0.52, blue: 0.78) // steel blue
|
case "Flanger": return Color(red: 0.28, green: 0.52, blue: 0.78) // steel blue
|
||||||
case "Vibrato": return Color(red: 0.42, green: 0.30, blue: 0.70) // violet-blue
|
case "Vibrato": return Color(red: 0.42, green: 0.30, blue: 0.70) // violet-blue
|
||||||
@@ -414,6 +428,10 @@ public struct PedalView: View {
|
|||||||
/// Horizontal gap between the Level knob and the bypass control in the bottom row.
|
/// Horizontal gap between the Level knob and the bypass control in the bottom row.
|
||||||
private static let bottomControlsSpacing: CGFloat = 18
|
private static let bottomControlsSpacing: CGFloat = 18
|
||||||
private static let sectionSpacing: CGFloat = 14
|
private static let sectionSpacing: CGFloat = 14
|
||||||
|
/// Neural Amp model row: label/button spacing, caption size, and caption opacity.
|
||||||
|
private static let neuralRowSpacing: CGFloat = 6
|
||||||
|
private static let neuralRowFontSize: CGFloat = 11
|
||||||
|
private static let neuralRowLabelOpacity: Double = 0.85
|
||||||
private static let namePlateCornerRadius: CGFloat = 8
|
private static let namePlateCornerRadius: CGFloat = 8
|
||||||
private static let namePlatePaddingH: CGFloat = 10
|
private static let namePlatePaddingH: CGFloat = 10
|
||||||
private static let namePlatePaddingV: CGFloat = 4
|
private static let namePlatePaddingV: CGFloat = 4
|
||||||
@@ -449,6 +467,13 @@ public struct PedalView: View {
|
|||||||
/// Presentation flag for the pedal info panel (description + control ranges).
|
/// Presentation flag for the pedal info panel (description + control ranges).
|
||||||
@State private var showInfo: Bool = false
|
@State private var showInfo: Bool = false
|
||||||
|
|
||||||
|
/// Presentation flag for the Neural Amp model-file importer.
|
||||||
|
@State private var showModelImporter: Bool = false
|
||||||
|
|
||||||
|
/// Rebuilds this pedal's board after a non-`@UIParam` change (Neural Amp model file). Injected
|
||||||
|
/// by the builder; no-op elsewhere.
|
||||||
|
@Environment(\.pedalRebuildAction) private var pedalRebuildAction: @MainActor @Sendable (Pedal) -> Void
|
||||||
|
|
||||||
/// The rig's control map, injected by the builder so the pedal can draw a mapping strip. `nil`
|
/// The rig's control map, injected by the builder so the pedal can draw a mapping strip. `nil`
|
||||||
/// when the rig has no bindings (or in contexts that don't set it) — the strip renders nothing.
|
/// when the rig has no bindings (or in contexts that don't set it) — the strip renders nothing.
|
||||||
@Environment(\.controlMappingMap) private var controlMappingMap: MIDIMap?
|
@Environment(\.controlMappingMap) private var controlMappingMap: MIDIMap?
|
||||||
@@ -474,7 +499,20 @@ public struct PedalView: View {
|
|||||||
// the enclosure-width calculation consume the same array.
|
// the enclosure-width calculation consume the same array.
|
||||||
let sliders: [PedalSlider] = pedal.effectSliders
|
let sliders: [PedalSlider] = pedal.effectSliders
|
||||||
|
|
||||||
ZStack(alignment: .topLeading) {
|
// Content is the sizing layer so the enclosure hugs it vertically — a short pedal stays
|
||||||
|
// short. The gradient fill and border/screw strokes are attached as background/overlay so
|
||||||
|
// they conform to the content height instead of a greedy `RoundedRectangle` in a ZStack
|
||||||
|
// dictating (and stretching) the height to fill the row.
|
||||||
|
Group {
|
||||||
|
if let looper: LooperPedal = pedal as? LooperPedal {
|
||||||
|
looperColumnarContent(looper)
|
||||||
|
} else {
|
||||||
|
defaultContent(sliders: sliders)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(PedalView.enclosurePadding)
|
||||||
|
.frame(width: enclosureWidth(for: sliders))
|
||||||
|
.background(
|
||||||
// Enclosure fill with top-to-bottom gradient
|
// Enclosure fill with top-to-bottom gradient
|
||||||
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius)
|
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius)
|
||||||
.fill(
|
.fill(
|
||||||
@@ -484,38 +522,28 @@ public struct PedalView: View {
|
|||||||
endPoint: .bottom
|
endPoint: .bottom
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
// Outer border
|
.overlay(
|
||||||
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius)
|
|
||||||
.stroke(Color.black.opacity(PedalView.outerBorderOpacity),
|
|
||||||
lineWidth: PedalView.outerBorderLineWidth)
|
|
||||||
|
|
||||||
// Inner highlight rim (subtle bevel)
|
// Inner highlight rim (subtle bevel)
|
||||||
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius - PedalView.innerHighlightPadding)
|
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius - PedalView.innerHighlightPadding)
|
||||||
.stroke(Color.white.opacity(PedalView.innerHighlightOpacity),
|
.stroke(Color.white.opacity(PedalView.innerHighlightOpacity),
|
||||||
lineWidth: PedalView.innerHighlightLineWidth)
|
lineWidth: PedalView.innerHighlightLineWidth)
|
||||||
.padding(PedalView.innerHighlightPadding)
|
.padding(PedalView.innerHighlightPadding)
|
||||||
|
)
|
||||||
// Content stack — the looper uses a wide, columnar layout to stay short; every other
|
.overlay(
|
||||||
// pedal uses the default single-column section stack.
|
// Outer border
|
||||||
Group {
|
RoundedRectangle(cornerRadius: PedalView.enclosureCornerRadius)
|
||||||
if let looper: LooperPedal = pedal as? LooperPedal {
|
.stroke(Color.black.opacity(PedalView.outerBorderOpacity),
|
||||||
looperColumnarContent(looper)
|
lineWidth: PedalView.outerBorderLineWidth)
|
||||||
} else {
|
)
|
||||||
defaultContent(sliders: sliders)
|
// Corner screws — overlaid at the four corners.
|
||||||
}
|
.overlay { screwCorners }
|
||||||
}
|
|
||||||
.padding(PedalView.enclosurePadding)
|
|
||||||
|
|
||||||
// Corner screws — overlaid at the four corners
|
|
||||||
screwCorners
|
|
||||||
|
|
||||||
// Info button, tucked just under the top-left corner screw.
|
// Info button, tucked just under the top-left corner screw.
|
||||||
|
.overlay(alignment: .topLeading) {
|
||||||
infoButton
|
infoButton
|
||||||
.padding(.leading, PedalView.infoButtonLeading)
|
.padding(.leading, PedalView.infoButtonLeading)
|
||||||
.padding(.top, PedalView.infoButtonTop)
|
.padding(.top, PedalView.infoButtonTop)
|
||||||
}
|
}
|
||||||
.frame(width: enclosureWidth(for: sliders))
|
|
||||||
.shadow(
|
.shadow(
|
||||||
color: Color.black.opacity(PedalView.shadowOpacity),
|
color: Color.black.opacity(PedalView.shadowOpacity),
|
||||||
radius: PedalView.shadowRadius,
|
radius: PedalView.shadowRadius,
|
||||||
@@ -535,6 +563,7 @@ public struct PedalView: View {
|
|||||||
VStack(spacing: PedalView.sectionSpacing) {
|
VStack(spacing: PedalView.sectionSpacing) {
|
||||||
namePlate
|
namePlate
|
||||||
knobGrid
|
knobGrid
|
||||||
|
neuralModelRow
|
||||||
selectorRow
|
selectorRow
|
||||||
switchRow
|
switchRow
|
||||||
// Keyed on the pedal instance so the buttons' live captions (which poll the pedal
|
// Keyed on the pedal instance so the buttons' live captions (which poll the pedal
|
||||||
@@ -543,7 +572,6 @@ public struct PedalView: View {
|
|||||||
.id(ObjectIdentifier(pedal))
|
.id(ObjectIdentifier(pedal))
|
||||||
buttonRow
|
buttonRow
|
||||||
sliderBank(sliders)
|
sliderBank(sliders)
|
||||||
Spacer(minLength: 0)
|
|
||||||
bottomControls
|
bottomControls
|
||||||
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
||||||
}
|
}
|
||||||
@@ -558,20 +586,20 @@ public struct PedalView: View {
|
|||||||
namePlate
|
namePlate
|
||||||
HStack(alignment: .top, spacing: PedalView.looperColumnSpacing) {
|
HStack(alignment: .top, spacing: PedalView.looperColumnSpacing) {
|
||||||
// Left column: timeline, then the Free/Sync switch, then the Reset footswitch.
|
// Left column: timeline, then the Free/Sync switch, then the Reset footswitch.
|
||||||
|
// No trailing Spacer — the flow canvas offers the row its full viewport height,
|
||||||
|
// and a greedy Spacer here would stretch the whole card to fill it (leaving a
|
||||||
|
// large empty gap). Each column sizes to its content, like every other pedal.
|
||||||
VStack(spacing: PedalView.sectionSpacing) {
|
VStack(spacing: PedalView.sectionSpacing) {
|
||||||
LooperTimelineView(pedal: looper)
|
LooperTimelineView(pedal: looper)
|
||||||
switchRow
|
switchRow
|
||||||
looperResetCell
|
looperResetCell
|
||||||
Spacer(minLength: 0)
|
|
||||||
}
|
}
|
||||||
.frame(width: PedalView.looperTimelineColumnWidth)
|
.frame(width: PedalView.looperTimelineColumnWidth)
|
||||||
|
|
||||||
// Centre column: the four effect knobs (2×2), with the Level + Bypass footer at the
|
// Centre column: the four effect knobs (2×2), with the Level + Bypass footer
|
||||||
// bottom. The Mix slot is reserved (empty) so Bypass stays horizontally centred,
|
// directly beneath (no greedy Spacer — see the left column note).
|
||||||
// matching a normal pedal's footer.
|
|
||||||
VStack(spacing: PedalView.sectionSpacing) {
|
VStack(spacing: PedalView.sectionSpacing) {
|
||||||
looperEffectKnobs(columns: 2)
|
looperEffectKnobs(columns: 2)
|
||||||
Spacer(minLength: 0)
|
|
||||||
looperFooter
|
looperFooter
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,9 +607,11 @@ public struct PedalView: View {
|
|||||||
looperTransportGrid(columns: 2)
|
looperTransportGrid(columns: 2)
|
||||||
.id(ObjectIdentifier(pedal))
|
.id(ObjectIdentifier(pedal))
|
||||||
}
|
}
|
||||||
Spacer(minLength: 0)
|
|
||||||
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
||||||
}
|
}
|
||||||
|
// Pin to intrinsic height so the enclosure hugs its content even though the flow
|
||||||
|
// canvas offers the row its full viewport height.
|
||||||
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The looper's effect knobs (everything except the trailing `Mix` / `Level`) laid out in
|
/// The looper's effect knobs (everything except the trailing `Mix` / `Level`) laid out in
|
||||||
@@ -755,20 +785,26 @@ public struct PedalView: View {
|
|||||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in
|
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in
|
||||||
PedalSelectorKnobView(pair.element)
|
PedalSelectorKnobView(
|
||||||
|
pair.element,
|
||||||
|
onCommit: pair.element.rebuildsOnChange
|
||||||
|
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||||
|
: nil
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Row of segmented switches drawn from `pedal.effectSwitches`, one per row, beneath
|
/// Row of segmented switches drawn from `pedal.effectSwitches`, laid out side by side beneath
|
||||||
/// the knob grid. Renders nothing when the pedal publishes no switches.
|
/// the knob grid. Renders nothing when the pedal publishes no switches. `.top` alignment keeps
|
||||||
|
/// the segment bars level even if one switch's caption wraps differently.
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var switchRow: some View {
|
private var switchRow: some View {
|
||||||
let switches: [PedalSwitch] = pedal.effectSwitches
|
let switches: [PedalSwitch] = pedal.effectSwitches
|
||||||
if !switches.isEmpty {
|
if !switches.isEmpty {
|
||||||
VStack(spacing: PedalView.knobSpacing) {
|
HStack(alignment: .top, spacing: PedalView.knobSpacing) {
|
||||||
ForEach(Array(switches.enumerated()), id: \.offset) { pair in
|
ForEach(Array(switches.enumerated()), id: \.offset) { pair in
|
||||||
PedalSwitchView(pair.element)
|
PedalSwitchView(pair.element)
|
||||||
}
|
}
|
||||||
@@ -841,6 +877,42 @@ public struct PedalView: View {
|
|||||||
|
|
||||||
/// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,
|
/// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,
|
||||||
/// side-by-side and centred — a symmetric knob-switch-knob footer shared by all pedals.
|
/// side-by-side and centred — a symmetric knob-switch-knob footer shared by all pedals.
|
||||||
|
/// Neural Amp only: shows the loaded model file name and a picker to load a `.json` capture.
|
||||||
|
/// Setting the model changes the graph, so after a pick it asks the host to rebuild the board.
|
||||||
|
@ViewBuilder
|
||||||
|
private var neuralModelRow: some View {
|
||||||
|
if let neural: NeuralAmpPedal = pedal as? NeuralAmpPedal {
|
||||||
|
VStack(spacing: PedalView.neuralRowSpacing) {
|
||||||
|
Text(neuralModelLabel(neural))
|
||||||
|
.font(.system(size: PedalView.neuralRowFontSize, weight: .medium))
|
||||||
|
.foregroundStyle(Color.white.opacity(PedalView.neuralRowLabelOpacity))
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.middle)
|
||||||
|
Button("Load Model…") { showModelImporter = true }
|
||||||
|
.buttonStyle(.bordered)
|
||||||
|
.controlSize(.small)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.fileImporter(
|
||||||
|
isPresented: $showModelImporter,
|
||||||
|
allowedContentTypes: [.json]
|
||||||
|
) { (result: Result<URL, Error>) in
|
||||||
|
guard case .success(let url) = result else { return }
|
||||||
|
// The app is unsandboxed, so a plain path read works; still bracket access defensively.
|
||||||
|
let accessed: Bool = url.startAccessingSecurityScopedResource()
|
||||||
|
neural.resourcePath = url.path
|
||||||
|
if accessed { url.stopAccessingSecurityScopedResource() }
|
||||||
|
pedalRebuildAction(neural)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loaded-model caption for the Neural Amp row — the model file's base name, or a prompt.
|
||||||
|
private func neuralModelLabel(_ neural: NeuralAmpPedal) -> String {
|
||||||
|
guard let path: String = neural.resourcePath, !path.isEmpty else { return "No model loaded" }
|
||||||
|
return (path as NSString).lastPathComponent
|
||||||
|
}
|
||||||
|
|
||||||
private var bottomControls: some View {
|
private var bottomControls: some View {
|
||||||
HStack(alignment: .center, spacing: PedalView.bottomControlsSpacing) {
|
HStack(alignment: .center, spacing: PedalView.bottomControlsSpacing) {
|
||||||
levelControl
|
levelControl
|
||||||
|
|||||||
@@ -670,6 +670,18 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
// Feed the rig's control map into the board tree so each pedal can draw its mapping strip.
|
// Feed the rig's control map into the board tree so each pedal can draw its mapping strip.
|
||||||
// Reading `shoeGaze.midiMap` here (observable) refreshes every strip when a binding changes.
|
// Reading `shoeGaze.midiMap` here (observable) refreshes every strip when a binding changes.
|
||||||
.environment(\.controlMappingMap, shoeGaze.midiMap)
|
.environment(\.controlMappingMap, shoeGaze.midiMap)
|
||||||
|
// Let a pedal (e.g. Neural Amp on a model-file change) request a rebuild of its board.
|
||||||
|
// Captures only `shoeGaze` (a @MainActor session); `rebuildBoard` is safe on a running
|
||||||
|
// engine (at most one block of glitch).
|
||||||
|
.environment(\.pedalRebuildAction, { @MainActor [shoeGaze] (pedal: Pedal) in
|
||||||
|
// Branch-aware lookup — the pedal may live inside a parallel / stereo-split section.
|
||||||
|
guard let board: PedalBoard = shoeGaze.board(containing: pedal) else { return }
|
||||||
|
do {
|
||||||
|
_ = try shoeGaze.rebuildBoard(board, from: board.captureState())
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGaze] board rebuild after model change failed: \(error)")
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Compact layout (iPhone / narrow iPad)
|
// MARK: - Compact layout (iPhone / narrow iPad)
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
// AmpVoicePedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("AmpVoicePedal")
|
||||||
|
struct AmpVoicePedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: P = make()
|
||||||
|
pedal.inputBus = srcBus.index
|
||||||
|
pedal.outputBus = dstBus.index
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sum-of-squared-differences after RMS-normalizing each window, so a pure level difference
|
||||||
|
/// collapses to ~0 and only a genuine waveshape (saturation) change registers.
|
||||||
|
private func rmsNormalizedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||||
|
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||||
|
func rms(_ x: ArraySlice<Float>) -> Double {
|
||||||
|
let sumSq: Double = x.reduce(0.0) { $0 + Double($1) * Double($1) }
|
||||||
|
return (sumSq / Double(x.count)).squareRoot()
|
||||||
|
}
|
||||||
|
let ra: Double = rms(aw)
|
||||||
|
let rb: Double = rms(bw)
|
||||||
|
guard ra > 0.0, rb > 0.0 else { return 0.0 }
|
||||||
|
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0) / ra - Double(pair.1) / rb
|
||||||
|
return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The three concrete voices under test, keyed by their display name / registry key.
|
||||||
|
private let voices: [(name: String, make: () -> AmpVoicePedal)] = [
|
||||||
|
("California", { CaliforniaAmpPedal() }),
|
||||||
|
("British", { BritishAmpPedal() }),
|
||||||
|
("Chime", { ChimeAmpPedal() }),
|
||||||
|
]
|
||||||
|
|
||||||
|
@Test func allVoicesBuildNonSilentFiniteOutput() throws {
|
||||||
|
for voice in voices {
|
||||||
|
let samples: [Float] = try render(voice.make)
|
||||||
|
#expect(!samples.isEmpty)
|
||||||
|
#expect(hasNonSilentOutput(samples), "\(voice.name) produced silence")
|
||||||
|
#expect(samples.allSatisfy { $0.isFinite }, "\(voice.name) produced non-finite output")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func gainChangesOutput() throws {
|
||||||
|
for voice in voices {
|
||||||
|
let clean: [Float] = try render(voice.make) { $0.gain = 2.0 }
|
||||||
|
let hot: [Float] = try render(voice.make) { $0.gain = 25.0 }
|
||||||
|
#expect(windowedSSD(clean, hot) > 0, "\(voice.name) gain had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func toneControlsChangeOutput() throws {
|
||||||
|
for voice in voices {
|
||||||
|
let dark: [Float] = try render(voice.make) { $0.treble = 0.0; $0.bass = 1.0 }
|
||||||
|
let bright: [Float] = try render(voice.make) { $0.treble = 1.0; $0.bass = 0.0 }
|
||||||
|
#expect(windowedSSD(dark, bright) > 0, "\(voice.name) tone controls had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func midChangesOutput() throws {
|
||||||
|
for voice in voices {
|
||||||
|
let scooped: [Float] = try render(voice.make) { $0.mid = 0.0 }
|
||||||
|
let full: [Float] = try render(voice.make) { $0.mid = 1.0 }
|
||||||
|
#expect(windowedSSD(scooped, full) > 0, "\(voice.name) mid control had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cabChangesOutput() throws {
|
||||||
|
for voice in voices {
|
||||||
|
let cabA: [Float] = try render(voice.make) { $0.cab = 0.0 }
|
||||||
|
let cabB: [Float] = try render(voice.make) { $0.cab = 2.0 }
|
||||||
|
#expect(windowedSSD(cabA, cabB) > 0, "\(voice.name) cab selection had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func outputStaysWithinDigitalCeiling() throws {
|
||||||
|
// The tanh soft-limits and the trailing Clip(±1) hard-clamps, so no sample may exceed ±1
|
||||||
|
// (a tiny epsilon covers float round-trip through the CAF). Drive every voice hard.
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
for voice in voices {
|
||||||
|
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) peak \(peak) exceeds the ±1 ceiling")
|
||||||
|
#expect(peak > 0.3, "\(voice.name) unexpectedly quiet at max gain: \(peak)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Signature controls
|
||||||
|
|
||||||
|
@Test func californiaBrightChangesOutput() throws {
|
||||||
|
let flat: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 0.0 }
|
||||||
|
let sparkle: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, sparkle) > 0, "California Bright had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func britishPresenceChangesOutput() throws {
|
||||||
|
let flat: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 0.0 }
|
||||||
|
let lifted: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, lifted) > 0, "British Presence had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func britishMasterDrivesPowerAmp() throws {
|
||||||
|
// Master drives the power-amp stage into saturation — so it must change the *waveshape*, not
|
||||||
|
// just the level (which is what `level` would do). RMS-normalize each window before diffing:
|
||||||
|
// a pure level change collapses to ~0, so a clearly-positive normalized SSD proves genuine
|
||||||
|
// power-amp saturation.
|
||||||
|
let low: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 0.1 }
|
||||||
|
let high: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 1.0 }
|
||||||
|
#expect(hasNonSilentOutput(low) && hasNonSilentOutput(high))
|
||||||
|
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "Master changed level but not tone (no power-amp saturation)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func britishStaysWithinCeilingAtMaxMaster() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
let hot: [Float] = try render({ BritishAmpPedal() }) { (pedal: BritishAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.master = 1.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "British peak \(peak) exceeds the ±1 ceiling at max Master")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func britishMasterRoundTripsThroughState() throws {
|
||||||
|
let pedal: BritishAmpPedal = BritishAmpPedal()
|
||||||
|
pedal.master = 0.8
|
||||||
|
let restored: BritishAmpPedal = BritishAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.master == 0.8, "Master did not round-trip")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chimeCutChangesOutput() throws {
|
||||||
|
let open: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 0.0 }
|
||||||
|
let dark: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 1.0 }
|
||||||
|
#expect(windowedSSD(open, dark) > 0, "Chime Cut had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Chrome / config
|
||||||
|
|
||||||
|
@Test func exposesControls() throws {
|
||||||
|
#expect(CaliforniaAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Bright"])
|
||||||
|
#expect(BritishAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"])
|
||||||
|
#expect(ChimeAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Cut"])
|
||||||
|
for voice in voices {
|
||||||
|
let pedal: AmpVoicePedal = voice.make()
|
||||||
|
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(voice.name) selectors")
|
||||||
|
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true,
|
||||||
|
"\(voice.name) cab selector should rebuild on change")
|
||||||
|
#expect(pedal.widthUnits == 2, "\(voice.name) amp head should use a double-width card")
|
||||||
|
#expect(pedal.showsMixControl == false, "\(voice.name) should be fully wet")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func distinctToneStackModels() throws {
|
||||||
|
#expect(CaliforniaAmpPedal().toneStackModel == .fender)
|
||||||
|
#expect(BritishAmpPedal().toneStackModel == .marshall)
|
||||||
|
#expect(ChimeAmpPedal().toneStackModel == .vox)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func selectionsRoundTripThroughState() throws {
|
||||||
|
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||||
|
pedal.gain = 12.0
|
||||||
|
pedal.cab = 2.0
|
||||||
|
pedal.bright = 0.8
|
||||||
|
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.gain == 12.0 && restored.cab == 2.0 && restored.bright == 0.8,
|
||||||
|
"California controls did not round-trip")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "California") is CaliforniaAmpPedal)
|
||||||
|
#expect(PedalRegistry.makePedal(type: "British") is BritishAmpPedal)
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Chime") is ChimeAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -461,6 +461,33 @@ struct BoardEditAPITests {
|
|||||||
#expect(hasNonSilentOutput(samples), "stereo-split board should render audio")
|
#expect(hasNonSilentOutput(samples), "stereo-split board should render audio")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func boardContainingFindsMainAndBranchPedals() throws {
|
||||||
|
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||||
|
try makeRig(pedals: ["Overdrive"])
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
// Main-chain pedal is found.
|
||||||
|
guard let mainPedal: Pedal = board.pedals.first else {
|
||||||
|
Issue.record("no main pedal"); return
|
||||||
|
}
|
||||||
|
#expect(sg.board(containing: mainPedal) === board)
|
||||||
|
|
||||||
|
// A pedal inside a stereo-split branch is also found (the fix: not just the main chain).
|
||||||
|
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||||
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
|
var branchPedal: Pedal?
|
||||||
|
for segment: BoardSegment in live.orderedSegments {
|
||||||
|
if case .stereoSplit(let section) = segment { branchPedal = section.left.pedals.first }
|
||||||
|
}
|
||||||
|
guard let branch: Pedal = branchPedal else {
|
||||||
|
Issue.record("no branch pedal"); return
|
||||||
|
}
|
||||||
|
#expect(sg.board(containing: branch) === live, "branch pedal should resolve to its board")
|
||||||
|
|
||||||
|
// A pedal not in any board resolves to nil.
|
||||||
|
#expect(sg.board(containing: OverdrivePedal()) == nil)
|
||||||
|
}
|
||||||
|
|
||||||
@Test func removePedalFromBranchLane() throws {
|
@Test func removePedalFromBranchLane() throws {
|
||||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||||
try makeRig(pedals: ["Overdrive"])
|
try makeRig(pedals: ["Overdrive"])
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
// BritishComboAmpPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("British non-master combos")
|
||||||
|
struct BritishComboAmpPedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: P = make()
|
||||||
|
pedal.inputBus = srcBus.index
|
||||||
|
pedal.outputBus = dstBus.index
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let voices: [(name: String, make: () -> BritishComboAmpPedal)] = [
|
||||||
|
("British Plexi", { BritishPlexiAmpPedal() }),
|
||||||
|
("British JTM", { BritishJTMAmpPedal() }),
|
||||||
|
("British Bluesbreaker", { BritishBluesbreakerAmpPedal() }),
|
||||||
|
]
|
||||||
|
|
||||||
|
@Test func allBuildNonSilentFinite() throws {
|
||||||
|
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||||
|
let s: [Float] = try render(v.make)
|
||||||
|
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||||
|
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func presenceChangesOutput() throws {
|
||||||
|
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||||
|
let low: [Float] = try render(v.make) { $0.presence = 0.0 }
|
||||||
|
let high: [Float] = try render(v.make) { $0.presence = 1.0 }
|
||||||
|
#expect(windowedSSD(low, high) > 0, "\(v.name) Presence had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func brightSwitchChangesOutput() throws {
|
||||||
|
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||||
|
let flat: [Float] = try render(v.make) { $0.bright = 0.0 }
|
||||||
|
let bright: [Float] = try render(v.make) { $0.bright = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, bright) > 0, "\(v.name) Bright had no effect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func areMarshallVoicedNonMaster() throws {
|
||||||
|
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||||
|
let pedal: BritishComboAmpPedal = v.make()
|
||||||
|
#expect(pedal.toneStackModel == .marshall, "\(v.name) tone stack")
|
||||||
|
// Non-master: no "Master" knob (that is the separate BritishAmpPedal voice).
|
||||||
|
#expect(!pedal.effectKnobs.map { $0.label }.contains("Master"), "\(v.name) should be non-master")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func plexiAndJTMExposePresenceAndBright() throws {
|
||||||
|
for pedal: BritishComboAmpPedal in [BritishPlexiAmpPedal(), BritishJTMAmpPedal()] {
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"])
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func voicesDifferFromEachOther() throws {
|
||||||
|
let cfg: (BritishComboAmpPedal) -> Void = { $0.gain = 6.0 }
|
||||||
|
let plexi: [Float] = try render({ BritishPlexiAmpPedal() }, configure: cfg)
|
||||||
|
let jtm: [Float] = try render({ BritishJTMAmpPedal() }, configure: cfg)
|
||||||
|
#expect(windowedSSD(plexi, jtm) > 0, "Plexi and JTM should voice differently")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Bluesbreaker tremolo
|
||||||
|
|
||||||
|
@Test func bluesbreakerExposesTremolo() throws {
|
||||||
|
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Speed", "Intensity"])
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Tremolo"])
|
||||||
|
#expect(pedal.widthUnits == 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func bluesbreakerTremoloIntensityChangesOutput() throws {
|
||||||
|
let off: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||||
|
let on: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||||
|
#expect(windowedSSD(off, on) > 0, "Bluesbreaker tremolo had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func bluesbreakerTremoloFootswitchBypassesToIdentity() throws {
|
||||||
|
let bypassed: [Float] = try render({ BritishBluesbreakerAmpPedal() }) {
|
||||||
|
$0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0
|
||||||
|
}
|
||||||
|
let noTremolo: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||||
|
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func stayWithinCeilingAtMaxGain() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||||
|
let hot: [Float] = try render(v.make) { (pedal: BritishComboAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.presence = 1.0
|
||||||
|
pedal.bright = 1.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "\(v.name) peak \(peak) exceeds the ±1 ceiling")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func roundTripsThroughState() throws {
|
||||||
|
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||||
|
pedal.presence = 0.7
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.speed = 9.0
|
||||||
|
pedal.intensity = 0.5
|
||||||
|
pedal.tremoloEnabled = 0.0
|
||||||
|
pedal.cab = 2.0
|
||||||
|
let restored: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.presence == 0.7 && restored.bright == 1.0 && restored.speed == 9.0)
|
||||||
|
#expect(restored.intensity == 0.5 && restored.tremoloEnabled == 0.0 && restored.cab == 2.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "British Plexi") is BritishPlexiAmpPedal)
|
||||||
|
#expect(PedalRegistry.makePedal(type: "British JTM") is BritishJTMAmpPedal)
|
||||||
|
#expect(PedalRegistry.makePedal(type: "British Bluesbreaker") is BritishBluesbreakerAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
// CabinetIRFactoryTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("CabinetIRFactory")
|
||||||
|
struct CabinetIRFactoryTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
/// Goertzel magnitude of the IR's frequency response at `hz`.
|
||||||
|
private func responseMagnitude(_ ir: LyrebirdBuffer, hz: Double) -> Double {
|
||||||
|
let omega: Double = 2.0 * Double.pi * hz / sampleRate
|
||||||
|
let cosine: Double = cos(omega)
|
||||||
|
let sine: Double = sin(omega)
|
||||||
|
let coeff: Double = 2.0 * cosine
|
||||||
|
var s1: Double = 0.0
|
||||||
|
var s2: Double = 0.0
|
||||||
|
for i: Int in 0..<ir.count {
|
||||||
|
let s0: Double = ir[i, 0] + coeff * s1 - s2
|
||||||
|
s2 = s1
|
||||||
|
s1 = s0
|
||||||
|
}
|
||||||
|
let real: Double = s1 - s2 * cosine
|
||||||
|
let imag: Double = s2 * sine
|
||||||
|
return (real * real + imag * imag).squareRoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func producesFiniteNormalizedMonoIR() {
|
||||||
|
for voice: CabinetVoice in CabinetVoice.allCases {
|
||||||
|
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate)
|
||||||
|
#expect(ir.channelCount == 1)
|
||||||
|
#expect(ir.count == CabinetIRFactory.defaultFrames)
|
||||||
|
var peak: Double = 0.0
|
||||||
|
for i: Int in 0..<ir.count {
|
||||||
|
let v: Double = ir[i, 0]
|
||||||
|
#expect(v.isFinite, "\(voice) IR had non-finite sample")
|
||||||
|
peak = Swift.max(peak, abs(v))
|
||||||
|
}
|
||||||
|
#expect(peak > 0.9 && peak <= 1.0001, "\(voice) IR not peak-normalized: \(peak)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func rollsOffLowAndHighFrequencies() {
|
||||||
|
// A speaker cab attenuates sub-bass and high treble relative to the midrange.
|
||||||
|
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||||
|
let low: Double = responseMagnitude(ir, hz: 40.0) // below the ~80 Hz high-pass
|
||||||
|
let mid: Double = responseMagnitude(ir, hz: 800.0) // passband
|
||||||
|
let high: Double = responseMagnitude(ir, hz: 12000.0) // above the ~5.5 kHz low-pass
|
||||||
|
#expect(mid > low * 2.0, "low end not attenuated (mid=\(mid) low=\(low))")
|
||||||
|
#expect(mid > high * 2.0, "high end not attenuated (mid=\(mid) high=\(high))")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func voicesDifferInResponse() {
|
||||||
|
let american: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||||
|
let dark: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .vintageDark, sampleRate: sampleRate)
|
||||||
|
// The darker voice rolls off earlier, so it has less 5 kHz energy than the American voice.
|
||||||
|
let americanHigh: Double = responseMagnitude(american, hz: 5000.0)
|
||||||
|
let darkHigh: Double = responseMagnitude(dark, hz: 5000.0)
|
||||||
|
#expect(americanHigh > darkHigh, "vintageDark should be darker at 5 kHz")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func fullRangeExtendsHigherThanCombo() {
|
||||||
|
// Full-Range (FRFR) has a ~9 kHz low-pass vs the American combo's ~5.5 kHz, so it keeps
|
||||||
|
// markedly more energy at 8 kHz.
|
||||||
|
let frfr: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, sampleRate: sampleRate)
|
||||||
|
let combo: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate)
|
||||||
|
let frfrHigh: Double = responseMagnitude(frfr, hz: 8000.0)
|
||||||
|
let comboHigh: Double = responseMagnitude(combo, hz: 8000.0)
|
||||||
|
#expect(frfrHigh > comboHigh * 2.0, "FRFR should keep more 8 kHz than the combo")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func notchCreatesMidDip() {
|
||||||
|
// Modern 4×12 has a deep interference notch at 1.7 kHz. Its response there should dip below
|
||||||
|
// the surrounding midrange (points chosen clear of the body / presence peaks).
|
||||||
|
let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .modernStack, sampleRate: sampleRate)
|
||||||
|
let atNotch: Double = responseMagnitude(ir, hz: 1700.0)
|
||||||
|
let below: Double = responseMagnitude(ir, hz: 1100.0)
|
||||||
|
let above: Double = responseMagnitude(ir, hz: 2400.0)
|
||||||
|
#expect(atNotch < below, "notch did not dip below the lower midrange")
|
||||||
|
#expect(atNotch < above, "notch did not dip below the upper midrange")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func loFiIsDarkerThanFullRange() {
|
||||||
|
// Lo-Fi 1×8 rolls off at ~3 kHz vs Full-Range's ~9 kHz, so it is markedly darker at 4 kHz.
|
||||||
|
let loFi: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .loFiBox, sampleRate: sampleRate)
|
||||||
|
let frfr: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, sampleRate: sampleRate)
|
||||||
|
#expect(responseMagnitude(frfr, hz: 4000.0) > responseMagnitude(loFi, hz: 4000.0),
|
||||||
|
"Lo-Fi should be darker than Full-Range at 4 kHz")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func breakupPeakLiftsUpperMid() {
|
||||||
|
// Bright 1×12 (breakup +3 dB @ 5.2 kHz, LP 6.5 kHz) keeps more ~5.1 kHz energy than
|
||||||
|
// Boutique 2×12 (breakup +1.5 dB @ 5.0 kHz, LP 6.0 kHz) — both the stronger breakup boost
|
||||||
|
// and the higher low-pass push the same direction.
|
||||||
|
let bright: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .brightCombo, sampleRate: sampleRate)
|
||||||
|
let boutique: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .boutiqueOpen, sampleRate: sampleRate)
|
||||||
|
#expect(responseMagnitude(bright, hz: 5100.0) > responseMagnitude(boutique, hz: 5100.0),
|
||||||
|
"brightCombo should have more upper-mid bite than boutiqueOpen at 5.1 kHz")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func voiceNamesAreUnique() {
|
||||||
|
let names: [String] = CabinetVoice.allCases.map { $0.displayName }
|
||||||
|
#expect(Set(names).count == names.count, "duplicate cabinet display names")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// CabinetPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("CabinetPedal")
|
||||||
|
struct CabinetPedalTests {
|
||||||
|
|
||||||
|
private func render(configure: (CabinetPedal) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let sampleRate: Double = 48000.0
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: CabinetPedal = CabinetPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||||
|
let samples: [Float] = try render()
|
||||||
|
#expect(!samples.isEmpty)
|
||||||
|
#expect(hasNonSilentOutput(samples), "CabinetPedal produced silence")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cabinetSelectionChangesOutput() throws {
|
||||||
|
// Index 0 = American 1×12, index 2 = Vintage Dark — different voicings, different output.
|
||||||
|
let american: [Float] = try render { $0.cabinet = 0.0 }
|
||||||
|
let dark: [Float] = try render { $0.cabinet = 2.0 }
|
||||||
|
#expect(hasNonSilentOutput(american) && hasNonSilentOutput(dark))
|
||||||
|
|
||||||
|
let skip: Int = 4096
|
||||||
|
let window: Int = 4096
|
||||||
|
guard american.count >= skip + window, dark.count >= skip + window else { return }
|
||||||
|
let ssd: Double = zip(american[skip..<(skip + window)], dark[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
#expect(ssd > 0, "cabinet selection had no effect on output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func exposesCabinetSelector() throws {
|
||||||
|
let pedal: CabinetPedal = CabinetPedal()
|
||||||
|
let labels: [String] = pedal.effectSelectors.map { $0.label }
|
||||||
|
#expect(labels == ["Cab"])
|
||||||
|
// One stop per voice, in allCases order.
|
||||||
|
let stops: [String] = pedal.effectSelectors.first?.stops.map { $0.title } ?? []
|
||||||
|
#expect(stops == CabinetVoice.allCases.map { $0.displayName })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cabinetSelectorRebuildsOnChange() throws {
|
||||||
|
// Only the selected voice's convolver is built, so changing it must rebuild the board.
|
||||||
|
let pedal: CabinetPedal = CabinetPedal()
|
||||||
|
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func voiceAtSelectorValueClampsAndRounds() throws {
|
||||||
|
let all: [CabinetVoice] = CabinetVoice.allCases
|
||||||
|
#expect(CabinetVoice.voice(atSelectorValue: 0.0) == all[0])
|
||||||
|
#expect(CabinetVoice.voice(atSelectorValue: 2.0) == all[2])
|
||||||
|
#expect(CabinetVoice.voice(atSelectorValue: 1.4) == all[1], "should round to nearest stop")
|
||||||
|
#expect(CabinetVoice.voice(atSelectorValue: -5.0) == all[0], "clamp below 0")
|
||||||
|
#expect(CabinetVoice.voice(atSelectorValue: 999.0) == all[all.count - 1], "clamp above max")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cabinetSelectionRoundTripsThroughState() throws {
|
||||||
|
// The selector value must survive capture/apply (preset round-trip).
|
||||||
|
let pedal: CabinetPedal = CabinetPedal()
|
||||||
|
pedal.cabinet = 2.0
|
||||||
|
let state: PedalState = pedal.captureState()
|
||||||
|
let restored: CabinetPedal = CabinetPedal()
|
||||||
|
restored.applyState(state)
|
||||||
|
#expect(restored.cabinet == 2.0, "cabinet selection did not round-trip through PedalState")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
let pedal: Pedal? = PedalRegistry.makePedal(type: "Cabinet")
|
||||||
|
#expect(pedal is CabinetPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
// ChimeTopBoostAmpPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("ChimeTopBoostAmpPedal")
|
||||||
|
struct ChimeTopBoostAmpPedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
private func render(configure: (ChimeTopBoostAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal(
|
||||||
|
inputBus: srcBus.index, outputBus: dstBus.index)
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func buildsNonSilentFiniteOutput() throws {
|
||||||
|
let samples: [Float] = try render()
|
||||||
|
#expect(!samples.isEmpty)
|
||||||
|
#expect(hasNonSilentOutput(samples), "Chime Top Boost produced silence")
|
||||||
|
#expect(samples.allSatisfy { $0.isFinite }, "Chime Top Boost produced non-finite output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cutChangesOutput() throws {
|
||||||
|
let open: [Float] = try render { $0.cut = 0.0 }
|
||||||
|
let dark: [Float] = try render { $0.cut = 1.0 }
|
||||||
|
#expect(windowedSSD(open, dark) > 0, "Cut had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func tremoloIntensityChangesOutput() throws {
|
||||||
|
let off: [Float] = try render { $0.intensity = 0.0 }
|
||||||
|
let on: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||||
|
#expect(windowedSSD(off, on) > 0, "tremolo intensity had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func tremoloSpeedChangesOutput() throws {
|
||||||
|
let slow: [Float] = try render { $0.intensity = 1.0; $0.speed = 1.0 }
|
||||||
|
let fast: [Float] = try render { $0.intensity = 1.0; $0.speed = 10.0 }
|
||||||
|
#expect(windowedSSD(slow, fast) > 0, "tremolo speed had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func brilliantSwitchChangesOutput() throws {
|
||||||
|
let flat: [Float] = try render { $0.brilliant = 0.0 }
|
||||||
|
let bright: [Float] = try render { $0.brilliant = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, bright) > 0, "brilliant switch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func tremoloFootswitchBypassesToIdentity() throws {
|
||||||
|
// Footswitch off with Intensity up must equal no tremolo (Intensity 0), and differ from on.
|
||||||
|
// The differing `speed` is harmless: with depth gated to 0 the LFO is a constant 1.0.
|
||||||
|
let bypassed: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0 }
|
||||||
|
let noTremolo: [Float] = try render { $0.intensity = 0.0 }
|
||||||
|
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||||
|
let engaged: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 1.0 }
|
||||||
|
#expect(windowedSSD(bypassed, engaged) > 0, "tremolo footswitch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
let hot: [Float] = try render { (pedal: ChimeTopBoostAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.brilliant = 1.0
|
||||||
|
pedal.intensity = 1.0
|
||||||
|
pedal.speed = 6.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "peak \(peak) exceeds the ±1 ceiling")
|
||||||
|
#expect(peak > 0.3, "unexpectedly quiet at max gain: \(peak)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func exposesFullControlSurface() throws {
|
||||||
|
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label }
|
||||||
|
== ["Gain", "Bass", "Mid", "Treble", "Cut", "Speed", "Intensity"])
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Brilliant", "Tremolo"])
|
||||||
|
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||||
|
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||||
|
#expect(pedal.widthUnits == 3)
|
||||||
|
#expect(pedal.showsMixControl == false)
|
||||||
|
#expect(pedal.toneStackModel == .vox)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func controlsRoundTripThroughState() throws {
|
||||||
|
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||||
|
pedal.gain = 7.0
|
||||||
|
pedal.cut = 0.6
|
||||||
|
pedal.speed = 9.0
|
||||||
|
pedal.intensity = 0.5
|
||||||
|
pedal.brilliant = 1.0
|
||||||
|
pedal.tremoloEnabled = 0.0
|
||||||
|
pedal.cab = 2.0
|
||||||
|
let restored: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.gain == 7.0)
|
||||||
|
#expect(restored.cut == 0.6)
|
||||||
|
#expect(restored.speed == 9.0)
|
||||||
|
#expect(restored.intensity == 0.5)
|
||||||
|
#expect(restored.brilliant == 1.0)
|
||||||
|
#expect(restored.tremoloEnabled == 0.0)
|
||||||
|
#expect(restored.cab == 2.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Chime Top Boost") is ChimeTopBoostAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,6 +105,82 @@ struct CompressorPedalTests {
|
|||||||
#expect(labels == ["Input", "Threshold", "Ratio"])
|
#expect(labels == ["Input", "Threshold", "Ratio"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func exposesSafetySwitch() throws {
|
||||||
|
let pedal: CompressorPedal = CompressorPedal()
|
||||||
|
let switchLabels: [String] = pedal.effectSwitches.map { $0.label }
|
||||||
|
#expect(switchLabels == ["Safety"])
|
||||||
|
let optionTitles: [String] = pedal.effectSwitches.first?.options.map { $0.title } ?? []
|
||||||
|
#expect(optionTitles == ["Off", "On"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func safetyLimiterCapsPeaks() throws {
|
||||||
|
// Drive the compressor hard (hot input + makeup gain) so its non-zero attack lets
|
||||||
|
// transients overshoot. With the safety limiter engaged the output peak must stay
|
||||||
|
// near full scale; the two switch states must also produce different output.
|
||||||
|
let renderDuration: Double = 0.1
|
||||||
|
let sampleRate: Double = 44100.0
|
||||||
|
|
||||||
|
func render(safety: Double) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: renderDuration,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: CompressorPedal = CompressorPedal(
|
||||||
|
inputBus: srcBus.index,
|
||||||
|
outputBus: dstBus.index
|
||||||
|
)
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
pedal.inputGain = 24.0
|
||||||
|
pedal.threshold = -30.0
|
||||||
|
pedal.ratio = 8.0
|
||||||
|
pedal.safetyLimiter = safety
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
let off: [Float] = try render(safety: 0.0)
|
||||||
|
let on: [Float] = try render(safety: 1.0)
|
||||||
|
|
||||||
|
#expect(hasNonSilentOutput(off), "safety-off render was silent")
|
||||||
|
#expect(hasNonSilentOutput(on), "safety-on render was silent")
|
||||||
|
|
||||||
|
// Skip the safety limiter's look-ahead fill window before measuring the peak.
|
||||||
|
let lookAheadFillSamples: Int = 2048
|
||||||
|
guard on.count > lookAheadFillSamples else { return }
|
||||||
|
let onWindow: ArraySlice<Float> = on[lookAheadFillSamples...]
|
||||||
|
let onPeak: Float = onWindow.reduce(0) { Swift.max($0, abs($1)) }
|
||||||
|
|
||||||
|
// Safety ceiling is just under full scale; downstream master only attenuates.
|
||||||
|
let ceilingTolerance: Float = 0.05
|
||||||
|
#expect(onPeak <= 1.0 + ceilingTolerance, "safety limiter failed to cap peak: \(onPeak)")
|
||||||
|
|
||||||
|
// The two switch positions must differ.
|
||||||
|
let skip: Int = lookAheadFillSamples
|
||||||
|
let window: Int = 2048
|
||||||
|
guard off.count >= skip + window, on.count >= skip + window else { return }
|
||||||
|
let offWindow: [Float] = Array(off[skip..<(skip + window)])
|
||||||
|
let onWindow2: [Float] = Array(on[skip..<(skip + window)])
|
||||||
|
let ssd: Double = zip(offWindow, onWindow2).reduce(0.0) { acc, pair in
|
||||||
|
let diff: Double = Double(pair.0 - pair.1)
|
||||||
|
return acc + diff * diff
|
||||||
|
}
|
||||||
|
#expect(ssd > 0, "safety switch had no effect on output")
|
||||||
|
}
|
||||||
|
|
||||||
@Test func inputGainChangesOutput() throws {
|
@Test func inputGainChangesOutput() throws {
|
||||||
// The pre-compression input gain stage must alter the output: boosting the input
|
// The pre-compression input gain stage must alter the output: boosting the input
|
||||||
// drives more of the signal past the threshold, changing the compressed result.
|
// drives more of the signal past the threshold, changing the compressed result.
|
||||||
|
|||||||
@@ -84,6 +84,16 @@ struct DistortionPedalTests {
|
|||||||
#expect(labels == ["Drive", "Tone"])
|
#expect(labels == ["Drive", "Tone"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func outputStaysBoundedAtHighDrive() throws {
|
||||||
|
// The final hard clip (after the tone low-pass) must re-establish the ±1 output bound
|
||||||
|
// even at extreme drive, despite the oversampled clip sitting before the low-pass.
|
||||||
|
let samples: [Float] = try render { pedal in pedal.drive = 50.0; pedal.tone = 6000.0 }
|
||||||
|
let skip: Int = 2048
|
||||||
|
guard samples.count > skip else { return }
|
||||||
|
let peak: Float = samples[skip...].reduce(0) { Swift.max($0, abs($1)) }
|
||||||
|
#expect(peak <= 1.05, "distortion output exceeded the clip ceiling: peak=\(peak)")
|
||||||
|
}
|
||||||
|
|
||||||
@Test func registeredInBuiltInRegistry() throws {
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Distortion")
|
let pedal: Pedal? = PedalRegistry.makePedal(type: "Distortion")
|
||||||
#expect(pedal is DistortionPedal)
|
#expect(pedal is DistortionPedal)
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
// FullertonReverbAmpPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("FullertonReverbAmpPedal")
|
||||||
|
struct FullertonReverbAmpPedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
private func render(configure: (FullertonReverbAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal(
|
||||||
|
inputBus: srcBus.index, outputBus: dstBus.index)
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func buildsNonSilentFiniteOutput() throws {
|
||||||
|
let samples: [Float] = try render()
|
||||||
|
#expect(!samples.isEmpty)
|
||||||
|
#expect(hasNonSilentOutput(samples), "Fullerton Reverb produced silence")
|
||||||
|
#expect(samples.allSatisfy { $0.isFinite }, "Fullerton Reverb produced non-finite output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reverbMixChangesOutput() throws {
|
||||||
|
let dry: [Float] = try render { $0.reverb = 0.0 }
|
||||||
|
let wet: [Float] = try render { $0.reverb = 0.9 }
|
||||||
|
#expect(windowedSSD(dry, wet) > 0, "reverb mix had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func tremoloIntensityChangesOutput() throws {
|
||||||
|
let off: [Float] = try render { $0.intensity = 0.0 }
|
||||||
|
let on: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||||
|
#expect(windowedSSD(off, on) > 0, "tremolo intensity had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func tremoloSpeedChangesOutput() throws {
|
||||||
|
let slow: [Float] = try render { $0.intensity = 1.0; $0.speed = 1.0 }
|
||||||
|
let fast: [Float] = try render { $0.intensity = 1.0; $0.speed = 10.0 }
|
||||||
|
#expect(windowedSSD(slow, fast) > 0, "tremolo speed had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func brightSwitchChangesOutput() throws {
|
||||||
|
let flat: [Float] = try render { $0.bright = 0.0 }
|
||||||
|
let bright: [Float] = try render { $0.bright = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, bright) > 0, "bright switch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reverbFootswitchBypassesToDry() throws {
|
||||||
|
// Footswitch off with the Reverb knob up must equal the dry signal (knob at 0), and must
|
||||||
|
// differ from the same knob with the footswitch on.
|
||||||
|
let bypassed: [Float] = try render { $0.reverb = 0.9; $0.reverbEnabled = 0.0 }
|
||||||
|
let dry: [Float] = try render { $0.reverb = 0.0; $0.reverbEnabled = 1.0 }
|
||||||
|
#expect(windowedSSD(bypassed, dry) == 0.0, "reverb footswitch off should be a dry pass-through")
|
||||||
|
let engaged: [Float] = try render { $0.reverb = 0.9; $0.reverbEnabled = 1.0 }
|
||||||
|
#expect(windowedSSD(bypassed, engaged) > 0, "reverb footswitch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func vibratoFootswitchBypassesToIdentity() throws {
|
||||||
|
// Footswitch off with Intensity up must equal no tremolo (Intensity 0), and must differ
|
||||||
|
// from the same Intensity with the footswitch on. The differing `speed` is intentional and
|
||||||
|
// harmless: with depth gated to 0 the LFO is a constant 1.0 regardless of its frequency.
|
||||||
|
let bypassed: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.vibratoEnabled = 0.0 }
|
||||||
|
let noTremolo: [Float] = try render { $0.intensity = 0.0 }
|
||||||
|
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "vibrato footswitch off should be identity")
|
||||||
|
let engaged: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.vibratoEnabled = 1.0 }
|
||||||
|
#expect(windowedSSD(bypassed, engaged) > 0, "vibrato footswitch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
let hot: [Float] = try render { (pedal: FullertonReverbAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.reverb = 1.0
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.intensity = 1.0
|
||||||
|
pedal.speed = 6.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "peak \(peak) exceeds the ±1 ceiling")
|
||||||
|
#expect(peak > 0.3, "unexpectedly quiet at max gain: \(peak)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func exposesFullControlSurface() throws {
|
||||||
|
let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label }
|
||||||
|
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"])
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"])
|
||||||
|
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||||
|
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||||
|
#expect(pedal.widthUnits == 3)
|
||||||
|
#expect(pedal.showsMixControl == false)
|
||||||
|
#expect(pedal.toneStackModel == .fender)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func controlsRoundTripThroughState() throws {
|
||||||
|
let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal()
|
||||||
|
pedal.gain = 8.0
|
||||||
|
pedal.reverb = 0.7
|
||||||
|
pedal.speed = 9.0
|
||||||
|
pedal.intensity = 0.6
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.cab = 2.0
|
||||||
|
pedal.reverbEnabled = 0.0
|
||||||
|
pedal.vibratoEnabled = 0.0
|
||||||
|
let restored: FullertonReverbAmpPedal = FullertonReverbAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.gain == 8.0)
|
||||||
|
#expect(restored.reverb == 0.7)
|
||||||
|
#expect(restored.speed == 9.0)
|
||||||
|
#expect(restored.intensity == 0.6)
|
||||||
|
#expect(restored.bright == 1.0)
|
||||||
|
#expect(restored.cab == 2.0)
|
||||||
|
#expect(restored.reverbEnabled == 0.0)
|
||||||
|
#expect(restored.vibratoEnabled == 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Fullerton Reverb") is FullertonReverbAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
// FullertonVariantsTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("Fullerton blackface variants")
|
||||||
|
struct FullertonVariantsTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: P = make()
|
||||||
|
pedal.inputBus = srcBus.index
|
||||||
|
pedal.outputBus = dstBus.index
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let variants: [(name: String, make: () -> FullertonReverbAmpPedal)] = [
|
||||||
|
("Fullerton Deluxe", { FullertonDeluxeAmpPedal() }),
|
||||||
|
("Fullerton Princeton", { FullertonPrincetonAmpPedal() }),
|
||||||
|
]
|
||||||
|
|
||||||
|
@Test func bothBuildNonSilentFinite() throws {
|
||||||
|
for v: (name: String, make: () -> FullertonReverbAmpPedal) in variants {
|
||||||
|
let s: [Float] = try render(v.make)
|
||||||
|
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||||
|
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func variantsDifferFromTwinAndEachOther() throws {
|
||||||
|
// Same knob settings, different voicing (power-amp drive; plus cab for Princeton) → different output.
|
||||||
|
let cfg: (FullertonReverbAmpPedal) -> Void = { $0.gain = 6.0; $0.reverb = 0.3 }
|
||||||
|
let twin: [Float] = try render({ FullertonReverbAmpPedal() }, configure: cfg)
|
||||||
|
let deluxe: [Float] = try render({ FullertonDeluxeAmpPedal() }, configure: cfg)
|
||||||
|
let princeton: [Float] = try render({ FullertonPrincetonAmpPedal() }, configure: cfg)
|
||||||
|
#expect(windowedSSD(twin, deluxe) > 0, "Deluxe should differ from the Twin")
|
||||||
|
#expect(windowedSSD(deluxe, princeton) > 0, "Princeton should differ from the Deluxe")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func inheritedReverbAndBrightWork() throws {
|
||||||
|
// The reverb knob and Bright switch are inherited from the Twin — spot-check on the Deluxe.
|
||||||
|
let dry: [Float] = try render({ FullertonDeluxeAmpPedal() }) { $0.reverb = 0.0 }
|
||||||
|
let wet: [Float] = try render({ FullertonDeluxeAmpPedal() }) { $0.reverb = 0.9 }
|
||||||
|
#expect(windowedSSD(dry, wet) > 0, "inherited reverb had no effect")
|
||||||
|
let flat: [Float] = try render({ FullertonPrincetonAmpPedal() }) { $0.bright = 0.0 }
|
||||||
|
let bright: [Float] = try render({ FullertonPrincetonAmpPedal() }) { $0.bright = 1.0 }
|
||||||
|
#expect(windowedSSD(flat, bright) > 0, "inherited bright switch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func stayWithinCeilingAtMaxGain() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
for v: (name: String, make: () -> FullertonReverbAmpPedal) in variants {
|
||||||
|
let hot: [Float] = try render(v.make) { (pedal: FullertonReverbAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.reverb = 1.0
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.intensity = 1.0
|
||||||
|
}
|
||||||
|
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
#expect(peak <= 1.0 + ceilingEpsilon, "\(v.name) peak \(peak) exceeds the ±1 ceiling")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func inheritFullControlSurface() throws {
|
||||||
|
for v: (name: String, make: () -> FullertonReverbAmpPedal) in variants {
|
||||||
|
let pedal: FullertonReverbAmpPedal = v.make()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label }
|
||||||
|
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"], "\(v.name) knobs")
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"], "\(v.name) switches")
|
||||||
|
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(v.name) selectors")
|
||||||
|
#expect(pedal.widthUnits == 3, "\(v.name) width")
|
||||||
|
#expect(pedal.toneStackModel == .fender, "\(v.name) tone stack")
|
||||||
|
#expect(pedal.powerAmpOversample == 4, "\(v.name) should oversample the harder-driven power amp at 4×")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reverbRoundTripsThroughState() throws {
|
||||||
|
let pedal: FullertonDeluxeAmpPedal = FullertonDeluxeAmpPedal()
|
||||||
|
pedal.reverb = 0.7
|
||||||
|
pedal.cab = 3.0
|
||||||
|
let restored: FullertonDeluxeAmpPedal = FullertonDeluxeAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.reverb == 0.7 && restored.cab == 3.0, "Deluxe state did not round-trip")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Fullerton Deluxe") is FullertonDeluxeAmpPedal)
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Fullerton Princeton") is FullertonPrincetonAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
// JazzCleanAmpPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("JazzCleanAmpPedal")
|
||||||
|
struct JazzCleanAmpPedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
/// Renders the amp as a stereo widener, returning the separated (left, right) channels — the
|
||||||
|
/// pedal's `outputBusRight` is wired to a second bus and a split master routes both to the
|
||||||
|
/// hardware L/R so `readStereoCAF` can capture them independently.
|
||||||
|
private func renderStereo(configure: (JazzCleanAmpPedal) -> Void = { _ in }) throws
|
||||||
|
-> (left: [Float], right: [Float]) {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstL: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstR: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstL)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstR)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: JazzCleanAmpPedal = JazzCleanAmpPedal(inputBus: srcBus.index, outputBus: dstL.index)
|
||||||
|
pedal.outputBusRight = dstR.index
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: JazzStereoSplitMaster = JazzStereoSplitMaster(left: dstL.index, right: dstR.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
|
||||||
|
let interleaved: [Float] = readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
var left: [Float] = []
|
||||||
|
var right: [Float] = []
|
||||||
|
left.reserveCapacity(interleaved.count / 2)
|
||||||
|
right.reserveCapacity(interleaved.count / 2)
|
||||||
|
for frame: Int in 0..<(interleaved.count / 2) {
|
||||||
|
left.append(interleaved[2 * frame])
|
||||||
|
right.append(interleaved[2 * frame + 1])
|
||||||
|
}
|
||||||
|
return (left, right)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 2048, window: Int = 2048) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func peak(_ samples: [Float]) -> Double {
|
||||||
|
samples.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func buildsNonSilentFiniteOutput() throws {
|
||||||
|
let (left, right): ([Float], [Float]) = try renderStereo()
|
||||||
|
#expect(hasNonSilentOutput(left), "Jazz Clean left channel was silent")
|
||||||
|
#expect(hasNonSilentOutput(right), "Jazz Clean right channel was silent")
|
||||||
|
#expect(left.allSatisfy { $0.isFinite } && right.allSatisfy { $0.isFinite },
|
||||||
|
"Jazz Clean produced non-finite output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chorusEngagedWidensToStereo() throws {
|
||||||
|
// Engaged: the two chorus taps differ → genuine stereo width.
|
||||||
|
let (left, right): ([Float], [Float]) = try renderStereo { $0.chorusEnabled = 1.0 }
|
||||||
|
#expect(windowedSSD(left, right) > 0, "engaged chorus should make L and R differ")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chorusBypassedCollapsesToMono() throws {
|
||||||
|
// Bypassed: mix 0 → both taps are the dry core → L == R (bit-identical).
|
||||||
|
let (left, right): ([Float], [Float]) = try renderStereo { $0.chorusEnabled = 0.0 }
|
||||||
|
#expect(hasNonSilentOutput(left))
|
||||||
|
#expect(windowedSSD(left, right) == 0.0, "bypassed chorus should collapse to mono (L == R)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chorusFootswitchChangesOutput() throws {
|
||||||
|
let on: [Float] = try renderStereo { $0.chorusEnabled = 1.0; $0.chorusRate = 3.0 }.left
|
||||||
|
let off: [Float] = try renderStereo { $0.chorusEnabled = 0.0; $0.chorusRate = 3.0 }.left
|
||||||
|
#expect(windowedSSD(on, off) > 0, "chorus footswitch had no effect")
|
||||||
|
// With the chorus off, the Rate knob is irrelevant (mix 0 → dry) — two off-renders match.
|
||||||
|
let offSlow: [Float] = try renderStereo { $0.chorusEnabled = 0.0; $0.chorusRate = 0.2 }.left
|
||||||
|
let offFast: [Float] = try renderStereo { $0.chorusEnabled = 0.0; $0.chorusRate = 5.0 }.left
|
||||||
|
#expect(windowedSSD(offSlow, offFast) == 0.0, "chorus off should ignore rate (dry pass-through)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chorusRateChangesOutput() throws {
|
||||||
|
let slow: [Float] = try renderStereo { $0.chorusRate = 0.2 }.left
|
||||||
|
let fast: [Float] = try renderStereo { $0.chorusRate = 5.0 }.left
|
||||||
|
#expect(windowedSSD(slow, fast) > 0, "chorus rate had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func chorusDepthChangesOutput() throws {
|
||||||
|
let shallow: [Float] = try renderStereo { $0.chorusDepth = 0.001 }.left
|
||||||
|
let deep: [Float] = try renderStereo { $0.chorusDepth = 0.014 }.left
|
||||||
|
#expect(windowedSSD(shallow, deep) > 0, "chorus depth had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reverbMixChangesOutput() throws {
|
||||||
|
let dry: [Float] = try renderStereo { $0.reverb = 0.0 }.left
|
||||||
|
let wet: [Float] = try renderStereo { $0.reverb = 0.9 }.left
|
||||||
|
#expect(windowedSSD(dry, wet) > 0, "reverb mix had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func brightSwitchChangesOutput() throws {
|
||||||
|
let flat: [Float] = try renderStereo { $0.bright = 0.0 }.left
|
||||||
|
let bright: [Float] = try renderStereo { $0.bright = 1.0 }.left
|
||||||
|
#expect(windowedSSD(flat, bright) > 0, "bright switch had no effect")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func bothChannelsStayWithinCeilingWithFXEngaged() throws {
|
||||||
|
let ceilingEpsilon: Double = 1.0e-4
|
||||||
|
let (left, right): ([Float], [Float]) = try renderStereo { (pedal: JazzCleanAmpPedal) in
|
||||||
|
pedal.gain = 30.0
|
||||||
|
pedal.bass = 1.0
|
||||||
|
pedal.treble = 1.0
|
||||||
|
pedal.reverb = 1.0
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.chorusDepth = 0.015
|
||||||
|
}
|
||||||
|
#expect(peak(left) <= 1.0 + ceilingEpsilon, "left peak \(peak(left)) exceeds the ±1 ceiling")
|
||||||
|
#expect(peak(right) <= 1.0 + ceilingEpsilon, "right peak \(peak(right)) exceeds the ±1 ceiling")
|
||||||
|
#expect(peak(left) > 0.3 && peak(right) > 0.3, "unexpectedly quiet at max gain")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func exposesFullControlSurface() throws {
|
||||||
|
let pedal: JazzCleanAmpPedal = JazzCleanAmpPedal()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label }
|
||||||
|
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Rate", "Depth"])
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Chorus"])
|
||||||
|
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||||
|
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||||
|
#expect(pedal.widthUnits == 3)
|
||||||
|
#expect(pedal.showsMixControl == false)
|
||||||
|
#expect(pedal.channelKind == .widener, "Jazz Clean should be a stereo widener")
|
||||||
|
#expect(pedal.toneStackModel == .fender)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func controlsRoundTripThroughState() throws {
|
||||||
|
let pedal: JazzCleanAmpPedal = JazzCleanAmpPedal()
|
||||||
|
pedal.gain = 6.0
|
||||||
|
pedal.reverb = 0.5
|
||||||
|
pedal.chorusRate = 2.0
|
||||||
|
pedal.chorusDepth = 0.008
|
||||||
|
pedal.bright = 1.0
|
||||||
|
pedal.chorusEnabled = 0.0
|
||||||
|
pedal.cab = 3.0
|
||||||
|
let restored: JazzCleanAmpPedal = JazzCleanAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.gain == 6.0)
|
||||||
|
#expect(restored.reverb == 0.5)
|
||||||
|
#expect(restored.chorusRate == 2.0)
|
||||||
|
#expect(restored.chorusDepth == 0.008)
|
||||||
|
#expect(restored.bright == 1.0)
|
||||||
|
#expect(restored.chorusEnabled == 0.0)
|
||||||
|
#expect(restored.cab == 3.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
#expect(PedalRegistry.makePedal(type: "Jazz Clean") is JazzCleanAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Routes two mono board buses to hardware left (0) and right (1) so the widener's channels can be
|
||||||
|
/// captured separately by `readStereoCAF`.
|
||||||
|
@MainActor
|
||||||
|
private final class JazzStereoSplitMaster: SynthesizerBase {
|
||||||
|
private let left: Int
|
||||||
|
private let right: Int
|
||||||
|
|
||||||
|
init(left: Int, right: Int) {
|
||||||
|
self.left = left
|
||||||
|
self.right = right
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func build() {
|
||||||
|
output(bus: 0, source: input(bus: left))
|
||||||
|
output(bus: 1, source: input(bus: right))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ struct LimiterPedalTests {
|
|||||||
private func render(
|
private func render(
|
||||||
boost: Double,
|
boost: Double,
|
||||||
ceiling: Double,
|
ceiling: Double,
|
||||||
|
release: Double = 0.05,
|
||||||
sampleRate: Double = 44100.0
|
sampleRate: Double = 44100.0
|
||||||
) throws -> [Float] {
|
) throws -> [Float] {
|
||||||
let renderDuration: Double = 0.1
|
let renderDuration: Double = 0.1
|
||||||
@@ -43,6 +44,7 @@ struct LimiterPedalTests {
|
|||||||
pedal.sampleRate = sampleRate
|
pedal.sampleRate = sampleRate
|
||||||
pedal.boost = boost
|
pedal.boost = boost
|
||||||
pedal.ceiling = ceiling
|
pedal.ceiling = ceiling
|
||||||
|
pedal.release = release
|
||||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
|
||||||
try engine.add(source)
|
try engine.add(source)
|
||||||
@@ -78,4 +80,32 @@ struct LimiterPedalTests {
|
|||||||
let tolerance: Float = 0.05
|
let tolerance: Float = 0.05
|
||||||
#expect(peak <= Float(ceiling) + tolerance, "Limiter overshot ceiling: peak=\(peak)")
|
#expect(peak <= Float(ceiling) + tolerance, "Limiter overshot ceiling: peak=\(peak)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func exposesBoostCeilingReleaseKnobs() throws {
|
||||||
|
let pedal: LimiterPedal = LimiterPedal()
|
||||||
|
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||||
|
#expect(labels == ["Boost", "Ceiling", "Release"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func releaseChangesOutput() throws {
|
||||||
|
// Same drive and ceiling, different release times: the gain recovers between peaks
|
||||||
|
// at different rates, so the limited output differs. Ceiling still holds for both.
|
||||||
|
let ceiling: Double = 0.4
|
||||||
|
let fast: [Float] = try render(boost: 12.0, ceiling: ceiling, release: 0.01)
|
||||||
|
let slow: [Float] = try render(boost: 12.0, ceiling: ceiling, release: 0.5)
|
||||||
|
|
||||||
|
#expect(hasNonSilentOutput(fast), "fast-release render was silent")
|
||||||
|
#expect(hasNonSilentOutput(slow), "slow-release render was silent")
|
||||||
|
|
||||||
|
let skip: Int = 2048
|
||||||
|
let window: Int = 2048
|
||||||
|
guard fast.count >= skip + window, slow.count >= skip + window else { return }
|
||||||
|
let fastWindow: [Float] = Array(fast[skip..<(skip + window)])
|
||||||
|
let slowWindow: [Float] = Array(slow[skip..<(skip + window)])
|
||||||
|
let ssd: Double = zip(fastWindow, slowWindow).reduce(0.0) { acc, pair in
|
||||||
|
let diff: Double = Double(pair.0 - pair.1)
|
||||||
|
return acc + diff * diff
|
||||||
|
}
|
||||||
|
#expect(ssd > 0, "release time had no effect on limiter output")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
// NeuralAmpPedalTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("NeuralAmpPedal")
|
||||||
|
struct NeuralAmpPedalTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 48000.0
|
||||||
|
|
||||||
|
/// Writes a small, deterministic Proteus/NeuralPi-format model JSON to a temp file and returns
|
||||||
|
/// its path. Weights are arbitrary-but-fixed (a real capture is not needed to exercise the
|
||||||
|
/// load → import → LSTMAmp path).
|
||||||
|
private func writeTempModel(hidden h: Int) throws -> String {
|
||||||
|
let gated: Int = 4 * h
|
||||||
|
let weightIH: [[Double]] = (0..<gated).map { [0.1 * sin(Double($0) + 1.0)] }
|
||||||
|
let weightHH: [[Double]] = (0..<gated).map { r in (0..<h).map { 0.05 * cos(Double(r * h + $0) + 1.0) } }
|
||||||
|
let biasIH: [Double] = (0..<gated).map { 0.01 * Double($0) }
|
||||||
|
let biasHH: [Double] = [Double](repeating: 0.0, count: gated)
|
||||||
|
let linWeight: [[Double]] = [(0..<h).map { 0.3 * sin(Double($0) + 0.5) }]
|
||||||
|
let object: [String: Any] = [
|
||||||
|
"model_data": [
|
||||||
|
"unit_type": "LSTM", "input_size": 1, "hidden_size": h,
|
||||||
|
"num_layers": 1, "output_size": 1, "skip": 1,
|
||||||
|
],
|
||||||
|
"state_dict": [
|
||||||
|
"rec.weight_ih_l0": weightIH,
|
||||||
|
"rec.weight_hh_l0": weightHH,
|
||||||
|
"rec.bias_ih_l0": biasIH,
|
||||||
|
"rec.bias_hh_l0": biasHH,
|
||||||
|
"lin.weight": linWeight,
|
||||||
|
"lin.bias": [0.05],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
let data: Data = try JSONSerialization.data(withJSONObject: object)
|
||||||
|
let url: URL = FileManager.default.temporaryDirectory
|
||||||
|
.appendingPathComponent("neuralamp-test-\(h)-\(UUID().uuidString).json")
|
||||||
|
try data.write(to: url)
|
||||||
|
return url.path
|
||||||
|
}
|
||||||
|
|
||||||
|
private func render(configure: (NeuralAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: 0.15, sampleRate: sampleRate, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: NeuralAmpPedal = NeuralAmpPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||||
|
pedal.sampleRate = sampleRate
|
||||||
|
configure(pedal)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 2048, window: Int = 2048) -> Double {
|
||||||
|
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||||
|
return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func noModelPassesThroughNonSilent() throws {
|
||||||
|
let out: [Float] = try render()
|
||||||
|
#expect(hasNonSilentOutput(out), "no-model passthrough was silent")
|
||||||
|
#expect(out.allSatisfy { $0.isFinite })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func loadedModelTransformsAndDiffersFromPassthrough() throws {
|
||||||
|
let path: String = try writeTempModel(hidden: 8)
|
||||||
|
defer { try? FileManager.default.removeItem(atPath: path) }
|
||||||
|
let passthrough: [Float] = try render()
|
||||||
|
let modeled: [Float] = try render { $0.resourcePath = path }
|
||||||
|
#expect(hasNonSilentOutput(modeled), "modeled output was silent")
|
||||||
|
#expect(modeled.allSatisfy { $0.isFinite })
|
||||||
|
#expect(windowedSSD(passthrough, modeled) > 0, "loaded model did not change the output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func gainChangesModeledOutput() throws {
|
||||||
|
let path: String = try writeTempModel(hidden: 8)
|
||||||
|
defer { try? FileManager.default.removeItem(atPath: path) }
|
||||||
|
let low: [Float] = try render { $0.resourcePath = path; $0.gain = 0.5 }
|
||||||
|
let high: [Float] = try render { $0.resourcePath = path; $0.gain = 3.0 }
|
||||||
|
#expect(windowedSSD(low, high) > 0, "gain had no effect on modeled output")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func resourcePathRoundTripsThroughState() throws {
|
||||||
|
let pedal: NeuralAmpPedal = NeuralAmpPedal()
|
||||||
|
pedal.resourcePath = "/some/model.json"
|
||||||
|
let restored: NeuralAmpPedal = NeuralAmpPedal()
|
||||||
|
restored.applyState(pedal.captureState())
|
||||||
|
#expect(restored.resourcePath == "/some/model.json", "resourcePath did not round-trip")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func exposesGainKnob() throws {
|
||||||
|
let pedal: NeuralAmpPedal = NeuralAmpPedal()
|
||||||
|
#expect(pedal.effectKnobs.map { $0.label } == ["Gain"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func registeredInBuiltInRegistry() throws {
|
||||||
|
let pedal: Pedal? = PedalRegistry.makePedal(type: "Neural Amp")
|
||||||
|
#expect(pedal is NeuralAmpPedal)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
// OversampledRingModulatorTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("OversampledRingModulator")
|
||||||
|
struct OversampledRingModulatorTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 44100.0
|
||||||
|
|
||||||
|
/// Minimal synth: a sine through an `OversampledRingModulator`, written to a mono bus.
|
||||||
|
private final class RingSynth: SynthesizerBase {
|
||||||
|
private let inFreq: Double
|
||||||
|
private let carrierFreq: Double
|
||||||
|
private let factor: Int
|
||||||
|
private let outBus: Int
|
||||||
|
|
||||||
|
init(inFreq: Double, carrierFreq: Double, factor: Int, outBus: Int) {
|
||||||
|
self.inFreq = inFreq
|
||||||
|
self.carrierFreq = carrierFreq
|
||||||
|
self.factor = factor
|
||||||
|
self.outBus = outBus
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func build() {
|
||||||
|
let osc: OscSin.Audio = OscSin.Audio(freq: inFreq)
|
||||||
|
output(bus: outBus, source: OversampledRingModulator(
|
||||||
|
osc, freq: carrierFreq, oversample: factor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func render(inFreq: Double, carrierFreq: Double, factor: Int) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.15, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer { engine.busAllocator.releaseAudioBus(dstBus) }
|
||||||
|
let synth: RingSynth = RingSynth(
|
||||||
|
inFreq: inFreq, carrierFreq: carrierFreq, factor: factor, outBus: dstBus.index)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(synth)
|
||||||
|
try engine.add(master, position: NodePosition.after(synth))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func leftChannel(_ samples: [Float], skip: Int) -> [Double] {
|
||||||
|
var out: [Double] = []
|
||||||
|
var i: Int = skip * 2
|
||||||
|
while i < samples.count {
|
||||||
|
out.append(Double(samples[i]))
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
private func goertzelMagnitude(_ x: [Double], cyclesPerSample: Double) -> Double {
|
||||||
|
let omega: Double = 2.0 * Double.pi * cyclesPerSample
|
||||||
|
let cosine: Double = cos(omega)
|
||||||
|
let sine: Double = sin(omega)
|
||||||
|
let coeff: Double = 2.0 * cosine
|
||||||
|
var s1: Double = 0.0
|
||||||
|
var s2: Double = 0.0
|
||||||
|
for v: Double in x {
|
||||||
|
let s0: Double = v + coeff * s1 - s2
|
||||||
|
s2 = s1
|
||||||
|
s1 = s0
|
||||||
|
}
|
||||||
|
let real: Double = s1 - s2 * cosine
|
||||||
|
let imag: Double = s2 * sine
|
||||||
|
return (real * real + imag * imag).squareRoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func naiveRingMod(inFreq: Double, carrierFreq: Double, count: Int) -> [Double] {
|
||||||
|
let inCps: Double = inFreq / sampleRate
|
||||||
|
let cCps: Double = carrierFreq / sampleRate
|
||||||
|
var out: [Double] = []
|
||||||
|
out.reserveCapacity(count)
|
||||||
|
for n: Int in 0..<count {
|
||||||
|
let x: Double = sin(2.0 * Double.pi * inCps * Double(n))
|
||||||
|
let c: Double = sin(2.0 * Double.pi * cCps * Double(n))
|
||||||
|
out.append(x * c)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reducesSumSidebandAliasVersusNaive() throws {
|
||||||
|
// in = 0.20·Fs, carrier = 0.35·Fs. Difference sideband = 0.15·Fs (legit, below Nyquist);
|
||||||
|
// sum sideband = 0.55·Fs, which folds to a 0.45·Fs alias at the base rate. Measure the
|
||||||
|
// alias relative to the legit difference sideband (self-normalising).
|
||||||
|
let inHz: Double = 0.20 * sampleRate
|
||||||
|
let carrierHz: Double = 0.35 * sampleRate
|
||||||
|
let diffBin: Double = 0.15 // |0.35 − 0.20|
|
||||||
|
let aliasBin: Double = 0.45 // |1 − 0.55|
|
||||||
|
|
||||||
|
let os: [Float] = try render(inFreq: inHz, carrierFreq: carrierHz, factor: 2)
|
||||||
|
let osLeft: [Double] = leftChannel(os, skip: 2048)
|
||||||
|
#expect(osLeft.count > 2048)
|
||||||
|
|
||||||
|
let osDiff: Double = goertzelMagnitude(osLeft, cyclesPerSample: diffBin)
|
||||||
|
let osAlias: Double = goertzelMagnitude(osLeft, cyclesPerSample: aliasBin)
|
||||||
|
let osRatio: Double = osAlias / osDiff
|
||||||
|
|
||||||
|
let naive: [Double] = naiveRingMod(inFreq: inHz, carrierFreq: carrierHz, count: osLeft.count)
|
||||||
|
let nDiff: Double = goertzelMagnitude(naive, cyclesPerSample: diffBin)
|
||||||
|
let nAlias: Double = goertzelMagnitude(naive, cyclesPerSample: aliasBin)
|
||||||
|
let naiveRatio: Double = nAlias / nDiff
|
||||||
|
|
||||||
|
#expect(naiveRatio > 0.05, "baseline did not alias as expected (ratio=\(naiveRatio))")
|
||||||
|
#expect(
|
||||||
|
osRatio < naiveRatio * 0.5,
|
||||||
|
"oversampling did not reduce ring-mod aliasing: os=\(osRatio) naive=\(naiveRatio)"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func producesNonSilentOutput() throws {
|
||||||
|
let os: [Float] = try render(inFreq: 440.0, carrierFreq: 220.0, factor: 2)
|
||||||
|
#expect(hasNonSilentOutput(os), "ring modulator produced silence")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func negativeCarrierStaysFiniteAndBounded() throws {
|
||||||
|
// A negative carrier frequency drives the phase increment negative; the phase must wrap
|
||||||
|
// both directions rather than growing unbounded and pushing sin() out of accurate range.
|
||||||
|
let os: [Float] = try render(inFreq: 440.0, carrierFreq: -220.0, factor: 2)
|
||||||
|
let left: [Double] = leftChannel(os, skip: 1024)
|
||||||
|
#expect(!left.isEmpty)
|
||||||
|
#expect(left.allSatisfy { $0.isFinite }, "negative carrier produced non-finite output")
|
||||||
|
let peak: Double = left.map { abs($0) }.max() ?? 0
|
||||||
|
#expect(peak <= 1.2, "negative carrier output was not bounded: peak=\(peak)")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
// OversampledSaturatorTests.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Testing
|
||||||
|
import Foundation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite("OversampledSaturator")
|
||||||
|
struct OversampledSaturatorTests {
|
||||||
|
|
||||||
|
private let sampleRate: Double = 44100.0
|
||||||
|
|
||||||
|
/// Minimal synth: a sine through an `OversampledSaturator`, written to a mono bus.
|
||||||
|
private final class SaturatorSynth: SynthesizerBase {
|
||||||
|
private let freq: Double
|
||||||
|
private let drive: Double
|
||||||
|
private let curve: SaturationCurve
|
||||||
|
private let factor: Int
|
||||||
|
private let outBus: Int
|
||||||
|
|
||||||
|
init(freq: Double, drive: Double, curve: SaturationCurve, factor: Int, outBus: Int) {
|
||||||
|
self.freq = freq
|
||||||
|
self.drive = drive
|
||||||
|
self.curve = curve
|
||||||
|
self.factor = factor
|
||||||
|
self.outBus = outBus
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func build() {
|
||||||
|
let osc: OscSin.Audio = OscSin.Audio(freq: freq)
|
||||||
|
output(bus: outBus, source: OversampledSaturator(
|
||||||
|
osc, drive: drive, curve: curve, oversample: factor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func render(
|
||||||
|
freq: Double,
|
||||||
|
drive: Double,
|
||||||
|
curve: SaturationCurve,
|
||||||
|
factor: Int
|
||||||
|
) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.15, numAudioBuses: 64)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer { engine.busAllocator.releaseAudioBus(dstBus) }
|
||||||
|
let synth: SaturatorSynth = SaturatorSynth(
|
||||||
|
freq: freq, drive: drive, curve: curve, factor: factor, outBus: dstBus.index)
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(synth)
|
||||||
|
try engine.add(master, position: NodePosition.after(synth))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Left channel (interleaved stereo), warm-up frames skipped.
|
||||||
|
private func leftChannel(_ samples: [Float], skip: Int) -> [Double] {
|
||||||
|
var out: [Double] = []
|
||||||
|
var i: Int = skip * 2
|
||||||
|
while i < samples.count {
|
||||||
|
out.append(Double(samples[i]))
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Goertzel magnitude at normalised frequency `cyclesPerSample`.
|
||||||
|
private func goertzelMagnitude(_ x: [Double], cyclesPerSample: Double) -> Double {
|
||||||
|
let omega: Double = 2.0 * Double.pi * cyclesPerSample
|
||||||
|
let cosine: Double = cos(omega)
|
||||||
|
let sine: Double = sin(omega)
|
||||||
|
let coeff: Double = 2.0 * cosine
|
||||||
|
var s1: Double = 0.0
|
||||||
|
var s2: Double = 0.0
|
||||||
|
for v: Double in x {
|
||||||
|
let s0: Double = v + coeff * s1 - s2
|
||||||
|
s2 = s1
|
||||||
|
s1 = s0
|
||||||
|
}
|
||||||
|
let real: Double = s1 - s2 * cosine
|
||||||
|
let imag: Double = s2 * sine
|
||||||
|
return (real * real + imag * imag).squareRoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A naive base-rate hard clipper on the same sine — the alias-generating baseline the
|
||||||
|
/// oversampled path is meant to beat.
|
||||||
|
private func naiveHardClip(
|
||||||
|
freq: Double,
|
||||||
|
drive: Double,
|
||||||
|
low: Double,
|
||||||
|
high: Double,
|
||||||
|
count: Int
|
||||||
|
) -> [Double] {
|
||||||
|
let cyclesPerSample: Double = freq / sampleRate
|
||||||
|
var out: [Double] = []
|
||||||
|
out.reserveCapacity(count)
|
||||||
|
for n: Int in 0..<count {
|
||||||
|
let x: Double = sin(2.0 * Double.pi * cyclesPerSample * Double(n))
|
||||||
|
let shaped: Double = tanh(x) * drive
|
||||||
|
out.append(Swift.min(high, Swift.max(low, shaped)))
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reducesAliasingVersusNaiveHardClip() throws {
|
||||||
|
// 13230 Hz = 0.3·Fs. A symmetric clipper's dominant 3rd harmonic lands at 0.9·Fs,
|
||||||
|
// which folds to a 0.1·Fs (4410 Hz) alias at the base rate. Measure the alias energy
|
||||||
|
// RELATIVE to the fundamental (self-normalising, so downstream routing gain cancels).
|
||||||
|
let fundamentalHz: Double = 0.3 * sampleRate
|
||||||
|
let aliasHz: Double = 0.1 * sampleRate // |3·0.3 − 1|·Fs
|
||||||
|
let drive: Double = 5.0
|
||||||
|
let low: Double = -1.0
|
||||||
|
let high: Double = 1.0
|
||||||
|
|
||||||
|
let os: [Float] = try render(
|
||||||
|
freq: fundamentalHz, drive: drive,
|
||||||
|
curve: .tanhPostGainHardClip(low: low, high: high), factor: 4)
|
||||||
|
let osLeft: [Double] = leftChannel(os, skip: 2048)
|
||||||
|
#expect(osLeft.count > 2048)
|
||||||
|
|
||||||
|
let fundamentalBin: Double = fundamentalHz / sampleRate
|
||||||
|
let aliasBin: Double = aliasHz / sampleRate
|
||||||
|
|
||||||
|
let osFund: Double = goertzelMagnitude(osLeft, cyclesPerSample: fundamentalBin)
|
||||||
|
let osAlias: Double = goertzelMagnitude(osLeft, cyclesPerSample: aliasBin)
|
||||||
|
let osRatio: Double = osAlias / osFund
|
||||||
|
|
||||||
|
let naive: [Double] = naiveHardClip(
|
||||||
|
freq: fundamentalHz, drive: drive, low: low, high: high, count: osLeft.count)
|
||||||
|
let nFund: Double = goertzelMagnitude(naive, cyclesPerSample: fundamentalBin)
|
||||||
|
let nAlias: Double = goertzelMagnitude(naive, cyclesPerSample: aliasBin)
|
||||||
|
let naiveRatio: Double = nAlias / nFund
|
||||||
|
|
||||||
|
// The naive clipper must actually alias (sanity), and oversampling must cut the
|
||||||
|
// alias-to-fundamental ratio by at least half. In practice the 4× halfband path
|
||||||
|
// attenuates it far more; 0.5 is a conservative, non-flaky bound.
|
||||||
|
#expect(naiveRatio > 0.05, "baseline did not alias as expected (ratio=\(naiveRatio))")
|
||||||
|
#expect(
|
||||||
|
osRatio < naiveRatio * 0.5,
|
||||||
|
"oversampling did not reduce aliasing: os=\(osRatio) naive=\(naiveRatio)"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func hardClipCurveRespectsBounds() throws {
|
||||||
|
// With a hard-clip curve the output must stay within [low, high] (plus a small margin
|
||||||
|
// for halfband ripple / routing) regardless of how hard it is driven.
|
||||||
|
let low: Double = -0.5
|
||||||
|
let high: Double = 0.5
|
||||||
|
let samples: [Float] = try render(
|
||||||
|
freq: 2000.0, drive: 10.0,
|
||||||
|
curve: .tanhPostGainHardClip(low: low, high: high), factor: 4)
|
||||||
|
let left: [Double] = leftChannel(samples, skip: 2048)
|
||||||
|
#expect(!left.isEmpty)
|
||||||
|
let peak: Double = left.map { abs($0) }.max() ?? 0
|
||||||
|
let margin: Double = 0.1
|
||||||
|
#expect(peak <= high + margin, "hard-clip curve exceeded its ceiling: peak=\(peak)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func softCurvesStayBounded() throws {
|
||||||
|
// tanh-family curves saturate toward ±1; output must stay bounded well under runaway.
|
||||||
|
let samples: [Float] = try render(
|
||||||
|
freq: 2000.0, drive: 30.0, curve: .tanhPreGain, factor: 2)
|
||||||
|
let left: [Double] = leftChannel(samples, skip: 2048)
|
||||||
|
#expect(!left.isEmpty)
|
||||||
|
let peak: Double = left.map { abs($0) }.max() ?? 0
|
||||||
|
#expect(peak <= 1.2, "tanh saturator output was not bounded near ±1: peak=\(peak)")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -275,6 +275,60 @@ struct PresetTests {
|
|||||||
#expect(section.route == .stereo, "Route should be recalled")
|
#expect(section.route == .stereo, "Route should be recalled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func applyStateRebuildsBoardWhenCabinetVoiceChanges() throws {
|
||||||
|
// A cabinet voice is a `rebuildsOnChange` selector: only the selected voice's convolver is
|
||||||
|
// built, so a lightweight recall that changes it must rebuild the board (a plain node write
|
||||||
|
// would leave audio on the previously-built convolver).
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.1, numAudioBuses: 128)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let sg: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
let board: PedalBoard = try sg.addBoard()
|
||||||
|
try board.add(CabinetPedal())
|
||||||
|
try sg.finalizeBoard(board)
|
||||||
|
|
||||||
|
guard let original: CabinetPedal = board.pedals.first as? CabinetPedal else {
|
||||||
|
Issue.record("No CabinetPedal in board")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Snapshot at voice 3, then move the live pedal to voice 0 and recall the snapshot.
|
||||||
|
original.cabinet = 3.0
|
||||||
|
let snapshot: ShoeGazeState = sg.captureState()
|
||||||
|
original.cabinet = 0.0
|
||||||
|
|
||||||
|
sg.applyState(snapshot)
|
||||||
|
|
||||||
|
// The rebuild replaces the instance — the recalled voice must be reflected on the new one.
|
||||||
|
guard let rebuilt: CabinetPedal = sg.boards[0].pedals.first as? CabinetPedal else {
|
||||||
|
Issue.record("No CabinetPedal after recall")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
#expect(rebuilt !== original, "board should rebuild when the cabinet voice changes")
|
||||||
|
#expect(rebuilt.cabinet == 3.0, "recalled cabinet voice should be applied")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func applyStateDoesNotRebuildWhenCabinetVoiceUnchanged() throws {
|
||||||
|
// Recall with the same cabinet voice must NOT rebuild — the lightweight path stays cheap.
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.1, numAudioBuses: 128)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let sg: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
let board: PedalBoard = try sg.addBoard()
|
||||||
|
try board.add(CabinetPedal())
|
||||||
|
try sg.finalizeBoard(board)
|
||||||
|
|
||||||
|
guard let original: CabinetPedal = board.pedals.first as? CabinetPedal else {
|
||||||
|
Issue.record("No CabinetPedal in board")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
original.cabinet = 2.0
|
||||||
|
let snapshot: ShoeGazeState = sg.captureState()
|
||||||
|
|
||||||
|
sg.applyState(snapshot)
|
||||||
|
|
||||||
|
#expect(sg.boards[0].pedals.first === original, "unchanged cabinet voice should not rebuild")
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - In-memory round-trip
|
// MARK: - In-memory round-trip
|
||||||
|
|
||||||
@Test func captureStateRoundTripEquality() throws {
|
@Test func captureStateRoundTripEquality() throws {
|
||||||
|
|||||||
@@ -61,4 +61,35 @@ struct SustainerPedalTests {
|
|||||||
}
|
}
|
||||||
#expect(ssd > 0, "sustain knob had no effect on output")
|
#expect(ssd > 0, "sustain knob had no effect on output")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func exposesSafetySwitch() throws {
|
||||||
|
let pedal: SustainerPedal = SustainerPedal()
|
||||||
|
#expect(pedal.effectSwitches.map { $0.label } == ["Safety"])
|
||||||
|
#expect(pedal.effectSwitches.first?.options.map { $0.title } == ["Off", "On"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func safetyLimiterCapsPeaks() throws {
|
||||||
|
// Max sustain drives a low threshold, high ratio, and +18 dB makeup — the compressor's
|
||||||
|
// non-zero attack lets transients overshoot. With Safety on, the output peak must stay
|
||||||
|
// near full scale, and the two switch states must differ.
|
||||||
|
let off: [Float] = try render {
|
||||||
|
$0.sampleRate = 44100.0; $0.sustain = 10.0; $0.safetyLimiter = 0.0
|
||||||
|
}
|
||||||
|
let on: [Float] = try render {
|
||||||
|
$0.sampleRate = 44100.0; $0.sustain = 10.0; $0.safetyLimiter = 1.0
|
||||||
|
}
|
||||||
|
#expect(hasNonSilentOutput(off) && hasNonSilentOutput(on))
|
||||||
|
|
||||||
|
let fill: Int = 2048
|
||||||
|
guard on.count > fill else { return }
|
||||||
|
let onPeak: Float = on[fill...].reduce(0) { Swift.max($0, abs($1)) }
|
||||||
|
#expect(onPeak <= 1.05, "safety limiter failed to cap peak: \(onPeak)")
|
||||||
|
|
||||||
|
let window: Int = 2048
|
||||||
|
guard off.count >= fill + window, on.count >= fill + window else { return }
|
||||||
|
let ssd: Double = zip(off[fill..<(fill + window)], on[fill..<(fill + window)]).reduce(0.0) { acc, pair in
|
||||||
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||||
|
}
|
||||||
|
#expect(ssd > 0, "safety switch had no effect on output")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
# ShoeGaze 2.0 — Amp Modeling Plan
|
||||||
|
|
||||||
|
Adds guitar-amp modeling to ShoeGaze. Core DSP primitives that don't yet exist land in
|
||||||
|
Lyrebird and ship as **Lyrebird 1.7**; the amp pedals + UI land in ShoeGaze and ship as
|
||||||
|
**ShoeGaze 2.0**.
|
||||||
|
|
||||||
|
Feasibility basis: the public literature is deep (WDF/DAFx for white-box, NAM/GuitarML for
|
||||||
|
black-box), and Lyrebird already provides most of the DSP (oversampling, waveshapers, the full
|
||||||
|
filter suite, `SampleLoop` per-sample feedback, partitioned FFT convolution via
|
||||||
|
`ConvolutionReverb`, WAV IR loading via `LyrebirdBuffer.read(filePath:)`, and the
|
||||||
|
`PhysicalModels` precedent for nonlinear stateful per-sample DSP). The only genuine gap is a
|
||||||
|
real-time neural-inference kernel.
|
||||||
|
|
||||||
|
## Versioning & repo strategy
|
||||||
|
|
||||||
|
- **Lyrebird → 1.7.0** for every core addition. Dev repo is BitBucket (`origin`, SSH); public
|
||||||
|
release repo is mooo. Cut 1.7 once the needed core subset is merged to `main`: RELEASES entry,
|
||||||
|
tag `v1.7.0`, push BitBucket, then `/lyrebird_release_prep` → commit/tag → push mooo
|
||||||
|
(**HTTPS, force `-c http.version=HTTP/1.1`** — mooo's HTTP2 is flaky).
|
||||||
|
- **ShoeGaze → 2.0.0**. `origin` is mooo (HTTPS). Bump `Package.swift` dependency to
|
||||||
|
`from: "1.7.0"` once 1.7 is released; bump `MARKETING_VERSION` to `2.0.0` at the end.
|
||||||
|
- **Dev-time cross-repo:** ShoeGaze work needing unreleased Lyrebird uses
|
||||||
|
`swift package edit lyrebird --path <dev-repo>` locally, then drops the override and bumps
|
||||||
|
`from:` after 1.7 ships. (Same flow used for the 1.6.4 work.)
|
||||||
|
|
||||||
|
## Branch + review gates (apply to every feature below)
|
||||||
|
|
||||||
|
**Lyrebird feature** (`feat/<name>` off `main`):
|
||||||
|
1. `swift test` green.
|
||||||
|
2. Guards as applicable: `check-docc.sh`, `check-doc-snippets.sh`; if a public generator init
|
||||||
|
changes, regenerate the DSL registry and run `generate-dsl-registry.sh --check`.
|
||||||
|
3. `/lyrebird_review` clean (no blocking findings) — re-run until clean.
|
||||||
|
4. FF/merge to `main`. Append phase entry to `phase_history.md`.
|
||||||
|
|
||||||
|
**ShoeGaze feature** (`feat/<name>` off `main`):
|
||||||
|
1. `swift test` green.
|
||||||
|
2. `/lyrebird_external_review` clean (RT-safety on any new Generators).
|
||||||
|
3. Merge to `main`.
|
||||||
|
|
||||||
|
New public RT generators require a deterministic input→output test (not just "not silent") —
|
||||||
|
e.g. the Goertzel alias-ratio pattern used for the oversampled saturators.
|
||||||
|
|
||||||
|
## Phase 0 — Decisions (no code)
|
||||||
|
|
||||||
|
- **Neural kernel strategy:** (a) hand-written Swift LSTM/GRU (Proteus-size), or (b) bridge
|
||||||
|
RTNeural (C++) via the existing `LyrebirdC` target. **Recommend (a)** first — pure Swift keeps
|
||||||
|
the Linux/Windows port intact (see the cross-platform feasibility work) and Proteus-size LSTMs
|
||||||
|
are small. Keep (b) as an optional fast-path later.
|
||||||
|
- **White-box depth:** full nodal/WDF vs static triode waveshaper + oversampling. **Recommend
|
||||||
|
static-waveshaper triode stages first** (Koren/Dempwolf transfer curves), add a minimal WDF
|
||||||
|
core later only if the voicing demands true bidirectional stages.
|
||||||
|
|
||||||
|
## Lyrebird 1.7 — core additions
|
||||||
|
|
||||||
|
Only what has no existing primitive. Each is its own branch + `/lyrebird_review`.
|
||||||
|
|
||||||
|
- **L1 · ToneStack generator** (`feat/tonestack`) — passive Fender/Marshall/Vox tone-stack IIR
|
||||||
|
(Yeh coefficients), control-rate coefficient updates. Filters exist but not this specific
|
||||||
|
topology as a first-class, model-selectable block.
|
||||||
|
- **L2 · Triode preamp stage** (`feat/triode-stage`) — nonlinear tube gain stage: bias +
|
||||||
|
coupling cap + Koren/Dempwolf static curve, **built-in 2×/4× oversampling** (reuse the
|
||||||
|
halfband primitives), grid-conduction asymmetry. The white-box building block.
|
||||||
|
- **L3 · Neural inference generator** (`feat/neural-inference`) — RT-safe LSTM/GRU (and later
|
||||||
|
WaveNet) as a `GeneratorBase` subclass: weights preloaded at `init` into pre-allocated
|
||||||
|
matrices, alloc-free/lock-free per-sample matmul on the render thread (same discipline as the
|
||||||
|
physical models). Plus a weight-container loader for NAM `.nam` / Proteus JSON.
|
||||||
|
- **L4 · (optional) WDF core** (`feat/wdf-core`) — minimal wave-digital adaptors (series/parallel
|
||||||
|
/R/C/diode + triode root with a **bounded, alloc-free Newton solve**). Defer unless L2 proves
|
||||||
|
insufficient.
|
||||||
|
- **L0 · Verify, likely no-op:** cabinet convolution + WAV IR loading already exist
|
||||||
|
(`ConvolutionReverb`, `LyrebirdBuffer.read`). Confirm the convolver is comfortable with
|
||||||
|
cab-length IRs (tens of ms) at low latency; only add a thin general `Convolution` alias if the
|
||||||
|
reverb framing is awkward for cabs. **Probably needs no 1.7 change.**
|
||||||
|
|
||||||
|
Cut **Lyrebird 1.7.0** after L1–L3 (and L0 if touched) are merged.
|
||||||
|
|
||||||
|
## ShoeGaze 2.0 — amp pedals + UI
|
||||||
|
|
||||||
|
- **S1 · Cabinet IR pedal** (`feat/cabinet-pedal`) — wraps `ConvolutionReverb` + a bundled/loadable
|
||||||
|
IR set + IR picker. **No Lyrebird dependency change — ships on 1.6.4.** Quick win; can land
|
||||||
|
before 1.7. Pair with an oversampled `Waveshaper` for an immediate amp-ish chain.
|
||||||
|
- **S2 · Component amp pedals** (`feat/amp-component` → `feat/amp-voices`, needs 1.7 L1+L2) —
|
||||||
|
input → gain → oversampled triode stage(s) → tone stack → power-amp stage → cabinet IR.
|
||||||
|
Shipped as dedicated amp-voice blocks — **California** (Fender-style, Bright shelf),
|
||||||
|
**British** (Marshall-style, Presence shelf), **Chime** (Vox-style, Cut low-pass), and the
|
||||||
|
full-surface **Fullerton Reverb** (blackface combo: spring reverb + tremolo + Bright switch) —
|
||||||
|
rather than a single model-selector pedal, so each voice fixes its tone-stack model and exposes its own
|
||||||
|
signature control. Shared base: `AmpVoicePedal`.
|
||||||
|
- **S3 · Neural amp pedal** (`feat/amp-neural`, needs 1.7 L3) — loads NAM/Proteus captures;
|
||||||
|
model browser; DI-in → neural → (optional) cabinet IR.
|
||||||
|
- **S4 · Amp UI** (`feat/amp-ui`) — amp-head-style card: Gain, Bass/Mid/Treble/Presence, Master,
|
||||||
|
Cab select, Model select; MIDI/CC mapping; larger `widthUnits`. (Mind the flow-canvas height:
|
||||||
|
no greedy vertical `Spacer`s — see the looper fix.)
|
||||||
|
- **S5 · Rigs, presets, release** — factory amp rigs; docs; bump dep to Lyrebird 1.7, app to
|
||||||
|
2.0.0; tag + push mooo (HTTP/1.1).
|
||||||
|
|
||||||
|
## Suggested order
|
||||||
|
|
||||||
|
1. S1 cabinet pedal (independent, ships on 1.6.4).
|
||||||
|
2. Lyrebird 1.7: L1 tone stack → L2 triode → L3 neural (each branch + review); cut 1.7.
|
||||||
|
3. ShoeGaze: S2 component amp, then S3 neural amp; S4 UI alongside; S5 release 2.0.
|
||||||
|
|
||||||
|
## Risks / open items
|
||||||
|
|
||||||
|
- **RT budget:** stacked oversampled stages + convolution + neural can be heavy. Measure with the
|
||||||
|
CPU meter; consider `ParallelGroup` for independent chains.
|
||||||
|
- **Neural portability:** Swift kernel preserves the cross-platform port; an RTNeural C++ bridge
|
||||||
|
would not — decide in Phase 0.
|
||||||
|
- **WDF Newton solve** must be strictly alloc-free with bounded iterations to satisfy RT rules.
|
||||||
|
- **Licensing:** vet cab-IR and NAM-model licenses before bundling any factory content.
|
||||||
|
- **Anti-aliasing:** every nonlinear stage oversamples (the halfband primitives are proven);
|
||||||
|
neural distortion aliases too — consider the fine-tuning / oversampling mitigations from the
|
||||||
|
recent literature if artifacts appear.
|
||||||