Compare commits
93 Commits
393fb47a78
..
v1.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 957a99d802 | |||
| e839447aa8 | |||
| a21121e120 | |||
| bc6e6286df | |||
| bc7157b7ee | |||
| 7d3bafe200 | |||
| 284093c302 | |||
| a5f3aab237 | |||
| f573d1e9a6 | |||
| 8775134d4f | |||
| 7a39a2477e | |||
| a12f58e1d1 | |||
| 16f837ee10 | |||
| 0d75108fb1 | |||
| 17f74a4ede | |||
| 077a8ad9f0 | |||
| 7ceb93e411 | |||
| a334a76f7c | |||
| 5af4230038 | |||
| 0f69c27772 | |||
| eafc68d283 | |||
| f0b30379c7 | |||
| de4d650378 | |||
| 6e299b9d38 | |||
| 9a8e5461c0 | |||
| 849240e6e2 | |||
| e8e134499d | |||
| dc42db0c59 | |||
| b55df174a6 | |||
| f87fc1d4b1 | |||
| a99c3e86ce | |||
| 900b441082 | |||
| 8c701af128 | |||
| 12c7dc60f7 | |||
| 0d17ed260b | |||
| f29ab609bd | |||
| 9bc049d8a3 | |||
| 5040ea1518 | |||
| 21b9123a87 | |||
| 24ce4564e8 | |||
| b1303a25ae | |||
| 21fda7067d | |||
| 8c601e2029 | |||
| 5a07a6d4b4 | |||
| 475dd392e6 | |||
| dff58175f1 | |||
| 42268b65a1 | |||
| 2c36de5c0d | |||
| f19dc2c1b3 | |||
| 6ad813601f | |||
| 652a5a76ca | |||
| 9b31be7921 | |||
| 705b4ed534 | |||
| 4627b3b800 | |||
| c25d783b71 | |||
| b4b2f58762 | |||
| c0605d295d | |||
| cdac587454 | |||
| 69f50b2037 | |||
| b08ce4d999 | |||
| 372494aae4 | |||
| 37ec8cd331 | |||
| 9ebcbd4027 | |||
| 77156e696b | |||
| 46e075fb8c | |||
| ed27ab166c | |||
| c6f567535b | |||
| e36dc3a527 | |||
| 5633ede630 | |||
| c491f97440 | |||
| 499ab1310e | |||
| 9b7c5246ec | |||
| 1a09cf9cf8 | |||
| d8142c9d7d | |||
| 8ffc1caa42 | |||
| 6c1859c59d | |||
| 35971d4acc | |||
| d41ba37093 | |||
| e1ec98413d | |||
| 0960d4e7c5 | |||
| 2ba57cadd6 | |||
| c677e124f4 | |||
| 712f049f96 | |||
| 211b9da438 | |||
| d5b17b7663 | |||
| 5522109689 | |||
| 30e96b8ee1 | |||
| 02cee9a358 | |||
| f89229282f | |||
| ca4cabb42f | |||
| 1ecacbfc21 | |||
| 79e200a61e | |||
| b564b154a0 |
@@ -18,3 +18,5 @@ DerivedData/
|
|||||||
*.swiftmodule
|
*.swiftmodule
|
||||||
|
|
||||||
# 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
|
||||||
|
review.diff
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# ShoeGaze — Claude Context
|
||||||
|
|
||||||
|
A virtual guitar-pedalboard framework built on Lyrebird. Two products:
|
||||||
|
`LyrebirdShoeGaze` (core pedal/board framework, no SwiftUI) and `LyrebirdShoeGazeUI`
|
||||||
|
(SwiftUI views). Depends on the published Lyrebird package.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- **MIT SPDX header** on every new `.swift` file (first 5 lines): file name, `// Lyrebird`,
|
||||||
|
blank comment, `// Copyright (c) 2026 Joshua Parmenter / realizedsound`,
|
||||||
|
`// SPDX-License-Identifier: MIT`, then a blank line.
|
||||||
|
- **Explicit type annotations** on `let`/`var` bindings, named constants for non-trivial
|
||||||
|
literals, doc comments on public init params — matches the Lyrebird house style.
|
||||||
|
- Pedals subclass `Pedal` (in `Sources/LyrebirdShoeGaze/Pedals/`), expose parameters as
|
||||||
|
`@UIParam`, and surface them via `effectKnobs` / `effectSwitches` / `effectSliders`.
|
||||||
|
- A pedal's `displayName` **is** its serialization key and its `PedalType.rawValue`, and the
|
||||||
|
`PedalRegistry.builtIn` key. Keep all three identical when adding a pedal.
|
||||||
|
|
||||||
|
## Adding a new pedal — required checklist
|
||||||
|
|
||||||
|
1. `Sources/LyrebirdShoeGaze/Pedals/<Name>Pedal.swift` — subclass `Pedal`, override `effect`
|
||||||
|
(or `wideEffect`/`stereoEffect`), `effectKnobs`/`effectSwitches`/`effectSliders`.
|
||||||
|
2. **`summary`** — override `open var summary: String` with a one-line, user-facing
|
||||||
|
description. **This is mandatory for every pedal** (see "Pedal info" below).
|
||||||
|
3. Register in `PedalRegistry.builtIn["<DisplayName>"]`.
|
||||||
|
4. Add `PedalType.<name> = PedalType("<DisplayName>")`.
|
||||||
|
5. Enclosure color case in `PedalView.enclosureColor(for:)`.
|
||||||
|
6. Add to `PedalPaletteView.preferredOrder`.
|
||||||
|
7. Tests in `Tests/LyrebirdShoeGazeTests/<Name>PedalTests.swift` — at minimum: builds +
|
||||||
|
non-silent, each effect parameter measurably changes the output, knob-list assertion,
|
||||||
|
and (if it has switches/sliders) a preset round-trip.
|
||||||
|
8. Use `PedalType` static members at call sites (`appendPedal(.overdrive, to:)`), never raw
|
||||||
|
strings, except where a string is inherently dynamic (registry / preset load).
|
||||||
|
|
||||||
|
## Pedal info (mandatory)
|
||||||
|
|
||||||
|
Every pedal participates in the pedal-info UI:
|
||||||
|
|
||||||
|
- **`summary`** (required): a short, non-proprietary, user-facing sentence describing what
|
||||||
|
the pedal does. The picker shows it as a subtitle; the pedal's ⓘ info panel shows it as
|
||||||
|
the description. A new pedal without a non-empty `summary` is incomplete — a test asserts
|
||||||
|
every registered pedal has one.
|
||||||
|
- The info panel lists the **effect controls only** (`effectKnobs` + `effectSliders` +
|
||||||
|
`effectSwitches`) with their ranges/options — never the common Mix / Level / bypass. Put
|
||||||
|
the meaningful range and a clear unit in each control's `label`/`range` so the info panel
|
||||||
|
reads well.
|
||||||
|
|
||||||
|
## dB parameters
|
||||||
|
|
||||||
|
There is no dB→linear generator for a control-rate node. To apply a dB gain to a signal,
|
||||||
|
convert in the graph: `Exp.Audio($gainDB * dbToLinExpScale)` where
|
||||||
|
`dbToLinExpScale = ln(10)/20 ≈ 0.11512925464970229` (gives `10^(dB/20)`). RBJ shelving/peaking
|
||||||
|
filters take gain in dB directly, so pass dB nodes straight through.
|
||||||
|
|
||||||
|
## Build / test
|
||||||
|
|
||||||
|
- Package: `swift build` / `swift test --no-parallel` (the multi-engine suite can hit
|
||||||
|
Lyrebird's parallel-teardown flake without `--no-parallel`).
|
||||||
|
- Apps: `Demo/ShoeGaze.xcworkspace` (macOS builder, iPad builder, demos). iOS targets are
|
||||||
|
iPad-only, landscape.
|
||||||
|
|
||||||
|
## Planned work
|
||||||
|
|
||||||
|
`docs/plans/` holds the next-version feature plans.
|
||||||
@@ -0,0 +1,399 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 60;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
C3B100000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B10000000000000000001E /* LyrebirdShoeGaze */; };
|
||||||
|
C3B100000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B10000000000000000001F /* LyrebirdShoeGazeUI */; };
|
||||||
|
C3B100000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B100000000000000000023 /* Lyrebird */; };
|
||||||
|
C3B100000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B100000000000000000025 /* LyrebirdUI */; };
|
||||||
|
C3B100000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3B100000000000000000030 /* Assets.xcassets */; };
|
||||||
|
C3B1000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B100000000000000000007 /* main.swift */; };
|
||||||
|
C3B1000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B100000000000000000008 /* AppDelegate.swift */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
C3B100000000000000000004 /* ShoeGazeBuilder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeBuilder.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
C3B100000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
C3B100000000000000000007 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||||
|
C3B100000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
C3B100000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
C3B100000000000000000012 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3B100000000000000000020 /* LyrebirdShoeGaze in Frameworks */,
|
||||||
|
C3B100000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */,
|
||||||
|
C3B100000000000000000022 /* Lyrebird in Frameworks */,
|
||||||
|
C3B100000000000000000024 /* LyrebirdUI in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
C3B100000000000000000002 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3B100000000000000000005 /* ShoeGazeBuilder */,
|
||||||
|
C3B100000000000000000003 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C3B100000000000000000003 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3B100000000000000000004 /* ShoeGazeBuilder.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C3B100000000000000000005 /* ShoeGazeBuilder */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3B100000000000000000007 /* main.swift */,
|
||||||
|
C3B100000000000000000008 /* AppDelegate.swift */,
|
||||||
|
C3B100000000000000000030 /* Assets.xcassets */,
|
||||||
|
C3B100000000000000000006 /* Info.plist */,
|
||||||
|
);
|
||||||
|
path = ShoeGazeBuilder;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
C3B100000000000000000014 /* ShoeGazeBuilder */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C3B100000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilder" */;
|
||||||
|
buildPhases = (
|
||||||
|
C3B100000000000000000011 /* Sources */,
|
||||||
|
C3B100000000000000000012 /* Frameworks */,
|
||||||
|
C3B100000000000000000013 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = ShoeGazeBuilder;
|
||||||
|
packageProductDependencies = (
|
||||||
|
C3B10000000000000000001E /* LyrebirdShoeGaze */,
|
||||||
|
C3B10000000000000000001F /* LyrebirdShoeGazeUI */,
|
||||||
|
C3B100000000000000000023 /* Lyrebird */,
|
||||||
|
C3B100000000000000000025 /* LyrebirdUI */,
|
||||||
|
);
|
||||||
|
productName = ShoeGazeBuilder;
|
||||||
|
productReference = C3B100000000000000000004 /* ShoeGazeBuilder.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
C3B100000000000000000001 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastSwiftUpdateCheck = 1600;
|
||||||
|
LastUpgradeCheck = 2620;
|
||||||
|
TargetAttributes = {
|
||||||
|
C3B100000000000000000014 = {
|
||||||
|
CreatedOnToolsVersion = 16.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = C3B100000000000000000018 /* Build configuration list for PBXProject "ShoeGazeBuilder" */;
|
||||||
|
compatibilityVersion = "Xcode 14.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = C3B100000000000000000002;
|
||||||
|
packageReferences = (
|
||||||
|
C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */,
|
||||||
|
C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */,
|
||||||
|
);
|
||||||
|
productRefGroup = C3B100000000000000000003 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
C3B100000000000000000014 /* ShoeGazeBuilder */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
C3B100000000000000000013 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3B100000000000000000031 /* Assets.xcassets in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
C3B100000000000000000011 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3B1000000000000000000C /* main.swift in Sources */,
|
||||||
|
C3B1000000000000000000D /* AppDelegate.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C3B100000000000000000016 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilder/ShoeGazeBuilder.entitlements;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
CURRENT_PROJECT_VERSION = 4;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
|
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/../Frameworks",
|
||||||
|
);
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
|
MARKETING_VERSION = 1.2.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C3B100000000000000000017 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilder/ShoeGazeBuilder.entitlements;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
CURRENT_PROJECT_VERSION = 4;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
|
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/../Frameworks",
|
||||||
|
);
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
|
MARKETING_VERSION = 1.2.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C3B100000000000000000019 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C3B10000000000000000001A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C3B100000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilder" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C3B100000000000000000016 /* Debug */,
|
||||||
|
C3B100000000000000000017 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C3B100000000000000000018 /* Build configuration list for PBXProject "ShoeGazeBuilder" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C3B100000000000000000019 /* Debug */,
|
||||||
|
C3B10000000000000000001A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCLocalSwiftPackageReference section */
|
||||||
|
C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */ = {
|
||||||
|
isa = XCLocalSwiftPackageReference;
|
||||||
|
relativePath = ..;
|
||||||
|
};
|
||||||
|
/* End XCLocalSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 1.2.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
C3B10000000000000000001E /* LyrebirdShoeGaze */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */;
|
||||||
|
productName = LyrebirdShoeGaze;
|
||||||
|
};
|
||||||
|
C3B10000000000000000001F /* LyrebirdShoeGazeUI */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */;
|
||||||
|
productName = LyrebirdShoeGazeUI;
|
||||||
|
};
|
||||||
|
C3B100000000000000000023 /* Lyrebird */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||||
|
productName = Lyrebird;
|
||||||
|
};
|
||||||
|
C3B100000000000000000025 /* LyrebirdUI */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||||
|
productName = LyrebirdUI;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
|
};
|
||||||
|
rootObject = C3B100000000000000000001 /* Project object */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "linenoise-swift",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/andybest/linenoise-swift",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
|
||||||
|
"version" : "0.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "lyrebird",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||||
|
"version" : "1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "nimble",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/Quick/Nimble.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
|
||||||
|
"version" : "7.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2620"
|
||||||
|
version = "1.7">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3B100000000000000000014"
|
||||||
|
BuildableName = "ShoeGazeBuilder.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilder"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilder.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3B100000000000000000014"
|
||||||
|
BuildableName = "ShoeGazeBuilder.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilder"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilder.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3B100000000000000000014"
|
||||||
|
BuildableName = "ShoeGazeBuilder.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilder"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilder.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,346 @@
|
|||||||
|
// AppDelegate.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
import AppKit
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
import LyrebirdShoeGazeUI
|
||||||
|
|
||||||
|
/// Application delegate for the ShoeGaze Builder.
|
||||||
|
///
|
||||||
|
/// Creates a `SynthesisEngine` and a `ShoeGaze` session seeded with one empty board, then opens a
|
||||||
|
/// `LyrebirdWindow` hosting ``ShoeGazeBuilderView`` — the interactive palette + board builder.
|
||||||
|
///
|
||||||
|
/// The engine is **not** started automatically; the user clicks Start in the builder's toolbar.
|
||||||
|
/// On termination the engine is stopped to release Core Audio resources cleanly.
|
||||||
|
@MainActor
|
||||||
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
|
// MARK: - Engine configuration constants
|
||||||
|
|
||||||
|
private static let blockSize: Int = 512
|
||||||
|
private static let sampleRate: Double = 48_000.0
|
||||||
|
private static let outputChannels: Int = 2
|
||||||
|
// Built-in mics are mono; default to one input channel so live input works out of the box.
|
||||||
|
// CoreAudio can't satisfy a request for more input channels than the device provides, which
|
||||||
|
// leaves live input silent. Users with multi-input interfaces can raise this in the UI.
|
||||||
|
private static let inputChannels: Int = 1
|
||||||
|
private static let numAudioBuses: Int = 256
|
||||||
|
|
||||||
|
// MARK: - Window geometry constants
|
||||||
|
|
||||||
|
private static let windowWidth: CGFloat = 1_400
|
||||||
|
private static let windowHeight: CGFloat = 860
|
||||||
|
|
||||||
|
/// Margin from the left edge of the screen's visible area, in points.
|
||||||
|
private static let leftMargin: CGFloat = 100
|
||||||
|
/// Margin reserved at the right edge so the window never runs off-screen.
|
||||||
|
private static let rightMargin: CGFloat = 40
|
||||||
|
/// Fraction of the visible screen height the window should occupy.
|
||||||
|
private static let heightFraction: CGFloat = 0.88
|
||||||
|
|
||||||
|
/// The default pedal the seed board comes up with, so audio is audible immediately on Start.
|
||||||
|
private static let seedPedalType: PedalType = .overdrive
|
||||||
|
|
||||||
|
// MARK: - Owned objects
|
||||||
|
|
||||||
|
private let coreDriver: CoreAudioDriver
|
||||||
|
private let engine: SynthesisEngine
|
||||||
|
private let shoeGaze: ShoeGaze
|
||||||
|
private let window: LyrebirdWindow
|
||||||
|
|
||||||
|
/// The rig library; constructed in `init`, resolved + loaded asynchronously after launch.
|
||||||
|
private let library: RigLibraryStore
|
||||||
|
|
||||||
|
/// Record toggle item, retained so `validateMenuItem(_:)` can flip its title + enabled state.
|
||||||
|
private var recordMenuItem: NSMenuItem?
|
||||||
|
|
||||||
|
/// Default file name offered by the archive Export panel.
|
||||||
|
private static let defaultArchiveFileName: String = "ShoeGaze Library"
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
override init() {
|
||||||
|
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
||||||
|
let engine: SynthesisEngine = SynthesisEngine(
|
||||||
|
blockSize: AppDelegate.blockSize,
|
||||||
|
sampleRate: AppDelegate.sampleRate,
|
||||||
|
numOutputChannels: AppDelegate.outputChannels,
|
||||||
|
numInputChannels: AppDelegate.inputChannels,
|
||||||
|
numAudioBuses: AppDelegate.numAudioBuses,
|
||||||
|
driver: coreDriver
|
||||||
|
)
|
||||||
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
self.coreDriver = coreDriver
|
||||||
|
self.engine = engine
|
||||||
|
self.shoeGaze = shoeGaze
|
||||||
|
self.window = LyrebirdWindow(
|
||||||
|
title: "ShoeGaze Builder — Lyrebird Pedalboard",
|
||||||
|
width: AppDelegate.windowWidth,
|
||||||
|
height: AppDelegate.windowHeight
|
||||||
|
)
|
||||||
|
|
||||||
|
// Stored `let`s must be set before `super.init()`. Restore the autosaved working rig (or
|
||||||
|
// seed a board) — operating on `shoeGaze`, not on `self` methods (unavailable pre-super).
|
||||||
|
if !RigStore.restore(into: shoeGaze) {
|
||||||
|
AppDelegate.seedInitialBoard(into: shoeGaze)
|
||||||
|
}
|
||||||
|
// The library constructs instantly; it resolves iCloud + loads asynchronously after launch.
|
||||||
|
self.library = RigLibraryBootstrap.makeStore()
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Seeds one board with a single pedal so the builder opens with an audible starting point.
|
||||||
|
private static func seedInitialBoard(into shoeGaze: ShoeGaze) {
|
||||||
|
var created: PedalBoard?
|
||||||
|
do {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
created = board
|
||||||
|
try shoeGaze.appendPedal(AppDelegate.seedPedalType, to: board)
|
||||||
|
} catch {
|
||||||
|
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||||
|
print("[ShoeGazeBuilder] seed board failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - NSApplicationDelegate
|
||||||
|
|
||||||
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
|
installMainMenu()
|
||||||
|
let session: ShoeGaze = shoeGaze
|
||||||
|
let driver: CoreAudioDriver = coreDriver
|
||||||
|
let rigLibrary: RigLibraryStore = library
|
||||||
|
window.open {
|
||||||
|
ShoeGazeBuilderView(
|
||||||
|
shoeGaze: session,
|
||||||
|
library: rigLibrary,
|
||||||
|
hardwareSampleRate: { driver.deviceSampleRate }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
anchorWindowLeft()
|
||||||
|
|
||||||
|
// Resolve iCloud + load the library off the main thread, then seed from the working rig if
|
||||||
|
// it is still empty (first run).
|
||||||
|
let rigSession: ShoeGaze = shoeGaze
|
||||||
|
Task { await RigLibraryBootstrap.start(rigLibrary, seedFrom: rigSession) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Anchors the window `leftMargin` points from the left of the visible screen and sizes it to
|
||||||
|
/// most of the visible height, so it presents large and left-aligned rather than centered.
|
||||||
|
private func anchorWindowLeft() {
|
||||||
|
guard let nsWindow: NSWindow = window.nsWindow,
|
||||||
|
let screen: NSScreen = nsWindow.screen ?? NSScreen.main else { return }
|
||||||
|
let visible: NSRect = screen.visibleFrame
|
||||||
|
let height: CGFloat = visible.height * AppDelegate.heightFraction
|
||||||
|
let maxWidth: CGFloat = visible.width - AppDelegate.leftMargin - AppDelegate.rightMargin
|
||||||
|
let width: CGFloat = min(AppDelegate.windowWidth, maxWidth)
|
||||||
|
let originX: CGFloat = visible.minX + AppDelegate.leftMargin
|
||||||
|
// Top-align: place the window's top near the top of the visible area.
|
||||||
|
let originY: CGFloat = visible.maxY - height
|
||||||
|
nsWindow.setFrame(
|
||||||
|
NSRect(x: originX, y: originY, width: width, height: height),
|
||||||
|
display: true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationWillTerminate(_ notification: Notification) {
|
||||||
|
RigStore.save(shoeGaze)
|
||||||
|
// Ensure any in-flight background rig-library writes finish before exit.
|
||||||
|
library.flushPendingWrites()
|
||||||
|
engine.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationDidResignActive(_ notification: Notification) {
|
||||||
|
// Persist on every deactivation too, so state survives an unexpected exit.
|
||||||
|
RigStore.save(shoeGaze)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Main menu
|
||||||
|
|
||||||
|
/// Builds a minimal menu bar: an application menu with About / Hide / Quit (⌘Q).
|
||||||
|
private func installMainMenu() {
|
||||||
|
let appName: String = ProcessInfo.processInfo.processName
|
||||||
|
let mainMenu: NSMenu = NSMenu()
|
||||||
|
|
||||||
|
let appMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(appMenuItem)
|
||||||
|
let appMenu: NSMenu = NSMenu()
|
||||||
|
appMenuItem.submenu = appMenu
|
||||||
|
appMenu.addItem(
|
||||||
|
withTitle: "About \(appName)",
|
||||||
|
action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)),
|
||||||
|
keyEquivalent: ""
|
||||||
|
)
|
||||||
|
appMenu.addItem(NSMenuItem.separator())
|
||||||
|
appMenu.addItem(
|
||||||
|
withTitle: "Hide \(appName)",
|
||||||
|
action: #selector(NSApplication.hide(_:)),
|
||||||
|
keyEquivalent: "h"
|
||||||
|
)
|
||||||
|
appMenu.addItem(NSMenuItem.separator())
|
||||||
|
appMenu.addItem(
|
||||||
|
withTitle: "Quit \(appName)",
|
||||||
|
action: #selector(NSApplication.terminate(_:)),
|
||||||
|
keyEquivalent: "q"
|
||||||
|
)
|
||||||
|
|
||||||
|
// File menu — rig save / load.
|
||||||
|
let fileMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(fileMenuItem)
|
||||||
|
let fileMenu: NSMenu = NSMenu(title: "File")
|
||||||
|
fileMenuItem.submenu = fileMenu
|
||||||
|
// Per-rig commands forward to the in-window builder (which owns the current-rig state and
|
||||||
|
// the naming prompts) via notifications.
|
||||||
|
addItem(to: fileMenu, title: "New Rig", action: #selector(newRigAction(_:)), key: "n")
|
||||||
|
addItem(to: fileMenu, title: "Save Rig", action: #selector(saveRigAction(_:)), key: "s")
|
||||||
|
fileMenu.addItem(NSMenuItem.separator())
|
||||||
|
// The whole-library archive: a single file holding every rig, for backup or transfer.
|
||||||
|
addItem(to: fileMenu, title: "Export Archive…", action: #selector(exportArchiveAction(_:)), key: "e")
|
||||||
|
addItem(to: fileMenu, title: "Import Archive…", action: #selector(importArchiveAction(_:)), key: "i")
|
||||||
|
|
||||||
|
// Board menu — add board + transport.
|
||||||
|
let boardMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(boardMenuItem)
|
||||||
|
let boardMenu: NSMenu = NSMenu(title: "Board")
|
||||||
|
boardMenuItem.submenu = boardMenu
|
||||||
|
// Engine start/stop lives in the in-window EngineConfigView (with sample-rate/channel
|
||||||
|
// config and the mismatch alert), so the Board menu only adds boards.
|
||||||
|
addItem(to: boardMenu, title: "Add Board", action: #selector(addBoardAction(_:)), key: "b")
|
||||||
|
|
||||||
|
// Record menu — choose an output folder, then toggle recording.
|
||||||
|
let recordMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(recordMenuItem)
|
||||||
|
let recordMenu: NSMenu = NSMenu(title: "Record")
|
||||||
|
recordMenuItem.submenu = recordMenu
|
||||||
|
addItem(
|
||||||
|
to: recordMenu,
|
||||||
|
title: "Choose Recording Folder…",
|
||||||
|
action: #selector(chooseRecordingFolderAction(_:)),
|
||||||
|
key: ""
|
||||||
|
)
|
||||||
|
recordMenu.addItem(NSMenuItem.separator())
|
||||||
|
self.recordMenuItem = addItem(
|
||||||
|
to: recordMenu,
|
||||||
|
title: "Start Recording",
|
||||||
|
action: #selector(toggleRecordingAction(_:)),
|
||||||
|
key: "R" // ⇧⌘R
|
||||||
|
)
|
||||||
|
|
||||||
|
NSApplication.shared.mainMenu = mainMenu
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds a menu item targeting this delegate and returns it.
|
||||||
|
@discardableResult
|
||||||
|
private func addItem(
|
||||||
|
to menu: NSMenu,
|
||||||
|
title: String,
|
||||||
|
action: Selector,
|
||||||
|
key: String
|
||||||
|
) -> NSMenuItem {
|
||||||
|
let item: NSMenuItem = NSMenuItem(title: title, action: action, keyEquivalent: key)
|
||||||
|
item.target = self
|
||||||
|
menu.addItem(item)
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Menu actions
|
||||||
|
|
||||||
|
@objc private func newRigAction(_ sender: Any?) {
|
||||||
|
// Forward to the builder view, which owns the current-rig state and naming prompt.
|
||||||
|
NotificationCenter.default.post(name: .shoeGazeNewRig, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func saveRigAction(_ sender: Any?) {
|
||||||
|
NotificationCenter.default.post(name: .shoeGazeSaveRig, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func exportArchiveAction(_ sender: Any?) {
|
||||||
|
let panel: NSSavePanel = NSSavePanel()
|
||||||
|
panel.allowedContentTypes = [.json]
|
||||||
|
panel.nameFieldStringValue = "\(AppDelegate.defaultArchiveFileName).json"
|
||||||
|
panel.canCreateDirectories = true
|
||||||
|
let rigLibrary: RigLibraryStore = library
|
||||||
|
panel.begin { response in
|
||||||
|
guard response == .OK, let url: URL = panel.url else { return }
|
||||||
|
do { try rigLibrary.exportArchiveData().write(to: url, options: .atomic) }
|
||||||
|
catch { print("[ShoeGazeBuilder] export archive failed: \(error)") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func importArchiveAction(_ sender: Any?) {
|
||||||
|
let panel: NSOpenPanel = NSOpenPanel()
|
||||||
|
panel.allowedContentTypes = [.json]
|
||||||
|
panel.canChooseDirectories = false
|
||||||
|
panel.allowsMultipleSelection = false
|
||||||
|
let rigLibrary: RigLibraryStore = library
|
||||||
|
panel.begin { response in
|
||||||
|
guard response == .OK, let url: URL = panel.url else { return }
|
||||||
|
do {
|
||||||
|
let data: Data = try Data(contentsOf: url)
|
||||||
|
_ = try rigLibrary.importArchive(from: data)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilder] import archive failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func addBoardAction(_ sender: Any?) {
|
||||||
|
var created: PedalBoard?
|
||||||
|
do {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
created = board
|
||||||
|
try shoeGaze.finalizeBoard(board)
|
||||||
|
} catch {
|
||||||
|
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||||
|
print("[ShoeGazeBuilder] addBoard failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func chooseRecordingFolderAction(_ sender: Any?) {
|
||||||
|
let panel: NSOpenPanel = NSOpenPanel()
|
||||||
|
panel.canChooseDirectories = true
|
||||||
|
panel.canChooseFiles = false
|
||||||
|
panel.allowsMultipleSelection = false
|
||||||
|
panel.canCreateDirectories = true
|
||||||
|
panel.prompt = "Choose"
|
||||||
|
panel.message = "Select a folder for recording output"
|
||||||
|
let session: ShoeGaze = shoeGaze
|
||||||
|
panel.begin { response in
|
||||||
|
if response == .OK, let url: URL = panel.url {
|
||||||
|
session.recordingFolder = url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func toggleRecordingAction(_ sender: Any?) {
|
||||||
|
if shoeGaze.isRecording {
|
||||||
|
shoeGaze.stopRecording()
|
||||||
|
} else {
|
||||||
|
do { try shoeGaze.startRecording() }
|
||||||
|
catch { print("[ShoeGazeBuilder] startRecording() failed: \(error)") }
|
||||||
|
}
|
||||||
|
// Reflect the new state on the item immediately, not only on the next menu-open validation.
|
||||||
|
recordMenuItem?.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording"
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||||
|
if menuItem == recordMenuItem {
|
||||||
|
menuItem.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording"
|
||||||
|
// Can always stop; can only start once a folder has been chosen.
|
||||||
|
return shoeGaze.isRecording || shoeGaze.recordingFolder != nil
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{"size":"16x16","idiom":"mac","filename":"icon_16x16.png","scale":"1x"},
|
||||||
|
{"size":"16x16","idiom":"mac","filename":"icon_16x16@2x.png","scale":"2x"},
|
||||||
|
{"size":"32x32","idiom":"mac","filename":"icon_32x32.png","scale":"1x"},
|
||||||
|
{"size":"32x32","idiom":"mac","filename":"icon_32x32@2x.png","scale":"2x"},
|
||||||
|
{"size":"128x128","idiom":"mac","filename":"icon_128x128.png","scale":"1x"},
|
||||||
|
{"size":"128x128","idiom":"mac","filename":"icon_128x128@2x.png","scale":"2x"},
|
||||||
|
{"size":"256x256","idiom":"mac","filename":"icon_256x256.png","scale":"1x"},
|
||||||
|
{"size":"256x256","idiom":"mac","filename":"icon_256x256@2x.png","scale":"2x"},
|
||||||
|
{"size":"512x512","idiom":"mac","filename":"icon_512x512.png","scale":"1x"},
|
||||||
|
{"size":"512x512","idiom":"mac","filename":"icon_512x512@2x.png","scale":"2x"}
|
||||||
|
],
|
||||||
|
"info" : {"author":"xcode","version":1}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 782 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 345 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 345 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1 @@
|
|||||||
|
{ "info" : {"author":"xcode","version":1} }
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.2.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSApplicationCategoryType</key>
|
||||||
|
<string>public.app-category.music</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
<key>NSUbiquitousContainers</key>
|
||||||
|
<dict>
|
||||||
|
<key>iCloud.net.realizedsound.ShoeGazeData</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSUbiquitousContainerName</key>
|
||||||
|
<string>ShoeGaze</string>
|
||||||
|
<key>NSUbiquitousContainerSupportedFolderLevels</key>
|
||||||
|
<string>Any</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.device.audio-input</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||||
|
<array>
|
||||||
|
<string>iCloud.net.realizedsound.ShoeGazeData</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.developer.icloud-services</key>
|
||||||
|
<array>
|
||||||
|
<string>CloudDocuments</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
||||||
|
<array>
|
||||||
|
<string>iCloud.net.realizedsound.ShoeGazeData</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// main.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
import AppKit
|
||||||
|
|
||||||
|
// Program entry runs on the main thread; assert main-actor isolation for the AppKit bootstrap
|
||||||
|
// rather than hopping asynchronously. `AppDelegate.init` builds `@MainActor` synthesizers and UI.
|
||||||
|
MainActor.assumeIsolated {
|
||||||
|
let app: NSApplication = NSApplication.shared
|
||||||
|
let delegate: AppDelegate = AppDelegate()
|
||||||
|
app.setActivationPolicy(.regular)
|
||||||
|
app.delegate = delegate
|
||||||
|
app.activate(ignoringOtherApps: true)
|
||||||
|
app.run()
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// The ShoeGaze Builder is a macOS AppKit application and has no iOS entry point here.
|
||||||
|
print("ShoeGazeBuilder runs on macOS only.")
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,391 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 60;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */; };
|
||||||
|
C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */; };
|
||||||
|
C3C10000000000000000000B /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001A /* LyrebirdShoeGaze */; };
|
||||||
|
C3C10000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001B /* LyrebirdShoeGazeUI */; };
|
||||||
|
C3C10000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001C /* LyrebirdUI */; };
|
||||||
|
C3C10000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001E /* Lyrebird */; };
|
||||||
|
C3C100000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000030 /* Assets.xcassets */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeBuilderiOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
C3C100000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; 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>"; };
|
||||||
|
C3C100000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
C3C10000000000000000000F /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3C10000000000000000000B /* LyrebirdShoeGaze in Frameworks */,
|
||||||
|
C3C10000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */,
|
||||||
|
C3C10000000000000000000D /* LyrebirdUI in Frameworks */,
|
||||||
|
C3C10000000000000000001D /* Lyrebird in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
C3C100000000000000000002 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3C100000000000000000005 /* ShoeGazeBuilderiOS */,
|
||||||
|
C3C100000000000000000003 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C3C100000000000000000003 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C3C100000000000000000005 /* ShoeGazeBuilderiOS */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */,
|
||||||
|
C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */,
|
||||||
|
C3C100000000000000000030 /* Assets.xcassets */,
|
||||||
|
C3C100000000000000000006 /* Info.plist */,
|
||||||
|
);
|
||||||
|
path = ShoeGazeBuilderiOS;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
C3C100000000000000000011 /* ShoeGazeBuilderiOS */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C3C100000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilderiOS" */;
|
||||||
|
buildPhases = (
|
||||||
|
C3C10000000000000000000E /* Sources */,
|
||||||
|
C3C10000000000000000000F /* Frameworks */,
|
||||||
|
C3C100000000000000000010 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = ShoeGazeBuilderiOS;
|
||||||
|
packageProductDependencies = (
|
||||||
|
C3C10000000000000000001A /* LyrebirdShoeGaze */,
|
||||||
|
C3C10000000000000000001B /* LyrebirdShoeGazeUI */,
|
||||||
|
C3C10000000000000000001C /* LyrebirdUI */,
|
||||||
|
C3C10000000000000000001E /* Lyrebird */,
|
||||||
|
);
|
||||||
|
productName = ShoeGazeBuilderiOS;
|
||||||
|
productReference = C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
C3C100000000000000000001 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastSwiftUpdateCheck = 1600;
|
||||||
|
LastUpgradeCheck = 2620;
|
||||||
|
TargetAttributes = {
|
||||||
|
C3C100000000000000000011 = {
|
||||||
|
CreatedOnToolsVersion = 16.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = C3C100000000000000000015 /* Build configuration list for PBXProject "ShoeGazeBuilderiOS" */;
|
||||||
|
compatibilityVersion = "Xcode 14.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = C3C100000000000000000002;
|
||||||
|
packageReferences = (
|
||||||
|
C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */,
|
||||||
|
C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */,
|
||||||
|
);
|
||||||
|
productRefGroup = C3C100000000000000000003 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
C3C100000000000000000011 /* ShoeGazeBuilderiOS */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
C3C100000000000000000010 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3C100000000000000000031 /* Assets.xcassets in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
C3C10000000000000000000E /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */,
|
||||||
|
C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C3C100000000000000000013 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
|
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SUPPORTS_MACCATALYST = NO;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 6.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 2;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C3C100000000000000000014 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
|
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SUPPORTS_MACCATALYST = NO;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_VERSION = 6.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 2;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C3C100000000000000000016 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C3C100000000000000000017 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C3C100000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilderiOS" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C3C100000000000000000013 /* Debug */,
|
||||||
|
C3C100000000000000000014 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C3C100000000000000000015 /* Build configuration list for PBXProject "ShoeGazeBuilderiOS" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C3C100000000000000000016 /* Debug */,
|
||||||
|
C3C100000000000000000017 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCLocalSwiftPackageReference section */
|
||||||
|
C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */ = {
|
||||||
|
isa = XCLocalSwiftPackageReference;
|
||||||
|
relativePath = ..;
|
||||||
|
};
|
||||||
|
/* End XCLocalSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 1.2.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
C3C10000000000000000001A /* LyrebirdShoeGaze */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */;
|
||||||
|
productName = LyrebirdShoeGaze;
|
||||||
|
};
|
||||||
|
C3C10000000000000000001B /* LyrebirdShoeGazeUI */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */;
|
||||||
|
productName = LyrebirdShoeGazeUI;
|
||||||
|
};
|
||||||
|
C3C10000000000000000001C /* LyrebirdUI */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||||
|
productName = LyrebirdUI;
|
||||||
|
};
|
||||||
|
C3C10000000000000000001E /* Lyrebird */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */;
|
||||||
|
productName = Lyrebird;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
|
};
|
||||||
|
rootObject = C3C100000000000000000001 /* Project object */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "linenoise-swift",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/andybest/linenoise-swift",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
|
||||||
|
"version" : "0.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "lyrebird",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||||
|
"version" : "1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "nimble",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/Quick/Nimble.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
|
||||||
|
"version" : "7.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2620"
|
||||||
|
version = "1.7">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3C100000000000000000011"
|
||||||
|
BuildableName = "ShoeGazeBuilderiOS.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilderiOS"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilderiOS.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3C100000000000000000011"
|
||||||
|
BuildableName = "ShoeGazeBuilderiOS.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilderiOS"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilderiOS.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "C3C100000000000000000011"
|
||||||
|
BuildableName = "ShoeGazeBuilderiOS.app"
|
||||||
|
BlueprintName = "ShoeGazeBuilderiOS"
|
||||||
|
ReferencedContainer = "container:ShoeGazeBuilderiOS.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{"filename":"icon_1024.png","idiom":"universal","platform":"ios","size":"1024x1024"}
|
||||||
|
],
|
||||||
|
"info" : {"author":"xcode","version":1}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 402 KiB |
@@ -0,0 +1 @@
|
|||||||
|
{ "info" : {"author":"xcode","version":1} }
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.2.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
<key>UILaunchScreen</key>
|
||||||
|
<dict/>
|
||||||
|
<key>UIRequiresFullScreen</key>
|
||||||
|
<true/>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>NSUbiquitousContainers</key>
|
||||||
|
<dict>
|
||||||
|
<key>iCloud.net.realizedsound.ShoeGazeData</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSUbiquitousContainerName</key>
|
||||||
|
<string>ShoeGaze</string>
|
||||||
|
<key>NSUbiquitousContainerSupportedFolderLevels</key>
|
||||||
|
<string>Any</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||||
|
<array>
|
||||||
|
<string>iCloud.net.realizedsound.ShoeGazeData</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.developer.icloud-services</key>
|
||||||
|
<array>
|
||||||
|
<string>CloudDocuments</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
||||||
|
<array>
|
||||||
|
<string>iCloud.net.realizedsound.ShoeGazeData</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
// ShoeGazeBuilderiOSApp.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import LyrebirdShoeGazeUI
|
||||||
|
|
||||||
|
/// iOS entry point for the ShoeGaze Builder.
|
||||||
|
///
|
||||||
|
/// Holds the `ShoeGazeBuilderiOSAppModel` as `@State` so it is created once and owned for the
|
||||||
|
/// lifetime of the app. The audio engine is **not** started automatically — the user presses
|
||||||
|
/// Start in ``ShoeGazeBuilderView``. The engine is stopped when the view disappears.
|
||||||
|
///
|
||||||
|
/// ``ShoeGazeBuilderView`` manages its own scroll regions (palette + builder), so it is hosted
|
||||||
|
/// directly rather than wrapped in an outer `ScrollView`.
|
||||||
|
@main
|
||||||
|
struct ShoeGazeBuilderiOSApp: App {
|
||||||
|
|
||||||
|
@State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel()
|
||||||
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
|
var body: some Scene {
|
||||||
|
WindowGroup {
|
||||||
|
NavigationStack {
|
||||||
|
ShoeGazeBuilderView(
|
||||||
|
shoeGaze: model.shoeGaze,
|
||||||
|
library: model.library,
|
||||||
|
hardwareSampleRate: { model.hardwareSampleRate },
|
||||||
|
onEnableLiveInput: { model.enableLiveInput() }
|
||||||
|
)
|
||||||
|
.navigationTitle("ShoeGaze Builder")
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
.task { await model.startLibrary() }
|
||||||
|
}
|
||||||
|
.onDisappear { model.stop() }
|
||||||
|
}
|
||||||
|
.onChange(of: scenePhase) { _, phase in
|
||||||
|
// Persist the rig whenever the app leaves the foreground.
|
||||||
|
if phase != .active { model.save() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
// ShoeGazeBuilderiOSAppModel.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import AVFoundation
|
||||||
|
import Observation
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
import LyrebirdShoeGazeUI
|
||||||
|
|
||||||
|
/// Observable model owning the `SynthesisEngine` and `ShoeGaze` session for the iOS builder.
|
||||||
|
///
|
||||||
|
/// `AVAudioSession` is activated at init so the hardware sample rate is known before the engine
|
||||||
|
/// is constructed (iOS devices typically lock to 48 000 Hz). The session is seeded with one board
|
||||||
|
/// holding a single pedal so the builder opens with an audible starting point; the user adds /
|
||||||
|
/// removes / reorders pedals from the palette. Input defaults to `.testLoop`, so no microphone
|
||||||
|
/// permission is required to start.
|
||||||
|
@Observable
|
||||||
|
@MainActor
|
||||||
|
final class ShoeGazeBuilderiOSAppModel {
|
||||||
|
|
||||||
|
// MARK: - Engine configuration constants
|
||||||
|
|
||||||
|
private static let blockSize: Int = 512
|
||||||
|
private static let outputChannels: Int = 2
|
||||||
|
// Default to one input channel so live input is available immediately. The trade-off is
|
||||||
|
// that the iOS driver runs a `.playAndRecord` session with the RemoteIO input element
|
||||||
|
// enabled, so iOS prompts for microphone access at the first Start even while the input
|
||||||
|
// still defaults to `.testLoop`. (The permission-gated `enableLiveInput()` rebuild remains
|
||||||
|
// available for any future build that starts input-less.)
|
||||||
|
private static let inputChannels: Int = 1
|
||||||
|
private static let numAudioBuses: Int = 256
|
||||||
|
private static let seedPedalType: PedalType = .overdrive
|
||||||
|
|
||||||
|
/// UserDefaults key persisting the input selection. Must match the key written by the
|
||||||
|
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
||||||
|
private static let inputSelectionDefaultsKey: String = "ShoeGaze.inputSelection"
|
||||||
|
/// Persisted value meaning "live input, channel 0".
|
||||||
|
private static let liveInputChannelZeroTag: Int = 0
|
||||||
|
|
||||||
|
// MARK: - Owned objects
|
||||||
|
|
||||||
|
/// The active ShoeGaze builder session. Swapped out when live input is enabled (the engine
|
||||||
|
/// is rebuilt with an input channel); the `@Observable` change re-binds the hosting view.
|
||||||
|
private(set) var shoeGaze: ShoeGaze
|
||||||
|
|
||||||
|
private var engine: SynthesisEngine
|
||||||
|
private var iosDriver: iOSAudioDriver
|
||||||
|
|
||||||
|
/// The shared rig library (iCloud-or-local). Independent of the engine, so it survives the
|
||||||
|
/// live-input engine rebuild.
|
||||||
|
private(set) var library: RigLibraryStore
|
||||||
|
|
||||||
|
/// The sample rate the audio session actually committed to (for the config mismatch warning).
|
||||||
|
var hardwareSampleRate: Double? { iosDriver.sessionSampleRate }
|
||||||
|
|
||||||
|
/// Resolves iCloud + loads the library off the main thread, then seeds it from the working rig
|
||||||
|
/// on first run. Call once from the app's `.task`. Safe to call again (no-op once non-empty).
|
||||||
|
func startLibrary() async {
|
||||||
|
await RigLibraryBootstrap.start(library, seedFrom: shoeGaze)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
init() {
|
||||||
|
ShoeGazeBuilderiOSAppModel.configureAudioSession()
|
||||||
|
let built: (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) =
|
||||||
|
ShoeGazeBuilderiOSAppModel.buildEngine(inputChannels: ShoeGazeBuilderiOSAppModel.inputChannels)
|
||||||
|
let shoeGaze: ShoeGaze = built.shoeGaze
|
||||||
|
self.engine = built.engine
|
||||||
|
self.iosDriver = built.driver
|
||||||
|
self.shoeGaze = shoeGaze
|
||||||
|
|
||||||
|
// Restore the autosaved working rig if there is one; otherwise seed a default board. Operate
|
||||||
|
// on the local `shoeGaze`, not `self.shoeGaze`: self may not be touched until every stored
|
||||||
|
// property (including `library`) is initialized.
|
||||||
|
if !RigStore.restore(into: shoeGaze) {
|
||||||
|
ShoeGazeBuilderiOSAppModel.seedFallbackBoard(into: shoeGaze)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct the library instantly; it resolves iCloud + loads asynchronously via
|
||||||
|
// startLibrary() from the app's .task.
|
||||||
|
self.library = RigLibraryBootstrap.makeStore()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Persists the current rig. Call when the app moves to the background.
|
||||||
|
func save() {
|
||||||
|
RigStore.save(shoeGaze)
|
||||||
|
// Flush any in-flight background rig-library writes while we still have time in the
|
||||||
|
// background.
|
||||||
|
library.flushPendingWrites()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Audio session / engine construction
|
||||||
|
|
||||||
|
/// Activates the play-and-record audio session once. Idempotent; safe to call before each
|
||||||
|
/// engine build. Activating the session does not by itself prompt for microphone access —
|
||||||
|
/// the prompt only fires when an input-enabled engine first starts.
|
||||||
|
private static func configureAudioSession() {
|
||||||
|
let session: AVAudioSession = AVAudioSession.sharedInstance()
|
||||||
|
do {
|
||||||
|
try session.setCategory(.playAndRecord,
|
||||||
|
mode: .default,
|
||||||
|
options: [.defaultToSpeaker, .allowBluetoothHFP])
|
||||||
|
try session.setActive(true)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] AVAudioSession setup failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds a fresh engine + driver + empty `ShoeGaze` with the given input-channel count.
|
||||||
|
private static func buildEngine(
|
||||||
|
inputChannels: Int
|
||||||
|
) -> (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) {
|
||||||
|
let sampleRate: Double = AVAudioSession.sharedInstance().sampleRate
|
||||||
|
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||||
|
let engine: SynthesisEngine = SynthesisEngine(
|
||||||
|
blockSize: ShoeGazeBuilderiOSAppModel.blockSize,
|
||||||
|
sampleRate: sampleRate,
|
||||||
|
numOutputChannels: ShoeGazeBuilderiOSAppModel.outputChannels,
|
||||||
|
numInputChannels: inputChannels,
|
||||||
|
numAudioBuses: ShoeGazeBuilderiOSAppModel.numAudioBuses,
|
||||||
|
driver: driver
|
||||||
|
)
|
||||||
|
return (engine, driver, ShoeGaze(engine: engine))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Live input
|
||||||
|
|
||||||
|
/// Enables live input on iOS: requests microphone access, then (on grant) rebuilds the
|
||||||
|
/// engine with one input channel — preserving the current rig — and selects live input.
|
||||||
|
///
|
||||||
|
/// The rebuild is required because the input-channel count is fixed at engine construction,
|
||||||
|
/// and constructing with an input channel up-front would make iOS prompt for the microphone
|
||||||
|
/// at the first Start even in test-loop mode. Gating the rebuild behind an explicit request
|
||||||
|
/// keeps the prompt where the user expects it.
|
||||||
|
func enableLiveInput() {
|
||||||
|
MicrophonePermission.request { [weak self] granted in
|
||||||
|
guard let self, granted else { return }
|
||||||
|
self.rebuildWithLiveInput()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Snapshots the rig, rebuilds the engine with one input channel, restores the rig, and
|
||||||
|
/// selects live input on channel 0. No-op if the engine already has an input channel.
|
||||||
|
private func rebuildWithLiveInput() {
|
||||||
|
guard engine.numInputChannels == 0 else {
|
||||||
|
// Engine already has an input channel: just select live input, no rebuild.
|
||||||
|
selectLiveInputAndPersist()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let wasRunning: Bool = engine.isRunning
|
||||||
|
|
||||||
|
// Snapshot the rig BEFORE any teardown. If this fails, abort the rebuild rather than
|
||||||
|
// tear the engine down and lose the rig — the user stays on the current engine.
|
||||||
|
let snapshot: Data
|
||||||
|
do {
|
||||||
|
snapshot = try shoeGaze.rigData()
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] rig snapshot failed; aborting live-input rebuild: \(error)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.stop()
|
||||||
|
shoeGaze.teardown()
|
||||||
|
|
||||||
|
ShoeGazeBuilderiOSAppModel.configureAudioSession()
|
||||||
|
let rebuilt: (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) =
|
||||||
|
ShoeGazeBuilderiOSAppModel.buildEngine(inputChannels: 1)
|
||||||
|
self.engine = rebuilt.engine
|
||||||
|
self.iosDriver = rebuilt.driver
|
||||||
|
self.shoeGaze = rebuilt.shoeGaze
|
||||||
|
|
||||||
|
do {
|
||||||
|
// Teardown already happened, so a restore failure can only recover by seeding.
|
||||||
|
try shoeGaze.loadRig(from: snapshot)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] rig restore after rebuild failed: \(error)")
|
||||||
|
ShoeGazeBuilderiOSAppModel.seedFallbackBoard(into: shoeGaze)
|
||||||
|
}
|
||||||
|
|
||||||
|
selectLiveInputAndPersist()
|
||||||
|
|
||||||
|
if wasRunning { try? engine.start() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Selects live input on channel 0 and persists the choice for restore-on-relaunch.
|
||||||
|
private func selectLiveInputAndPersist() {
|
||||||
|
do {
|
||||||
|
try shoeGaze.setInputSource(.liveInput(channel: 0))
|
||||||
|
UserDefaults.standard.set(
|
||||||
|
ShoeGazeBuilderiOSAppModel.liveInputChannelZeroTag,
|
||||||
|
forKey: ShoeGazeBuilderiOSAppModel.inputSelectionDefaultsKey
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] selecting live input failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Seeds a single default board so the rig is never empty after a failed restore.
|
||||||
|
private static func seedFallbackBoard(into shoeGaze: ShoeGaze) {
|
||||||
|
do {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
board.label = "Board 1"
|
||||||
|
try shoeGaze.appendPedal(ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeBuilderiOS] fallback seed board failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Transport
|
||||||
|
|
||||||
|
/// Stops the audio engine. Call from `.onDisappear`.
|
||||||
|
func stop() {
|
||||||
|
engine.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,14 +7,15 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
C3B0000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000007 /* main.swift */; };
|
|
||||||
C3B0000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000008 /* AppDelegate.swift */; };
|
|
||||||
C3B0000000000000000000E /* DemoRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000009 /* DemoRootView.swift */; };
|
|
||||||
C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B00000000000000000000A /* ShoeGazeDemoController.swift */; };
|
|
||||||
C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001E /* LyrebirdShoeGaze */; };
|
C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001E /* LyrebirdShoeGaze */; };
|
||||||
C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001F /* LyrebirdShoeGazeUI */; };
|
C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001F /* LyrebirdShoeGazeUI */; };
|
||||||
C3B000000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000023 /* Lyrebird */; };
|
C3B000000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000023 /* Lyrebird */; };
|
||||||
C3B000000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000025 /* LyrebirdUI */; };
|
C3B000000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000025 /* LyrebirdUI */; };
|
||||||
|
C3B000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000030 /* Assets.xcassets */; };
|
||||||
|
C3B0000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000007 /* main.swift */; };
|
||||||
|
C3B0000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000008 /* AppDelegate.swift */; };
|
||||||
|
C3B0000000000000000000E /* DemoRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000009 /* DemoRootView.swift */; };
|
||||||
|
C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B00000000000000000000A /* ShoeGazeDemoController.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
C3B000000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
C3B000000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
C3B000000000000000000009 /* DemoRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoRootView.swift; sourceTree = "<group>"; };
|
C3B000000000000000000009 /* DemoRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoRootView.swift; sourceTree = "<group>"; };
|
||||||
C3B00000000000000000000A /* ShoeGazeDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeDemoController.swift; sourceTree = "<group>"; };
|
C3B00000000000000000000A /* ShoeGazeDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeDemoController.swift; sourceTree = "<group>"; };
|
||||||
|
C3B000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
C3B000000000000000000008 /* AppDelegate.swift */,
|
C3B000000000000000000008 /* AppDelegate.swift */,
|
||||||
C3B000000000000000000009 /* DemoRootView.swift */,
|
C3B000000000000000000009 /* DemoRootView.swift */,
|
||||||
C3B00000000000000000000A /* ShoeGazeDemoController.swift */,
|
C3B00000000000000000000A /* ShoeGazeDemoController.swift */,
|
||||||
|
C3B000000000000000000030 /* Assets.xcassets */,
|
||||||
C3B000000000000000000006 /* Info.plist */,
|
C3B000000000000000000006 /* Info.plist */,
|
||||||
);
|
);
|
||||||
path = ShoeGazeDemo;
|
path = ShoeGazeDemo;
|
||||||
@@ -137,6 +140,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
C3B000000000000000000031 /* Assets.xcassets in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -160,14 +164,17 @@
|
|||||||
C3B000000000000000000016 /* Debug */ = {
|
C3B000000000000000000016 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGNING_REQUIRED = NO;
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
@@ -183,13 +190,16 @@
|
|||||||
C3B000000000000000000017 /* Release */ = {
|
C3B000000000000000000017 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGNING_REQUIRED = NO;
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
INFOPLIST_FILE = ShoeGazeDemo/Info.plist;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "linenoise-swift",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/andybest/linenoise-swift",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
|
||||||
|
"version" : "0.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "lyrebird",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||||
|
"version" : "1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "nimble",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/Quick/Nimble.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
|
||||||
|
"version" : "7.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -27,7 +27,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
private static let blockSize: Int = 512
|
private static let blockSize: Int = 512
|
||||||
private static let sampleRate: Double = 48_000.0
|
private static let sampleRate: Double = 48_000.0
|
||||||
private static let outputChannels: Int = 2
|
private static let outputChannels: Int = 2
|
||||||
private static let inputChannels: Int = 6
|
// Built-in mics are mono; default to one input channel so live input works out of the box
|
||||||
|
// (CoreAudio can't satisfy more input channels than the device provides). Raise in the UI.
|
||||||
|
private static let inputChannels: Int = 1
|
||||||
private static let numAudioBuses: Int = 256
|
private static let numAudioBuses: Int = 256
|
||||||
|
|
||||||
// MARK: - Window geometry constants
|
// MARK: - Window geometry constants
|
||||||
@@ -37,6 +39,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
// MARK: - Owned objects
|
// MARK: - Owned objects
|
||||||
|
|
||||||
|
private let coreDriver: CoreAudioDriver
|
||||||
private let controller: ShoeGazeDemoController
|
private let controller: ShoeGazeDemoController
|
||||||
private let window: LyrebirdWindow
|
private let window: LyrebirdWindow
|
||||||
|
|
||||||
@@ -46,15 +49,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
|
let coreDriver: CoreAudioDriver = CoreAudioDriver()
|
||||||
let engine: SynthesisEngine = SynthesisEngine(
|
let engine: SynthesisEngine = SynthesisEngine(
|
||||||
blockSize: AppDelegate.blockSize,
|
blockSize: AppDelegate.blockSize,
|
||||||
sampleRate: AppDelegate.sampleRate,
|
sampleRate: AppDelegate.sampleRate,
|
||||||
numOutputChannels: AppDelegate.outputChannels,
|
numOutputChannels: AppDelegate.outputChannels,
|
||||||
numInputChannels: AppDelegate.inputChannels,
|
numInputChannels: AppDelegate.inputChannels,
|
||||||
numAudioBuses: AppDelegate.numAudioBuses,
|
numAudioBuses: AppDelegate.numAudioBuses,
|
||||||
driver: CoreAudioDriver()
|
driver: coreDriver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.coreDriver = coreDriver
|
||||||
self.controller = ShoeGazeDemoController(engine: engine)
|
self.controller = ShoeGazeDemoController(engine: engine)
|
||||||
self.window = LyrebirdWindow(
|
self.window = LyrebirdWindow(
|
||||||
title: "ShoeGaze — Lyrebird Guitar Pedalboard",
|
title: "ShoeGaze — Lyrebird Guitar Pedalboard",
|
||||||
@@ -69,8 +74,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
installMainMenu()
|
installMainMenu()
|
||||||
let demoController: ShoeGazeDemoController = controller
|
let demoController: ShoeGazeDemoController = controller
|
||||||
|
let driver: CoreAudioDriver = coreDriver
|
||||||
window.open {
|
window.open {
|
||||||
DemoRootView(controller: demoController)
|
DemoRootView(controller: demoController, hardwareSampleRate: { driver.deviceSampleRate })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{"size":"16x16","idiom":"mac","filename":"icon_16x16.png","scale":"1x"},
|
||||||
|
{"size":"16x16","idiom":"mac","filename":"icon_16x16@2x.png","scale":"2x"},
|
||||||
|
{"size":"32x32","idiom":"mac","filename":"icon_32x32.png","scale":"1x"},
|
||||||
|
{"size":"32x32","idiom":"mac","filename":"icon_32x32@2x.png","scale":"2x"},
|
||||||
|
{"size":"128x128","idiom":"mac","filename":"icon_128x128.png","scale":"1x"},
|
||||||
|
{"size":"128x128","idiom":"mac","filename":"icon_128x128@2x.png","scale":"2x"},
|
||||||
|
{"size":"256x256","idiom":"mac","filename":"icon_256x256.png","scale":"1x"},
|
||||||
|
{"size":"256x256","idiom":"mac","filename":"icon_256x256@2x.png","scale":"2x"},
|
||||||
|
{"size":"512x512","idiom":"mac","filename":"icon_512x512.png","scale":"1x"},
|
||||||
|
{"size":"512x512","idiom":"mac","filename":"icon_512x512@2x.png","scale":"2x"}
|
||||||
|
],
|
||||||
|
"info" : {"author":"xcode","version":1}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 782 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 345 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 345 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1 @@
|
|||||||
|
{ "info" : {"author":"xcode","version":1} }
|
||||||
@@ -28,6 +28,7 @@ import LyrebirdShoeGazeUI
|
|||||||
/// - `.editor` → `BoardEditorView` — board + FlowLayout pedal area + version snapshots.
|
/// - `.editor` → `BoardEditorView` — board + FlowLayout pedal area + version snapshots.
|
||||||
/// - `.parallel` → `ParallelSectionView` — splitter, two branch rows, merger (via board).
|
/// - `.parallel` → `ParallelSectionView` — splitter, two branch rows, merger (via board).
|
||||||
/// - `.router` → `ChainRouterView` — dual-board chain router with splitter + master.
|
/// - `.router` → `ChainRouterView` — dual-board chain router with splitter + master.
|
||||||
|
/// - `.stereo` → `StereoSplitSectionView` — stereo split with the four route modes.
|
||||||
struct DemoRootView: View {
|
struct DemoRootView: View {
|
||||||
|
|
||||||
// MARK: - Layout constants
|
// MARK: - Layout constants
|
||||||
@@ -46,6 +47,7 @@ struct DemoRootView: View {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
|
|
||||||
private let controller: ShoeGazeDemoController
|
private let controller: ShoeGazeDemoController
|
||||||
|
private let hardwareSampleRate: () -> Double?
|
||||||
|
|
||||||
/// Bumped on each transport press so the buttons re-read `controller.isRunning`
|
/// Bumped on each transport press so the buttons re-read `controller.isRunning`
|
||||||
/// (which derives from the non-observable engine).
|
/// (which derives from the non-observable engine).
|
||||||
@@ -55,10 +57,17 @@ struct DemoRootView: View {
|
|||||||
|
|
||||||
/// Creates the root demo view bound to the given controller.
|
/// Creates the root demo view bound to the given controller.
|
||||||
///
|
///
|
||||||
/// - Parameter controller: The `ShoeGazeDemoController` that owns the engine, active
|
/// - Parameters:
|
||||||
/// `ShoeGaze` session, and current mode. All toolbar actions dispatch through this.
|
/// - controller: The `ShoeGazeDemoController` that owns the engine, active `ShoeGaze`
|
||||||
init(controller: ShoeGazeDemoController) {
|
/// session, and current mode. All toolbar actions dispatch through this.
|
||||||
|
/// - hardwareSampleRate: Returns the actual hardware sample rate (or `nil`), for the engine-
|
||||||
|
/// config mismatch warning. Defaults to `nil`.
|
||||||
|
init(
|
||||||
|
controller: ShoeGazeDemoController,
|
||||||
|
hardwareSampleRate: @escaping () -> Double? = { nil }
|
||||||
|
) {
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
self.hardwareSampleRate = hardwareSampleRate
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Body
|
// MARK: - Body
|
||||||
@@ -70,6 +79,10 @@ struct DemoRootView: View {
|
|||||||
.overlay(Color.white.opacity(DemoRootView.dividerOpacity))
|
.overlay(Color.white.opacity(DemoRootView.dividerOpacity))
|
||||||
contentArea
|
contentArea
|
||||||
.padding(DemoRootView.contentPadding)
|
.padding(DemoRootView.contentPadding)
|
||||||
|
Divider()
|
||||||
|
.overlay(Color.white.opacity(DemoRootView.dividerOpacity))
|
||||||
|
ShoeGazeScopeView(shoeGaze: controller.shoeGaze)
|
||||||
|
.padding(DemoRootView.contentPadding)
|
||||||
}
|
}
|
||||||
.frame(
|
.frame(
|
||||||
minWidth: DemoRootView.windowMinWidth,
|
minWidth: DemoRootView.windowMinWidth,
|
||||||
@@ -82,6 +95,18 @@ struct DemoRootView: View {
|
|||||||
blue: DemoRootView.backgroundBlue
|
blue: DemoRootView.backgroundBlue
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.alert(
|
||||||
|
"Microphone Access Needed",
|
||||||
|
isPresented: Binding(
|
||||||
|
get: { controller.microphoneAccessDenied },
|
||||||
|
set: { controller.microphoneAccessDenied = $0 }
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Button("OK", role: .cancel) { }
|
||||||
|
} message: {
|
||||||
|
Text("Live input needs microphone access. Enable it in System Settings › Privacy & "
|
||||||
|
+ "Security › Microphone, then select the input again.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Toolbar
|
// MARK: - Toolbar
|
||||||
@@ -156,7 +181,7 @@ struct DemoRootView: View {
|
|||||||
.foregroundStyle(Color.white.opacity(0.65))
|
.foregroundStyle(Color.white.opacity(0.65))
|
||||||
Picker("Input", selection: inputSourceBinding) {
|
Picker("Input", selection: inputSourceBinding) {
|
||||||
Text("Test Loop").tag(-1)
|
Text("Test Loop").tag(-1)
|
||||||
ForEach(0..<controller.engine.numInputChannels, id: \.self) { channel in
|
ForEach(Array(0..<max(0, controller.engine.numInputChannels)), id: \.self) { channel in
|
||||||
Text("In \(channel)").tag(channel)
|
Text("In \(channel)").tag(channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,29 +190,20 @@ struct DemoRootView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start and Stop transport buttons.
|
/// Engine configuration + transport (sample rate, ins/outs, Start/Stop, mismatch alert).
|
||||||
private var transportButtons: some View {
|
private var transportButtons: some View {
|
||||||
// `controller.isRunning` derives from the engine; toggling the tick on press
|
EngineConfigView(
|
||||||
// re-evaluates this view so the buttons reflect the change immediately.
|
shoeGaze: controller.shoeGaze,
|
||||||
_ = transportTick
|
hardwareSampleRate: hardwareSampleRate,
|
||||||
let isRunning: Bool = controller.isRunning
|
applyConfig: { rate, inputs, outputs in
|
||||||
return HStack(spacing: DemoRootView.toolbarSpacing) {
|
try controller.reconfigure(
|
||||||
Button("Start") {
|
sampleRate: rate,
|
||||||
controller.start()
|
inputChannels: inputs,
|
||||||
transportTick.toggle()
|
outputChannels: outputs
|
||||||
}
|
)
|
||||||
.buttonStyle(.borderedProminent)
|
},
|
||||||
.tint(.green)
|
onConfigApplied: { transportTick.toggle() }
|
||||||
.disabled(isRunning)
|
)
|
||||||
|
|
||||||
Button("Stop") {
|
|
||||||
controller.stop()
|
|
||||||
transportTick.toggle()
|
|
||||||
}
|
|
||||||
.buttonStyle(.bordered)
|
|
||||||
.tint(.red)
|
|
||||||
.disabled(!isRunning)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Content area
|
// MARK: - Content area
|
||||||
@@ -197,7 +213,7 @@ struct DemoRootView: View {
|
|||||||
private var contentArea: some View {
|
private var contentArea: some View {
|
||||||
switch controller.mode {
|
switch controller.mode {
|
||||||
case .boards:
|
case .boards:
|
||||||
ShoeGazeView(shoeGaze: controller.shoeGaze)
|
ShoeGazeView(shoeGaze: controller.shoeGaze, hardwareSampleRate: hardwareSampleRate)
|
||||||
|
|
||||||
case .editor:
|
case .editor:
|
||||||
editorContent
|
editorContent
|
||||||
@@ -207,6 +223,9 @@ struct DemoRootView: View {
|
|||||||
|
|
||||||
case .router:
|
case .router:
|
||||||
routerContent
|
routerContent
|
||||||
|
|
||||||
|
case .stereo:
|
||||||
|
stereoContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +266,27 @@ struct DemoRootView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `.stereo` content: the full board view (shows the pre-split pedal) stacked above a
|
||||||
|
/// width badge and `StereoSplitSectionView` (route picker + L/R branch rows).
|
||||||
|
@ViewBuilder
|
||||||
|
private var stereoContent: some View {
|
||||||
|
if let section: StereoSplitSection = controller.stereoSection,
|
||||||
|
let board: PedalBoard = controller.shoeGaze.boards.first {
|
||||||
|
ScrollView(.vertical, showsIndicators: true) {
|
||||||
|
VStack(alignment: .leading, spacing: 20) {
|
||||||
|
HStack(spacing: 10) {
|
||||||
|
PedalBoardView(board: board)
|
||||||
|
StereoWidthBadge(width: board.width)
|
||||||
|
}
|
||||||
|
StereoSplitSectionView(section: section)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Text("Stereo split unavailable.")
|
||||||
|
.foregroundStyle(Color.white.opacity(0.55))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// `.router` content: `ChainRouterView` bound to the live `ChainRouter`.
|
/// `.router` content: `ChainRouterView` bound to the live `ChainRouter`.
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var routerContent: some View {
|
private var routerContent: some View {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.device.audio-input</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -32,6 +32,10 @@ enum DemoMode: String, CaseIterable, Identifiable {
|
|||||||
/// B: Fuzz + Reverb) and recombines them through a shared master stage.
|
/// B: Fuzz + Reverb) and recombines them through a shared master stage.
|
||||||
case router = "Router"
|
case router = "Router"
|
||||||
|
|
||||||
|
/// A board with a ``StereoSplitSection`` (Overdrive → splitStereo(Delay | PingPong) →
|
||||||
|
/// collectStereo) showcasing the four ``StereoRoute`` modes and stereo output.
|
||||||
|
case stereo = "Stereo"
|
||||||
|
|
||||||
var id: String { rawValue }
|
var id: String { rawValue }
|
||||||
|
|
||||||
/// Short human-readable title used in the mode picker.
|
/// Short human-readable title used in the mode picker.
|
||||||
@@ -41,6 +45,7 @@ enum DemoMode: String, CaseIterable, Identifiable {
|
|||||||
case .editor: return "Editor"
|
case .editor: return "Editor"
|
||||||
case .parallel: return "Parallel"
|
case .parallel: return "Parallel"
|
||||||
case .router: return "Router"
|
case .router: return "Router"
|
||||||
|
case .stereo: return "Stereo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,6 +84,9 @@ final class ShoeGazeDemoController {
|
|||||||
/// Non-nil only in `.parallel` mode, after ``buildParallel()`` succeeds.
|
/// Non-nil only in `.parallel` mode, after ``buildParallel()`` succeeds.
|
||||||
private(set) var parallelSection: ParallelSection?
|
private(set) var parallelSection: ParallelSection?
|
||||||
|
|
||||||
|
/// Non-nil only in `.stereo` mode, after ``buildStereo()`` succeeds.
|
||||||
|
private(set) var stereoSection: StereoSplitSection?
|
||||||
|
|
||||||
/// Stores named board snapshots for the `.editor` showcase.
|
/// Stores named board snapshots for the `.editor` showcase.
|
||||||
let versionStore: BoardVersionStore = BoardVersionStore()
|
let versionStore: BoardVersionStore = BoardVersionStore()
|
||||||
|
|
||||||
@@ -119,9 +127,29 @@ final class ShoeGazeDemoController {
|
|||||||
|
|
||||||
/// Changes the input source policy and triggers a full rebuild.
|
/// Changes the input source policy and triggers a full rebuild.
|
||||||
///
|
///
|
||||||
|
/// Live input requires microphone authorisation first — without it macOS feeds the AUHAL input
|
||||||
|
/// silent zeros. The request is asynchronous, so `.liveInput` is applied only once the grant
|
||||||
|
/// resolves; a denial falls back to the test loop.
|
||||||
|
///
|
||||||
/// - Parameter source: `.testLoop` for the built-in test signal or `.liveInput(channel:)`
|
/// - Parameter source: `.testLoop` for the built-in test signal or `.liveInput(channel:)`
|
||||||
/// for hardware microphone/instrument input on the given channel.
|
/// for hardware microphone/instrument input on the given channel.
|
||||||
func setInputSource(_ source: InputSource) {
|
func setInputSource(_ source: InputSource) {
|
||||||
|
guard case .liveInput = source else {
|
||||||
|
applyInputSource(source)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
MicrophonePermission.request { [weak self] granted in
|
||||||
|
if !granted { self?.microphoneAccessDenied = true }
|
||||||
|
self?.applyInputSource(granted ? source : .testLoop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set when live input is requested but microphone access is denied/restricted. The UI observes
|
||||||
|
/// this and presents an alert, then clears it.
|
||||||
|
var microphoneAccessDenied: Bool = false
|
||||||
|
|
||||||
|
/// Applies an input-source change and triggers a full rebuild.
|
||||||
|
private func applyInputSource(_ source: InputSource) {
|
||||||
inputSource = source
|
inputSource = source
|
||||||
rebuild()
|
rebuild()
|
||||||
}
|
}
|
||||||
@@ -152,6 +180,34 @@ final class ShoeGazeDemoController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Engine reconfiguration
|
||||||
|
|
||||||
|
/// Applies new engine settings (while stopped) and rebuilds the current mode so the showcase
|
||||||
|
/// is reconstructed at the new sample rate / channel counts. Used by the engine-config UI.
|
||||||
|
///
|
||||||
|
/// Tears the session down BEFORE reconfiguring — changing channel counts re-partitions the bus
|
||||||
|
/// allocator, which would invalidate rig buses still allocated under the old layout.
|
||||||
|
///
|
||||||
|
/// - Throws: `SynthesisEngineConfigError` if the engine is running or a value is invalid.
|
||||||
|
func reconfigure(sampleRate: Double, inputChannels: Int, outputChannels: Int) throws {
|
||||||
|
let wasRunning: Bool = isRunning
|
||||||
|
if wasRunning { stop() }
|
||||||
|
|
||||||
|
tearDownSession()
|
||||||
|
try engine.setSampleRate(sampleRate)
|
||||||
|
try engine.setNumOutputChannels(outputChannels)
|
||||||
|
try engine.setNumInputChannels(inputChannels)
|
||||||
|
// A live-input source past the new channel count would make rebuild fail; fall back.
|
||||||
|
if case .liveInput(let channel) = inputSource, channel >= inputChannels {
|
||||||
|
inputSource = .testLoop
|
||||||
|
}
|
||||||
|
buildSession()
|
||||||
|
// `buildSession()` creates a fresh `ShoeGaze`, whose `init` installs the scope tap for the
|
||||||
|
// new channel layout — no explicit `installScopeTap()` needed here.
|
||||||
|
|
||||||
|
if wasRunning { start() }
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Rebuild
|
// MARK: - Rebuild
|
||||||
|
|
||||||
/// Tears down the current session and rebuilds the active mode.
|
/// Tears down the current session and rebuilds the active mode.
|
||||||
@@ -161,21 +217,29 @@ final class ShoeGazeDemoController {
|
|||||||
private func rebuild() {
|
private func rebuild() {
|
||||||
let wasRunning: Bool = isRunning
|
let wasRunning: Bool = isRunning
|
||||||
if wasRunning { stop() }
|
if wasRunning { stop() }
|
||||||
|
tearDownSession()
|
||||||
|
buildSession()
|
||||||
|
if wasRunning { start() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the current session's nodes and clears split/router references.
|
||||||
|
private func tearDownSession() {
|
||||||
shoeGaze.teardown()
|
shoeGaze.teardown()
|
||||||
router = nil
|
router = nil
|
||||||
parallelSection = nil
|
parallelSection = nil
|
||||||
|
stereoSection = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a fresh session and builds the active mode's graph.
|
||||||
|
private func buildSession() {
|
||||||
shoeGaze = ShoeGaze(engine: engine, inputSource: inputSource)
|
shoeGaze = ShoeGaze(engine: engine, inputSource: inputSource)
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case .boards: buildBoards()
|
case .boards: buildBoards()
|
||||||
case .editor: buildEditor()
|
case .editor: buildEditor()
|
||||||
case .parallel: buildParallel()
|
case .parallel: buildParallel()
|
||||||
case .router: buildRouter()
|
case .router: buildRouter()
|
||||||
|
case .stereo: buildStereo()
|
||||||
}
|
}
|
||||||
|
|
||||||
if wasRunning { start() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Mode builders
|
// MARK: - Mode builders
|
||||||
@@ -184,7 +248,7 @@ final class ShoeGazeDemoController {
|
|||||||
///
|
///
|
||||||
/// Board 1: Overdrive → Delay → Reverb → Modulation
|
/// Board 1: Overdrive → Delay → Reverb → Modulation
|
||||||
/// Board 2: Fuzz → Tremolo → Phaser → Compressor
|
/// Board 2: Fuzz → Tremolo → Phaser → Compressor
|
||||||
/// Board 3: Mu-Tron → Auto-Wah → Feedback Delay → Multi-Tap Delay
|
/// Board 3: Mutant → Auto-Wah → Feedback Delay → Multi-Tap Delay
|
||||||
private func buildBoards() {
|
private func buildBoards() {
|
||||||
do {
|
do {
|
||||||
let board1: PedalBoard = try shoeGaze.addBoard()
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
||||||
@@ -205,7 +269,7 @@ final class ShoeGazeDemoController {
|
|||||||
|
|
||||||
let board3: PedalBoard = try shoeGaze.addBoard()
|
let board3: PedalBoard = try shoeGaze.addBoard()
|
||||||
board3.label = "Board 3"
|
board3.label = "Board 3"
|
||||||
try board3.add(MuTronPedal())
|
try board3.add(MutantPedal())
|
||||||
try board3.add(AutoWahPedal())
|
try board3.add(AutoWahPedal())
|
||||||
try board3.add(FeedbackDelayPedal())
|
try board3.add(FeedbackDelayPedal())
|
||||||
try board3.add(MultiTapDelayPedal())
|
try board3.add(MultiTapDelayPedal())
|
||||||
@@ -279,5 +343,29 @@ final class ShoeGazeDemoController {
|
|||||||
print("[ShoeGazeDemoController] buildRouter failed: \(error)")
|
print("[ShoeGazeDemoController] buildRouter failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `.stereo` — Overdrive → splitStereo(left: Delay | right: Ping-Pong) → collectStereo.
|
||||||
|
///
|
||||||
|
/// Demonstrates the stereo split mechanism: a mono signal fanned into two independently
|
||||||
|
/// authored chains that become the left and right output channels, with the four
|
||||||
|
/// ``StereoRoute`` modes (stereo / left / right / bypass) selectable live. Stores the
|
||||||
|
/// `StereoSplitSection` so `DemoRootView` can display `StereoSplitSectionView`.
|
||||||
|
private func buildStereo() {
|
||||||
|
do {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
board.label = "Stereo Board"
|
||||||
|
try board.add(OverdrivePedal())
|
||||||
|
|
||||||
|
let section: StereoSplitSection = try board.splitStereo()
|
||||||
|
try section.left.add(DelayPedal())
|
||||||
|
try section.right.add(PingPongDelayPedal())
|
||||||
|
try board.collectStereo(section)
|
||||||
|
|
||||||
|
try shoeGaze.finalizeBoard(board)
|
||||||
|
stereoSection = section
|
||||||
|
} catch {
|
||||||
|
print("[ShoeGazeDemoController] buildStereo failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001B /* LyrebirdShoeGazeUI */; };
|
C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001B /* LyrebirdShoeGazeUI */; };
|
||||||
C3C00000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001C /* LyrebirdUI */; };
|
C3C00000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001C /* LyrebirdUI */; };
|
||||||
C3C00000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001E /* Lyrebird */; };
|
C3C00000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001E /* Lyrebird */; };
|
||||||
|
C3C000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000030 /* Assets.xcassets */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
C3C000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
C3C000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoApp.swift; sourceTree = "<group>"; };
|
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoApp.swift; sourceTree = "<group>"; };
|
||||||
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoAppModel.swift; sourceTree = "<group>"; };
|
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoAppModel.swift; sourceTree = "<group>"; };
|
||||||
|
C3C000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -58,6 +60,7 @@
|
|||||||
children = (
|
children = (
|
||||||
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */,
|
C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */,
|
||||||
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */,
|
C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */,
|
||||||
|
C3C000000000000000000030 /* Assets.xcassets */,
|
||||||
C3C000000000000000000006 /* Info.plist */,
|
C3C000000000000000000006 /* Info.plist */,
|
||||||
);
|
);
|
||||||
path = ShoeGazeiOSDemo;
|
path = ShoeGazeiOSDemo;
|
||||||
@@ -131,6 +134,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
C3C000000000000000000031 /* Assets.xcassets in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -152,11 +156,13 @@
|
|||||||
C3C000000000000000000013 /* Debug */ = {
|
C3C000000000000000000013 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGNING_REQUIRED = NO;
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -168,17 +174,19 @@
|
|||||||
SUPPORTS_MACCATALYST = NO;
|
SUPPORTS_MACCATALYST = NO;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 6.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = 2;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
C3C000000000000000000014 /* Release */ = {
|
C3C000000000000000000014 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGNING_REQUIRED = NO;
|
CODE_SIGNING_REQUIRED = NO;
|
||||||
DEVELOPMENT_TEAM = "";
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 18.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -190,7 +198,7 @@
|
|||||||
SUPPORTS_MACCATALYST = NO;
|
SUPPORTS_MACCATALYST = NO;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 6.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = 2;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "linenoise-swift",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/andybest/linenoise-swift",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
|
||||||
|
"version" : "0.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "lyrebird",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://realizedsound.mooo.com/josh/Lyrebird",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c",
|
||||||
|
"version" : "1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "nimble",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/Quick/Nimble.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
|
||||||
|
"version" : "7.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{"filename":"icon_1024.png","idiom":"universal","platform":"ios","size":"1024x1024"}
|
||||||
|
],
|
||||||
|
"info" : {"author":"xcode","version":1}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 402 KiB |
@@ -0,0 +1 @@
|
|||||||
|
{ "info" : {"author":"xcode","version":1} }
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>UIApplicationSceneManifest</key>
|
<key>UIApplicationSceneManifest</key>
|
||||||
@@ -29,16 +29,15 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<key>UILaunchScreen</key>
|
<key>UILaunchScreen</key>
|
||||||
<dict/>
|
<dict/>
|
||||||
|
<key>UIRequiresFullScreen</key>
|
||||||
|
<true/>
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct ShoeGazeiOSDemoApp: App {
|
|||||||
WindowGroup {
|
WindowGroup {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
ShoeGazeView(shoeGaze: model.shoeGaze)
|
ShoeGazeView(shoeGaze: model.shoeGaze, hardwareSampleRate: { model.hardwareSampleRate })
|
||||||
.padding(.horizontal, 12)
|
.padding(.horizontal, 12)
|
||||||
}
|
}
|
||||||
.navigationTitle("ShoeGaze")
|
.navigationTitle("ShoeGaze")
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ final class ShoeGazeiOSDemoAppModel {
|
|||||||
private(set) var shoeGaze: ShoeGaze
|
private(set) var shoeGaze: ShoeGaze
|
||||||
|
|
||||||
private let engine: SynthesisEngine
|
private let engine: SynthesisEngine
|
||||||
|
private let iosDriver: iOSAudioDriver
|
||||||
|
|
||||||
|
/// The sample rate the audio session actually committed to (for the config mismatch warning).
|
||||||
|
var hardwareSampleRate: Double? { iosDriver.sessionSampleRate }
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
@@ -54,14 +58,16 @@ final class ShoeGazeiOSDemoAppModel {
|
|||||||
try? session.setActive(true)
|
try? session.setActive(true)
|
||||||
let sampleRate: Double = session.sampleRate
|
let sampleRate: Double = session.sampleRate
|
||||||
|
|
||||||
|
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||||
let eng: SynthesisEngine = SynthesisEngine(
|
let eng: SynthesisEngine = SynthesisEngine(
|
||||||
blockSize: ShoeGazeiOSDemoAppModel.blockSize,
|
blockSize: ShoeGazeiOSDemoAppModel.blockSize,
|
||||||
sampleRate: sampleRate,
|
sampleRate: sampleRate,
|
||||||
numOutputChannels: ShoeGazeiOSDemoAppModel.outputChannels,
|
numOutputChannels: ShoeGazeiOSDemoAppModel.outputChannels,
|
||||||
numInputChannels: 0,
|
numInputChannels: 0,
|
||||||
numAudioBuses: ShoeGazeiOSDemoAppModel.numAudioBuses,
|
numAudioBuses: ShoeGazeiOSDemoAppModel.numAudioBuses,
|
||||||
driver: iOSAudioDriver()
|
driver: driver
|
||||||
)
|
)
|
||||||
|
self.iosDriver = driver
|
||||||
self.engine = eng
|
self.engine = eng
|
||||||
self.shoeGaze = ShoeGaze(engine: eng)
|
self.shoeGaze = ShoeGaze(engine: eng)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,118 @@
|
|||||||
# ShoeGaze
|
# ShoeGaze
|
||||||
|
|
||||||
A package depenedent on Lyrebird for creating and storing virtual Guitar Pedal Boards
|
**A virtual guitar-pedalboard framework for macOS and iPadOS, built on [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird).**
|
||||||
|
|
||||||
|
ShoeGaze turns Lyrebird's real-time synthesis engine into a stompbox rig: chain modeled
|
||||||
|
guitar pedals into one or more signal-flow boards, tweak them live with knobs and switches,
|
||||||
|
mix or switch between boards, and save the whole rig to disk. Run it on a synthesized test
|
||||||
|
signal (no hardware needed) or on live guitar through an audio input.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **22 modeled pedals** across drive, dynamics, EQ/filter, modulation, delay/reverb, and
|
||||||
|
pitch — see the catalog below.
|
||||||
|
- **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.
|
||||||
|
- **Signal-flow editor** — drag pedals in from the palette; reorder, split into parallel or
|
||||||
|
stereo lanes, and merge back to mono.
|
||||||
|
- **Rig library** — name, save, duplicate, and switch between rigs from a sidebar; synced across
|
||||||
|
your devices and both apps via iCloud, with JSON archive import/export for backup.
|
||||||
|
- **Recording** — capture your output to timestamped files.
|
||||||
|
- **Test signal or live input** — a built-in arpeggiated test loop (shared across all boards so
|
||||||
|
they stay phase-locked) or a hardware input channel.
|
||||||
|
- **SwiftUI views** — a complete stompbox UI (`LyrebirdShoeGazeUI`) or just the headless
|
||||||
|
framework (`LyrebirdShoeGaze`) to drive your own interface.
|
||||||
|
|
||||||
|
## Pedal catalog
|
||||||
|
|
||||||
|
| Category | Pedals |
|
||||||
|
|---|---|
|
||||||
|
| Drive & dynamics | Overdrive, Fuzz, Compressor, Sustainer, Limiter, Noise Gate |
|
||||||
|
| EQ & filter | Graphic EQ, Auto-Wah, Mutant, Phaser |
|
||||||
|
| Modulation | Tremolo, Modulation, Chorus, Ring Modulator, Diffuser |
|
||||||
|
| Delay & reverb | Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverb |
|
||||||
|
| Pitch & octave | Octave Splitter, Bass Octaver |
|
||||||
|
|
||||||
|
Every pedal exposes its parameters as knobs/switches and round-trips through the rig save format.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- macOS 15+ / iPadOS 18+ (iPad, landscape)
|
||||||
|
- Swift 6.0 toolchain / Xcode 16+
|
||||||
|
- [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird) 1.2.0+
|
||||||
|
|
||||||
|
## Packages
|
||||||
|
|
||||||
|
Two library products:
|
||||||
|
|
||||||
|
- **`LyrebirdShoeGaze`** — the core pedal/board framework (no SwiftUI).
|
||||||
|
- **`LyrebirdShoeGazeUI`** — SwiftUI pedalboard views (knobs, switches, faders, board mixer).
|
||||||
|
|
||||||
|
Add the dependency in your `Package.swift`:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
.package(url: "https://realizedsound.mooo.com/josh/ShoeGaze", from: "1.0.0"),
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
Build a board and start the engine (macOS):
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import Lyrebird
|
||||||
|
import LyrebirdShoeGaze
|
||||||
|
|
||||||
|
let driver = CoreAudioDriver()
|
||||||
|
let engine = SynthesisEngine(
|
||||||
|
blockSize: 512, sampleRate: 48_000,
|
||||||
|
numOutputChannels: 2, numInputChannels: 1,
|
||||||
|
numAudioBuses: 256, driver: driver
|
||||||
|
)
|
||||||
|
|
||||||
|
let shoeGaze = ShoeGaze(engine: engine) // defaults to the test-loop signal
|
||||||
|
let board = try shoeGaze.addBoard()
|
||||||
|
try shoeGaze.appendPedal(.overdrive, to: board)
|
||||||
|
try shoeGaze.appendPedal(.delay, to: board)
|
||||||
|
try shoeGaze.finalizeBoard(board)
|
||||||
|
|
||||||
|
try engine.start()
|
||||||
|
```
|
||||||
|
|
||||||
|
Drop in the full builder UI:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import SwiftUI
|
||||||
|
import LyrebirdShoeGazeUI
|
||||||
|
|
||||||
|
struct ContentView: View {
|
||||||
|
let shoeGaze: ShoeGaze
|
||||||
|
var body: some View {
|
||||||
|
ShoeGazeBuilderView(shoeGaze: shoeGaze)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Demo apps
|
||||||
|
|
||||||
|
Open `ShoeGaze.xcworkspace` in Xcode and run a scheme from `Demo/`:
|
||||||
|
|
||||||
|
- **ShoeGazeBuilder** (macOS) / **ShoeGazeBuilderiOS** (iPad) — the full palette + board builder.
|
||||||
|
- **ShoeGazeDemo** / **ShoeGazeiOSDemo** — a minimal player view.
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
| macOS builder | Board mixer |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
## Built on Lyrebird
|
||||||
|
|
||||||
|
ShoeGaze is a sample project for [Lyrebird](https://realizedsound.mooo.com/josh/Lyrebird), a
|
||||||
|
native Swift audio-synthesis framework. Pedals are Lyrebird `Synthesizer` graphs of `Generator`
|
||||||
|
nodes; the board/engine plumbing handles real-time-safe signal routing and scheduling.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT — see [LICENSE](LICENSE).
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
# Releases
|
||||||
|
|
||||||
|
## 1.1.1 — 2026-06-26
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Pedal **ⓘ info button** moved to the top-left corner (under the corner screw),
|
||||||
|
out of the way of the name plate.
|
||||||
|
- Fixed **dragging a pedal into a Stereo Unzip / Split / Parallel lane**. Dropping a pedal
|
||||||
|
from the main chain (or another lane) into a region lane now moves it there, preserving its
|
||||||
|
parameters — previously the drop was silently ignored. Empty lanes are also fully
|
||||||
|
hit-testable now.
|
||||||
|
|
||||||
|
## 1.1.0 — 2026-06-24
|
||||||
|
|
||||||
|
### New pedals
|
||||||
|
- **Chorus** — true-stereo chorus (two anti-phase modulated delay voices), distinct from the
|
||||||
|
mono Modulation chorus.
|
||||||
|
- **Sustainer** — one-knob compressor tuned for long, even sustain, with a tone control.
|
||||||
|
- **Ring Modulator** — multiplies the signal by a tunable sine carrier for metallic / bell /
|
||||||
|
robotic tones.
|
||||||
|
- **Diffuser** — stereo widener that fans the frequency spectrum across L/R, with a `spread`
|
||||||
|
control from mono to a wide, diffuse image.
|
||||||
|
|
||||||
|
### Pedal info UI
|
||||||
|
- Every pedal now has a one-line description (`summary`).
|
||||||
|
- The pedal picker shows each pedal's description as a subtitle.
|
||||||
|
- Each pedal has an ⓘ info button opening a panel with its description and effect controls
|
||||||
|
(knobs / sliders / switches) and their value ranges — excluding the common Mix/Level/bypass.
|
||||||
|
|
||||||
|
### Board persistence
|
||||||
|
- The board(s) persist across app restarts on macOS and iPadOS — the rig is autosaved to
|
||||||
|
Application Support and restored on launch (falls back to a default board if none).
|
||||||
|
- New **Clear** button removes all boards; it first prompts **Save & Clear / Clear Without
|
||||||
|
Saving / Cancel**, and "Save & Clear" only clears once the save completes.
|
||||||
|
- Rig save is now available in-view on macOS too (previously File-menu only).
|
||||||
|
|
||||||
|
### Developer notes
|
||||||
|
- Added `docs/plans/` (feature plans) and a project `CLAUDE.md` (conventions + a required
|
||||||
|
checklist for new pedals, including a mandatory `summary`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1.0.0 — 2026-06-24
|
||||||
|
|
||||||
|
First stable release: a virtual guitar-pedalboard framework built on Lyrebird, for macOS and
|
||||||
|
iPadOS, in two products — `LyrebirdShoeGaze` (core) and `LyrebirdShoeGazeUI` (SwiftUI).
|
||||||
|
|
||||||
|
### Pedals (18)
|
||||||
|
Overdrive, Fuzz, Compressor (with input gain), Limiter, Noise Gate, Graphic EQ, Auto-Wah,
|
||||||
|
Mutant, Phaser, Tremolo, Modulation, Delay, Feedback Delay, Multi-Tap Delay, Ping-Pong, Reverb,
|
||||||
|
Octave Splitter, Bass Octaver. Delay-family "decay" controls are labelled **Decay Time**.
|
||||||
|
|
||||||
|
### Boards & mixing
|
||||||
|
- Multiple boards with a board-mixer bar: **Solo** one (amp-channel style) or **Blend** any
|
||||||
|
subset, each with its own level and a click-free crossfade.
|
||||||
|
- A board-manager sheet (rename, drag-reorder, swipe-delete) and ⌘1–9 board switching.
|
||||||
|
- Signal-flow editor: add pedals from the palette; parallel and stereo-split lanes; merge to mono.
|
||||||
|
- One shared, phase-locked test signal across all boards (no per-board polyrhythm).
|
||||||
|
|
||||||
|
### Audio I/O
|
||||||
|
- Test-loop signal or live hardware input.
|
||||||
|
- macOS and iPadOS (iPad-only, landscape). iOS live input via a permission-gated engine rebuild;
|
||||||
|
the last input choice is remembered.
|
||||||
|
|
||||||
|
### Files & capture
|
||||||
|
- Save / load rigs as JSON.
|
||||||
|
- Record output to timestamped files.
|
||||||
|
|
||||||
|
### API
|
||||||
|
- Type-safe `PedalType` tokens for the board-edit API (`appendPedal(.overdrive, to:)`); the rig
|
||||||
|
JSON format is keyed on pedal display names.
|
||||||
@@ -10,4 +10,10 @@
|
|||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Demo/ShoeGazeiOSDemo.xcodeproj">
|
location = "group:Demo/ShoeGazeiOSDemo.xcodeproj">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Demo/ShoeGazeBuilder.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Demo/ShoeGazeBuilderiOS.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
|||||||
@@ -40,29 +40,52 @@ final class BoardOutputMaster: SynthesizerBase {
|
|||||||
|
|
||||||
// MARK: - Routing
|
// MARK: - Routing
|
||||||
|
|
||||||
|
/// Left / mono board output bus index.
|
||||||
private let boardOutputBusIndex: Int
|
private let boardOutputBusIndex: Int
|
||||||
|
|
||||||
|
/// Right board output bus index when the board tail is stereo (width 2), else `nil`.
|
||||||
|
/// When set, the left bus drives hardware 0 and the right bus drives hardware 1 directly,
|
||||||
|
/// bypassing the mono `Pan2` spread.
|
||||||
|
private let boardOutputBusRightIndex: Int?
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Pan position for the board in the stereo field. Centre = 0.0.
|
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
|
||||||
private let stereoPan: Double = 0.0
|
private let stereoPan: Double = 0.0
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
init(boardOutputBusIndex: Int) {
|
/// Creates a board output master.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - boardOutputBusIndex: Left / mono board output bus index.
|
||||||
|
/// - boardOutputBusRightIndex: Right board output bus index for a stereo (width-2) board,
|
||||||
|
/// or `nil` for a mono board (the signal is panned to centre instead).
|
||||||
|
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil) {
|
||||||
self.boardOutputBusIndex = boardOutputBusIndex
|
self.boardOutputBusIndex = boardOutputBusIndex
|
||||||
|
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Build
|
// MARK: - Build
|
||||||
|
|
||||||
override func build() {
|
override func build() {
|
||||||
let boardOut: In.Audio = input(bus: boardOutputBusIndex)
|
|
||||||
// Lag the board-select gain so switching boards crossfades over `crossfadeTime`
|
// Lag the board-select gain so switching boards crossfades over `crossfadeTime`
|
||||||
// seconds rather than clicking. The user master-gain knob is applied directly.
|
// seconds rather than clicking. The user master-gain knob is applied directly.
|
||||||
let smoothedSelect: Lag.Control = Lag.Control(input: $selectGain, time: $crossfadeTime)
|
let smoothedSelect: Lag.Control = Lag.Control(input: $selectGain, time: $crossfadeTime)
|
||||||
let gained: any ValidGeneratorInput = (boardOut * smoothedSelect) * $masterGain
|
|
||||||
// Pan2 spreads the mono pedalboard output to stereo hardware buses 0 + 1.
|
let boardOutLeft: In.Audio = input(bus: boardOutputBusIndex)
|
||||||
output(bus: 0, source: Pan2(input: gained, pan: stereoPan))
|
let gainedLeft: any ValidGeneratorInput = (boardOutLeft * smoothedSelect) * $masterGain
|
||||||
|
|
||||||
|
if let rightIndex: Int = boardOutputBusRightIndex {
|
||||||
|
// Stereo board: left tail → hardware 0, right tail → hardware 1, no pan spread.
|
||||||
|
let boardOutRight: In.Audio = input(bus: rightIndex)
|
||||||
|
let gainedRight: any ValidGeneratorInput = (boardOutRight * smoothedSelect) * $masterGain
|
||||||
|
output(bus: 0, source: gainedLeft)
|
||||||
|
output(bus: 1, source: gainedRight)
|
||||||
|
} else {
|
||||||
|
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1.
|
||||||
|
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// BoardSegment.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// One ordered element of a ``PedalBoard``'s signal chain, used to capture full topology
|
||||||
|
/// (including parallel and stereo split regions) in signal-flow order.
|
||||||
|
///
|
||||||
|
/// `PedalBoard` records these as pedals and split regions are added, so a board can be
|
||||||
|
/// serialized and rebuilt faithfully rather than as a flat pedal list. Branch pedals live
|
||||||
|
/// inside their section objects, not as separate segments.
|
||||||
|
///
|
||||||
|
/// Public so a UI can walk a board's live structure in signal-flow order (each element carries
|
||||||
|
/// the live `Pedal` / section object). The index of a segment within `PedalBoard.orderedSegments`
|
||||||
|
/// matches its index in `captureState().segments`, which is the region index used by the
|
||||||
|
/// lane-addressed edit API (see ``PedalLane``).
|
||||||
|
public enum BoardSegment {
|
||||||
|
|
||||||
|
/// A single linear pedal in the main chain.
|
||||||
|
case pedal(Pedal)
|
||||||
|
|
||||||
|
/// A parallel section (`split()` → two branches → `merge()`).
|
||||||
|
case parallel(ParallelSection)
|
||||||
|
|
||||||
|
/// A stereo split region (`splitStereo()` → two branches → `collectStereo()`).
|
||||||
|
case stereoSplit(StereoSplitSection)
|
||||||
|
|
||||||
|
/// A stereo unzip region (`unzipStereo()` → two branches → `collectStereo()`). Reuses the
|
||||||
|
/// `StereoSplitSection` payload; the distinct case lets capture/rebuild pick the unzip splitter.
|
||||||
|
case stereoUnzip(StereoSplitSection)
|
||||||
|
|
||||||
|
/// A `mergeToMono()` collapse — narrows a stereo tail back to mono. Carries no state;
|
||||||
|
/// recorded so the width transition replays on rebuild.
|
||||||
|
case mergeToMono
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// BitReduce.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
||||||
|
private let bitReduceZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Bit-depth reducer: quantises the signal to `2^bits` amplitude levels, producing the gritty
|
||||||
|
/// quantisation noise of the "bit" half of a lo-fi / bitcrusher effect.
|
||||||
|
///
|
||||||
|
/// `bits` is read at control rate (once per block) and clamped to `[1, 16]`. Each sample is
|
||||||
|
/// rounded to the nearest of `2^bits` levels over the `[-1, 1]` range (mid-tread). Output is mono.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate signal to quantise.
|
||||||
|
/// - bits: Bit depth — quantises to `2^bits` levels. Control rate; clamped to `[1, 16]`.
|
||||||
|
public final class BitReduce: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
/// Resolved input signal.
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// `true` when `_input` resolved to a generator; classified once so the RT path runs no
|
||||||
|
/// `is`/`as?` check.
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
|
||||||
|
/// Quantisation bit depth, read at block rate. Pass a control-rate node or scalar.
|
||||||
|
let _bits: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// Quantisation bounds.
|
||||||
|
private let minimumBits: Double = 1.0
|
||||||
|
private let maximumBits: Double = 16.0
|
||||||
|
|
||||||
|
/// Creates a bit-depth reducer.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to quantise.
|
||||||
|
/// - bits: Bit depth (control rate). Clamped to `[1, 16]`.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
bits: any ValidGeneratorInput
|
||||||
|
) {
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_bits = bits._resolvedInput()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
// Sanitise the control read (finite + clamped) so `Int(bits.rounded())` can't trap on a
|
||||||
|
// NaN/inf input.
|
||||||
|
let rawBits: Double = _bits.floatValue(graph: graph)
|
||||||
|
let bits: Double = rawBits.isFinite ? min(max(rawBits, minimumBits), maximumBits) : minimumBits
|
||||||
|
// Number of quantisation levels = 2^bits, via an integer shift (avoids importing `pow`).
|
||||||
|
// Clamp the shift amount directly too: `1 << bitsInt` is only safe while bits ∈ [1, 16].
|
||||||
|
let bitsInt: Int = min(max(Int(bits.rounded()), 1), 16)
|
||||||
|
let levels: Double = Double(1 << bitsInt)
|
||||||
|
// Step between adjacent levels over [-1, 1], and its reciprocal for the round.
|
||||||
|
let step: Double = 2.0 / levels
|
||||||
|
let inverseStep: Double = levels / 2.0
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? bitReduceZeroBlock)
|
||||||
|
: bitReduceZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = _inputIsGenerator
|
||||||
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
|
: inputScalar
|
||||||
|
_result[0][i] = (x * inverseStep).rounded() * step
|
||||||
|
}
|
||||||
|
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
// ReverseDelay.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 reverseDelayZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Segmented reverse delay: records the input in fixed-length segments and plays each segment back
|
||||||
|
/// **reversed**, so phrases come out backwards.
|
||||||
|
///
|
||||||
|
/// Two segment buffers ping-pong: one records the incoming signal while the other is read back from
|
||||||
|
/// its end to its start. At each segment boundary the buffers swap. A short raised-edge (linear)
|
||||||
|
/// fade at both ends of every reversed segment hides the wrap discontinuity, and an optional
|
||||||
|
/// feedback term recirculates the reversed output into the record buffer for layered reverse trails.
|
||||||
|
///
|
||||||
|
/// `delay` and `feedback` are read at **control rate** (once per block via `floatValue`); a changed
|
||||||
|
/// `delay` takes effect at the next segment boundary, so the segment length never changes mid-read.
|
||||||
|
/// Output is mono (channel 0 of the input is processed).
|
||||||
|
///
|
||||||
|
/// - Important: All buffers are pre-allocated at `init` for `maxDelay` seconds — the RT path never
|
||||||
|
/// allocates or resizes. Keep `delay <= maxDelay`; larger values are clamped.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate signal to reverse.
|
||||||
|
/// - maxDelay: Maximum segment length in seconds; sizes the pre-allocated buffers.
|
||||||
|
/// - delay: Segment length in seconds. Control rate; clamped to `[1 frame, maxDelay]`; a change
|
||||||
|
/// applies at the next segment boundary.
|
||||||
|
/// - feedback: Reverse-trail feedback factor. Control rate; clamped to `[0, 0.95]`.
|
||||||
|
/// - sampleRate: Sample rate used to size buffers and convert seconds → frames; match the engine.
|
||||||
|
/// - fadeTime: Edge-fade length in seconds hiding the segment wrap. Defaults to `0.004`.
|
||||||
|
public final class ReverseDelay: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
// MARK: - Inputs (classified once at init)
|
||||||
|
|
||||||
|
/// Resolved input signal.
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// `true` when `_input` resolved to a generator; `false` for a scalar constant. Classified once
|
||||||
|
/// so the RT path never runs an `is`/`as?` check.
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
|
||||||
|
/// Resolved control inputs. Read at block rate via `floatValue` — pass control-rate nodes
|
||||||
|
/// (`@UIParam` projections) or scalars, not audio-rate generators.
|
||||||
|
let _delay: any ValidGeneratorInput
|
||||||
|
let _feedback: any ValidGeneratorInput
|
||||||
|
|
||||||
|
// MARK: - Buffers + state
|
||||||
|
|
||||||
|
/// The two ping-pong segment buffers, each `_maxFrames` long. One records while the other plays.
|
||||||
|
private var _bufferA: [Double]
|
||||||
|
private var _bufferB: [Double]
|
||||||
|
|
||||||
|
/// Maximum segment length in frames (`maxDelay · sampleRate`).
|
||||||
|
private let _maxFrames: Int
|
||||||
|
|
||||||
|
/// `true` when buffer A is the record buffer (B plays); toggled at each segment boundary.
|
||||||
|
var _recordIsA: Bool = true
|
||||||
|
|
||||||
|
/// Read/write position within the current segment, `0 ..< _segLen`.
|
||||||
|
var _phase: Int = 0
|
||||||
|
|
||||||
|
/// Current segment length in frames.
|
||||||
|
var _segLen: Int
|
||||||
|
|
||||||
|
/// `false` until the first render block adopts the live `delay` as the segment length (the node
|
||||||
|
/// value isn't available at `init`).
|
||||||
|
var _segLenInitialized: Bool = false
|
||||||
|
|
||||||
|
/// Edge-fade length in frames, clamped to half the segment per call.
|
||||||
|
private let _fadeFrames: Int
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Largest stable feedback factor.
|
||||||
|
private let maxFeedback: Double = 0.95
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a reverse delay.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to reverse.
|
||||||
|
/// - maxDelay: Maximum segment length in seconds. Sizes the pre-allocated buffers.
|
||||||
|
/// - delay: Segment length in seconds (control rate). Clamped to `[1 frame, maxDelay]`; a
|
||||||
|
/// change applies at the next segment boundary.
|
||||||
|
/// - feedback: Reverse-trail feedback factor (control rate). Clamped to `[0, 0.95]`. Defaults
|
||||||
|
/// to `0`.
|
||||||
|
/// - sampleRate: Sample rate used to size the buffers and convert seconds → frames.
|
||||||
|
/// - fadeTime: Edge-fade length in seconds, hiding the segment wrap. Defaults to `0.004`.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
maxDelay: Double,
|
||||||
|
delay: any ValidGeneratorInput,
|
||||||
|
feedback: any ValidGeneratorInput = 0.0,
|
||||||
|
sampleRate: Double,
|
||||||
|
fadeTime: Double = 0.004
|
||||||
|
) {
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_delay = delay._resolvedInput()
|
||||||
|
_feedback = feedback._resolvedInput()
|
||||||
|
|
||||||
|
let frames: Int = max(1, Int((maxDelay * sampleRate).rounded()))
|
||||||
|
_maxFrames = frames
|
||||||
|
_bufferA = [Double](repeating: 0.0, count: frames)
|
||||||
|
_bufferB = [Double](repeating: 0.0, count: frames)
|
||||||
|
_segLen = frames
|
||||||
|
_fadeFrames = max(0, Int((fadeTime * sampleRate).rounded()))
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Render
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
let sampleRate: Double = graph.engine.sampleRate
|
||||||
|
// Sanitise control reads (finite + clamped): a NaN/inf/huge `delay` would otherwise trap the
|
||||||
|
// seconds→frames `Int` conversion, and a NaN `feedback` would poison the loop.
|
||||||
|
let maxDelaySeconds: Double = Double(_maxFrames) / sampleRate
|
||||||
|
let rawDelay: Double = _delay.floatValue(graph: graph)
|
||||||
|
let delaySeconds: Double = rawDelay.isFinite ? min(max(rawDelay, 0.0), maxDelaySeconds) : 0.0
|
||||||
|
let rawFeedback: Double = _feedback.floatValue(graph: graph)
|
||||||
|
let feedback: Double = rawFeedback.isFinite ? min(max(rawFeedback, 0.0), maxFeedback) : 0.0
|
||||||
|
|
||||||
|
// Target segment length, applied at the next boundary so a read never changes length mid-segment.
|
||||||
|
// `delaySeconds` is bounded to `maxDelaySeconds`, so the `Int` conversion cannot overflow.
|
||||||
|
let targetLen: Int = min(max(Int((delaySeconds * sampleRate).rounded()), 1), _maxFrames)
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? reverseDelayZeroBlock)
|
||||||
|
: reverseDelayZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
|
var phase: Int = _phase
|
||||||
|
var segLen: Int = _segLen
|
||||||
|
var recordIsA: Bool = _recordIsA
|
||||||
|
let fadeFrames: Int = _fadeFrames
|
||||||
|
|
||||||
|
// Adopt the live delay length on the first block — at `init` the node value isn't known, so
|
||||||
|
// the segment must not start at the full buffer length (that would delay the first reversed
|
||||||
|
// segment by `maxDelay`).
|
||||||
|
if !_segLenInitialized {
|
||||||
|
segLen = targetLen
|
||||||
|
phase = 0
|
||||||
|
_segLenInitialized = true
|
||||||
|
}
|
||||||
|
|
||||||
|
_bufferA.withUnsafeMutableBufferPointer { aBuffer in
|
||||||
|
_bufferB.withUnsafeMutableBufferPointer { bBuffer in
|
||||||
|
// `baseAddress` is non-nil for these always-non-empty buffers (sized `_maxFrames >= 1`
|
||||||
|
// at init), so this guard never fires; it satisfies the optional without an RT trap.
|
||||||
|
guard let aPointer: UnsafeMutablePointer<Double> = aBuffer.baseAddress,
|
||||||
|
let bPointer: UnsafeMutablePointer<Double> = bBuffer.baseAddress else { return }
|
||||||
|
_result[0].withUnsafeMutableBufferPointer { outBuffer in
|
||||||
|
guard let outPointer: UnsafeMutablePointer<Double> = outBuffer.baseAddress else { return }
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = _inputIsGenerator
|
||||||
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
|
: inputScalar
|
||||||
|
|
||||||
|
let recordPointer: UnsafeMutablePointer<Double> = recordIsA ? aPointer : bPointer
|
||||||
|
let playPointer: UnsafeMutablePointer<Double> = recordIsA ? bPointer : aPointer
|
||||||
|
|
||||||
|
// Reversed read: end of the play segment first.
|
||||||
|
let readIndex: Int = segLen - 1 - phase
|
||||||
|
let raw: Double = playPointer[readIndex]
|
||||||
|
let envelope: Double = ReverseDelay.edgeFade(
|
||||||
|
phase: phase, segLen: segLen, fadeFrames: fadeFrames
|
||||||
|
)
|
||||||
|
let out: Double = raw * envelope
|
||||||
|
|
||||||
|
recordPointer[phase] = x + feedback * out
|
||||||
|
outPointer[i] = out
|
||||||
|
|
||||||
|
phase += 1
|
||||||
|
if phase >= segLen {
|
||||||
|
phase = 0
|
||||||
|
recordIsA.toggle()
|
||||||
|
segLen = targetLen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_phase = phase
|
||||||
|
_segLen = segLen
|
||||||
|
_recordIsA = recordIsA
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Linear raised-edge fade in `[0, 1]`: ramps up over the first `fadeFrames` of a segment and
|
||||||
|
/// down over the last `fadeFrames`, flat `1` in the middle. De-clicks the reverse wrap.
|
||||||
|
private static func edgeFade(
|
||||||
|
phase: Int,
|
||||||
|
segLen: Int,
|
||||||
|
fadeFrames: Int
|
||||||
|
) -> Double {
|
||||||
|
let fade: Int = min(fadeFrames, segLen / 2)
|
||||||
|
guard fade > 0 else { return 1.0 }
|
||||||
|
let fromStart: Int = phase
|
||||||
|
let fromEnd: Int = segLen - 1 - phase
|
||||||
|
let nearestEdge: Int = min(fromStart, fromEnd)
|
||||||
|
guard nearestEdge < fade else { return 1.0 }
|
||||||
|
return Double(nearestEdge) / Double(fade)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
// SampleRateDecimate.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
||||||
|
private let sampleRateDecimateZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Sample-rate reducer (decimator): a sample-and-hold that latches a new input value only once
|
||||||
|
/// every `downsample` samples, holding it in between. The aliased, stair-stepped result is the
|
||||||
|
/// "crushed sample rate" half of a lo-fi / bitcrusher effect.
|
||||||
|
///
|
||||||
|
/// `downsample` is read at control rate (once per block). `1` passes the signal through; `N` holds
|
||||||
|
/// each sample for `N` output samples (effective rate `sampleRate / N`). Output is mono (channel 0).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate signal to decimate.
|
||||||
|
/// - downsample: Hold length in samples — effective rate is `sampleRate / downsample`. Control
|
||||||
|
/// rate; clamped to `>= 1` (`1` is transparent).
|
||||||
|
public final class SampleRateDecimate: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
/// Resolved input signal.
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// `true` when `_input` resolved to a generator; classified once so the RT path runs no
|
||||||
|
/// `is`/`as?` check.
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
|
||||||
|
/// Downsample factor, read at block rate. Pass a control-rate node or scalar.
|
||||||
|
let _downsample: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// Samples remaining before the next latch. `0` latches a fresh input on the current sample.
|
||||||
|
var _countdown: Int = 0
|
||||||
|
|
||||||
|
/// Currently held output value.
|
||||||
|
var _held: Double = 0.0
|
||||||
|
|
||||||
|
/// Smallest decimation factor (pass-through).
|
||||||
|
private let minimumFactor: Int = 1
|
||||||
|
|
||||||
|
/// Largest accepted decimation factor — bounds the control read so the `Int` conversion can
|
||||||
|
/// never overflow on a NaN/inf/huge input.
|
||||||
|
private let maximumFactor: Double = 1_048_576.0
|
||||||
|
|
||||||
|
/// Creates a sample-rate decimator.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to decimate.
|
||||||
|
/// - downsample: Hold length in samples (control rate). Clamped to `>= 1`; `1` is transparent.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
downsample: any ValidGeneratorInput
|
||||||
|
) {
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_downsample = downsample._resolvedInput()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
// Sanitise the control read (finite + clamped) so the `Int` conversion can't overflow.
|
||||||
|
let raw: Double = _downsample.floatValue(graph: graph)
|
||||||
|
let safeFactor: Double = raw.isFinite
|
||||||
|
? min(max(raw, Double(minimumFactor)), maximumFactor)
|
||||||
|
: Double(minimumFactor)
|
||||||
|
let factor: Int = Int(safeFactor.rounded())
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? sampleRateDecimateZeroBlock)
|
||||||
|
: sampleRateDecimateZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
|
var countdown: Int = _countdown
|
||||||
|
var held: Double = _held
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = _inputIsGenerator
|
||||||
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
|
: inputScalar
|
||||||
|
if countdown <= 0 {
|
||||||
|
held = x
|
||||||
|
countdown = factor
|
||||||
|
}
|
||||||
|
countdown -= 1
|
||||||
|
_result[0][i] = held
|
||||||
|
}
|
||||||
|
|
||||||
|
_countdown = countdown
|
||||||
|
_held = held
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,297 @@
|
|||||||
|
// ShimmerReverb.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation // `cos` for the init-time Hann window (not used on the RT path)
|
||||||
|
import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
||||||
|
private let shimmerReverbZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Regenerative shimmer reverb: a damped feedback tank with an octave-up grain reader **inside**
|
||||||
|
/// the feedback path, so the pitched-up tail recirculates and the shimmer builds and sustains
|
||||||
|
/// (rather than the one-shot parallel pitch-into-reverb approximation).
|
||||||
|
///
|
||||||
|
/// Signal path per sample:
|
||||||
|
/// ```
|
||||||
|
/// input → 2 series Schroeder allpasses (diffusion) ─┐
|
||||||
|
/// ▼
|
||||||
|
/// tank delay (size) → damping one-pole → ┬─────────→ output (wet tail)
|
||||||
|
/// │
|
||||||
|
/// octave-up grains read from the tank ───┤ (× shimmer)
|
||||||
|
/// ▼
|
||||||
|
/// feedback = decay·damped + shimmer·pitched → written back into the tank
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The octave-up is a two-grain, 50%-overlap, Hann-windowed reader running at 2× over the most
|
||||||
|
/// recent `grain` samples of the tank (the live wet content), a tape-style pitch raise whose
|
||||||
|
/// pitched output recirculates through the feedback. A per-sample safety clamp + denormal flush
|
||||||
|
/// keep the loop bounded even at high `decay` / `shimmer`.
|
||||||
|
///
|
||||||
|
/// `size`, `decay`, `shimmer`, and `damp` are read at control rate (once per block). Output is mono.
|
||||||
|
///
|
||||||
|
/// - Important: All buffers are pre-allocated at `init` for `maxDelay` seconds plus the grain
|
||||||
|
/// length — the RT path never allocates or resizes.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate signal to reverberate.
|
||||||
|
/// - maxDelay: Maximum tank delay in seconds; sizes the pre-allocated buffer.
|
||||||
|
/// - size: Tank delay in seconds. Control rate; clamped to `[0.005, maxDelay]`.
|
||||||
|
/// - decay: Feedback gain (tail length). Control rate; clamped to `[0, 0.92]`.
|
||||||
|
/// - shimmer: Octave-up feedback amount. Control rate; clamped to `[0, 0.85]`.
|
||||||
|
/// - damp: High-frequency damping in the feedback `[0, 1]` (0 = bright, 1 = dark). Control rate.
|
||||||
|
/// - sampleRate: Sample rate used to size buffers and convert seconds → frames; match the engine.
|
||||||
|
public final class ShimmerReverb: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
// MARK: - Inputs
|
||||||
|
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
let _size: any ValidGeneratorInput
|
||||||
|
let _decay: any ValidGeneratorInput
|
||||||
|
let _shimmer: any ValidGeneratorInput
|
||||||
|
let _damp: any ValidGeneratorInput
|
||||||
|
|
||||||
|
// MARK: - Buffers + state
|
||||||
|
|
||||||
|
/// Tank delay/grain buffer (circular), length `_bufLen`.
|
||||||
|
private var _tank: [Double]
|
||||||
|
/// Two Schroeder input-diffusion allpass buffers.
|
||||||
|
private var _allpassA: [Double]
|
||||||
|
private var _allpassB: [Double]
|
||||||
|
/// Precomputed Hann window over one grain, length `_grainFrames`.
|
||||||
|
private var _hann: [Double]
|
||||||
|
|
||||||
|
private let _bufLen: Int
|
||||||
|
private let _grainFrames: Int
|
||||||
|
private let _maxDelayFrames: Int
|
||||||
|
private let _allpassALen: Int
|
||||||
|
private let _allpassBLen: Int
|
||||||
|
|
||||||
|
private var _writePos: Int = 0
|
||||||
|
private var _allpassAPos: Int = 0
|
||||||
|
private var _allpassBPos: Int = 0
|
||||||
|
private var _grainCounter: Int = 0
|
||||||
|
private var _dampState: Double = 0.0
|
||||||
|
/// DC-blocker state (previous input/output) on the feedback path.
|
||||||
|
private var _dcX1: Double = 0.0
|
||||||
|
private var _dcY1: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private let minSizeSeconds: Double = 0.005
|
||||||
|
private let maxDecay: Double = 0.92
|
||||||
|
private let maxShimmer: Double = 0.85
|
||||||
|
private let grainSeconds: Double = 0.05
|
||||||
|
/// Schroeder allpass coefficient and (prime-ish) lengths in samples for input diffusion.
|
||||||
|
private let allpassGain: Double = 0.7
|
||||||
|
private let allpassAFrames: Int = 142
|
||||||
|
private let allpassBFrames: Int = 107
|
||||||
|
/// Hard safety bound on the recirculated value — prevents runaway / NaN at extreme settings.
|
||||||
|
private let safetyClamp: Double = 8.0
|
||||||
|
/// Below this magnitude feedback state is flushed to zero (denormal guard).
|
||||||
|
private let denormalFloor: Double = 1.0e-15
|
||||||
|
/// DC-blocker pole — a one-pole high-pass on the feedback path. Without it the octave-up of DC
|
||||||
|
/// (≈ DC) plus the DC-passing damping filter gives the loop a DC gain near `decay + shimmer`,
|
||||||
|
/// which exceeds 1 at higher settings and accumulates into a DC offset. ~7 Hz cutoff @ 44.1 kHz
|
||||||
|
/// — sub-bass only, so the shimmer wash is unaffected.
|
||||||
|
private let dcBlockCoeff: Double = 0.999
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a shimmer reverb.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate signal to reverberate.
|
||||||
|
/// - maxDelay: Maximum tank delay in seconds; sizes the pre-allocated buffer.
|
||||||
|
/// - size: Tank delay in seconds. Control rate; clamped to `[0.005, maxDelay]`.
|
||||||
|
/// - decay: Feedback gain (tail length). Control rate; clamped to `[0, 0.92]`.
|
||||||
|
/// - shimmer: Octave-up feedback amount. Control rate; clamped to `[0, 0.85]`.
|
||||||
|
/// - damp: High-frequency damping in the feedback `[0, 1]` (0 = bright, 1 = dark). Control rate.
|
||||||
|
/// - sampleRate: Sample rate used to size buffers and convert seconds → frames; match the engine.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
maxDelay: Double,
|
||||||
|
size: any ValidGeneratorInput,
|
||||||
|
decay: any ValidGeneratorInput,
|
||||||
|
shimmer: any ValidGeneratorInput,
|
||||||
|
damp: any ValidGeneratorInput,
|
||||||
|
sampleRate: Double
|
||||||
|
) {
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_size = size._resolvedInput()
|
||||||
|
_decay = decay._resolvedInput()
|
||||||
|
_shimmer = shimmer._resolvedInput()
|
||||||
|
_damp = damp._resolvedInput()
|
||||||
|
|
||||||
|
let maxFrames: Int = max(1, Int((maxDelay * sampleRate).rounded()))
|
||||||
|
let grain: Int = max(2, Int((grainSeconds * sampleRate).rounded()))
|
||||||
|
_maxDelayFrames = maxFrames
|
||||||
|
_grainFrames = grain
|
||||||
|
// Buffer holds the deepest tank read plus a full grain look-back, with headroom.
|
||||||
|
_bufLen = maxFrames + grain + 2
|
||||||
|
_allpassALen = allpassAFrames
|
||||||
|
_allpassBLen = allpassBFrames
|
||||||
|
|
||||||
|
_tank = [Double](repeating: 0.0, count: _bufLen)
|
||||||
|
_allpassA = [Double](repeating: 0.0, count: allpassAFrames)
|
||||||
|
_allpassB = [Double](repeating: 0.0, count: allpassBFrames)
|
||||||
|
|
||||||
|
// Precompute the Hann window for the grain (off the RT thread).
|
||||||
|
var hann: [Double] = [Double](repeating: 0.0, count: grain)
|
||||||
|
let twoPi: Double = 2.0 * Double.pi
|
||||||
|
for i: Int in 0..<grain {
|
||||||
|
hann[i] = 0.5 - 0.5 * cos(twoPi * Double(i) / Double(grain))
|
||||||
|
}
|
||||||
|
_hann = hann
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Render
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
let sampleRate: Double = graph.engine.sampleRate
|
||||||
|
// Sanitise control reads (finite + clamped) so a NaN/inf/huge value can never reach the
|
||||||
|
// feedback math or trap the seconds→frames `Int` conversion.
|
||||||
|
let maxSizeSeconds: Double = Double(_maxDelayFrames) / sampleRate
|
||||||
|
let sizeSeconds: Double = ShimmerReverb.clamp(_size.floatValue(graph: graph), minSizeSeconds, maxSizeSeconds)
|
||||||
|
let decay: Double = ShimmerReverb.clamp(_decay.floatValue(graph: graph), 0.0, maxDecay)
|
||||||
|
let shimmer: Double = ShimmerReverb.clamp(_shimmer.floatValue(graph: graph), 0.0, maxShimmer)
|
||||||
|
let damp: Double = ShimmerReverb.clamp(_damp.floatValue(graph: graph), 0.0, 1.0)
|
||||||
|
|
||||||
|
let minFrames: Int = max(1, Int((minSizeSeconds * sampleRate).rounded()))
|
||||||
|
// `sizeSeconds` is bounded to `maxSizeSeconds`, so `sizeSeconds · sampleRate <= _maxDelayFrames`
|
||||||
|
// and the `Int` conversion cannot overflow.
|
||||||
|
let sizeFrames: Int = min(max(Int((sizeSeconds * sampleRate).rounded()), minFrames), _maxDelayFrames)
|
||||||
|
let halfGrain: Int = _grainFrames / 2
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? shimmerReverbZeroBlock)
|
||||||
|
: shimmerReverbZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
|
var writePos: Int = _writePos
|
||||||
|
var grainCounter: Int = _grainCounter
|
||||||
|
var dampState: Double = _dampState
|
||||||
|
var allpassAPos: Int = _allpassAPos
|
||||||
|
var allpassBPos: Int = _allpassBPos
|
||||||
|
var dcX1: Double = _dcX1
|
||||||
|
var dcY1: Double = _dcY1
|
||||||
|
|
||||||
|
_tank.withUnsafeMutableBufferPointer { tankBuffer in
|
||||||
|
_allpassA.withUnsafeMutableBufferPointer { apABuffer in
|
||||||
|
_allpassB.withUnsafeMutableBufferPointer { apBBuffer in
|
||||||
|
_hann.withUnsafeBufferPointer { hannBuffer in
|
||||||
|
_result[0].withUnsafeMutableBufferPointer { outBuffer in
|
||||||
|
guard let tank: UnsafeMutablePointer<Double> = tankBuffer.baseAddress,
|
||||||
|
let apA: UnsafeMutablePointer<Double> = apABuffer.baseAddress,
|
||||||
|
let apB: UnsafeMutablePointer<Double> = apBBuffer.baseAddress,
|
||||||
|
let hann: UnsafePointer<Double> = hannBuffer.baseAddress,
|
||||||
|
let out: UnsafeMutablePointer<Double> = outBuffer.baseAddress
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = _inputIsGenerator
|
||||||
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
|
: inputScalar
|
||||||
|
|
||||||
|
// Input diffusion: two series Schroeder allpasses.
|
||||||
|
let diffused: Double = ShimmerReverb.allpass(
|
||||||
|
ShimmerReverb.allpass(x, apA, &allpassAPos, _allpassALen, allpassGain),
|
||||||
|
apB, &allpassBPos, _allpassBLen, allpassGain
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delayed tank read → one-pole damping (HF absorption).
|
||||||
|
let readTail: Double = tank[ShimmerReverb.wrap(writePos - sizeFrames, _bufLen)]
|
||||||
|
dampState = dampState + (1.0 - damp) * (readTail - dampState)
|
||||||
|
let damped: Double = dampState
|
||||||
|
|
||||||
|
// Octave-up: two 50%-overlapped Hann grains read at 2× over the tank.
|
||||||
|
let offsetA: Int = _grainFrames - grainCounter
|
||||||
|
let phaseB: Int = (grainCounter + halfGrain) % _grainFrames
|
||||||
|
let offsetB: Int = _grainFrames - phaseB
|
||||||
|
let pitched: Double =
|
||||||
|
hann[grainCounter] * tank[ShimmerReverb.wrap(writePos - offsetA, _bufLen)]
|
||||||
|
+ hann[phaseB] * tank[ShimmerReverb.wrap(writePos - offsetB, _bufLen)]
|
||||||
|
|
||||||
|
// Feedback: decayed damped tail + pitched shimmer, DC-blocked so the
|
||||||
|
// loop has no DC gain (the octave-up of DC is DC), then add the input.
|
||||||
|
let feedbackRaw: Double = decay * damped + shimmer * pitched
|
||||||
|
let feedback: Double = feedbackRaw - dcX1 + dcBlockCoeff * dcY1
|
||||||
|
dcX1 = feedbackRaw
|
||||||
|
dcY1 = feedback
|
||||||
|
var writeVal: Double = diffused + feedback
|
||||||
|
if writeVal > safetyClamp { writeVal = safetyClamp }
|
||||||
|
else if writeVal < -safetyClamp { writeVal = -safetyClamp }
|
||||||
|
// Flush denormals so they never recirculate in the tank (RT CPU guard).
|
||||||
|
if abs(writeVal) < denormalFloor { writeVal = 0.0 }
|
||||||
|
tank[writePos] = writeVal
|
||||||
|
|
||||||
|
out[i] = damped
|
||||||
|
|
||||||
|
writePos += 1
|
||||||
|
if writePos >= _bufLen { writePos = 0 }
|
||||||
|
grainCounter += 1
|
||||||
|
if grainCounter >= _grainFrames { grainCounter = 0 }
|
||||||
|
}
|
||||||
|
if abs(dampState) < denormalFloor { dampState = 0.0 }
|
||||||
|
if abs(dcY1) < denormalFloor { dcY1 = 0.0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_writePos = writePos
|
||||||
|
_grainCounter = grainCounter
|
||||||
|
_dampState = dampState
|
||||||
|
_allpassAPos = allpassAPos
|
||||||
|
_allpassBPos = allpassBPos
|
||||||
|
_dcX1 = dcX1
|
||||||
|
_dcY1 = dcY1
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One Schroeder allpass step over a circular buffer; advances `pos`. `y = -g·x + d;
|
||||||
|
/// buf = x + g·y` where `d` is the delayed sample.
|
||||||
|
private static func allpass(
|
||||||
|
_ x: Double,
|
||||||
|
_ buffer: UnsafeMutablePointer<Double>,
|
||||||
|
_ pos: inout Int,
|
||||||
|
_ length: Int,
|
||||||
|
_ gain: Double
|
||||||
|
) -> Double {
|
||||||
|
let delayed: Double = buffer[pos]
|
||||||
|
let y: Double = -gain * x + delayed
|
||||||
|
buffer[pos] = x + gain * y
|
||||||
|
pos += 1
|
||||||
|
if pos >= length { pos = 0 }
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `v` clamped to `[lo, hi]`, or `lo` when `v` is not finite — sanitising control reads
|
||||||
|
/// before they reach the feedback math or an `Int` frame conversion.
|
||||||
|
private static func clamp(_ v: Double, _ lo: Double, _ hi: Double) -> Double {
|
||||||
|
guard v.isFinite else { return lo }
|
||||||
|
return min(max(v, lo), hi)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wraps `index` into `[0, length)` (handles a single negative wrap, as produced by
|
||||||
|
/// `writePos - offset` with `offset <= length`).
|
||||||
|
private static func wrap(_ index: Int, _ length: Int) -> Int {
|
||||||
|
let m: Int = index % length
|
||||||
|
return m < 0 ? m + length : m
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
// StereoGranulator.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Foundation // `cos`/`sin` for the init-time Hann table and per-grain pan gains
|
||||||
|
@_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Shared zero-fill fallback block, allocated once at module load, so the RT path never allocates.
|
||||||
|
private let stereoGranulatorZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Stereo input granulator (straight-through): windows and pans the **live** input directly,
|
||||||
|
/// without a delay/look-back buffer, so there is no latency.
|
||||||
|
///
|
||||||
|
/// A pool of overlapping grain voices each apply a Hann envelope to the incoming sample and pan it
|
||||||
|
/// to a fresh random position in `[-1, 1] × spread`; the windowed, panned copies sum to the stereo
|
||||||
|
/// output. Because every active grain reads the current input sample (not buffered history), the
|
||||||
|
/// effect adds stereo width and a shimmering amplitude texture with **no time delay**. `spread = 0`
|
||||||
|
/// collapses every grain to centre (mono); `spread = 1` scatters grains across the full field.
|
||||||
|
/// Output is normalised by `overlap` so density doesn't change the level.
|
||||||
|
///
|
||||||
|
/// `grainSize`, `overlap`, and `spread` are read at control rate (once per block). Output is two
|
||||||
|
/// channels (`[0]` = left, `[1]` = right) — use the ``left`` / ``right`` accessors.
|
||||||
|
///
|
||||||
|
/// - Important: The grain voice pool is pre-allocated at `init` — the RT path never allocates.
|
||||||
|
public final class StereoGranulator: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
// MARK: - Inputs
|
||||||
|
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
let _grainSize: any ValidGeneratorInput
|
||||||
|
let _overlap: any ValidGeneratorInput
|
||||||
|
let _spread: any ValidGeneratorInput
|
||||||
|
|
||||||
|
// MARK: - State
|
||||||
|
|
||||||
|
/// Precomputed unit Hann window, indexed by `phase · hannSize / grainLen`.
|
||||||
|
private var _hann: [Double]
|
||||||
|
private let _hannSize: Int = 2048
|
||||||
|
|
||||||
|
private let _maxGrainFrames: Int
|
||||||
|
private let _minGrainFrames: Int
|
||||||
|
|
||||||
|
// Grain voice pool (fixed size; a grain that can't find a free voice is skipped).
|
||||||
|
private static let maxVoices: Int = 24
|
||||||
|
private var _vActive: [Bool]
|
||||||
|
private var _vPhase: [Int]
|
||||||
|
private var _vLen: [Int]
|
||||||
|
private var _vGainL: [Double]
|
||||||
|
private var _vGainR: [Double]
|
||||||
|
|
||||||
|
private var _spawnCountdown: Int = 0
|
||||||
|
private var _rng: UInt64
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private let minGrainSeconds: Double = 0.003
|
||||||
|
/// Equal-power pan: `angle = (pan + 1) · π/4`, `gainL = cos`, `gainR = sin`.
|
||||||
|
private let panAngleScale: Double = Double.pi / 4.0
|
||||||
|
/// Non-zero fallback PRNG seed (golden-ratio constant).
|
||||||
|
private static let defaultSeed: UInt64 = 0x9E37_79B9_7F4A_7C15
|
||||||
|
|
||||||
|
public override var outputChannelCount: Int { 2 }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a stereo granulator.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Audio-rate mono signal to granulate.
|
||||||
|
/// - maxGrainSize: Largest grain length in seconds; bounds the grain-length clamp.
|
||||||
|
/// - grainSize: Grain (window) length in seconds. Control rate; clamped to `[~0.003, maxGrainSize]`.
|
||||||
|
/// - overlap: Number of overlapping grains (density); also the level normaliser. Control rate;
|
||||||
|
/// clamped to `[1, 24]`.
|
||||||
|
/// - spread: Stereo spread `[0, 1]` — scales each grain's random pan. Control rate.
|
||||||
|
/// - sampleRate: Sample rate used to convert grain seconds → frames.
|
||||||
|
/// - seed: Optional PRNG seed for deterministic grain panning (tests). Defaults to a constant.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
maxGrainSize: Double,
|
||||||
|
grainSize: any ValidGeneratorInput,
|
||||||
|
overlap: any ValidGeneratorInput,
|
||||||
|
spread: any ValidGeneratorInput,
|
||||||
|
sampleRate: Double,
|
||||||
|
seed: UInt64? = nil
|
||||||
|
) {
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_grainSize = grainSize._resolvedInput()
|
||||||
|
_overlap = overlap._resolvedInput()
|
||||||
|
_spread = spread._resolvedInput()
|
||||||
|
|
||||||
|
_maxGrainFrames = max(1, Int((maxGrainSize * sampleRate).rounded()))
|
||||||
|
_minGrainFrames = max(1, Int((minGrainSeconds * sampleRate).rounded()))
|
||||||
|
|
||||||
|
_vActive = [Bool](repeating: false, count: StereoGranulator.maxVoices)
|
||||||
|
_vPhase = [Int](repeating: 0, count: StereoGranulator.maxVoices)
|
||||||
|
_vLen = [Int](repeating: 1, count: StereoGranulator.maxVoices)
|
||||||
|
_vGainL = [Double](repeating: 0.0, count: StereoGranulator.maxVoices)
|
||||||
|
_vGainR = [Double](repeating: 0.0, count: StereoGranulator.maxVoices)
|
||||||
|
|
||||||
|
var hann: [Double] = [Double](repeating: 0.0, count: _hannSize)
|
||||||
|
let twoPi: Double = 2.0 * Double.pi
|
||||||
|
for i: Int in 0..<_hannSize {
|
||||||
|
hann[i] = 0.5 - 0.5 * cos(twoPi * Double(i) / Double(_hannSize))
|
||||||
|
}
|
||||||
|
_hann = hann
|
||||||
|
|
||||||
|
let requestedSeed: UInt64 = seed ?? StereoGranulator.defaultSeed
|
||||||
|
_rng = requestedSeed == 0 ? StereoGranulator.defaultSeed : requestedSeed
|
||||||
|
|
||||||
|
super.init(channels: 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Render
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
guard count > 0 else { return _result }
|
||||||
|
|
||||||
|
let sampleRate: Double = graph.engine.sampleRate
|
||||||
|
|
||||||
|
let rawGrain: Double = _grainSize.floatValue(graph: graph)
|
||||||
|
let grainSeconds: Double = rawGrain.isFinite
|
||||||
|
? min(max(rawGrain, minGrainSeconds), Double(_maxGrainFrames) / sampleRate)
|
||||||
|
: minGrainSeconds
|
||||||
|
let grainLen: Int = min(max(Int((grainSeconds * sampleRate).rounded()), _minGrainFrames), _maxGrainFrames)
|
||||||
|
|
||||||
|
let rawOverlap: Double = _overlap.floatValue(graph: graph)
|
||||||
|
let overlap: Int = rawOverlap.isFinite
|
||||||
|
? min(max(Int(rawOverlap.rounded()), 1), StereoGranulator.maxVoices)
|
||||||
|
: 1
|
||||||
|
|
||||||
|
let rawSpread: Double = _spread.floatValue(graph: graph)
|
||||||
|
let spread: Double = rawSpread.isFinite ? min(max(rawSpread, 0.0), 1.0) : 0.0
|
||||||
|
|
||||||
|
let spawnPeriod: Int = max(1, grainLen / overlap)
|
||||||
|
// Normalise so denser overlap doesn't raise the level (≈ sum of overlapping Hann windows).
|
||||||
|
let norm: Double = 1.0 / Double(overlap)
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _inputIsGenerator
|
||||||
|
? (_input.calculatedSamples(graph: graph, count: count).first ?? stereoGranulatorZeroBlock)
|
||||||
|
: stereoGranulatorZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
let inputScalar: Double = _inputIsGenerator ? 0.0 : _input.floatValue(graph: graph)
|
||||||
|
|
||||||
|
var spawnCountdown: Int = _spawnCountdown
|
||||||
|
var rng: UInt64 = _rng
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
let x: Double = _inputIsGenerator
|
||||||
|
? (i < inputCount ? inputSamples[i] : 0.0)
|
||||||
|
: inputScalar
|
||||||
|
|
||||||
|
var left: Double = 0.0
|
||||||
|
var right: Double = 0.0
|
||||||
|
for v: Int in 0..<StereoGranulator.maxVoices where _vActive[v] {
|
||||||
|
let phase: Int = _vPhase[v]
|
||||||
|
let len: Int = _vLen[v]
|
||||||
|
let windowIndex: Int = phase * _hannSize / len
|
||||||
|
// Straight-through: window + pan the LIVE sample (no delay buffer).
|
||||||
|
let windowed: Double = x * _hann[windowIndex]
|
||||||
|
left += windowed * _vGainL[v]
|
||||||
|
right += windowed * _vGainR[v]
|
||||||
|
let nextPhase: Int = phase + 1
|
||||||
|
if nextPhase >= len {
|
||||||
|
_vActive[v] = false
|
||||||
|
} else {
|
||||||
|
_vPhase[v] = nextPhase
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spawnCountdown -= 1
|
||||||
|
if spawnCountdown <= 0 {
|
||||||
|
spawnCountdown = spawnPeriod
|
||||||
|
spawnGrain(grainLen: grainLen, spread: spread, rng: &rng)
|
||||||
|
}
|
||||||
|
|
||||||
|
_result[0][i] = left * norm
|
||||||
|
_result[1][i] = right * norm
|
||||||
|
}
|
||||||
|
|
||||||
|
_spawnCountdown = spawnCountdown
|
||||||
|
_rng = rng
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Activates the first free grain voice (no-op if all are busy — overlap saturates gracefully).
|
||||||
|
private func spawnGrain(
|
||||||
|
grainLen: Int,
|
||||||
|
spread: Double,
|
||||||
|
rng: inout UInt64
|
||||||
|
) {
|
||||||
|
var voice: Int = -1
|
||||||
|
for v: Int in 0..<StereoGranulator.maxVoices where !_vActive[v] {
|
||||||
|
voice = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
guard voice >= 0 else { return }
|
||||||
|
|
||||||
|
_vActive[voice] = true
|
||||||
|
_vPhase[voice] = 0
|
||||||
|
_vLen[voice] = grainLen
|
||||||
|
let pan: Double = xorshift64Next(&rng) * spread // shared RT-safe PRNG, [-1, 1) × spread
|
||||||
|
let angle: Double = (pan + 1.0) * panAngleScale
|
||||||
|
_vGainL[voice] = cos(angle)
|
||||||
|
_vGainR[voice] = sin(angle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Channel accessors
|
||||||
|
|
||||||
|
public extension StereoGranulator {
|
||||||
|
/// Left output channel.
|
||||||
|
var left: ChannelSelect.Audio { self[0] }
|
||||||
|
/// Right output channel.
|
||||||
|
var right: ChannelSelect.Audio { self[1] }
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
// SubOctaveDivider.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 subOctaveDividerZeroBlock: [Double] = makeSampleBuffer()
|
||||||
|
|
||||||
|
/// Analog-style sub-octave generator: a hysteresis comparator feeding a T flip-flop chain.
|
||||||
|
///
|
||||||
|
/// This is the core of the classic Boss OC-2 octave-down algorithm. The input is treated
|
||||||
|
/// as a square wave by a Schmitt-trigger comparator around zero; each rising edge clocks a
|
||||||
|
/// toggle flip-flop. Toggling on every rising edge halves the frequency (`divisor: 2`,
|
||||||
|
/// one octave down); toggling on every *second* rising edge quarters it (`divisor: 4`, two
|
||||||
|
/// octaves down). The output is a hard `±1` square wave at `inputFrequency / divisor`.
|
||||||
|
///
|
||||||
|
/// The comparator runs in the time domain, so unlike an FFT pitch tracker it follows low
|
||||||
|
/// bass fundamentals (sub-100 Hz) with no detection floor. It is strictly monophonic — fed
|
||||||
|
/// a chord it tracks the dominant zero-crossing rate and glitches, exactly as the original
|
||||||
|
/// analog divider does.
|
||||||
|
///
|
||||||
|
/// Feed it a band-limited, hard-limited signal (low-pass to isolate the fundamental, then a
|
||||||
|
/// `tanh` limiter to square it up) for clean triggering; the raw guitar signal's upper
|
||||||
|
/// harmonics cause double-triggering an octave too high.
|
||||||
|
///
|
||||||
|
/// Output is mono: only channel 0 of the input is read (a stereo input is mono-summed to its
|
||||||
|
/// first channel before division).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to divide. Should be pre-conditioned to a near-square `±1` waveform.
|
||||||
|
/// - divisor: Division ratio. `2` = one octave down, `4` = two octaves down. Even values
|
||||||
|
/// only; `init` traps on `divisor < 2`, and odd values truncate toward the next lower
|
||||||
|
/// even ratio (`divisor / 2` rising-edge count).
|
||||||
|
public final class SubOctaveDivider: GeneratorBase, AudioGenerator {
|
||||||
|
|
||||||
|
/// Resolved input signal (classified once at `init`, never on the RT thread).
|
||||||
|
let _input: any ValidGeneratorInput
|
||||||
|
|
||||||
|
/// `true` when `_input` resolved to an `any Generator`; `false` for a scalar constant.
|
||||||
|
/// Classified once at `init` so the RT path never runs an `is`/`as?` type check and never
|
||||||
|
/// hits `Double.calculatedSamples`, which would allocate every block.
|
||||||
|
let _inputIsGenerator: Bool
|
||||||
|
|
||||||
|
/// Number of rising input edges between output toggles: `divisor / 2`. A divide-by-2
|
||||||
|
/// square toggles every rising edge; divide-by-4 toggles every second rising edge.
|
||||||
|
let _toggleEvery: Int
|
||||||
|
|
||||||
|
/// Comparator state: `true` once the input has risen above `compHigh`, `false` once it
|
||||||
|
/// has fallen below `compLow`. The hysteresis band rejects zero-region noise.
|
||||||
|
var _high: Bool = false
|
||||||
|
|
||||||
|
/// Rising edges seen since the last output toggle.
|
||||||
|
var _edgeCount: Int = 0
|
||||||
|
|
||||||
|
/// Current square-wave output level, toggled between `+1` and `-1`.
|
||||||
|
var _outState: Double = 1.0
|
||||||
|
|
||||||
|
/// Comparator switch-on threshold. Input must exceed this (from below) to register a
|
||||||
|
/// rising edge. Small positive value rejects noise around zero for a limited input.
|
||||||
|
private let compHigh: Double = 0.1
|
||||||
|
|
||||||
|
/// Comparator switch-off threshold. Input must fall below this to re-arm the rising-edge
|
||||||
|
/// detector. The `compHigh` / `compLow` gap is the hysteresis band.
|
||||||
|
private let compLow: Double = -0.1
|
||||||
|
|
||||||
|
/// Smallest accepted division ratio (one octave down).
|
||||||
|
private static let minimumDivisor: Int = 2
|
||||||
|
|
||||||
|
/// Creates a sub-octave divider.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - input: Signal to divide. Should be pre-conditioned to a near-square `±1` waveform.
|
||||||
|
/// - divisor: Division ratio. `2` = one octave down, `4` = two octaves down. Even values
|
||||||
|
/// only; traps on `divisor < 2`, and odd values truncate toward the next lower even ratio.
|
||||||
|
public init(
|
||||||
|
input: any ValidGeneratorInput,
|
||||||
|
divisor: Int
|
||||||
|
) {
|
||||||
|
precondition(divisor >= SubOctaveDivider.minimumDivisor,
|
||||||
|
"SubOctaveDivider: divisor must be >= 2; got \(divisor).")
|
||||||
|
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
|
||||||
|
_input = resolvedInput
|
||||||
|
_inputIsGenerator = resolvedInput is any Generator
|
||||||
|
_toggleEvery = divisor / 2
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func _computeSamples(
|
||||||
|
graph: SynthGraph,
|
||||||
|
count: Int
|
||||||
|
) -> [[Double]] {
|
||||||
|
_checkCount(count)
|
||||||
|
|
||||||
|
var high: Bool = _high
|
||||||
|
var edgeCount: Int = _edgeCount
|
||||||
|
var outState: Double = _outState
|
||||||
|
|
||||||
|
// A scalar (constant) input never crosses the comparator thresholds, so no edges fire
|
||||||
|
// and the output holds its current level. Skip the input pull entirely — this also
|
||||||
|
// avoids `Double.calculatedSamples`, which would allocate on the RT thread.
|
||||||
|
guard _inputIsGenerator else {
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
_result[0][i] = outState
|
||||||
|
}
|
||||||
|
_high = high
|
||||||
|
_edgeCount = edgeCount
|
||||||
|
_outState = outState
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
|
||||||
|
let inputSamples: [Double] = _input.calculatedSamples(
|
||||||
|
graph: graph, count: count).first ?? subOctaveDividerZeroBlock
|
||||||
|
let inputCount: Int = inputSamples.count
|
||||||
|
|
||||||
|
for i: Int in 0..<count {
|
||||||
|
// Bounds-safe read: a short upstream block falls back to silence past its end.
|
||||||
|
let x: Double = i < inputCount ? inputSamples[i] : 0.0
|
||||||
|
if !high && x > compHigh {
|
||||||
|
// Rising edge: clock the flip-flop.
|
||||||
|
high = true
|
||||||
|
edgeCount += 1
|
||||||
|
if edgeCount >= _toggleEvery {
|
||||||
|
edgeCount = 0
|
||||||
|
outState = -outState
|
||||||
|
}
|
||||||
|
} else if high && x < compLow {
|
||||||
|
high = false
|
||||||
|
}
|
||||||
|
_result[0][i] = outState
|
||||||
|
}
|
||||||
|
|
||||||
|
_high = high
|
||||||
|
_edgeCount = edgeCount
|
||||||
|
_outState = outState
|
||||||
|
return _result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ import LyrebirdSynth
|
|||||||
/// the zero-based hardware input channel index (`0` = first input). It maps to engine
|
/// the zero-based hardware input channel index (`0` = first input). It maps to engine
|
||||||
/// audio-bus index `numOutputChannels + channel` (hardware input buses follow the
|
/// audio-bus index `numOutputChannels + channel` (hardware input buses follow the
|
||||||
/// output buses). Requires the engine to be created with `numInputChannels > channel`.
|
/// output buses). Requires the engine to be created with `numInputChannels > channel`.
|
||||||
public enum InputSource {
|
public enum InputSource: Equatable {
|
||||||
/// Synthesized test signal — no hardware required.
|
/// Synthesized test signal — no hardware required.
|
||||||
case testLoop
|
case testLoop
|
||||||
/// Live hardware input from the given zero-based input channel. The engine must be
|
/// Live hardware input from the given zero-based input channel. The engine must be
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// MicrophonePermission.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import AVFoundation
|
||||||
|
|
||||||
|
/// Microphone (audio-input) authorisation helper for live-input mode.
|
||||||
|
///
|
||||||
|
/// On macOS, an AUHAL input unit does **not** reliably trigger the system microphone prompt;
|
||||||
|
/// without an explicit `AVCaptureDevice.requestAccess(for: .audio)` the OS hands the app a stream
|
||||||
|
/// of silent zeros (no error). On iOS the record-permission prompt is likewise required before the
|
||||||
|
/// session delivers input. This helper centralises the cross-platform request so every app routes
|
||||||
|
/// live input through the same gate.
|
||||||
|
///
|
||||||
|
/// The Info.plist must contain `NSMicrophoneUsageDescription`, or the request crashes at runtime.
|
||||||
|
public enum MicrophonePermission {
|
||||||
|
|
||||||
|
/// Current authorisation state for audio capture.
|
||||||
|
public static var status: AVAuthorizationStatus {
|
||||||
|
AVCaptureDevice.authorizationStatus(for: .audio)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `true` only when audio capture is already authorised.
|
||||||
|
public static var isAuthorized: Bool {
|
||||||
|
status == .authorized
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensures microphone access, prompting the user once if the state is undetermined.
|
||||||
|
///
|
||||||
|
/// - `authorized` → `completion(true)` immediately (next run loop, on the main actor).
|
||||||
|
/// - `notDetermined` → shows the system prompt; `completion` fires with the user's choice.
|
||||||
|
/// - `denied` / `restricted` → `completion(false)` (the app must direct the user to Settings).
|
||||||
|
///
|
||||||
|
/// `completion` is always delivered on the main actor so callers can drive UI / engine state
|
||||||
|
/// directly without further hops.
|
||||||
|
///
|
||||||
|
/// - Parameter completion: Receives the final grant state.
|
||||||
|
public static func request(_ completion: @escaping @MainActor (Bool) -> Void) {
|
||||||
|
switch status {
|
||||||
|
case .authorized:
|
||||||
|
Task { @MainActor in completion(true) }
|
||||||
|
case .notDetermined:
|
||||||
|
AVCaptureDevice.requestAccess(for: .audio) { granted in
|
||||||
|
Task { @MainActor in completion(granted) }
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Task { @MainActor in completion(false) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,20 +9,23 @@ import LyrebirdUI
|
|||||||
|
|
||||||
/// A synthesized test signal source that writes to a target audio bus.
|
/// A synthesized test signal source that writes to a target audio bus.
|
||||||
///
|
///
|
||||||
/// Produces two detuned sine oscillators at 110 Hz and 165 Hz — an approximation
|
/// Plays a repeating E-minor arpeggio on a Karplus-Strong plucked string, cycling the open
|
||||||
/// of a guitar's A2 and E3 strings — with a slow amplitude envelope driven by a
|
/// pitches of a guitar's lower four strings — E2, A2, D3, G3 — so the board has a musical,
|
||||||
/// low-frequency sine LFO. This makes the board audible immediately without any
|
/// guitar-like signal to process without any hardware connected. A single ``Impulse`` drives
|
||||||
/// hardware connection.
|
/// both the pluck excitation and a ``Demand``/``DemandSequence`` that advances the pitch one step
|
||||||
|
/// per pluck, keeping note changes locked to the plucks.
|
||||||
///
|
///
|
||||||
/// The output is written to `targetBus` so downstream pedals read it from that bus.
|
/// The output is written to `targetBus` so downstream pedals read it from that bus.
|
||||||
/// `TestLoopSource` should be added to the engine **before** the first pedal in the
|
/// `TestLoopSource` should be added to the engine **before** the first pedal in the chain to
|
||||||
/// chain to ensure signal-order correctness (source evaluates first).
|
/// ensure signal-order correctness (source evaluates first).
|
||||||
///
|
///
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - targetBus: Audio bus index to write the test signal to. Typically the
|
/// - targetBus: Audio bus index to write the test signal to. Typically the pedalboard's
|
||||||
/// pedalboard's head bus index.
|
/// head bus index.
|
||||||
|
/// - sampleRate: Engine sample rate, used to size the Karplus-Strong delay line. Defaults to
|
||||||
|
/// `48000`; the pedalboard passes the engine's actual rate so the pitch is accurate.
|
||||||
/// - amplitude: Output amplitude in [0, 1]. Defaults to `0.25`.
|
/// - amplitude: Output amplitude in [0, 1]. Defaults to `0.25`.
|
||||||
public final class TestLoopSource: SynthesizerBase {
|
public final class TestLoopSource: SynthesizerBase {
|
||||||
|
|
||||||
@@ -33,44 +36,68 @@ public final class TestLoopSource: SynthesizerBase {
|
|||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Frequency of the first oscillator in Hz (approximates guitar A2 string).
|
/// Open pitches of the guitar's lower four strings, in Hz: E2, A2, D3, G3. Arpeggiated in
|
||||||
private let freqA: Double = 110.0
|
/// order and repeated — an E-minor flavored figure (all four are in E natural minor).
|
||||||
|
private let arpeggioPitches: [Double] = [82.41, 110.00, 146.83, 196.00]
|
||||||
|
|
||||||
/// Frequency of the second oscillator in Hz (approximates guitar E3 string, slightly detuned).
|
/// Plucks per second (the arpeggio step rate).
|
||||||
private let freqB: Double = 165.75
|
private let pluckRate: Double = 3.0
|
||||||
|
|
||||||
/// LFO frequency in Hz for amplitude modulation (slow tremolo).
|
/// Karplus-Strong feedback gain in [0, 1]; higher = longer sustain (strings ring into the
|
||||||
private let lfoFreq: Double = 0.5
|
/// next pluck like a real arpeggio).
|
||||||
|
private let feedback: Double = 0.99
|
||||||
|
|
||||||
/// LFO depth as a fraction of base amplitude [0, 1].
|
/// Karplus-Strong one-pole damping coefficient (`0.5` = classic natural damping).
|
||||||
private let lfoDepth: Double = 0.3
|
private let damping: Double = 0.5
|
||||||
|
|
||||||
/// Gain for each individual oscillator before summing. Two oscillators × 0.5 = unity.
|
/// Maximum delay time in seconds, sizing the delay line. `0.05 s` covers fundamentals down to
|
||||||
private let oscGain: Double = 0.5
|
/// 20 Hz — well below the lowest arpeggio pitch (E2, ~82 Hz).
|
||||||
|
private let maxDelayTime: Double = 0.05
|
||||||
|
|
||||||
|
/// Fixed seed for the pluck-excitation noise, so the test tone is deterministic and identical
|
||||||
|
/// across instances (two renders of the source produce the same output).
|
||||||
|
private let exciterSeed: UInt64 = 0x5E1E_C7ED_5017_C35A
|
||||||
|
|
||||||
// MARK: - Routing
|
// MARK: - Routing
|
||||||
|
|
||||||
/// The bus this source writes its output to.
|
/// The bus this source writes its output to.
|
||||||
private let targetBus: Int
|
private let targetBus: Int
|
||||||
|
|
||||||
|
/// Engine sample rate used to size the Karplus-Strong delay line.
|
||||||
|
private let sampleRate: Double
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
/// Creates a test loop source that writes to `targetBus`.
|
/// Creates a test loop source that writes to `targetBus`.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - targetBus: Audio bus index to write the synthesized test signal to.
|
/// - targetBus: Audio bus index to write the synthesized test signal to.
|
||||||
public init(targetBus: Int) {
|
/// - sampleRate: Engine sample rate (sizes the Karplus-Strong delay line). Defaults to `48000`.
|
||||||
|
public init(targetBus: Int, sampleRate: Double = 48_000.0) {
|
||||||
self.targetBus = targetBus
|
self.targetBus = targetBus
|
||||||
|
self.sampleRate = sampleRate
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Build
|
// MARK: - Build
|
||||||
|
|
||||||
public override func build() {
|
public override func build() {
|
||||||
let oscA: OscSin.Audio = OscSin.Audio(freq: freqA, mul: oscGain)
|
// One impulse drives both the pluck excitation and the pitch-stepping demand, so each
|
||||||
let oscB: OscSin.Audio = OscSin.Audio(freq: freqB, phase: 0.25, mul: oscGain)
|
// pluck lands on the next arpeggio note.
|
||||||
let lfo: OscSin.Audio = OscSin.Audio(freq: lfoFreq, mul: lfoDepth, add: 1.0 - lfoDepth)
|
let pluck: Impulse.Audio = Impulse.Audio(freq: pluckRate)
|
||||||
let signal: any ValidGeneratorInput = (oscA + oscB) * lfo * $amplitude
|
let pitch: Demand.Audio = Demand.Audio(
|
||||||
output(bus: targetBus, source: signal)
|
trig: pluck,
|
||||||
|
demand: DemandSequence(values: arpeggioPitches, repeats: -1)
|
||||||
|
)
|
||||||
|
let string: KarplusStrong.Audio = KarplusStrong.Audio(
|
||||||
|
exciter: WhiteNoise.Audio(seed: exciterSeed),
|
||||||
|
trigger: pluck,
|
||||||
|
freq: pitch,
|
||||||
|
feedback: feedback,
|
||||||
|
coef: damping,
|
||||||
|
sampleRate: sampleRate,
|
||||||
|
maxDelayTime: maxDelayTime
|
||||||
|
)
|
||||||
|
output(bus: targetBus, source: string * $amplitude)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
// TestLoopTap.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
|
||||||
|
/// Internal synthesizer that copies the shared global test-loop bus to a board head bus.
|
||||||
|
///
|
||||||
|
/// In `.testLoop` mode every board reads the **same** global ``TestLoopSource`` (so all boards
|
||||||
|
/// stay phase-locked instead of each running an independently-phased arpeggio). A `TestLoopTap`
|
||||||
|
/// per board reads the global test bus at `inputBusIndex` and writes it to the board's head bus
|
||||||
|
/// at `outputBusIndex`, so the first pedal still reads from a board-owned bus.
|
||||||
|
///
|
||||||
|
/// Added `.after(_:)` the global source so it evaluates once the source has written the test bus
|
||||||
|
/// for the current block.
|
||||||
|
///
|
||||||
|
/// - Note: Must be removed from the engine before the board's `teardown()` releases the head bus.
|
||||||
|
final class TestLoopTap: SynthesizerBase {
|
||||||
|
|
||||||
|
// MARK: - Routing
|
||||||
|
|
||||||
|
/// Index of the shared global test-loop bus to read from.
|
||||||
|
private let inputBusIndex: Int
|
||||||
|
|
||||||
|
/// Index of the board head bus to write to.
|
||||||
|
private let outputBusIndex: Int
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a tap that copies `inputBusIndex` (the global test bus) to `outputBusIndex`
|
||||||
|
/// (a board head bus).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBusIndex: Shared global test-loop bus index to read from.
|
||||||
|
/// - outputBusIndex: Board head bus index to write to.
|
||||||
|
init(inputBusIndex: Int, outputBusIndex: Int) {
|
||||||
|
self.inputBusIndex = inputBusIndex
|
||||||
|
self.outputBusIndex = outputBusIndex
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Build
|
||||||
|
|
||||||
|
override func build() {
|
||||||
|
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,12 +64,32 @@ open class Pedal: SynthesizerBase {
|
|||||||
/// Human-readable name for the pedal (e.g. "Overdrive", "Delay").
|
/// Human-readable name for the pedal (e.g. "Overdrive", "Delay").
|
||||||
public let displayName: String
|
public let displayName: String
|
||||||
|
|
||||||
/// Index of the audio bus from which this pedal reads its dry input.
|
/// Index of the audio bus from which this pedal reads its dry input (channel 0 /
|
||||||
|
/// left / mono).
|
||||||
public internal(set) var inputBus: Int
|
public internal(set) var inputBus: Int
|
||||||
|
|
||||||
/// Index of the audio bus to which this pedal writes its output.
|
/// Index of the audio bus to which this pedal writes its output (channel 0 /
|
||||||
|
/// left / mono).
|
||||||
public internal(set) var outputBus: Int
|
public internal(set) var outputBus: Int
|
||||||
|
|
||||||
|
/// Right-channel input bus index, or `nil` for a mono input. When the board places
|
||||||
|
/// this pedal in a stereo (width-2) region it sets this to the right tail bus. A
|
||||||
|
/// `stereoNative` pedal entering a mono region leaves this `nil` and broadcasts the
|
||||||
|
/// mono input to both channels.
|
||||||
|
public internal(set) var inputBusRight: Int?
|
||||||
|
|
||||||
|
/// Right-channel output bus index, or `nil` for a mono output. Non-nil exactly when
|
||||||
|
/// the pedal is part of a stereo region; `build()` emits a second channel only when
|
||||||
|
/// this is set.
|
||||||
|
public internal(set) var outputBusRight: Int?
|
||||||
|
|
||||||
|
/// Declares this pedal's channel topology. Defaults to ``PedalChannelKind/mono``.
|
||||||
|
/// Override in a widener or stereo-native subclass.
|
||||||
|
open var channelKind: PedalChannelKind { .mono }
|
||||||
|
|
||||||
|
/// `true` when the board has placed this pedal in a stereo (width-2) region.
|
||||||
|
public var isStereo: Bool { outputBusRight != nil }
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Lag time constant in seconds (60 dB convergence) for the bypass crossfade.
|
/// Lag time constant in seconds (60 dB convergence) for the bypass crossfade.
|
||||||
@@ -108,6 +128,17 @@ open class Pedal: SynthesizerBase {
|
|||||||
self.mix = initialMix
|
self.mix = initialMix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Description
|
||||||
|
|
||||||
|
/// One-line, user-facing description of what this pedal does.
|
||||||
|
///
|
||||||
|
/// Shown as a subtitle in the pedal picker and as the body of the pedal's info panel.
|
||||||
|
/// **Every pedal must override this** with a short, non-proprietary sentence — the empty
|
||||||
|
/// default is a placeholder only (a test asserts every registered pedal sets it).
|
||||||
|
open var summary: String {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - UI knob descriptors
|
// MARK: - UI knob descriptors
|
||||||
|
|
||||||
/// Effect-specific knobs for this pedal, listed before the common knobs in the UI.
|
/// Effect-specific knobs for this pedal, listed before the common knobs in the UI.
|
||||||
@@ -127,6 +158,25 @@ open class Pedal: SynthesizerBase {
|
|||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Effect-specific continuous sliders for this pedal, rendered as a row of vertical
|
||||||
|
/// faders beneath the knob grid and switches.
|
||||||
|
///
|
||||||
|
/// Override in subclasses to publish each `@UIParam` parameter that reads best as a
|
||||||
|
/// vertical fader rather than a rotary knob — graphic-EQ band gains, a master output
|
||||||
|
/// fader, and similar bank-style controls. Defaults to empty.
|
||||||
|
open var effectSliders: [PedalSlider] {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Effect-specific stepped "knob picker" controls for this pedal, rendered as a row of rotary
|
||||||
|
/// knobs that snap to labelled stops, beneath the knob grid.
|
||||||
|
///
|
||||||
|
/// Override in subclasses to publish each discrete `@UIParam` parameter that reads best as a
|
||||||
|
/// knob that snaps through fixed positions (e.g. a harmony interval selector). Defaults to empty.
|
||||||
|
open var effectSelectors: [PedalSelectorKnob] {
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
|
||||||
/// All knobs a generic UI should render for this pedal: effect-specific knobs
|
/// All knobs a generic UI should render for this pedal: effect-specific knobs
|
||||||
/// first, then the common `mix` and `level` knobs. The `bypass` parameter is
|
/// first, then the common `mix` and `level` knobs. The `bypass` parameter is
|
||||||
/// surfaced separately as a header toggle, not as a knob.
|
/// surfaced separately as a header toggle, not as a knob.
|
||||||
@@ -150,13 +200,53 @@ open class Pedal: SynthesizerBase {
|
|||||||
dry
|
dry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the two distinct wet outputs for a ``PedalChannelKind/widener`` pedal.
|
||||||
|
///
|
||||||
|
/// Called once with the mono dry input; the returned pair becomes the left and right
|
||||||
|
/// wet signals of the now-stereo region. The default applies `effect(_:)` to both,
|
||||||
|
/// which is rarely useful — widener subclasses override this to produce genuinely
|
||||||
|
/// different channels (e.g. dry left, octave-up right).
|
||||||
|
///
|
||||||
|
/// - Parameter dry: The dry mono signal read from `inputBus`.
|
||||||
|
/// - Returns: The left and right wet signals.
|
||||||
|
open func wideEffect(_ dry: any ValidGeneratorInput)
|
||||||
|
-> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
(effect(dry), effect(dry))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the coupled stereo wet outputs for a ``PedalChannelKind/stereoNative`` pedal.
|
||||||
|
///
|
||||||
|
/// Called with both dry channels; the returned pair becomes the wet left and right
|
||||||
|
/// signals. The default applies `effect(_:)` per channel independently — stereo-native
|
||||||
|
/// subclasses override this to introduce cross-channel coupling (e.g. ping-pong feedback).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - left: The left dry channel.
|
||||||
|
/// - right: The right dry channel (equals `left` when the pedal entered a mono region).
|
||||||
|
/// - Returns: The left and right wet signals.
|
||||||
|
open func stereoEffect(
|
||||||
|
left: any ValidGeneratorInput,
|
||||||
|
right: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
(effect(left), effect(right))
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Build
|
// MARK: - Build
|
||||||
|
|
||||||
/// Builds the signal graph: dry → effect → wet/dry blend → bypass switch → output.
|
/// Builds the signal graph for one channel: dry → wet/dry blend → bypass switch → × level.
|
||||||
public override func build() {
|
///
|
||||||
let dry: In.Audio = input(bus: inputBus)
|
/// Returns the final post-`level` source for the channel. The `mix`, `bypass`, and `level`
|
||||||
let wet: any ValidGeneratorInput = effect(dry)
|
/// `@UIParam` nodes are shared across channels; each channel gets its own `Lag.Control`
|
||||||
|
/// for the bypass crossfade so smoothing is per-channel state driven by the same target.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - dry: The dry signal for this channel.
|
||||||
|
/// - wet: The processed signal for this channel.
|
||||||
|
/// - Returns: The channel's output source (post mix/bypass/level).
|
||||||
|
private func applyChain(
|
||||||
|
dry: any ValidGeneratorInput,
|
||||||
|
wet: any ValidGeneratorInput
|
||||||
|
) -> any ValidGeneratorInput {
|
||||||
// Map mix [0, 1] → pan [-1, +1] for CrossFade (−1 = full inA/dry, +1 = full inB/wet).
|
// Map mix [0, 1] → pan [-1, +1] for CrossFade (−1 = full inA/dry, +1 = full inB/wet).
|
||||||
let mixPan: any ValidGeneratorInput = ($mix * bipolarSpan) - bipolarOffset
|
let mixPan: any ValidGeneratorInput = ($mix * bipolarSpan) - bipolarOffset
|
||||||
|
|
||||||
@@ -183,6 +273,40 @@ open class Pedal: SynthesizerBase {
|
|||||||
pan: bypassPan
|
pan: bypassPan
|
||||||
)
|
)
|
||||||
|
|
||||||
output(bus: outputBus, source: switched * $level)
|
return switched * $level
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds the pedal's signal graph, dispatching on ``channelKind`` and emitting a second
|
||||||
|
/// channel only when `outputBusRight` is set (a stereo region).
|
||||||
|
public override func build() {
|
||||||
|
switch channelKind {
|
||||||
|
case .mono:
|
||||||
|
// One independent `effect(_:)` graph per output channel; shared knobs.
|
||||||
|
let dryLeft: In.Audio = input(bus: inputBus)
|
||||||
|
output(bus: outputBus, source: applyChain(dry: dryLeft, wet: effect(dryLeft)))
|
||||||
|
if let rightOut: Int = outputBusRight {
|
||||||
|
// Broadcast the mono input to the right channel when no right input exists.
|
||||||
|
let dryRight: In.Audio = input(bus: inputBusRight ?? inputBus)
|
||||||
|
output(bus: rightOut, source: applyChain(dry: dryRight, wet: effect(dryRight)))
|
||||||
|
}
|
||||||
|
|
||||||
|
case .widener:
|
||||||
|
let dry: In.Audio = input(bus: inputBus)
|
||||||
|
let wet: (left: any ValidGeneratorInput, right: any ValidGeneratorInput) = wideEffect(dry)
|
||||||
|
output(bus: outputBus, source: applyChain(dry: dry, wet: wet.left))
|
||||||
|
if let rightOut: Int = outputBusRight {
|
||||||
|
output(bus: rightOut, source: applyChain(dry: dry, wet: wet.right))
|
||||||
|
}
|
||||||
|
|
||||||
|
case .stereoNative:
|
||||||
|
let dryLeft: In.Audio = input(bus: inputBus)
|
||||||
|
let dryRight: In.Audio = input(bus: inputBusRight ?? inputBus)
|
||||||
|
let wet: (left: any ValidGeneratorInput, right: any ValidGeneratorInput) =
|
||||||
|
stereoEffect(left: dryLeft, right: dryRight)
|
||||||
|
output(bus: outputBus, source: applyChain(dry: dryLeft, wet: wet.left))
|
||||||
|
if let rightOut: Int = outputBusRight {
|
||||||
|
output(bus: rightOut, source: applyChain(dry: dryRight, wet: wet.right))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,25 @@ public final class PedalBoard {
|
|||||||
/// All pedals in order of insertion (signal-flow order) in the main chain (not branches).
|
/// All pedals in order of insertion (signal-flow order) in the main chain (not branches).
|
||||||
public private(set) var pedals: [Pedal] = []
|
public private(set) var pedals: [Pedal] = []
|
||||||
|
|
||||||
/// The bus that the last node in the chain writes to.
|
/// The bus that the last node in the chain writes to (left / mono tail).
|
||||||
/// Before any node is added, this is `headBus` (the board is a pass-through).
|
/// Before any node is added, this is `headBus` (the board is a pass-through).
|
||||||
public private(set) var outputBus: AudioBus
|
public private(set) var outputBus: AudioBus
|
||||||
|
|
||||||
|
/// The right-channel tail bus when the chain is stereo (``width`` == 2), else `nil`.
|
||||||
|
/// Set by a widener, a stereo-native pedal, an auto-stereoized pedal, or `collectStereo(_:)`;
|
||||||
|
/// cleared by `mergeToMono()`.
|
||||||
|
public private(set) var outputBusRight: AudioBus?
|
||||||
|
|
||||||
|
/// Current channel width of the chain tail: `1` = mono, `2` = stereo. Capped at 2.
|
||||||
|
public private(set) var width: Int = 1
|
||||||
|
|
||||||
|
/// All stereo split sections created via `splitStereo()` (for inspection / UI binding).
|
||||||
|
public private(set) var stereoSplitSections: [StereoSplitSection] = []
|
||||||
|
|
||||||
|
/// All stereo unzip sections created via ``unzipStereo()``. Same `StereoSplitSection` type as
|
||||||
|
/// ``stereoSplitSections``; tracked separately so a UI can distinguish the two region kinds.
|
||||||
|
public private(set) var stereoUnzipSections: [StereoSplitSection] = []
|
||||||
|
|
||||||
/// The node that writes the head bus (e.g. a `TestLoopSource` or input pass-through).
|
/// The node that writes the head bus (e.g. a `TestLoopSource` or input pass-through).
|
||||||
/// Set by `ShoeGaze` after adding the input source. When non-nil, the first `add(_:)`
|
/// Set by `ShoeGaze` after adding the input source. When non-nil, the first `add(_:)`
|
||||||
/// call chains the first pedal after this node automatically (no `after:` arg needed).
|
/// call chains the first pedal after this node automatically (no `after:` arg needed).
|
||||||
@@ -110,6 +125,12 @@ public final class PedalBoard {
|
|||||||
/// All branch chains owned by the board (for teardown).
|
/// All branch chains owned by the board (for teardown).
|
||||||
private var branchChains: [BranchChain] = []
|
private var branchChains: [BranchChain] = []
|
||||||
|
|
||||||
|
/// Ordered signal-chain segments (pedals + split regions) in signal-flow order. Used to
|
||||||
|
/// capture full board topology for serialization and to drive signal-flow UIs. Maintained by
|
||||||
|
/// `add`/`split`/`splitStereo`. A segment's index here matches its index in
|
||||||
|
/// `captureState().segments` — the region index used by the lane-addressed edit API.
|
||||||
|
public private(set) var orderedSegments: [BoardSegment] = []
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
/// Creates a pedalboard that allocates its head bus and prepares for pedal insertion.
|
/// Creates a pedalboard that allocates its head bus and prepares for pedal insertion.
|
||||||
@@ -158,29 +179,298 @@ public final class PedalBoard {
|
|||||||
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available for output.
|
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available for output.
|
||||||
/// - `EngineAddError` if the engine rejects the add (e.g. queue full, double-add).
|
/// - `EngineAddError` if the engine rejects the add (e.g. queue full, double-add).
|
||||||
public func add(_ pedal: Pedal, after predecessor: (any Synthesizer)? = nil) throws {
|
public func add(_ pedal: Pedal, after predecessor: (any Synthesizer)? = nil) throws {
|
||||||
let pedalInputBus: AudioBus = outputBus
|
|
||||||
let pedalOutputBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
|
||||||
allocatedBuses.append(pedalOutputBus)
|
|
||||||
|
|
||||||
pedal.inputBus = pedalInputBus.index
|
|
||||||
pedal.outputBus = pedalOutputBus.index
|
|
||||||
pedal.sampleRate = engine.sampleRate
|
pedal.sampleRate = engine.sampleRate
|
||||||
|
|
||||||
// Maintain evaluation order: each node evaluates immediately after the previous.
|
// Each arm configures the pedal's buses, inserts it, advances the tail, and only then
|
||||||
// `lastNode` tracks the most recently inserted node (pedal, splitter, or merger).
|
// records it in `pedals` — so a pedal is never tracked unless it was fully wired and
|
||||||
// Falls back to the caller-supplied `predecessor` or `headInputNode` for the first
|
// added to the engine.
|
||||||
// node. If none is available, plain add is used as a last resort.
|
switch pedal.channelKind {
|
||||||
if let previous: any Synthesizer = lastNode {
|
case .mono:
|
||||||
try engine.add(pedal, position: .after(previous))
|
if width == 1 {
|
||||||
} else if let pred: any Synthesizer = predecessor ?? headInputNode {
|
// Mono region: one input, one output. Behaviour is identical to the original
|
||||||
try engine.add(pedal, position: .after(pred))
|
// single-bus path.
|
||||||
} else {
|
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||||
try engine.add(pedal)
|
pedal.inputBus = outputBus.index
|
||||||
|
pedal.inputBusRight = nil
|
||||||
|
pedal.outputBus = outLeft.index
|
||||||
|
pedal.outputBusRight = nil
|
||||||
|
try insertNode(pedal, after: predecessor)
|
||||||
|
advanceTail(left: outLeft, right: nil, width: 1)
|
||||||
|
} else {
|
||||||
|
// Stereo region: auto-stereoize. The pedal runs `effect(_:)` per channel into
|
||||||
|
// two new buses — one logical pedal, two independent DSP graphs, shared knobs.
|
||||||
|
let rightTail: AudioBus = try requireRightTail()
|
||||||
|
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||||
|
let outRight: AudioBus = try allocateInterNodeBus()
|
||||||
|
pedal.inputBus = outputBus.index
|
||||||
|
pedal.inputBusRight = rightTail.index
|
||||||
|
pedal.outputBus = outLeft.index
|
||||||
|
pedal.outputBusRight = outRight.index
|
||||||
|
try insertNode(pedal, after: predecessor)
|
||||||
|
advanceTail(left: outLeft, right: outRight, width: 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
case .widener:
|
||||||
|
// 1 → 2. Only valid from a mono tail; width is capped at 2.
|
||||||
|
guard width == 1 else { throw ShoeGazeError.stereoWidthExceeded }
|
||||||
|
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||||
|
let outRight: AudioBus = try allocateInterNodeBus()
|
||||||
|
pedal.inputBus = outputBus.index
|
||||||
|
pedal.inputBusRight = nil
|
||||||
|
pedal.outputBus = outLeft.index
|
||||||
|
pedal.outputBusRight = outRight.index
|
||||||
|
try insertNode(pedal, after: predecessor)
|
||||||
|
advanceTail(left: outLeft, right: outRight, width: 2)
|
||||||
|
|
||||||
|
case .stereoNative:
|
||||||
|
// 2 → 2 with cross-channel coupling. From a mono tail the input broadcasts to both
|
||||||
|
// channels (right input left nil); from a stereo tail it reads both tails.
|
||||||
|
let rightInput: Int? = (width == 2) ? try requireRightTail().index : nil
|
||||||
|
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||||
|
let outRight: AudioBus = try allocateInterNodeBus()
|
||||||
|
pedal.inputBus = outputBus.index
|
||||||
|
pedal.inputBusRight = rightInput
|
||||||
|
pedal.outputBus = outLeft.index
|
||||||
|
pedal.outputBusRight = outRight.index
|
||||||
|
try insertNode(pedal, after: predecessor)
|
||||||
|
advanceTail(left: outLeft, right: outRight, width: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
pedals.append(pedal)
|
pedals.append(pedal)
|
||||||
lastNode = pedal
|
orderedSegments.append(.pedal(pedal))
|
||||||
outputBus = pedalOutputBus
|
}
|
||||||
|
|
||||||
|
/// Returns the right tail bus, enforcing the `width == 2 ⟺ outputBusRight != nil` invariant.
|
||||||
|
/// Throws rather than crashing if the invariant is ever violated by a coding error.
|
||||||
|
private func requireRightTail() throws -> AudioBus {
|
||||||
|
guard let rightTail: AudioBus = outputBusRight else {
|
||||||
|
throw ShoeGazeError.stereoWidthExceeded
|
||||||
|
}
|
||||||
|
return rightTail
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Stereo width helpers
|
||||||
|
|
||||||
|
/// Allocates a mono inter-node bus and tracks it for release on teardown.
|
||||||
|
private func allocateInterNodeBus() throws -> AudioBus {
|
||||||
|
let bus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
allocatedBuses.append(bus)
|
||||||
|
return bus
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Inserts a node into the engine maintaining evaluation order, then records it as `lastNode`.
|
||||||
|
///
|
||||||
|
/// Inserts `.after(lastNode)` when a previous node exists, else `.after` the caller-supplied
|
||||||
|
/// predecessor or `headInputNode`, else a plain add as a last resort.
|
||||||
|
private func insertNode(_ node: any Synthesizer, after predecessor: (any Synthesizer)?) throws {
|
||||||
|
if let previous: any Synthesizer = lastNode {
|
||||||
|
try engine.add(node, position: .after(previous))
|
||||||
|
} else if let pred: any Synthesizer = predecessor ?? headInputNode {
|
||||||
|
try engine.add(node, position: .after(pred))
|
||||||
|
} else {
|
||||||
|
try engine.add(node)
|
||||||
|
}
|
||||||
|
lastNode = node
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Advances the chain tail to the given bus pair and width.
|
||||||
|
private func advanceTail(left: AudioBus, right: AudioBus?, width: Int) {
|
||||||
|
self.outputBus = left
|
||||||
|
self.outputBusRight = right
|
||||||
|
self.width = width
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collapses a stereo (width-2) tail back to mono by summing the two tails (×0.5 each)
|
||||||
|
/// through a ``Merger``. No-op when the chain is already mono.
|
||||||
|
///
|
||||||
|
/// - Throws:
|
||||||
|
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available.
|
||||||
|
/// - `EngineAddError` if the engine rejects the merger add.
|
||||||
|
public func mergeToMono() throws {
|
||||||
|
guard width == 2, let rightTail: AudioBus = outputBusRight else { return }
|
||||||
|
let monoBus: AudioBus = try allocateInterNodeBus()
|
||||||
|
let merger: Merger = Merger(
|
||||||
|
inputBusA: outputBus.index,
|
||||||
|
inputBusB: rightTail.index,
|
||||||
|
outputBus: monoBus.index
|
||||||
|
)
|
||||||
|
// Sum with equal half-gains so two correlated channels do not double in level.
|
||||||
|
merger.levelA = 0.5
|
||||||
|
merger.levelB = 0.5
|
||||||
|
try insertNode(merger, after: nil)
|
||||||
|
routingNodes.append(merger)
|
||||||
|
advanceTail(left: monoBus, right: nil, width: 1)
|
||||||
|
orderedSegments.append(.mergeToMono)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Stereo split
|
||||||
|
|
||||||
|
/// Fans the current mono tail into two independently authored branch chains that become the
|
||||||
|
/// stereo output pair, plus a clean dry tap for the `bypass` route.
|
||||||
|
///
|
||||||
|
/// Add pedals via `section.left.add(_:)` / `section.right.add(_:)`, then call
|
||||||
|
/// `collectStereo(_:)` to wire the route collector and advance the board to width 2.
|
||||||
|
/// Set `section.route` to choose the output mode (`stereo` / `leftOnly` / `rightOnly` /
|
||||||
|
/// `bypass`) at any time.
|
||||||
|
///
|
||||||
|
/// - Returns: A ``StereoSplitSection`` with two empty branch chains.
|
||||||
|
/// - Throws:
|
||||||
|
/// - `ShoeGazeError.stereoWidthExceeded` if the board is already stereo.
|
||||||
|
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available.
|
||||||
|
/// - `EngineAddError` if the engine rejects the splitter add.
|
||||||
|
public func splitStereo() throws -> StereoSplitSection {
|
||||||
|
guard width == 1 else { throw ShoeGazeError.stereoWidthExceeded }
|
||||||
|
let preBus: AudioBus = outputBus
|
||||||
|
|
||||||
|
// Branch input buses are owned (and released) by each BranchChain, not by the board,
|
||||||
|
// mirroring `split()`. The dry tap is board-owned.
|
||||||
|
let leftInBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let rightInBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dryTapBus: AudioBus = try allocateInterNodeBus()
|
||||||
|
|
||||||
|
let splitter: StereoSplitter = StereoSplitter(
|
||||||
|
inputBus: preBus.index,
|
||||||
|
outputBusLeft: leftInBus.index,
|
||||||
|
outputBusRight: rightInBus.index,
|
||||||
|
dryTapBus: dryTapBus.index
|
||||||
|
)
|
||||||
|
|
||||||
|
// Both branches share one tail pointer so their pedals form a flat linear sequence,
|
||||||
|
// guaranteeing all branch pedals evaluate before the collector regardless of add order.
|
||||||
|
// Construct and track the branch chains (which take ownership of `leftInBus`/`rightInBus`)
|
||||||
|
// BEFORE the throwing engine insert below, so those buses are always released on teardown
|
||||||
|
// even if the splitter add fails.
|
||||||
|
let tail: SharedTail = SharedTail(node: splitter)
|
||||||
|
let leftChain: BranchChain = BranchChain(
|
||||||
|
engine: engine,
|
||||||
|
inputBus: leftInBus,
|
||||||
|
sampleRate: engine.sampleRate,
|
||||||
|
sharedTail: tail
|
||||||
|
)
|
||||||
|
let rightChain: BranchChain = BranchChain(
|
||||||
|
engine: engine,
|
||||||
|
inputBus: rightInBus,
|
||||||
|
sampleRate: engine.sampleRate,
|
||||||
|
sharedTail: tail
|
||||||
|
)
|
||||||
|
branchChains.append(leftChain)
|
||||||
|
branchChains.append(rightChain)
|
||||||
|
|
||||||
|
try insertNode(splitter, after: nil)
|
||||||
|
routingNodes.append(splitter)
|
||||||
|
|
||||||
|
let section: StereoSplitSection = StereoSplitSection(
|
||||||
|
splitter: splitter,
|
||||||
|
left: leftChain,
|
||||||
|
right: rightChain,
|
||||||
|
sharedTail: tail,
|
||||||
|
dryTapBus: dryTapBus
|
||||||
|
)
|
||||||
|
stereoSplitSections.append(section)
|
||||||
|
orderedSegments.append(.stereoSplit(section))
|
||||||
|
return section
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Splits the current **stereo** tail into two independently authored branch chains — left
|
||||||
|
/// channel into one, right channel into the other — so the channels can be processed
|
||||||
|
/// separately, then recombined to stereo by ``collectStereo(_:)``.
|
||||||
|
///
|
||||||
|
/// The stereo counterpart of ``splitStereo()``: it requires a width-2 tail and uses a
|
||||||
|
/// ``StereoUnzipSplitter`` (which reads both channels) instead of a mono-duplicating
|
||||||
|
/// ``StereoSplitter``. Everything downstream (branch chains, route collector, route control)
|
||||||
|
/// is identical, so it returns the same ``StereoSplitSection`` type.
|
||||||
|
///
|
||||||
|
/// Route semantics for the reused ``StereoRouteCollector`` differ from a mono split, because
|
||||||
|
/// each lane here carries one *original* channel rather than a duplicated mono signal:
|
||||||
|
/// `.stereo` = L lane → left, R lane → right; `.leftOnly` / `.rightOnly` = center the chosen
|
||||||
|
/// lane (so you hear only that original channel, processed, in both speakers); `.bypass` =
|
||||||
|
/// the centered mono sum (`0.5·L + 0.5·R`) of the pre-unzip signal in both speakers.
|
||||||
|
///
|
||||||
|
/// - Returns: A ``StereoSplitSection`` with two empty branch chains; call `collectStereo(_:)`
|
||||||
|
/// after adding branch pedals.
|
||||||
|
/// - Throws:
|
||||||
|
/// - `ShoeGazeError.cannotUnzipMonoChain` if the tail is mono (width 1).
|
||||||
|
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available.
|
||||||
|
/// - `EngineAddError` if the engine rejects the splitter add.
|
||||||
|
public func unzipStereo() throws -> StereoSplitSection {
|
||||||
|
guard width == 2, let rightTail: AudioBus = outputBusRight else {
|
||||||
|
throw ShoeGazeError.cannotUnzipMonoChain
|
||||||
|
}
|
||||||
|
let preLeft: AudioBus = outputBus
|
||||||
|
let preRight: AudioBus = rightTail
|
||||||
|
|
||||||
|
// Branch input buses are branch-owned (mirroring `splitStereo`); the dry tap is board-owned.
|
||||||
|
let leftInBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let rightInBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dryTapBus: AudioBus = try allocateInterNodeBus()
|
||||||
|
|
||||||
|
let splitter: StereoUnzipSplitter = StereoUnzipSplitter(
|
||||||
|
inputLeft: preLeft.index,
|
||||||
|
inputRight: preRight.index,
|
||||||
|
outputBusLeft: leftInBus.index,
|
||||||
|
outputBusRight: rightInBus.index,
|
||||||
|
dryTapBus: dryTapBus.index
|
||||||
|
)
|
||||||
|
|
||||||
|
let tail: SharedTail = SharedTail(node: splitter)
|
||||||
|
let leftChain: BranchChain = BranchChain(
|
||||||
|
engine: engine,
|
||||||
|
inputBus: leftInBus,
|
||||||
|
sampleRate: engine.sampleRate,
|
||||||
|
sharedTail: tail
|
||||||
|
)
|
||||||
|
let rightChain: BranchChain = BranchChain(
|
||||||
|
engine: engine,
|
||||||
|
inputBus: rightInBus,
|
||||||
|
sampleRate: engine.sampleRate,
|
||||||
|
sharedTail: tail
|
||||||
|
)
|
||||||
|
branchChains.append(leftChain)
|
||||||
|
branchChains.append(rightChain)
|
||||||
|
|
||||||
|
try insertNode(splitter, after: nil)
|
||||||
|
routingNodes.append(splitter)
|
||||||
|
|
||||||
|
let section: StereoSplitSection = StereoSplitSection(
|
||||||
|
splitter: splitter,
|
||||||
|
left: leftChain,
|
||||||
|
right: rightChain,
|
||||||
|
sharedTail: tail,
|
||||||
|
dryTapBus: dryTapBus
|
||||||
|
)
|
||||||
|
stereoUnzipSections.append(section)
|
||||||
|
orderedSegments.append(.stereoUnzip(section))
|
||||||
|
return section
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Inserts the route collector for a stereo split section and advances the board to width 2.
|
||||||
|
///
|
||||||
|
/// The collector reads both branch tails and the dry tap, and writes the board's new left and
|
||||||
|
/// right tail buses. It is inserted after the section's shared tail (the last pedal added
|
||||||
|
/// across either branch), so all branch pedals have written their buses before it reads them.
|
||||||
|
/// Branches with no pedals pass their split signal straight through.
|
||||||
|
///
|
||||||
|
/// - Parameter section: A section returned by `splitStereo()`.
|
||||||
|
/// - Throws:
|
||||||
|
/// - `BusAllocatorError.noFreeBus` if no mono audio bus is available.
|
||||||
|
/// - `EngineAddError` if the engine rejects the collector add.
|
||||||
|
public func collectStereo(_ section: StereoSplitSection) throws {
|
||||||
|
let outLeft: AudioBus = try allocateInterNodeBus()
|
||||||
|
let outRight: AudioBus = try allocateInterNodeBus()
|
||||||
|
|
||||||
|
let collector: StereoRouteCollector = StereoRouteCollector(
|
||||||
|
inputBusLeft: section.left.tailBusIndex,
|
||||||
|
inputBusRight: section.right.tailBusIndex,
|
||||||
|
dryTapBus: section.dryTapBus.index,
|
||||||
|
outputBusLeft: outLeft.index,
|
||||||
|
outputBusRight: outRight.index
|
||||||
|
)
|
||||||
|
// Insert after the shared tail — the most recently added node across both branches.
|
||||||
|
try engine.add(collector, position: .after(section.sharedTail.node))
|
||||||
|
routingNodes.append(collector)
|
||||||
|
lastNode = collector
|
||||||
|
section.bind(collector: collector)
|
||||||
|
advanceTail(left: outLeft, right: outRight, width: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Parallel routing
|
// MARK: - Parallel routing
|
||||||
@@ -253,7 +543,14 @@ public final class PedalBoard {
|
|||||||
branchChains.append(chainA)
|
branchChains.append(chainA)
|
||||||
branchChains.append(chainB)
|
branchChains.append(chainB)
|
||||||
|
|
||||||
return ParallelSection(splitter: splitter, branchA: chainA, branchB: chainB, sharedTail: tail)
|
let section: ParallelSection = ParallelSection(
|
||||||
|
splitter: splitter,
|
||||||
|
branchA: chainA,
|
||||||
|
branchB: chainB,
|
||||||
|
sharedTail: tail
|
||||||
|
)
|
||||||
|
orderedSegments.append(.parallel(section))
|
||||||
|
return section
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Combines the two branches of a ``ParallelSection`` back into the main board chain.
|
/// Combines the two branches of a ``ParallelSection`` back into the main board chain.
|
||||||
@@ -342,6 +639,9 @@ public final class PedalBoard {
|
|||||||
branchChains.removeAll()
|
branchChains.removeAll()
|
||||||
|
|
||||||
lastNode = nil
|
lastNode = nil
|
||||||
|
orderedSegments.removeAll()
|
||||||
|
stereoSplitSections.removeAll()
|
||||||
|
stereoUnzipSections.removeAll()
|
||||||
|
|
||||||
// Step 4: Release board-owned buses (head bus and main-chain inter-node buses).
|
// Step 4: Release board-owned buses (head bus and main-chain inter-node buses).
|
||||||
for bus: AudioBus in allocatedBuses {
|
for bus: AudioBus in allocatedBuses {
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// PedalSelectorKnob.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// A UI-agnostic description of a knob that snaps to a fixed set of labelled stops.
|
||||||
|
///
|
||||||
|
/// Where ``PedalKnob`` is a continuous rotary and ``PedalSwitch`` is a segmented strip, a
|
||||||
|
/// `PedalSelectorKnob` reads like a rotary knob but quantises to discrete positions — a knob picker.
|
||||||
|
/// Dragging rotates through the stops; the knob shows the current stop's caption. A `Pedal`
|
||||||
|
/// publishes an array of these via ``Pedal/effectSelectors`` so a generic pedalboard UI can render
|
||||||
|
/// a stepped knob per discrete parameter without knowing the concrete type.
|
||||||
|
///
|
||||||
|
/// Each stop pairs a short caption with the exact `Double` written to the live ``UIParamNode`` when
|
||||||
|
/// that position is selected; the lit position is the stop whose `value` is nearest the node's
|
||||||
|
/// current value.
|
||||||
|
public struct PedalSelectorKnob {
|
||||||
|
|
||||||
|
/// One labelled position of a ``PedalSelectorKnob``.
|
||||||
|
public struct Stop {
|
||||||
|
|
||||||
|
/// Short caption shown under the knob when this position is selected (e.g. "M3", "Oct").
|
||||||
|
public let title: String
|
||||||
|
|
||||||
|
/// Value written to the node when this position is selected.
|
||||||
|
public let value: Double
|
||||||
|
|
||||||
|
/// Creates a selector stop.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - title: Short caption shown when this position is selected.
|
||||||
|
/// - value: Value written to the node when this position is selected.
|
||||||
|
public init(title: String, value: Double) {
|
||||||
|
self.title = title
|
||||||
|
self.value = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Short label shown beneath the knob (e.g. "Voice 1").
|
||||||
|
public let label: String
|
||||||
|
|
||||||
|
/// The live parameter node the knob reads and writes. Pass `pedal.$paramName`.
|
||||||
|
public let node: UIParamNode
|
||||||
|
|
||||||
|
/// Ordered stops the knob snaps through, from fully counter-clockwise to fully clockwise. Must
|
||||||
|
/// contain at least two.
|
||||||
|
public let stops: [Stop]
|
||||||
|
|
||||||
|
/// Creates a selector-knob descriptor.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - label: Short label shown beneath the knob.
|
||||||
|
/// - node: The `UIParamNode` projected value of an `@UIParam` property (`pedal.$voice1`, …).
|
||||||
|
/// - stops: Ordered stops, CCW → CW. At least two.
|
||||||
|
public init(
|
||||||
|
label: String,
|
||||||
|
node: UIParamNode,
|
||||||
|
stops: [Stop]
|
||||||
|
) {
|
||||||
|
precondition(stops.count >= 2, "PedalSelectorKnob requires at least two stops")
|
||||||
|
self.label = label
|
||||||
|
self.node = node
|
||||||
|
self.stops = stops
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// PedalSlider.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// A UI-agnostic description of one continuous vertical pedal fader.
|
||||||
|
///
|
||||||
|
/// Where ``PedalKnob`` describes a rotary control and ``PedalSwitch`` a discrete
|
||||||
|
/// segmented control, `PedalSlider` describes a continuous vertical fader — the control
|
||||||
|
/// a graphic EQ uses for its per-band gains and master output level. A `Pedal` publishes
|
||||||
|
/// an array of these via ``Pedal/effectSliders`` so a generic pedalboard UI can render a
|
||||||
|
/// bank of vertical faders without knowing the concrete pedal type.
|
||||||
|
///
|
||||||
|
/// Each descriptor pairs a display label with the live ``UIParamNode`` (the projected
|
||||||
|
/// value of an `@UIParam` property) and the value range the fader should span.
|
||||||
|
public struct PedalSlider {
|
||||||
|
|
||||||
|
/// Short label shown beneath the fader (e.g. "Low", "Gain").
|
||||||
|
public let label: String
|
||||||
|
|
||||||
|
/// The live parameter node the fader reads and writes. Pass `pedal.$paramName`.
|
||||||
|
public let node: UIParamNode
|
||||||
|
|
||||||
|
/// Inclusive value range the fader spans, in the parameter's own units.
|
||||||
|
public let range: ClosedRange<Double>
|
||||||
|
|
||||||
|
/// Creates a slider descriptor.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - label: Short label shown beneath the fader.
|
||||||
|
/// - node: The `UIParamNode` projected value of an `@UIParam` property
|
||||||
|
/// (`pedal.$lowGain`, `pedal.$globalGain`, …).
|
||||||
|
/// - range: Inclusive value range the fader spans, in the parameter's units.
|
||||||
|
public init(
|
||||||
|
label: String,
|
||||||
|
node: UIParamNode,
|
||||||
|
range: ClosedRange<Double>
|
||||||
|
) {
|
||||||
|
self.label = label
|
||||||
|
self.node = node
|
||||||
|
self.range = range
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// PedalType.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// A type-safe identifier for a pedal type, used by the board-edit API instead of a raw string.
|
||||||
|
///
|
||||||
|
/// `PedalType` is an extensible token (the `RawRepresentable` struct pattern, à la
|
||||||
|
/// `Notification.Name`): the built-in pedals are exposed as static members for discoverable,
|
||||||
|
/// autocompleting call sites —
|
||||||
|
///
|
||||||
|
/// ```swift
|
||||||
|
/// try shoeGaze.appendPedal(.overdrive, to: board)
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// — while staying open for custom pedals, since any `PedalType("My Pedal")` is valid and a
|
||||||
|
/// third party can add their own static members in an extension.
|
||||||
|
///
|
||||||
|
/// `rawValue` is the pedal's `displayName`, which is exactly what the rig save format stores
|
||||||
|
/// (`PedalState.type`) and what ``PedalRegistry`` keys on. `PedalType` therefore changes only the
|
||||||
|
/// authoring call site — the JSON format and load path are unchanged.
|
||||||
|
///
|
||||||
|
/// > Note: named `PedalType` rather than `PedalKind` to avoid colliding with Lyrebird's
|
||||||
|
/// > score-notation `PedalKind` enum, which is visible whenever both modules are imported.
|
||||||
|
public struct PedalType: RawRepresentable, Hashable, Sendable {
|
||||||
|
|
||||||
|
/// The pedal's `displayName`; the key used by ``PedalRegistry`` and stored in saved rigs.
|
||||||
|
public let rawValue: String
|
||||||
|
|
||||||
|
/// Creates a type from a raw `displayName` string.
|
||||||
|
public init(rawValue: String) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a type from a raw `displayName` string.
|
||||||
|
public init(_ rawValue: String) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Built-in pedals
|
||||||
|
|
||||||
|
public extension PedalType {
|
||||||
|
|
||||||
|
// Drive & dynamics
|
||||||
|
static let overdrive = PedalType("Overdrive")
|
||||||
|
static let distortion = PedalType("Distortion")
|
||||||
|
static let fuzz = PedalType("Fuzz")
|
||||||
|
static let compressor = PedalType("Compressor")
|
||||||
|
static let limiter = PedalType("Limiter")
|
||||||
|
static let noiseGate = PedalType("Noise Gate")
|
||||||
|
|
||||||
|
// EQ & filter
|
||||||
|
static let graphicEQ = PedalType("Graphic EQ")
|
||||||
|
static let autoWah = PedalType("Auto-Wah")
|
||||||
|
static let mutant = PedalType("Mutant")
|
||||||
|
static let phaser = PedalType("Phaser")
|
||||||
|
|
||||||
|
// Modulation
|
||||||
|
static let tremolo = PedalType("Tremolo")
|
||||||
|
static let modulation = PedalType("Modulation")
|
||||||
|
static let chorus = PedalType("Chorus")
|
||||||
|
static let flanger = PedalType("Flanger")
|
||||||
|
static let vibrato = PedalType("Vibrato")
|
||||||
|
static let rotary = PedalType("Rotary")
|
||||||
|
static let ringModulator = PedalType("Ring Modulator")
|
||||||
|
static let diffuser = PedalType("Diffuser")
|
||||||
|
static let bitcrusher = PedalType("Bitcrusher")
|
||||||
|
static let granulator = PedalType("Granulator")
|
||||||
|
static let autoGranulator = PedalType("Auto Granulator")
|
||||||
|
|
||||||
|
// Dynamics (additional)
|
||||||
|
static let sustainer = PedalType("Sustainer")
|
||||||
|
|
||||||
|
// Delay & reverb
|
||||||
|
static let delay = PedalType("Delay")
|
||||||
|
static let feedbackDelay = PedalType("Feedback Delay")
|
||||||
|
static let multiTapDelay = PedalType("Multi-Tap Delay")
|
||||||
|
static let pingPong = PedalType("Ping-Pong")
|
||||||
|
static let reverseDelay = PedalType("Reverse Delay")
|
||||||
|
static let reverb = PedalType("Reverb")
|
||||||
|
static let shimmerReverb = PedalType("Shimmer Reverb")
|
||||||
|
|
||||||
|
// Pitch & octave
|
||||||
|
static let octaveSplitter = PedalType("Octave Splitter")
|
||||||
|
static let bassOctaver = PedalType("Bass Octaver")
|
||||||
|
static let harmonizer = PedalType("Harmonizer")
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
// AutoGranulatorPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Amplitude-tracking stereo granulator.
|
||||||
|
///
|
||||||
|
/// Like ``GranulatorPedal``, but the grain size follows the input level: by default louder playing
|
||||||
|
/// uses the **minimum** grain size and softer playing the **maximum** (so dynamics shrink and grow
|
||||||
|
/// the grains). The `Response` switch flips that relationship. Grains are randomly scattered across
|
||||||
|
/// the stereo field by `Spread`. Wraps ``StereoGranulator`` as a `.widener`.
|
||||||
|
///
|
||||||
|
/// The level → grain-size map is `AmplitudeFollower` → `LinLin`, with a `CrossFade` selecting the
|
||||||
|
/// normal vs flipped mapping from the `Response` switch.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `minGrain`: Minimum grain size in seconds. Range `[0.005, 0.1]`.
|
||||||
|
/// - `maxGrain`: Maximum grain size in seconds. Range `[0.05, 0.4]`.
|
||||||
|
/// - `overlap`: Overlapping grain count (density). Range `[1, 16]`.
|
||||||
|
/// - `spread`: Stereo spread `[0, 1]`.
|
||||||
|
///
|
||||||
|
/// ## Switches
|
||||||
|
/// - `response` (two-state): `0` = Loud → Short grains, `1` = Loud → Long grains.
|
||||||
|
public final class AutoGranulatorPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Granular wash whose grain size tracks your dynamics — loud shrinks grains, soft grows them."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Minimum grain size in seconds. Range [0.005, 0.1].
|
||||||
|
@UIParam public var minGrain: Double = 0.02
|
||||||
|
|
||||||
|
/// Maximum grain size in seconds. Range [0.05, 0.4].
|
||||||
|
@UIParam public var maxGrain: Double = 0.25
|
||||||
|
|
||||||
|
/// Overlapping grain count (density). Range [1, 16].
|
||||||
|
@UIParam public var overlap: Double = 4.0
|
||||||
|
|
||||||
|
/// Stereo spread [0, 1].
|
||||||
|
@UIParam public var spread: Double = 0.7
|
||||||
|
|
||||||
|
/// Level → grain-size response. `0` = Loud → Short, `1` = Loud → Long. Two-state switch.
|
||||||
|
@UIParam public var response: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private static let defaultMix: Double = 0.5
|
||||||
|
/// Largest grain the buffer is allocated for, in seconds (≥ the `maxGrain` knob maximum).
|
||||||
|
private let maxGrainSize: Double = 0.4
|
||||||
|
/// Amplitude at which the grain size reaches its loud-end value (follower output is unbounded;
|
||||||
|
/// this sets the sensitivity). Values above it are clamped by the generator's grain-size clamp.
|
||||||
|
private let ampSensitivity: Double = 0.5
|
||||||
|
private let amplitudeAttack: Double = 0.01
|
||||||
|
private let amplitudeRelease: Double = 0.2
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let minGrainRange: ClosedRange<Double> = 0.005 ... 0.1
|
||||||
|
private let maxGrainRange: ClosedRange<Double> = 0.05 ... 0.4
|
||||||
|
private let overlapRange: ClosedRange<Double> = 1.0 ... 16.0
|
||||||
|
private let spreadRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Min Grain", node: $minGrain, range: minGrainRange),
|
||||||
|
PedalKnob(label: "Max Grain", node: $maxGrain, range: maxGrainRange),
|
||||||
|
PedalKnob(label: "Overlap", node: $overlap, range: overlapRange),
|
||||||
|
PedalKnob(label: "Spread", node: $spread, range: spreadRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Switches
|
||||||
|
|
||||||
|
private let responseLoudShortValue: Double = 0.0
|
||||||
|
private let responseLoudLongValue: Double = 1.0
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Response",
|
||||||
|
node: $response,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Loud→Short", value: responseLoudShortValue),
|
||||||
|
PedalSwitch.Option(title: "Loud→Long", value: responseLoudLongValue),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Channel topology
|
||||||
|
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates an amplitude-tracking granulator 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: "Auto Granulator",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: AutoGranulatorPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func wideEffect(
|
||||||
|
_ dry: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
let amplitude: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||||
|
in: dry,
|
||||||
|
attackTime: amplitudeAttack,
|
||||||
|
releaseTime: amplitudeRelease
|
||||||
|
)
|
||||||
|
// Loud → short: amp 0 → maxGrain, amp ampSensitivity → minGrain.
|
||||||
|
let loudShort: LinLin.Audio = LinLin.Audio(
|
||||||
|
amplitude, inLo: 0.0, inHi: ampSensitivity, outLo: $maxGrain, outHi: $minGrain
|
||||||
|
)
|
||||||
|
// Loud → long: amp 0 → minGrain, amp ampSensitivity → maxGrain.
|
||||||
|
let loudLong: LinLin.Audio = LinLin.Audio(
|
||||||
|
amplitude, inLo: 0.0, inHi: ampSensitivity, outLo: $minGrain, outHi: $maxGrain
|
||||||
|
)
|
||||||
|
// `response` 0 → pan −1 → loudShort; 1 → pan +1 → loudLong (endpoints are full A / full B).
|
||||||
|
let grainSize: CrossFade.Audio = CrossFade.Audio(
|
||||||
|
inA: loudShort, inB: loudLong, pan: $response * 2.0 - 1.0
|
||||||
|
)
|
||||||
|
|
||||||
|
let granulator: StereoGranulator = StereoGranulator(
|
||||||
|
input: dry,
|
||||||
|
maxGrainSize: maxGrainSize,
|
||||||
|
grainSize: grainSize,
|
||||||
|
overlap: $overlap,
|
||||||
|
spread: $spread,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
return (granulator.left, granulator.right)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import LyrebirdUI
|
|||||||
|
|
||||||
/// Amplitude-tracked auto-wah pedal built from discrete tracking + filter stages.
|
/// Amplitude-tracked auto-wah pedal built from discrete tracking + filter stages.
|
||||||
///
|
///
|
||||||
/// Unlike `MuTronPedal` (which wraps the single fused `MuTronIII` generator), this pedal
|
/// Unlike `MutantPedal` (which wraps the single fused `MuTronIII` generator), this pedal
|
||||||
/// wires the envelope path explicitly: an `AmplitudeFollower` tracks the dry signal level,
|
/// wires the envelope path explicitly: an `AmplitudeFollower` tracks the dry signal level,
|
||||||
/// the envelope is scaled by `sensitivity` and clamped to `[0, 1]`, then mapped through an
|
/// the envelope is scaled by `sensitivity` and clamped to `[0, 1]`, then mapped through an
|
||||||
/// exponential `LinExp` curve to a cutoff frequency that sweeps a resonant `SVF` bandpass.
|
/// exponential `LinExp` curve to a cutoff frequency that sweeps a resonant `SVF` bandpass.
|
||||||
@@ -27,6 +27,11 @@ import LyrebirdUI
|
|||||||
/// - `range`: Upper cutoff in Hz reached at full envelope. Sets the sweep span over `freqLo`.
|
/// - `range`: Upper cutoff in Hz reached at full envelope. Sets the sweep span over `freqLo`.
|
||||||
public final class AutoWahPedal: Pedal {
|
public final class AutoWahPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Touch-sensitive wah that sweeps a resonant filter from your playing dynamics."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Envelope drive into the cutoff sweep. Higher values open the filter on quieter input.
|
/// Envelope drive into the cutoff sweep. Higher values open the filter on quieter input.
|
||||||
|
|||||||
@@ -0,0 +1,237 @@
|
|||||||
|
// BassOctaverPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Monophonic bass octaver modeled on the Boss OC-2 Octave.
|
||||||
|
///
|
||||||
|
/// Adds one and two sub-octaves below the input, mixed against the direct signal — the
|
||||||
|
/// three-knob OC-2 panel layout (OCT1 = −1 octave, OCT2 = −2 octaves, Direct = dry level).
|
||||||
|
///
|
||||||
|
/// Two algorithms share the knobs, picked by the `mode` switch:
|
||||||
|
///
|
||||||
|
/// - **Flip-flop** (default): the authentic OC-2 path. The input is low-passed to isolate
|
||||||
|
/// the fundamental, hard-limited into a square wave, then clocked through a ``SubOctaveDivider``
|
||||||
|
/// T flip-flop chain to produce `±1` square sub-octaves an octave and two octaves down. Those
|
||||||
|
/// squares are amplitude-followed off the dry signal so they track its dynamics, then
|
||||||
|
/// low-passed to tame the square edges. Strictly monophonic; glitches on chords like the
|
||||||
|
/// original. Tracks low bass fundamentals (sub-100 Hz) cleanly because the divider works in
|
||||||
|
/// the time domain.
|
||||||
|
/// - **Tracking**: an FFT pitch tracker (`FreqTracker`) drives square oscillators at half and
|
||||||
|
/// quarter the detected frequency. Cleaner and glitch-free, but limited by the tracker's
|
||||||
|
/// ~90 Hz detection floor — best for notes above the low bass register. Flip-flop is the
|
||||||
|
/// bass mode.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `oct1`: −1 octave voice level in `[0, 1]`.
|
||||||
|
/// - `oct2`: −2 octave voice level in `[0, 1]`.
|
||||||
|
/// - `direct`: Dry signal level in `[0, 1]`.
|
||||||
|
///
|
||||||
|
/// ## Switches
|
||||||
|
/// - `mode` (two-state): `0` = Flip-flop (authentic OC-2), `1` = Tracking (pitch-tracked).
|
||||||
|
public final class BassOctaverPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Adds a sub-octave below your note for bass-like weight."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// −1 octave voice level in `[0, 1]`.
|
||||||
|
@UIParam public var oct1: Double = 0.7
|
||||||
|
|
||||||
|
/// −2 octave voice level in `[0, 1]`.
|
||||||
|
@UIParam public var oct2: Double = 0.0
|
||||||
|
|
||||||
|
/// Dry (direct) signal level in `[0, 1]`.
|
||||||
|
@UIParam public var direct: Double = 1.0
|
||||||
|
|
||||||
|
/// Algorithm selector. `0` = Flip-flop (authentic OC-2), `1` = Tracking. Driven by a two-state switch.
|
||||||
|
@UIParam public var mode: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Pedal blends everything internally via the level knobs, so the base wet/dry stays fully wet.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// DC-removal high-pass cutoff in Hz, applied before the divider's comparator.
|
||||||
|
private let dcBlockFreq: Double = 30.0
|
||||||
|
|
||||||
|
/// Pre-divider low-pass cutoff in Hz. Isolates the fundamental so upper harmonics do not
|
||||||
|
/// double-trigger the comparator an octave too high.
|
||||||
|
private let conditionCutoff: Double = 500.0
|
||||||
|
|
||||||
|
/// Pre-gain into the `tanh` limiter. Large enough to square the conditioned signal to `±1`
|
||||||
|
/// so the comparator sees clean edges regardless of input level.
|
||||||
|
private let limiterDrive: Double = 50.0
|
||||||
|
|
||||||
|
/// Low-pass cutoff in Hz applied to each square sub-octave to soften its harsh edges.
|
||||||
|
private let subToneCutoff: Double = 800.0
|
||||||
|
|
||||||
|
/// Butterworth Q (no resonant peak) for all conditioning filters.
|
||||||
|
private let filterQ: Double = 0.707
|
||||||
|
|
||||||
|
/// Envelope-follower attack/release times in seconds; the sub-octaves track the dry dynamics.
|
||||||
|
private let envAttack: Double = 0.005
|
||||||
|
private let envRelease: Double = 0.1
|
||||||
|
|
||||||
|
/// Frequency multipliers for the tracking-mode oscillators (one and two octaves down).
|
||||||
|
private let octave1Ratio: Double = 0.5
|
||||||
|
private let octave2Ratio: Double = 0.25
|
||||||
|
|
||||||
|
/// Pitch-tracker detection bounds in Hz for tracking mode.
|
||||||
|
private let trackMinFreq: Double = 60.0
|
||||||
|
private let trackMaxFreq: Double = 1000.0
|
||||||
|
|
||||||
|
/// Division ratios for the flip-flop divider.
|
||||||
|
private let divisorOctave1: Int = 2
|
||||||
|
private let divisorOctave2: Int = 4
|
||||||
|
|
||||||
|
/// Half-step bias added before `Select`'s truncate-toward-zero index, turning the `mode`
|
||||||
|
/// switch into a round-to-nearest position selector.
|
||||||
|
private let selectRoundingBias: Double = 0.5
|
||||||
|
|
||||||
|
/// Switch position values.
|
||||||
|
private let modeFlipFlopValue: Double = 0.0
|
||||||
|
private let modeTrackingValue: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let levelRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "OCT 1", node: $oct1, range: levelRange),
|
||||||
|
PedalKnob(label: "OCT 2", node: $oct2, range: levelRange),
|
||||||
|
PedalKnob(label: "Direct", node: $direct, range: levelRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Switches
|
||||||
|
|
||||||
|
public override var effectSwitches: [PedalSwitch] {
|
||||||
|
[
|
||||||
|
PedalSwitch(
|
||||||
|
label: "Mode",
|
||||||
|
node: $mode,
|
||||||
|
options: [
|
||||||
|
PedalSwitch.Option(title: "Flip", value: modeFlipFlopValue),
|
||||||
|
PedalSwitch.Option(title: "Track", value: modeTrackingValue),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a bass octaver pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: "Bass Octaver",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: BassOctaverPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// Sub-octaves track the dry signal's amplitude envelope.
|
||||||
|
let env: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||||
|
in: dry,
|
||||||
|
attackTime: envAttack,
|
||||||
|
releaseTime: envRelease
|
||||||
|
)
|
||||||
|
|
||||||
|
// Flip-flop branch: condition → limit → divide.
|
||||||
|
let (oct1Flip, oct2Flip): (any ValidGeneratorInput, any ValidGeneratorInput) =
|
||||||
|
flipFlopVoices(dry: dry, env: env)
|
||||||
|
|
||||||
|
// Tracking branch: pitch-track → square oscillators.
|
||||||
|
let (oct1Track, oct2Track): (any ValidGeneratorInput, any ValidGeneratorInput) =
|
||||||
|
trackingVoices(dry: dry, env: env)
|
||||||
|
|
||||||
|
// Per-voice mode select. `Select` advances both branches each block (warm state).
|
||||||
|
let modeWhich: any ValidGeneratorInput = $mode + selectRoundingBias
|
||||||
|
let oct1Voice: Select.Audio = Select.Audio(
|
||||||
|
which: modeWhich,
|
||||||
|
inputs: [oct1Flip, oct1Track]
|
||||||
|
)
|
||||||
|
let oct2Voice: Select.Audio = Select.Audio(
|
||||||
|
which: modeWhich,
|
||||||
|
inputs: [oct2Flip, oct2Track]
|
||||||
|
)
|
||||||
|
|
||||||
|
// OC-2 mixer: direct + OCT1 + OCT2, each scaled by its level knob.
|
||||||
|
let directVoice: any ValidGeneratorInput = dry * $direct
|
||||||
|
let sub1: any ValidGeneratorInput = oct1Voice * $oct1
|
||||||
|
let sub2: any ValidGeneratorInput = oct2Voice * $oct2
|
||||||
|
return directVoice + sub1 + sub2
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds the authentic flip-flop sub-octave voices: condition the input to a square,
|
||||||
|
/// clock the divider chain, amplitude-follow, then soften the square edges.
|
||||||
|
private func flipFlopVoices(
|
||||||
|
dry: any ValidGeneratorInput,
|
||||||
|
env: AmplitudeFollower.Audio
|
||||||
|
) -> (any ValidGeneratorInput, any ValidGeneratorInput) {
|
||||||
|
let dcBlocked: RBJHighPass.Audio = RBJHighPass.Audio(
|
||||||
|
input: dry,
|
||||||
|
freq: dcBlockFreq,
|
||||||
|
q: filterQ
|
||||||
|
)
|
||||||
|
let conditioned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||||
|
input: dcBlocked,
|
||||||
|
freq: conditionCutoff,
|
||||||
|
q: filterQ
|
||||||
|
)
|
||||||
|
let limited: Tanh.Audio = Tanh.Audio(conditioned, mul: limiterDrive)
|
||||||
|
|
||||||
|
let div1: SubOctaveDivider = SubOctaveDivider(input: limited, divisor: divisorOctave1)
|
||||||
|
let div2: SubOctaveDivider = SubOctaveDivider(input: limited, divisor: divisorOctave2)
|
||||||
|
|
||||||
|
let oct1: any ValidGeneratorInput = softened(div1) * env
|
||||||
|
let oct2: any ValidGeneratorInput = softened(div2) * env
|
||||||
|
return (oct1, oct2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds the pitch-tracked sub-octave voices: detect the fundamental, run square
|
||||||
|
/// oscillators an octave and two octaves below it, amplitude-follow, then soften.
|
||||||
|
private func trackingVoices(
|
||||||
|
dry: any ValidGeneratorInput,
|
||||||
|
env: AmplitudeFollower.Audio
|
||||||
|
) -> (any ValidGeneratorInput, any ValidGeneratorInput) {
|
||||||
|
let tracker: FreqTracker = FreqTracker(
|
||||||
|
in: dry,
|
||||||
|
minFreq: trackMinFreq,
|
||||||
|
maxFreq: trackMaxFreq
|
||||||
|
)
|
||||||
|
let freq: any ValidGeneratorInput = tracker.freq
|
||||||
|
let osc1: OscSquare.Audio = OscSquare.Audio(freq: freq * octave1Ratio)
|
||||||
|
let osc2: OscSquare.Audio = OscSquare.Audio(freq: freq * octave2Ratio)
|
||||||
|
|
||||||
|
let oct1: any ValidGeneratorInput = softened(osc1) * env
|
||||||
|
let oct2: any ValidGeneratorInput = softened(osc2) * env
|
||||||
|
return (oct1, oct2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Low-passes a raw square sub-octave to soften its edges before mixing.
|
||||||
|
private func softened(_ square: any ValidGeneratorInput) -> RBJLowPass.Audio {
|
||||||
|
RBJLowPass.Audio(input: square, freq: subToneCutoff, q: filterQ)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// BitcrusherPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Lo-fi bitcrusher: sample-rate decimation followed by bit-depth reduction.
|
||||||
|
///
|
||||||
|
/// A sample-and-hold drops the effective sample rate (aliasing, stair-stepping); a quantiser then
|
||||||
|
/// reduces the bit depth (gritty quantisation noise). A post `Tone` low-pass tames the harsh
|
||||||
|
/// aliasing for a more usable lo-fi voice. Wraps the ``SampleRateDecimate`` and ``BitReduce``
|
||||||
|
/// generators, run fully wet so the pedal's `Mix` knob sets the blend.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `crush`: Sample-rate decimation factor (hold length in samples). Range `[1, 50]`.
|
||||||
|
/// - `bits`: Bit depth. Range `[1, 16]`.
|
||||||
|
/// - `tone`: Post low-pass cutoff in Hz. Range `[800, 8000]`.
|
||||||
|
public final class BitcrusherPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Lo-fi crusher: drops the sample rate and bit depth for gritty digital grunge."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Sample-rate decimation factor (hold length in samples). Range [1, 50].
|
||||||
|
@UIParam public var crush: Double = 8.0
|
||||||
|
|
||||||
|
/// Bit depth. Range [1, 16].
|
||||||
|
@UIParam public var bits: Double = 8.0
|
||||||
|
|
||||||
|
/// Post low-pass cutoff in Hz. Range [800, 8000].
|
||||||
|
@UIParam public var tone: Double = 4000.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Bitcrusher is heard fully wet; the `Mix` knob can dial it back.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Butterworth Q (no resonant peak) for the tone low-pass.
|
||||||
|
private let filterQ: Double = 0.707
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let crushRange: ClosedRange<Double> = 1.0 ... 50.0
|
||||||
|
private let bitsRange: ClosedRange<Double> = 1.0 ... 16.0
|
||||||
|
private let toneRange: ClosedRange<Double> = 800.0 ... 8000.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Crush", node: $crush, range: crushRange),
|
||||||
|
PedalKnob(label: "Bits", node: $bits, range: bitsRange),
|
||||||
|
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a bitcrusher 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: "Bitcrusher",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: BitcrusherPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let decimated: SampleRateDecimate = SampleRateDecimate(input: dry, downsample: $crush)
|
||||||
|
let crushed: BitReduce = BitReduce(input: decimated, bits: $bits)
|
||||||
|
return RBJLowPass.Audio(input: crushed, freq: $tone, q: filterQ)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
// ChorusPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// True-stereo chorus pedal.
|
||||||
|
///
|
||||||
|
/// Two modulated delay lines, fed the same dry signal but driven by sine LFOs 180° apart,
|
||||||
|
/// produce a wide left/right shimmer. Unlike `ModulationPedal` (which sums Lyrebird's
|
||||||
|
/// `Chorus` to mono), this pedal is a ``PedalChannelKind/widener`` — it keeps the two voices
|
||||||
|
/// on separate channels for genuine stereo width.
|
||||||
|
///
|
||||||
|
/// Signal path (per channel, inside `wideEffect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → DelayLine(delay: base ± depth·sin(rate)) → wet L / wet R
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - rate: LFO rate in Hz. Range `[0.05, 6]`. Defaults to `0.8`.
|
||||||
|
/// - depth: Delay-sweep depth in seconds (half-swing around the base delay). Range
|
||||||
|
/// `[0.0005, 0.008]`. Defaults to `0.003`.
|
||||||
|
public final class ChorusPedal: Pedal {
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// LFO rate in Hz. Range [0.05, 6].
|
||||||
|
@UIParam public var rate: Double = 0.8
|
||||||
|
|
||||||
|
/// Delay-sweep depth in seconds. Range [0.0005, 0.008].
|
||||||
|
@UIParam public var depth: Double = 0.003
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — chorus sits under the dry signal.
|
||||||
|
private static let defaultMix: Double = 0.5
|
||||||
|
|
||||||
|
/// Base delay around which the LFO sweeps, in seconds.
|
||||||
|
private let baseDelayTime: Double = 0.012
|
||||||
|
|
||||||
|
/// Maximum delay the lines are allocated for, in seconds. Covers `baseDelayTime + max depth`.
|
||||||
|
private let maxDelayTime: Double = 0.03
|
||||||
|
|
||||||
|
/// LFO phase for the left voice, in cycles.
|
||||||
|
private let leftPhase: Double = 0.0
|
||||||
|
|
||||||
|
/// LFO phase for the right voice, in cycles — a half cycle (180°) opposite the left.
|
||||||
|
private let rightPhase: Double = 0.5
|
||||||
|
|
||||||
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
private let rateRange: ClosedRange<Double> = 0.05 ... 6.0
|
||||||
|
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.008
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Channel topology
|
||||||
|
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a stereo chorus 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: "Chorus",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: ChorusPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var summary: String {
|
||||||
|
"Lush stereo chorus: two detuned voices panned wide for shimmer and depth."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Builds one modulated delay line per channel, with the two LFOs in anti-phase.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The left and right wet voices.
|
||||||
|
public override func wideEffect(
|
||||||
|
_ dry: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
(voice(dry, phase: leftPhase), voice(dry, phase: rightPhase))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One chorus voice: a delay line whose time is swept by a sine LFO around `baseDelayTime`.
|
||||||
|
private func voice(
|
||||||
|
_ dry: any ValidGeneratorInput,
|
||||||
|
phase: Double
|
||||||
|
) -> any ValidGeneratorInput {
|
||||||
|
let sweep: OscSin.Audio = OscSin.Audio(
|
||||||
|
freq: $rate,
|
||||||
|
phase: phase,
|
||||||
|
mul: $depth,
|
||||||
|
add: baseDelayTime
|
||||||
|
)
|
||||||
|
return DelayLine(
|
||||||
|
input: dry,
|
||||||
|
maxDelay: maxDelayTime,
|
||||||
|
delay: sweep,
|
||||||
|
sampleRate: sampleRate,
|
||||||
|
interpolation: .linear
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,11 +11,13 @@ import LyrebirdUI
|
|||||||
///
|
///
|
||||||
/// Signal chain (inside `effect(_:)`):
|
/// Signal chain (inside `effect(_:)`):
|
||||||
/// ```
|
/// ```
|
||||||
/// dry → Compressor.Audio(threshold:, ratio:, attack:, release:, makeupGain:) → mono out
|
/// dry → × inputGain → Compressor.Audio(threshold:, ratio:, attack:, release:, makeupGain:) → mono out
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Attack, release, knee, and makeup gain are fixed at musically sensible defaults.
|
/// An input gain stage boosts (or cuts) the signal *before* compression, so driving the
|
||||||
/// Knobs expose the two most-musical parameters: threshold and ratio.
|
/// input harder pushes more of the signal past the threshold. Attack, release, knee, and
|
||||||
|
/// makeup gain are fixed at musically sensible defaults; knobs expose input gain, threshold,
|
||||||
|
/// and ratio.
|
||||||
///
|
///
|
||||||
/// 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.
|
||||||
///
|
///
|
||||||
@@ -24,14 +26,24 @@ import LyrebirdUI
|
|||||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
|
/// - inputGain: Pre-compression input gain in dB. `0` = unity. Range `[-12, 24]`.
|
||||||
|
/// Defaults to `0.0`.
|
||||||
/// - threshold: Gain-reduction threshold in dB. Signals above this level are
|
/// - threshold: Gain-reduction threshold in dB. Signals above this level are
|
||||||
/// 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`.
|
||||||
public final class CompressorPedal: Pedal {
|
public final class CompressorPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Feed-forward compressor that evens out dynamics, with a pre-gain input stage."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Pre-compression input gain in dB. Range [-12, 24]. `0` = unity.
|
||||||
|
@UIParam public var inputGain: Double = 0.0
|
||||||
|
|
||||||
/// Compression threshold in dB. Range [-40, 0].
|
/// Compression threshold in dB. Range [-40, 0].
|
||||||
@UIParam public var threshold: Double = -12.0
|
@UIParam public var threshold: Double = -12.0
|
||||||
|
|
||||||
@@ -43,6 +55,10 @@ public final class CompressorPedal: Pedal {
|
|||||||
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
|
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
|
||||||
private static let defaultMix: Double = 1.0
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// dB → natural-exponent scale, `ln(10) / 20`. `exp(dB · scale) == 10^(dB/20)`, the
|
||||||
|
/// linear amplitude multiplier for a dB gain. Applied to the input-gain stage.
|
||||||
|
private let dbToLinExpScale: Double = 0.115_129_254_649_702_28
|
||||||
|
|
||||||
/// Attack time constant in seconds — time to reach full gain reduction on a transient.
|
/// Attack time constant in seconds — time to reach full gain reduction on a transient.
|
||||||
private let attackTime: Double = 0.01
|
private let attackTime: Double = 0.01
|
||||||
|
|
||||||
@@ -57,6 +73,9 @@ public final class CompressorPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - UI knobs
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
/// Input-gain knob range in dB.
|
||||||
|
private let inputGainRange: ClosedRange<Double> = -12.0 ... 24.0
|
||||||
|
|
||||||
/// Threshold knob range in dB.
|
/// Threshold knob range in dB.
|
||||||
private let thresholdRange: ClosedRange<Double> = -40.0 ... 0.0
|
private let thresholdRange: ClosedRange<Double> = -40.0 ... 0.0
|
||||||
|
|
||||||
@@ -65,6 +84,7 @@ public final class CompressorPedal: Pedal {
|
|||||||
|
|
||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
|
PedalKnob(label: "Input", node: $inputGain, range: inputGainRange),
|
||||||
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
||||||
PedalKnob(label: "Ratio", node: $ratio, range: ratioRange),
|
PedalKnob(label: "Ratio", node: $ratio, range: ratioRange),
|
||||||
]
|
]
|
||||||
@@ -91,15 +111,18 @@ public final class CompressorPedal: Pedal {
|
|||||||
|
|
||||||
// MARK: - Effect
|
// MARK: - Effect
|
||||||
|
|
||||||
/// Applies feed-forward dynamic range compression.
|
/// Boosts the input by `inputGain` dB, then applies feed-forward dynamic range compression.
|
||||||
///
|
///
|
||||||
/// Output is mono.
|
/// Output is mono.
|
||||||
///
|
///
|
||||||
/// - Parameter dry: Dry mono input signal.
|
/// - Parameter dry: Dry mono input signal.
|
||||||
/// - Returns: Compressed mono output.
|
/// - Returns: Compressed mono output.
|
||||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
Compressor.Audio(
|
// Convert the input-gain dB to a linear multiplier (10^(dB/20)) and apply before compression.
|
||||||
in: dry,
|
let inputGainLinear: Exp.Audio = Exp.Audio($inputGain * dbToLinExpScale)
|
||||||
|
let boosted: any ValidGeneratorInput = dry * inputGainLinear
|
||||||
|
return Compressor.Audio(
|
||||||
|
in: boosted,
|
||||||
threshold: $threshold,
|
threshold: $threshold,
|
||||||
ratio: $ratio,
|
ratio: $ratio,
|
||||||
attack: attackTime,
|
attack: attackTime,
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ import LyrebirdUI
|
|||||||
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
|
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
|
||||||
public final class DelayPedal: Pedal {
|
public final class DelayPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Echo delay with adjustable time and decay, from slapback to long repeats."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Delay time in seconds. Range [0.01, 1.5].
|
/// Delay time in seconds. Range [0.01, 1.5].
|
||||||
@@ -77,7 +82,7 @@ public final class DelayPedal: Pedal {
|
|||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||||
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
|
PedalKnob(label: "Decay Time", node: $feedback, range: feedbackRange),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
// DiffuserPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Stereo diffuser pedal: fans the frequency spectrum across the left and right channels.
|
||||||
|
///
|
||||||
|
/// A `.widener` pedal. The dry signal is split into overlapping frequency bands; each band is
|
||||||
|
/// panned by its centre frequency — lows toward the left, highs toward the right — and the
|
||||||
|
/// `spread` knob sets how far the bands fan out. At `spread = 0` every band sits centre (a mono
|
||||||
|
/// collapse); at `spread = 1` the spectrum is splayed hard across the stereo field, giving a
|
||||||
|
/// wide, diffuse image without time smearing.
|
||||||
|
///
|
||||||
|
/// Signal path (inside `wideEffect(_:)`), per band `k` at position `pos_k ∈ [-1, 1]`:
|
||||||
|
/// ```
|
||||||
|
/// dry → RBJBandPass(freq_k) → ×gainL_k → Σ → left
|
||||||
|
/// → ×gainR_k → Σ → right
|
||||||
|
/// gainL_k = 0.5 − 0.5·pos_k·spread, gainR_k = 0.5 + 0.5·pos_k·spread (linear pan)
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - spread: Stereo spectral spread. `0` = centred (mono), `1` = fully fanned L↔R.
|
||||||
|
/// Range `[0, 1]`. Defaults to `0.6`.
|
||||||
|
public final class DiffuserPedal: Pedal {
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Stereo spectral spread in [0, 1]. `0` = mono, `1` = full fan.
|
||||||
|
@UIParam public var spread: Double = 0.6
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Centre pan gain (each band's gain when `spread == 0` or it sits dead-centre).
|
||||||
|
private let centerGain: Double = 0.5
|
||||||
|
|
||||||
|
/// RBJ band-pass width in octaves — wide enough that adjacent bands overlap and recombine.
|
||||||
|
private let bandwidthOctaves: Double = 1.5
|
||||||
|
|
||||||
|
/// The frequency bands and their base stereo positions (low = left, high = right).
|
||||||
|
/// `position ∈ [-1, 1]`; multiplied by `spread` to place the band.
|
||||||
|
private let bands: [(freq: Double, position: Double)] = [
|
||||||
|
(150.0, -1.0),
|
||||||
|
(400.0, -0.5),
|
||||||
|
(1000.0, 0.0),
|
||||||
|
(2500.0, 0.5),
|
||||||
|
(6000.0, 1.0),
|
||||||
|
]
|
||||||
|
|
||||||
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
private let spreadRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Spread", node: $spread, range: spreadRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Channel topology
|
||||||
|
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a stereo diffuser 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: "Diffuser",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: DiffuserPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var summary: String {
|
||||||
|
"Stereo diffuser that fans the frequency spectrum across the left and right channels."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Splits the dry signal into frequency bands and pans each across the field by `spread`.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: The left and right diffused signals.
|
||||||
|
public override func wideEffect(
|
||||||
|
_ dry: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
var left: (any ValidGeneratorInput)?
|
||||||
|
var right: (any ValidGeneratorInput)?
|
||||||
|
|
||||||
|
for band: (freq: Double, position: Double) in bands {
|
||||||
|
let bandPass: RBJBandPass.Audio = RBJBandPass.Audio(
|
||||||
|
input: dry,
|
||||||
|
freq: band.freq,
|
||||||
|
bandwidth: bandwidthOctaves
|
||||||
|
)
|
||||||
|
// Linear pan, fully expressible as node arithmetic (no per-sample trig):
|
||||||
|
// gainL = centerGain − (0.5·position)·spread
|
||||||
|
// gainR = centerGain + (0.5·position)·spread
|
||||||
|
let halfPosition: Double = centerGain * band.position
|
||||||
|
let gainL: any ValidGeneratorInput = ($spread * (-halfPosition)) + centerGain
|
||||||
|
let gainR: any ValidGeneratorInput = ($spread * halfPosition) + centerGain
|
||||||
|
let leftContribution: any ValidGeneratorInput = bandPass * gainL
|
||||||
|
let rightContribution: any ValidGeneratorInput = bandPass * gainR
|
||||||
|
left = left.map { $0 + leftContribution } ?? leftContribution
|
||||||
|
right = right.map { $0 + rightContribution } ?? rightContribution
|
||||||
|
}
|
||||||
|
|
||||||
|
return (left ?? dry, right ?? dry)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// DistortionPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Mid-gain distortion — more saturated than `OverdrivePedal`, more controlled than `FuzzPedal`.
|
||||||
|
///
|
||||||
|
/// A DC-blocking high-pass feeds a `tanh` soft-clipper driven hard by the `Drive` knob; a
|
||||||
|
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip guarantees the
|
||||||
|
/// output stays bounded.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `drive`: Pre-clip gain into the `tanh` stage. Range `[1, 50]`.
|
||||||
|
/// - `tone`: Post-clip low-pass cutoff in Hz. Range `[500, 6000]`.
|
||||||
|
public final class DistortionPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Mid-gain saturated distortion sitting between overdrive and fuzz."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Pre-clip gain into the `tanh` stage. Range [1, 50].
|
||||||
|
@UIParam public var drive: Double = 12.0
|
||||||
|
|
||||||
|
/// Post-clip low-pass cutoff in Hz. Range [500, 6000].
|
||||||
|
@UIParam public var tone: Double = 3000.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Distortion is heard fully wet; the `Level` knob sets output gain.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// DC-blocking high-pass cutoff in Hz, applied before the clipper.
|
||||||
|
private let dcBlockFreq: Double = 80.0
|
||||||
|
|
||||||
|
/// Butterworth Q (no resonant peak) for the conditioning filters.
|
||||||
|
private let filterQ: Double = 0.707
|
||||||
|
|
||||||
|
/// Output hard-clip bounds — guarantees a bounded signal after tone shaping.
|
||||||
|
private let clipLow: Double = -1.0
|
||||||
|
private let clipHigh: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 50.0
|
||||||
|
private let toneRange: ClosedRange<Double> = 500.0 ... 6000.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||||
|
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a distortion 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: "Distortion",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: DistortionPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let dcBlocked: RBJHighPass.Audio = RBJHighPass.Audio(
|
||||||
|
input: dry,
|
||||||
|
freq: dcBlockFreq,
|
||||||
|
q: filterQ
|
||||||
|
)
|
||||||
|
let driven: Tanh.Audio = Tanh.Audio(dcBlocked, mul: $drive)
|
||||||
|
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||||
|
input: driven,
|
||||||
|
freq: $tone,
|
||||||
|
q: filterQ
|
||||||
|
)
|
||||||
|
return Clip.Audio(toned, lo: clipLow, hi: clipHigh)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,11 @@ import LyrebirdUI
|
|||||||
/// - `tone`: Lowpass cutoff in Hz applied to the wet signal; lower darkens the echoes.
|
/// - `tone`: Lowpass cutoff in Hz applied to the wet signal; lower darkens the echoes.
|
||||||
public final class FeedbackDelayPedal: Pedal {
|
public final class FeedbackDelayPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Feedback delay with a tone-shaped repeat for dub-style echoes."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Delay time between repeats, in seconds.
|
/// Delay time between repeats, in seconds.
|
||||||
@@ -62,7 +67,7 @@ public final class FeedbackDelayPedal: Pedal {
|
|||||||
public override var effectKnobs: [PedalKnob] {
|
public override var effectKnobs: [PedalKnob] {
|
||||||
[
|
[
|
||||||
PedalKnob(label: "Time", node: $time, range: timeRange),
|
PedalKnob(label: "Time", node: $time, range: timeRange),
|
||||||
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
|
PedalKnob(label: "Decay Time", node: $feedback, range: feedbackRange),
|
||||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
// FlangerPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Classic jet-flanger.
|
||||||
|
///
|
||||||
|
/// A short LFO-swept delay summed with the dry signal produces the sweeping comb-filter notches;
|
||||||
|
/// feedback sharpens them into the metallic "jet" whoosh. Wraps Lyrebird's `Flanger` generator,
|
||||||
|
/// run fully wet so the pedal's own `Mix` knob sets the wet/dry blend.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `rate`: LFO sweep rate in Hz. Range `[0.05, 8]`.
|
||||||
|
/// - `depth`: Sweep depth as a fraction of the center delay. Range `[0, 1]`.
|
||||||
|
/// - `feedback`: Comb feedback (resonance). Range `[0, 0.95]`.
|
||||||
|
public final class FlangerPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Sweeping comb-filter jet flanger, with feedback for that metallic whoosh."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// LFO sweep rate in Hz. Range [0.05, 8].
|
||||||
|
@UIParam public var rate: Double = 0.4
|
||||||
|
|
||||||
|
/// Sweep depth as a fraction of the center delay. Range [0, 1].
|
||||||
|
@UIParam public var depth: Double = 0.6
|
||||||
|
|
||||||
|
/// Comb feedback (resonance). Range [0, 0.95].
|
||||||
|
@UIParam public var feedback: Double = 0.3
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — flanger sits under the dry signal.
|
||||||
|
private static let defaultMix: Double = 0.5
|
||||||
|
|
||||||
|
/// Center delay the LFO sweeps around, in seconds.
|
||||||
|
private let centerDelayTime: Double = 0.005
|
||||||
|
|
||||||
|
/// Maximum delay the line is allocated for, in seconds. Covers `centerDelayTime · (1 + maxDepth)`.
|
||||||
|
private let maxDelayTime: Double = 0.05
|
||||||
|
|
||||||
|
/// The wrapped generator runs fully wet; the `Pedal` base `Mix` knob does the blend.
|
||||||
|
private let fullyWetMix: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let rateRange: ClosedRange<Double> = 0.05 ... 8.0
|
||||||
|
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.95
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||||
|
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||||
|
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a flanger 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: "Flanger",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: FlangerPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
Flanger.Audio(
|
||||||
|
input: dry,
|
||||||
|
delayTime: centerDelayTime,
|
||||||
|
depth: $depth,
|
||||||
|
rate: $rate,
|
||||||
|
feedback: $feedback,
|
||||||
|
mix: fullyWetMix,
|
||||||
|
sampleRate: sampleRate,
|
||||||
|
maxDelayTime: maxDelayTime
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,11 @@ import LyrebirdUI
|
|||||||
/// Range `[200, 8000]` Hz. Defaults to `3500.0`.
|
/// Range `[200, 8000]` Hz. Defaults to `3500.0`.
|
||||||
public final class FuzzPedal: Pedal {
|
public final class FuzzPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Thick, saturated fuzz for aggressive, sustaining distortion."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Pre-gain drive into the saturator. Range [1, 60]; higher = more fuzz.
|
/// Pre-gain drive into the saturator. Range [1, 60]; higher = more fuzz.
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// GranulatorPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Stereo input granulator.
|
||||||
|
///
|
||||||
|
/// Chops the input into a cloud of overlapping windowed grains, each randomly scattered across the
|
||||||
|
/// stereo field by `Spread`, for a lush, smeared, widened texture. Wraps the ``StereoGranulator``
|
||||||
|
/// generator (mono in → stereo out) as a `.widener`.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `grain`: Grain size in seconds. Range `[0.01, 0.5]`.
|
||||||
|
/// - `overlap`: Overlapping grain count (density). Range `[1, 16]`.
|
||||||
|
/// - `spread`: Stereo spread `[0, 1]` — 0 = centred (mono), 1 = full field.
|
||||||
|
public final class GranulatorPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Scatters overlapping grains of your sound across the stereo field — a lush, smeared wash."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Grain size in seconds. Range [0.01, 0.5].
|
||||||
|
@UIParam public var grain: Double = 0.08
|
||||||
|
|
||||||
|
/// Overlapping grain count (density). Range [1, 16].
|
||||||
|
@UIParam public var overlap: Double = 4.0
|
||||||
|
|
||||||
|
/// Stereo spread [0, 1].
|
||||||
|
@UIParam public var spread: Double = 0.7
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
private static let defaultMix: Double = 0.5
|
||||||
|
/// Largest grain the buffer is allocated for, in seconds (≥ the `grain` knob maximum).
|
||||||
|
private let maxGrainSize: Double = 0.5
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let grainRange: ClosedRange<Double> = 0.01 ... 0.5
|
||||||
|
private let overlapRange: ClosedRange<Double> = 1.0 ... 16.0
|
||||||
|
private let spreadRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Grain", node: $grain, range: grainRange),
|
||||||
|
PedalKnob(label: "Overlap", node: $overlap, range: overlapRange),
|
||||||
|
PedalKnob(label: "Spread", node: $spread, range: spreadRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Channel topology
|
||||||
|
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a granulator 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: "Granulator",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: GranulatorPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func wideEffect(
|
||||||
|
_ dry: any ValidGeneratorInput
|
||||||
|
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
let granulator: StereoGranulator = StereoGranulator(
|
||||||
|
input: dry,
|
||||||
|
maxGrainSize: maxGrainSize,
|
||||||
|
grainSize: $grain,
|
||||||
|
overlap: $overlap,
|
||||||
|
spread: $spread,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
return (granulator.left, granulator.right)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
// GraphicEQPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Five-band graphic EQ pedal built from cascaded RBJ filters, with a master output gain.
|
||||||
|
///
|
||||||
|
/// Signal chain (inside `effect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → RBJLowShelf(80 Hz) → RBJPeakingEQ(240 Hz) → RBJPeakingEQ(750 Hz)
|
||||||
|
/// → RBJPeakingEQ(2.2 kHz) → RBJHighShelf(6.5 kHz) → × globalGain → mono out
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// Each band's gain is an `@UIParam` in decibels and is published as a vertical fader via
|
||||||
|
/// ``effectSliders`` — the pedalboard UI renders the bank as a row of graphic-EQ sliders.
|
||||||
|
/// The trailing master fader (`globalGain`, a linear multiplier) trims the overall level
|
||||||
|
/// after the EQ curve so boosting several bands need not clip the output.
|
||||||
|
///
|
||||||
|
/// Band centre frequencies and filter Q/slope are fixed; only the per-band gains and the
|
||||||
|
/// master output level are adjustable.
|
||||||
|
///
|
||||||
|
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - lowGain: Low-shelf gain at 80 Hz, in dB. Range `[-12, 12]`. Defaults to `0.0`.
|
||||||
|
/// - lowMidGain: Peaking gain at 240 Hz, in dB. Range `[-12, 12]`. Defaults to `0.0`.
|
||||||
|
/// - midGain: Peaking gain at 750 Hz, in dB. Range `[-12, 12]`. Defaults to `0.0`.
|
||||||
|
/// - highMidGain: Peaking gain at 2.2 kHz, in dB. Range `[-12, 12]`. Defaults to `0.0`.
|
||||||
|
/// - highGain: High-shelf gain at 6.5 kHz, in dB. Range `[-12, 12]`. Defaults to `0.0`.
|
||||||
|
/// - globalGain: Master output gain in dB. `0` = unity. Range `[-12, 12]`.
|
||||||
|
/// Defaults to `0.0`.
|
||||||
|
public final class GraphicEQPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Five-band graphic EQ with per-band faders and a master output level."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Low-shelf gain in dB. Range [-12, 12].
|
||||||
|
@UIParam public var lowGain: Double = 0.0
|
||||||
|
|
||||||
|
/// Low-mid peaking gain in dB. Range [-12, 12].
|
||||||
|
@UIParam public var lowMidGain: Double = 0.0
|
||||||
|
|
||||||
|
/// Mid peaking gain in dB. Range [-12, 12].
|
||||||
|
@UIParam public var midGain: Double = 0.0
|
||||||
|
|
||||||
|
/// High-mid peaking gain in dB. Range [-12, 12].
|
||||||
|
@UIParam public var highMidGain: Double = 0.0
|
||||||
|
|
||||||
|
/// High-shelf gain in dB. Range [-12, 12].
|
||||||
|
@UIParam public var highGain: Double = 0.0
|
||||||
|
|
||||||
|
/// Master output gain in dB. Range [-12, 12]. `0` = unity.
|
||||||
|
@UIParam public var globalGain: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — fully wet; the EQ sits in-line.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Band centre frequencies in Hz (low shelf, three peaks, high shelf).
|
||||||
|
private let lowFreq: Double = 80.0
|
||||||
|
private let lowMidFreq: Double = 240.0
|
||||||
|
private let midFreq: Double = 750.0
|
||||||
|
private let highMidFreq: Double = 2200.0
|
||||||
|
private let highFreq: Double = 6500.0
|
||||||
|
|
||||||
|
/// Shelf slope. `1.0` = maximum (steepest) shelf with no overshoot.
|
||||||
|
private let shelfSlope: Double = 1.0
|
||||||
|
|
||||||
|
/// Peaking-band quality factor — moderate bandwidth so adjacent bands overlap smoothly.
|
||||||
|
private let peakQ: Double = 0.9
|
||||||
|
|
||||||
|
/// dB → natural-exponent scale, `ln(10) / 20`. `exp(dB · scale) == 10^(dB/20)`, the
|
||||||
|
/// linear amplitude multiplier for a dB gain. Applied to the master output gain.
|
||||||
|
private let dbToLinExpScale: Double = 0.115_129_254_649_702_28
|
||||||
|
|
||||||
|
// MARK: - UI sliders
|
||||||
|
|
||||||
|
/// Per-band gain fader range, in dB.
|
||||||
|
private let bandGainRange: ClosedRange<Double> = -12.0 ... 12.0
|
||||||
|
|
||||||
|
/// Master output fader range, in dB.
|
||||||
|
private let globalGainRange: ClosedRange<Double> = -12.0 ... 12.0
|
||||||
|
|
||||||
|
public override var effectSliders: [PedalSlider] {
|
||||||
|
[
|
||||||
|
PedalSlider(label: "80", node: $lowGain, range: bandGainRange),
|
||||||
|
PedalSlider(label: "240", node: $lowMidGain, range: bandGainRange),
|
||||||
|
PedalSlider(label: "750", node: $midGain, range: bandGainRange),
|
||||||
|
PedalSlider(label: "2.2k", node: $highMidGain, range: bandGainRange),
|
||||||
|
PedalSlider(label: "6.5k", node: $highGain, range: bandGainRange),
|
||||||
|
PedalSlider(label: "Gain", node: $globalGain, range: globalGainRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a five-band graphic EQ 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: "Graphic EQ",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: GraphicEQPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Applies the cascaded five-band RBJ EQ curve, then the master output gain.
|
||||||
|
///
|
||||||
|
/// Output is mono.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: Equalised, level-trimmed mono output.
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let lowShelf: RBJLowShelf.Audio = RBJLowShelf.Audio(
|
||||||
|
input: dry,
|
||||||
|
freq: lowFreq,
|
||||||
|
gain: $lowGain,
|
||||||
|
slope: shelfSlope
|
||||||
|
)
|
||||||
|
let lowMid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||||
|
input: lowShelf,
|
||||||
|
freq: lowMidFreq,
|
||||||
|
gain: $lowMidGain,
|
||||||
|
q: peakQ
|
||||||
|
)
|
||||||
|
let mid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||||
|
input: lowMid,
|
||||||
|
freq: midFreq,
|
||||||
|
gain: $midGain,
|
||||||
|
q: peakQ
|
||||||
|
)
|
||||||
|
let highMid: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||||
|
input: mid,
|
||||||
|
freq: highMidFreq,
|
||||||
|
gain: $highMidGain,
|
||||||
|
q: peakQ
|
||||||
|
)
|
||||||
|
let highShelf: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||||||
|
input: highMid,
|
||||||
|
freq: highFreq,
|
||||||
|
gain: $highGain,
|
||||||
|
slope: shelfSlope
|
||||||
|
)
|
||||||
|
// Convert the master dB gain to a linear amplitude multiplier: 10^(dB/20).
|
||||||
|
let masterGain: Exp.Audio = Exp.Audio($globalGain * dbToLinExpScale)
|
||||||
|
return highShelf * masterGain
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
// HarmonizerPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Two-voice diatonic-interval harmonizer.
|
||||||
|
///
|
||||||
|
/// Adds two pitch-shifted harmony voices at fixed musical intervals above or below the input,
|
||||||
|
/// mixed against the dry signal — an OC-2-style level layout (Voice 1 / Voice 2 / Direct) with a
|
||||||
|
/// knob picker selecting each voice's interval.
|
||||||
|
///
|
||||||
|
/// Each voice is a granular `PitchShift` whose ratio is `2^(semitones/12)`, driven live from the
|
||||||
|
/// voice's interval selector. Intervals include minor and major thirds above and below, plus
|
||||||
|
/// fourths, fifths, and octaves.
|
||||||
|
///
|
||||||
|
/// ## Knobs
|
||||||
|
/// - `voice1Level`: Voice 1 level in `[0, 1]`.
|
||||||
|
/// - `voice2Level`: Voice 2 level in `[0, 1]`.
|
||||||
|
/// - `direct`: Dry signal level in `[0, 1]`.
|
||||||
|
///
|
||||||
|
/// ## Selectors (knob pickers)
|
||||||
|
/// - `voice1`: Voice 1 interval in semitones (snaps to musical intervals).
|
||||||
|
/// - `voice2`: Voice 2 interval in semitones.
|
||||||
|
public final class HarmonizerPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Two pitch-shifted harmony voices at intervals you pick, stacked under your note."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Voice 1 interval in semitones. Snaps to musical-interval stops.
|
||||||
|
@UIParam public var voice1: Double = 4.0
|
||||||
|
|
||||||
|
/// Voice 2 interval in semitones. Snaps to musical-interval stops.
|
||||||
|
@UIParam public var voice2: Double = 7.0
|
||||||
|
|
||||||
|
/// Voice 1 level in `[0, 1]`.
|
||||||
|
@UIParam public var voice1Level: Double = 0.6
|
||||||
|
|
||||||
|
/// Voice 2 level in `[0, 1]`.
|
||||||
|
@UIParam public var voice2Level: Double = 0.45
|
||||||
|
|
||||||
|
/// Dry (direct) signal level in `[0, 1]`.
|
||||||
|
@UIParam public var direct: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Pedal blends internally via the level knobs, so the base wet/dry stays fully wet.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// `semitones → ratio` exponent scale: `2^(s/12) = e^(s · ln2/12)`, fed to `Exp.Audio`.
|
||||||
|
private let semitoneToRatioScale: Double = 0.05776226504666215 // ln(2) / 12
|
||||||
|
|
||||||
|
/// Granular pitch-shift window in seconds. Larger = smoother but more latency.
|
||||||
|
private let windowSize: Double = 0.1
|
||||||
|
|
||||||
|
// MARK: - Ranges
|
||||||
|
|
||||||
|
private let levelRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
// MARK: - Knobs
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "V1 Level", node: $voice1Level, range: levelRange),
|
||||||
|
PedalKnob(label: "V2 Level", node: $voice2Level, range: levelRange),
|
||||||
|
PedalKnob(label: "Direct", node: $direct, range: levelRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Selectors
|
||||||
|
|
||||||
|
/// Musical-interval stops for the voice pickers, low to high. Values are semitones; captions are
|
||||||
|
/// short interval names (`m3`/`M3` = minor/major third, `4`/`5` = perfect fourth/fifth,
|
||||||
|
/// `8ve` = octave, `Uni` = unison). Minus = below the input.
|
||||||
|
private static let intervalStops: [PedalSelectorKnob.Stop] = [
|
||||||
|
PedalSelectorKnob.Stop(title: "-8ve", value: -12.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-M6", value: -9.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-m6", value: -8.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-5", value: -7.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-4", value: -5.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-M3", value: -4.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "-m3", value: -3.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "Uni", value: 0.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "m3", value: 3.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "M3", value: 4.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "4", value: 5.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "5", value: 7.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "m6", value: 8.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "M6", value: 9.0),
|
||||||
|
PedalSelectorKnob.Stop(title: "8ve", value: 12.0),
|
||||||
|
]
|
||||||
|
|
||||||
|
public override var effectSelectors: [PedalSelectorKnob] {
|
||||||
|
[
|
||||||
|
PedalSelectorKnob(label: "Voice 1", node: $voice1, stops: HarmonizerPedal.intervalStops),
|
||||||
|
PedalSelectorKnob(label: "Voice 2", node: $voice2, stops: HarmonizerPedal.intervalStops),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a harmonizer pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: "Harmonizer",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: HarmonizerPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let voice1Signal: any ValidGeneratorInput = harmonyVoice(dry, semitones: $voice1)
|
||||||
|
let voice2Signal: any ValidGeneratorInput = harmonyVoice(dry, semitones: $voice2)
|
||||||
|
|
||||||
|
let directVoice: any ValidGeneratorInput = dry * $direct
|
||||||
|
let harmony1: any ValidGeneratorInput = voice1Signal * $voice1Level
|
||||||
|
let harmony2: any ValidGeneratorInput = voice2Signal * $voice2Level
|
||||||
|
return directVoice + harmony1 + harmony2
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One pitch-shifted voice: ratio `2^(semitones/12)` via `Exp`, fed to a granular `PitchShift`.
|
||||||
|
private func harmonyVoice(
|
||||||
|
_ dry: any ValidGeneratorInput,
|
||||||
|
semitones: any ValidGeneratorInput
|
||||||
|
) -> any ValidGeneratorInput {
|
||||||
|
let ratio: Exp.Audio = Exp.Audio(semitones * semitoneToRatioScale)
|
||||||
|
return PitchShift.Audio(input: dry, pitchRatio: ratio, windowSize: windowSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
// LimiterPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Limiter pedal: a clean gain-boost stage feeding a brick-wall look-ahead limiter.
|
||||||
|
///
|
||||||
|
/// Signal chain (inside `effect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry → × boost → LookAheadLimiter(maxAmplitude: ceiling) → mono out
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The boost stage drives the signal up *before* the limiter, so cranking `boost`
|
||||||
|
/// pushes more of the signal into limiting and raises sustain/perceived loudness while
|
||||||
|
/// the look-ahead limiter guarantees the output peak never exceeds `ceiling`.
|
||||||
|
///
|
||||||
|
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - boost: Pre-limit input gain as a linear multiplier. `1.0` = unity. Higher values
|
||||||
|
/// drive harder into the limiter. Range `[1, 12]`. Defaults to `1.0`.
|
||||||
|
/// - ceiling: Output peak ceiling as a linear amplitude in `[0, 1]`. The limited output
|
||||||
|
/// never exceeds this absolute value. Range `[0.1, 1.0]`. Defaults to `0.95`.
|
||||||
|
public final class LimiterPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Brick-wall limiter with an input boost to push level safely to the ceiling."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Pre-limit input gain (linear multiplier). Range [1, 12].
|
||||||
|
@UIParam public var boost: Double = 1.0
|
||||||
|
|
||||||
|
/// Output peak ceiling (linear amplitude). Range [0.1, 1.0].
|
||||||
|
@UIParam public var ceiling: Double = 0.95
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — fully wet; the limiter sits in-line.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Look-ahead / output delay in seconds. Fixed at a short window that catches
|
||||||
|
/// transients without smearing attack.
|
||||||
|
private let lookAheadTime: Double = 0.005
|
||||||
|
|
||||||
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
/// Boost knob range (linear pre-limit gain).
|
||||||
|
private let boostRange: ClosedRange<Double> = 1.0 ... 12.0
|
||||||
|
|
||||||
|
/// Ceiling knob range (linear output peak).
|
||||||
|
private let ceilingRange: ClosedRange<Double> = 0.1 ... 1.0
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Boost", node: $boost, range: boostRange),
|
||||||
|
PedalKnob(label: "Ceiling", node: $ceiling, range: ceilingRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a limiter 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: "Limiter",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: LimiterPedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Boosts the dry signal then constrains its peak with a look-ahead limiter.
|
||||||
|
///
|
||||||
|
/// Output is mono.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: Boosted, peak-limited mono output.
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
let boosted: any ValidGeneratorInput = dry * $boost
|
||||||
|
return LookAheadLimiter(
|
||||||
|
in: boosted,
|
||||||
|
maxAmplitude: $ceiling,
|
||||||
|
lookAheadTime: lookAheadTime,
|
||||||
|
sampleRate: sampleRate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,11 @@ import LyrebirdUI
|
|||||||
/// Smaller values (0.001–0.01) produce classic chorus width. Defaults to `0.002`.
|
/// Smaller values (0.001–0.01) produce classic chorus width. Defaults to `0.002`.
|
||||||
public final class ModulationPedal: Pedal {
|
public final class ModulationPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Classic mono chorus for subtle thickening and shimmer."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Chorus LFO rate in Hz. Range [0.1, 10].
|
/// Chorus LFO rate in Hz. Range [0.1, 10].
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ import LyrebirdUI
|
|||||||
/// - `vol1`, `vol2`, `vol3`: Linear output level of each tap in `[0, 1]`.
|
/// - `vol1`, `vol2`, `vol3`: Linear output level of each tap in `[0, 1]`.
|
||||||
public final class MultiTapDelayPedal: Pedal {
|
public final class MultiTapDelayPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Multi-tap delay producing rhythmic patterns of echoes."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Tap times
|
// MARK: - Tap times
|
||||||
|
|
||||||
/// Tap 1 delay time, in seconds.
|
/// Tap 1 delay time, in seconds.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// MuTronPedal.swift
|
// MutantPedal.swift
|
||||||
// Lyrebird
|
// Lyrebird
|
||||||
//
|
//
|
||||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
import LyrebirdSynth
|
import LyrebirdSynth
|
||||||
import LyrebirdUI
|
import LyrebirdUI
|
||||||
|
|
||||||
/// Envelope-following filter pedal modeled on the Musitronics Mu-Tron III.
|
/// Envelope-following auto-wah / funk-filter pedal.
|
||||||
///
|
///
|
||||||
/// Wraps the Lyrebird `MuTronIII` generator. The input amplitude drives an exponential
|
/// Wraps the Lyrebird `MuTronIII` generator. The input amplitude drives an exponential
|
||||||
/// cutoff sweep through a resonant Chamberlin state-variable filter. Because `MuTronIII`
|
/// cutoff sweep through a resonant Chamberlin state-variable filter. Because `MuTronIII`
|
||||||
@@ -24,7 +24,12 @@ import LyrebirdUI
|
|||||||
/// ## Switches
|
/// ## Switches
|
||||||
/// - `direction` (two-state): `0` = Down (louder closes the filter), `1` = Up (louder opens it).
|
/// - `direction` (two-state): `0` = Down (louder closes the filter), `1` = Up (louder opens it).
|
||||||
/// - `mode` (three-state): `0` = lowpass, `1` = bandpass (classic vowel wah), `2` = highpass.
|
/// - `mode` (three-state): `0` = lowpass, `1` = bandpass (classic vowel wah), `2` = highpass.
|
||||||
public final class MuTronPedal: Pedal {
|
public final class MutantPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Envelope-following auto-wah / funk filter that opens with your picking."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
@@ -107,10 +112,10 @@ public final class MuTronPedal: Pedal {
|
|||||||
|
|
||||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||||
super.init(
|
super.init(
|
||||||
name: "Mu-Tron",
|
name: "Mutant",
|
||||||
inputBus: inputBus,
|
inputBus: inputBus,
|
||||||
outputBus: outputBus,
|
outputBus: outputBus,
|
||||||
initialMix: MuTronPedal.defaultMix
|
initialMix: MutantPedal.defaultMix
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
// NoiseGatePedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Noise-gate pedal: an amplitude-tracked gate with a tuneable residual floor.
|
||||||
|
///
|
||||||
|
/// Signal chain (inside `effect(_:)`):
|
||||||
|
/// ```
|
||||||
|
/// dry ─┬─────────────────────────────────────────────────────────┐
|
||||||
|
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │
|
||||||
|
/// → LinLin(0…1 → floor…1) │
|
||||||
|
/// → Lag(smooth) ───────────── × ──┴→ mono out
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// An `AmplitudeFollower` tracks the dry signal level. A Schmitt trigger turns that
|
||||||
|
/// envelope into an open/closed gate with hysteresis (opens above `threshold × openRatio`,
|
||||||
|
/// closes below `threshold`) so the gate does not chatter around the threshold. The 0/1
|
||||||
|
/// gate is mapped to a gain in `[floor, 1]` and smoothed before multiplying the dry signal:
|
||||||
|
/// when the gate is closed the signal is attenuated to `floor` rather than hard-muted, so
|
||||||
|
/// `floor` sets how much of the quiet signal/noise tail bleeds through.
|
||||||
|
///
|
||||||
|
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - threshold: Gate close threshold as a linear amplitude. Envelope below this closes
|
||||||
|
/// the gate. Range `[0, 0.2]`. Defaults to `0.02`.
|
||||||
|
/// - floor: Residual gain applied while the gate is closed, in `[0, 1]`. `0` = full
|
||||||
|
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
|
||||||
|
public final class NoiseGatePedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Noise gate that silences hiss and hum below a tunable threshold."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Gate close threshold (linear amplitude). Range [0, 0.2].
|
||||||
|
@UIParam public var threshold: Double = 0.02
|
||||||
|
|
||||||
|
/// Residual gain while closed, [0, 1]. Range [0, 1].
|
||||||
|
@UIParam public var floor: Double = 0.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Default wet/dry blend — fully wet; the gate sits in-line.
|
||||||
|
private static let defaultMix: Double = 1.0
|
||||||
|
|
||||||
|
/// Envelope-follower attack time, in seconds — fast so the gate opens promptly on a note.
|
||||||
|
private let detectAttack: Double = 0.002
|
||||||
|
|
||||||
|
/// Envelope-follower release time, in seconds — slower so the gate holds through decay.
|
||||||
|
private let detectRelease: Double = 0.05
|
||||||
|
|
||||||
|
/// Open-threshold multiplier. The gate opens above `threshold × openRatio` and closes
|
||||||
|
/// below `threshold`, giving hysteresis that prevents chatter near the threshold.
|
||||||
|
private let openRatio: Double = 2.0
|
||||||
|
|
||||||
|
/// Gain-smoothing lag time, in seconds — removes the click of an instantaneous 0↔1 gate.
|
||||||
|
private let gainSmoothTime: Double = 0.01
|
||||||
|
|
||||||
|
/// Gate signal bounds for the `LinLin` floor map.
|
||||||
|
private let gateLo: Double = 0.0
|
||||||
|
private let gateHi: Double = 1.0
|
||||||
|
|
||||||
|
/// Upper gain the open gate maps to (unity).
|
||||||
|
private let openGain: Double = 1.0
|
||||||
|
|
||||||
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
/// Threshold knob range (linear amplitude).
|
||||||
|
private let thresholdRange: ClosedRange<Double> = 0.0 ... 0.2
|
||||||
|
|
||||||
|
/// Floor knob range (residual gain).
|
||||||
|
private let floorRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
||||||
|
PedalKnob(label: "Floor", node: $floor, range: floorRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates a noise-gate 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: "Noise Gate",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: NoiseGatePedal.defaultMix
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Gates the dry signal below `threshold`, attenuating closed passages to `floor`.
|
||||||
|
///
|
||||||
|
/// Output is mono.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: Gated mono output.
|
||||||
|
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||||
|
// Track the dry signal's amplitude envelope.
|
||||||
|
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||||
|
in: dry,
|
||||||
|
attackTime: detectAttack,
|
||||||
|
releaseTime: detectRelease
|
||||||
|
)
|
||||||
|
|
||||||
|
// Hysteretic open/closed gate: opens above threshold×openRatio, closes below threshold.
|
||||||
|
let gate: Schmidt.Audio = Schmidt.Audio(
|
||||||
|
input: envelope,
|
||||||
|
lo: $threshold,
|
||||||
|
hi: $threshold * openRatio
|
||||||
|
)
|
||||||
|
|
||||||
|
// Map the 0/1 gate to a gain in [floor, 1] so closed passages bleed `floor`, not silence.
|
||||||
|
let gain: LinLin.Audio = LinLin.Audio(
|
||||||
|
gate,
|
||||||
|
inLo: gateLo,
|
||||||
|
inHi: gateHi,
|
||||||
|
outLo: $floor,
|
||||||
|
outHi: openGain
|
||||||
|
)
|
||||||
|
|
||||||
|
// Smooth the gain to remove the click of an instantaneous gate transition.
|
||||||
|
let smoothed: Lag.Audio = Lag.Audio(
|
||||||
|
input: gain,
|
||||||
|
time: gainSmoothTime
|
||||||
|
)
|
||||||
|
|
||||||
|
return dry * smoothed
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
// OctaveUpSplitterPedal.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdSynth
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// Widener pedal: clean signal on the left, an octave-up fuzz on the right (1 → 2).
|
||||||
|
///
|
||||||
|
/// A ``PedalChannelKind/widener``. It takes a mono input and produces two distinct wet
|
||||||
|
/// channels, widening the board chain from mono to stereo:
|
||||||
|
///
|
||||||
|
/// - **Left**: the dry signal, passed through clean.
|
||||||
|
/// - **Right**: an octave-up voice produced by full-wave rectification (`Abs`, which doubles
|
||||||
|
/// the perceived frequency), DC-removed, driven into a `tanh` saturator, and tone-shaped —
|
||||||
|
/// the classic "Octavia"-style octave fuzz.
|
||||||
|
///
|
||||||
|
/// After this pedal the chain is stereo; subsequent mono pedals auto-stereoize across both
|
||||||
|
/// channels, so you can, for example, add a delay that processes the clean and octave voices
|
||||||
|
/// independently.
|
||||||
|
///
|
||||||
|
/// ## Parameters
|
||||||
|
///
|
||||||
|
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - drive: Pre-gain into the octave-channel saturator. Higher = thicker octave fuzz.
|
||||||
|
/// Range `[1, 40]`. Defaults to `12.0`.
|
||||||
|
/// - tone: Octave-channel low-pass cutoff in Hz. Range `[500, 8000]`. Defaults to `4000.0`.
|
||||||
|
public final class OctaveUpSplitterPedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Splits a clean octave-up voice alongside your dry signal in stereo."
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Parameters
|
||||||
|
|
||||||
|
/// Pre-gain into the octave-channel saturator. Range [1, 40]; higher = thicker octave fuzz.
|
||||||
|
@UIParam public var drive: Double = 12.0
|
||||||
|
|
||||||
|
/// Octave-channel tone low-pass cutoff in Hz. Range [500, 8000].
|
||||||
|
@UIParam public var tone: Double = 4000.0
|
||||||
|
|
||||||
|
// MARK: - Constants
|
||||||
|
|
||||||
|
/// Gain applied to the rectified signal before drive, compensating the level drop from
|
||||||
|
/// full-wave rectification.
|
||||||
|
private let rectifyGain: Double = 2.0
|
||||||
|
|
||||||
|
/// DC-removal high-pass cutoff in Hz. Rectification introduces a DC offset that must be
|
||||||
|
/// removed before the octave voice reaches the output.
|
||||||
|
private let dcBlockFreq: Double = 30.0
|
||||||
|
|
||||||
|
/// Q factor for the tone low-pass (Butterworth, no resonant peak).
|
||||||
|
private let toneQ: Double = 0.707
|
||||||
|
|
||||||
|
/// High-pass Q (Butterworth).
|
||||||
|
private let dcBlockQ: Double = 0.707
|
||||||
|
|
||||||
|
/// Output trim after the saturator (`tanh` output is roughly ±1).
|
||||||
|
private let outputTrim: Double = 0.6
|
||||||
|
|
||||||
|
// MARK: - UI knobs
|
||||||
|
|
||||||
|
/// Drive knob range (octave-channel saturator pre-gain).
|
||||||
|
private let driveRange: ClosedRange<Double> = 1.0 ... 40.0
|
||||||
|
|
||||||
|
/// Tone knob range in Hz (octave-channel low-pass cutoff).
|
||||||
|
private let toneRange: ClosedRange<Double> = 500.0 ... 8000.0
|
||||||
|
|
||||||
|
// MARK: - Channel kind
|
||||||
|
|
||||||
|
/// This pedal widens mono → stereo.
|
||||||
|
public override var channelKind: PedalChannelKind { .widener }
|
||||||
|
|
||||||
|
// MARK: - Init
|
||||||
|
|
||||||
|
/// Creates an octave-up splitter pedal.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||||
|
/// - outputBus: Audio bus index to write the left output to. Defaults to `0`.
|
||||||
|
public init(
|
||||||
|
inputBus: Int = 0,
|
||||||
|
outputBus: Int = 0
|
||||||
|
) {
|
||||||
|
super.init(
|
||||||
|
name: "Octave Splitter",
|
||||||
|
inputBus: inputBus,
|
||||||
|
outputBus: outputBus,
|
||||||
|
initialMix: 1.0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override var effectKnobs: [PedalKnob] {
|
||||||
|
[
|
||||||
|
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||||
|
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Effect
|
||||||
|
|
||||||
|
/// Produces the clean left channel and the octave-up right channel.
|
||||||
|
///
|
||||||
|
/// - Parameter dry: Dry mono input signal.
|
||||||
|
/// - Returns: `(left: clean dry, right: octave-up fuzz)`.
|
||||||
|
public override func wideEffect(_ dry: any ValidGeneratorInput)
|
||||||
|
-> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||||
|
// Full-wave rectification doubles the perceived frequency (octave up).
|
||||||
|
let rectified: Abs.Audio = Abs.Audio(dry, mul: rectifyGain)
|
||||||
|
// Remove the DC offset rectification introduces before it reaches the output.
|
||||||
|
let dcBlocked: RBJHighPass.Audio = RBJHighPass.Audio(
|
||||||
|
input: rectified,
|
||||||
|
freq: dcBlockFreq,
|
||||||
|
q: dcBlockQ
|
||||||
|
)
|
||||||
|
// Drive into a saturator for the octave-fuzz texture, then tone-shape.
|
||||||
|
let driven: any ValidGeneratorInput = dcBlocked * $drive
|
||||||
|
let saturated: Tanh.Audio = Tanh.Audio(driven, mul: outputTrim)
|
||||||
|
let shaped: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||||
|
input: saturated,
|
||||||
|
freq: $tone,
|
||||||
|
q: toneQ
|
||||||
|
)
|
||||||
|
return (left: dry, right: shaped)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,11 @@ import LyrebirdUI
|
|||||||
/// Range `(0, 20000]`. Defaults to `4000.0`.
|
/// Range `(0, 20000]`. Defaults to `4000.0`.
|
||||||
public final class OverdrivePedal: Pedal {
|
public final class OverdrivePedal: Pedal {
|
||||||
|
|
||||||
|
/// One-line description shown in the picker and info panel.
|
||||||
|
public override var summary: String {
|
||||||
|
"Warm soft-clip overdrive with a tone control, from gentle grit to singing sustain."
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
/// Saturation drive amount. Range [1, 20]; higher = more clipping.
|
/// Saturation drive amount. Range [1, 20]; higher = more clipping.
|
||||||
|
|||||||