Compare commits
8 Commits
dff58175f1
..
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 5040ea1518 | |||
| 21b9123a87 | |||
| 24ce4564e8 | |||
| b1303a25ae | |||
| 21fda7067d | |||
| 8c601e2029 | |||
| 5a07a6d4b4 | |||
| 475dd392e6 |
@@ -163,7 +163,7 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 2;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 0.9;
|
MARKETING_VERSION = 0.91;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -194,7 +194,7 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 2;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
MARKETING_VERSION = 0.9;
|
MARKETING_VERSION = 0.91;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
private static let heightFraction: CGFloat = 0.88
|
private static let heightFraction: CGFloat = 0.88
|
||||||
|
|
||||||
/// The default pedal the seed board comes up with, so audio is audible immediately on Start.
|
/// The default pedal the seed board comes up with, so audio is audible immediately on Start.
|
||||||
private static let seedPedalType: String = "Overdrive"
|
private static let seedPedalType: PedalType = .overdrive
|
||||||
|
|
||||||
// MARK: - Owned objects
|
// MARK: - Owned objects
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
do {
|
do {
|
||||||
let board: PedalBoard = try shoeGaze.addBoard()
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
created = board
|
created = board
|
||||||
try shoeGaze.appendPedal(type: AppDelegate.seedPedalType, to: board)
|
try shoeGaze.appendPedal(AppDelegate.seedPedalType, to: board)
|
||||||
} catch {
|
} catch {
|
||||||
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||||
print("[ShoeGazeBuilder] seed board failed: \(error)")
|
print("[ShoeGazeBuilder] seed board failed: \(error)")
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
// available for any future build that starts input-less.)
|
// available for any future build that starts input-less.)
|
||||||
private static let inputChannels: Int = 1
|
private static let inputChannels: Int = 1
|
||||||
private static let numAudioBuses: Int = 256
|
private static let numAudioBuses: Int = 256
|
||||||
private static let seedPedalType: String = "Overdrive"
|
private static let seedPedalType: PedalType = .overdrive
|
||||||
|
|
||||||
/// UserDefaults key persisting the input selection. Must match the key written by the
|
/// UserDefaults key persisting the input selection. Must match the key written by the
|
||||||
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
||||||
@@ -64,7 +64,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
do {
|
do {
|
||||||
let board: PedalBoard = try shoeGaze.addBoard()
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
board.label = "Board 1"
|
board.label = "Board 1"
|
||||||
try shoeGaze.appendPedal(type: ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
try shoeGaze.appendPedal(ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderiOS] seed board failed: \(error)")
|
print("[ShoeGazeBuilderiOS] seed board failed: \(error)")
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
|||||||
do {
|
do {
|
||||||
let board: PedalBoard = try shoeGaze.addBoard()
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
board.label = "Board 1"
|
board.label = "Board 1"
|
||||||
try shoeGaze.appendPedal(type: ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
try shoeGaze.appendPedal(ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderiOS] fallback seed board failed: \(error)")
|
print("[ShoeGazeBuilderiOS] fallback seed board failed: \(error)")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,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()
|
||||||
@@ -269,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())
|
||||||
|
|||||||
@@ -1,3 +1,117 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
- **18 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.
|
||||||
|
- **Save / load rigs** as JSON, on both platforms.
|
||||||
|
- **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, Limiter, Noise Gate |
|
||||||
|
| EQ & filter | Graphic EQ, Auto-Wah, Mutant, Phaser |
|
||||||
|
| Modulation | Tremolo, Modulation |
|
||||||
|
| 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,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))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
// 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 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")
|
||||||
|
|
||||||
|
// 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 reverb = PedalType("Reverb")
|
||||||
|
|
||||||
|
// Pitch & octave
|
||||||
|
static let octaveSplitter = PedalType("Octave Splitter")
|
||||||
|
static let bassOctaver = PedalType("Bass Octaver")
|
||||||
|
}
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -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,6 +26,8 @@ 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.
|
||||||
@@ -32,6 +36,9 @@ public final class CompressorPedal: Pedal {
|
|||||||
|
|
||||||
// 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 +50,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 +68,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 +79,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 +106,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,
|
||||||
|
|||||||
+5
-5
@@ -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,7 @@ 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 {
|
||||||
|
|
||||||
// MARK: - Parameters
|
// MARK: - Parameters
|
||||||
|
|
||||||
@@ -107,10 +107,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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
/// To register custom pedal types, extend `builtIn` by building your own dictionary
|
/// To register custom pedal types, extend `builtIn` by building your own dictionary
|
||||||
/// and merging it before calling `loadRig`. The built-in registry covers the factory
|
/// and merging it before calling `loadRig`. The built-in registry covers the factory
|
||||||
/// pedals: Overdrive, Delay, Reverb, Modulation, Fuzz, Tremolo, Phaser, Compressor,
|
/// pedals: Overdrive, Delay, Reverb, Modulation, Fuzz, Tremolo, Phaser, Compressor,
|
||||||
/// Mu-Tron, Auto-Wah, Feedback Delay, Multi-Tap Delay, Octave Splitter, and Ping-Pong.
|
/// Mutant, Auto-Wah, Feedback Delay, Multi-Tap Delay, Octave Splitter, and Ping-Pong.
|
||||||
///
|
///
|
||||||
/// > Note: A saved rig captures each board's *linear* pedal chain only (see `BoardState`).
|
/// > Note: A saved rig captures each board's *linear* pedal chain only (see `BoardState`).
|
||||||
/// > When a registered widener (e.g. Octave Splitter) or stereo-native pedal (e.g.
|
/// > When a registered widener (e.g. Octave Splitter) or stereo-native pedal (e.g.
|
||||||
@@ -39,7 +39,7 @@ public enum PedalRegistry {
|
|||||||
"Tremolo": { TremoloPedal() },
|
"Tremolo": { TremoloPedal() },
|
||||||
"Phaser": { PhaserPedal() },
|
"Phaser": { PhaserPedal() },
|
||||||
"Compressor": { CompressorPedal() },
|
"Compressor": { CompressorPedal() },
|
||||||
"Mu-Tron": { MuTronPedal() },
|
"Mutant": { MutantPedal() },
|
||||||
"Auto-Wah": { AutoWahPedal() },
|
"Auto-Wah": { AutoWahPedal() },
|
||||||
"Feedback Delay": { FeedbackDelayPedal() },
|
"Feedback Delay": { FeedbackDelayPedal() },
|
||||||
"Multi-Tap Delay": { MultiTapDelayPedal() },
|
"Multi-Tap Delay": { MultiTapDelayPedal() },
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ extension ShoeGaze {
|
|||||||
/// running engine with at most one block of glitch (see ``rebuildBoard(_:from:)``).
|
/// running engine with at most one block of glitch (see ``rebuildBoard(_:from:)``).
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - type: The pedal's `displayName`, e.g. `"Overdrive"`. Must be a key in `PedalRegistry.builtIn`.
|
/// - kind: The pedal type, e.g. ``PedalType/overdrive``. Its `rawValue` must be a key in
|
||||||
|
/// `PedalRegistry.builtIn`.
|
||||||
/// - board: The board to edit. Must have been returned by `addBoard()` on this instance.
|
/// - board: The board to edit. Must have been returned by `addBoard()` on this instance.
|
||||||
/// - lane: Where to append. Defaults to ``PedalLane/main``.
|
/// - lane: Where to append. Defaults to ``PedalLane/main``.
|
||||||
/// - Returns: The rebuilt board occupying the same slot in `boards`.
|
/// - Returns: The rebuilt board occupying the same slot in `boards`.
|
||||||
@@ -29,10 +30,11 @@ extension ShoeGaze {
|
|||||||
/// any error from ``rebuildBoard(_:from:)``.
|
/// any error from ``rebuildBoard(_:from:)``.
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public func appendPedal(
|
public func appendPedal(
|
||||||
type: String,
|
_ kind: PedalType,
|
||||||
to board: PedalBoard,
|
to board: PedalBoard,
|
||||||
lane: PedalLane = .main
|
lane: PedalLane = .main
|
||||||
) throws -> PedalBoard {
|
) throws -> PedalBoard {
|
||||||
|
let type: String = kind.rawValue
|
||||||
guard PedalRegistry.builtIn[type] != nil else {
|
guard PedalRegistry.builtIn[type] != nil else {
|
||||||
throw ShoeGazeError.unknownPedalType(type)
|
throw ShoeGazeError.unknownPedalType(type)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ import LyrebirdUI
|
|||||||
///
|
///
|
||||||
/// ## Input routing
|
/// ## Input routing
|
||||||
///
|
///
|
||||||
/// When `inputSource == .testLoop`, a `TestLoopSource` is added to the engine
|
/// When `inputSource == .testLoop`, a **single** shared `TestLoopSource` writes a global
|
||||||
/// **before** the first pedal on each board (plain `engine.add` places it at the
|
/// test bus, and each board gets a `TestLoopTap` (added `.after(_:)` the source) copying that
|
||||||
/// head of `mainGroup`, so it evaluates first).
|
/// bus into the board's head bus. One shared source keeps every board phase-locked and survives
|
||||||
|
/// board add/remove, so the arpeggio never restarts into a polyrhythm.
|
||||||
///
|
///
|
||||||
/// When `inputSource == .liveInput(channel:)`, a `HardwareInputPassThrough` synthesizer
|
/// When `inputSource == .liveInput(channel:)`, a `HardwareInputPassThrough` synthesizer
|
||||||
/// copies hardware input `channel` (engine bus `numOutputChannels + channel`) to the
|
/// copies hardware input `channel` (engine bus `numOutputChannels + channel`) to the
|
||||||
@@ -96,7 +97,14 @@ public final class ShoeGaze {
|
|||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private var testLoopSources: [TestLoopSource] = []
|
/// The single shared test-loop source feeding every board in `.testLoop` mode, and the bus
|
||||||
|
/// it writes. One global source keeps all boards phase-locked (no per-board polyrhythm) and
|
||||||
|
/// survives board add/remove so its arpeggio never restarts. `nil` outside `.testLoop` mode.
|
||||||
|
private var globalTestSource: TestLoopSource?
|
||||||
|
private var globalTestBus: AudioBus?
|
||||||
|
|
||||||
|
/// Per-board taps copying the global test bus into each board's head bus.
|
||||||
|
private var testLoopTaps: [TestLoopTap] = []
|
||||||
private var inputPassThroughs: [HardwareInputPassThrough] = []
|
private var inputPassThroughs: [HardwareInputPassThrough] = []
|
||||||
private var outputMasters: [BoardOutputMaster] = []
|
private var outputMasters: [BoardOutputMaster] = []
|
||||||
|
|
||||||
@@ -149,16 +157,19 @@ public final class ShoeGaze {
|
|||||||
// Route the input source to the board head bus.
|
// Route the input source to the board head bus.
|
||||||
switch inputSource {
|
switch inputSource {
|
||||||
case .testLoop:
|
case .testLoop:
|
||||||
let source: TestLoopSource = TestLoopSource(
|
// All boards share one global test source so they stay phase-locked. Each board
|
||||||
targetBus: board.headBus.index,
|
// gets a tap copying the shared test bus into its head bus, added `.after(_:)` the
|
||||||
sampleRate: engine.sampleRate
|
// source so it sees the source's output for the current block.
|
||||||
|
let (source, testBus): (TestLoopSource, AudioBus) = try ensureGlobalTestSource()
|
||||||
|
let tap: TestLoopTap = TestLoopTap(
|
||||||
|
inputBusIndex: testBus.index,
|
||||||
|
outputBusIndex: board.headBus.index
|
||||||
)
|
)
|
||||||
// Plain add → head of mainGroup (evaluates before any pedal).
|
try engine.add(tap, position: NodePosition.after(source))
|
||||||
try engine.add(source)
|
testLoopTaps.append(tap)
|
||||||
testLoopSources.append(source)
|
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
|
||||||
// Record the source as the head input node so PedalBoard.add(_:) can chain
|
// pedal after it automatically (without needing an explicit `after:`).
|
||||||
// the first pedal after it automatically (without needing an explicit `after:`).
|
board.headInputNode = tap
|
||||||
board.headInputNode = source
|
|
||||||
|
|
||||||
case .liveInput(let channel):
|
case .liveInput(let channel):
|
||||||
// Hardware input channel `channel` lives at bus numOutputChannels + channel.
|
// Hardware input channel `channel` lives at bus numOutputChannels + channel.
|
||||||
@@ -181,6 +192,36 @@ public final class ShoeGaze {
|
|||||||
return board
|
return board
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Lazily creates the single shared test-loop source and its bus, returning both.
|
||||||
|
///
|
||||||
|
/// Created once per `.testLoop` session and reused by every board's tap, so the arpeggio
|
||||||
|
/// phase is continuous across board add/remove (no per-board polyrhythm). Torn down by
|
||||||
|
/// ``teardown()`` (and thus by ``setInputSource(_:)`` when leaving test-loop mode).
|
||||||
|
///
|
||||||
|
/// The source and bus are committed to `globalTestSource` / `globalTestBus` only after the
|
||||||
|
/// engine add succeeds — if `engine.add` throws, the freshly allocated bus is released so it
|
||||||
|
/// is never orphaned.
|
||||||
|
private func ensureGlobalTestSource() throws -> (source: TestLoopSource, bus: AudioBus) {
|
||||||
|
if let source: TestLoopSource = globalTestSource, let bus: AudioBus = globalTestBus {
|
||||||
|
return (source, bus)
|
||||||
|
}
|
||||||
|
let testBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let source: TestLoopSource = TestLoopSource(
|
||||||
|
targetBus: testBus.index,
|
||||||
|
sampleRate: engine.sampleRate
|
||||||
|
)
|
||||||
|
do {
|
||||||
|
// Plain add → head of mainGroup (evaluates before its taps and any pedal).
|
||||||
|
try engine.add(source)
|
||||||
|
} catch {
|
||||||
|
engine.busAllocator.releaseAudioBus(testBus)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
globalTestBus = testBus
|
||||||
|
globalTestSource = source
|
||||||
|
return (source, testBus)
|
||||||
|
}
|
||||||
|
|
||||||
/// Connects the output master for a previously prepared board and adds it to the engine.
|
/// Connects the output master for a previously prepared board and adds it to the engine.
|
||||||
///
|
///
|
||||||
/// Call this after all pedals have been added to the board via `board.add(_:)`.
|
/// Call this after all pedals have been added to the board via `board.add(_:)`.
|
||||||
@@ -333,10 +374,12 @@ public final class ShoeGaze {
|
|||||||
outputMasters.removeAll { $0 === master }
|
outputMasters.removeAll { $0 === master }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the board's input source (writer of the head bus).
|
// Remove the board's input node (writer of the head bus). In `.testLoop` mode this is a
|
||||||
if let testLoop: TestLoopSource = board.headInputNode as? TestLoopSource {
|
// tap; the shared global source is left running so the remaining boards keep their
|
||||||
engine.remove(testLoop)
|
// phase-locked test signal.
|
||||||
testLoopSources.removeAll { $0 === testLoop }
|
if let tap: TestLoopTap = board.headInputNode as? TestLoopTap {
|
||||||
|
engine.remove(tap)
|
||||||
|
testLoopTaps.removeAll { $0 === tap }
|
||||||
} else if let passThrough: HardwareInputPassThrough = board.headInputNode as? HardwareInputPassThrough {
|
} else if let passThrough: HardwareInputPassThrough = board.headInputNode as? HardwareInputPassThrough {
|
||||||
engine.remove(passThrough)
|
engine.remove(passThrough)
|
||||||
inputPassThroughs.removeAll { $0 === passThrough }
|
inputPassThroughs.removeAll { $0 === passThrough }
|
||||||
@@ -377,6 +420,13 @@ public final class ShoeGaze {
|
|||||||
/// try engine.start()
|
/// try engine.start()
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// > Note: In `.testLoop` mode a `ChainRouter` allocates **its own** test source (shared by
|
||||||
|
/// > the router's two boards via the splitter, so those two stay phase-locked to each other).
|
||||||
|
/// > That source is independent of the global test source used by ``addBoard()``-created
|
||||||
|
/// > boards, so a router's boards are *not* phase-locked to the main board list. Routers are
|
||||||
|
/// > a separate multi-board path (not used by the standard builder UI); unifying them onto the
|
||||||
|
/// > global source is intentionally out of scope here.
|
||||||
|
///
|
||||||
/// - Returns: A ``ChainRouter`` with both boards ready to receive pedals.
|
/// - Returns: A ``ChainRouter`` with both boards ready to receive pedals.
|
||||||
/// - Throws:
|
/// - Throws:
|
||||||
/// - `ShoeGazeError.liveInputRequiresInputChannels` when `inputSource == .liveInput`
|
/// - `ShoeGazeError.liveInputRequiresInputChannels` when `inputSource == .liveInput`
|
||||||
@@ -440,10 +490,21 @@ public final class ShoeGaze {
|
|||||||
|
|
||||||
// Step 1: Remove all engine nodes that write to board buses.
|
// Step 1: Remove all engine nodes that write to board buses.
|
||||||
// Order within this step does not matter; all must finish before bus release.
|
// Order within this step does not matter; all must finish before bus release.
|
||||||
for source: TestLoopSource in testLoopSources {
|
for tap: TestLoopTap in testLoopTaps {
|
||||||
|
engine.remove(tap)
|
||||||
|
}
|
||||||
|
testLoopTaps.removeAll()
|
||||||
|
|
||||||
|
// Remove the shared global test source and release its bus (after its taps are removed,
|
||||||
|
// preserving remove-before-release ordering).
|
||||||
|
if let source: TestLoopSource = globalTestSource {
|
||||||
engine.remove(source)
|
engine.remove(source)
|
||||||
}
|
}
|
||||||
testLoopSources.removeAll()
|
globalTestSource = nil
|
||||||
|
if let testBus: AudioBus = globalTestBus {
|
||||||
|
engine.busAllocator.releaseAudioBus(testBus)
|
||||||
|
}
|
||||||
|
globalTestBus = nil
|
||||||
|
|
||||||
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
||||||
engine.remove(passThrough)
|
engine.remove(passThrough)
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public enum ShoeGazeError: Error, LocalizedError, Equatable, Sendable {
|
|||||||
/// Narrow the chain with `mergeToMono()` before adding another widener.
|
/// Narrow the chain with `mergeToMono()` before adding another widener.
|
||||||
case stereoWidthExceeded
|
case stereoWidthExceeded
|
||||||
|
|
||||||
/// Thrown by the linear pedal-edit API (`appendPedal(type:to:)`) when `type` is not a
|
/// Thrown by the linear pedal-edit API (`appendPedal(_:to:)`) when the kind's `rawValue` is
|
||||||
/// known pedal in `PedalRegistry.builtIn`. The associated value is the requested type string.
|
/// not a known pedal in `PedalRegistry.builtIn`. The associated value is the requested type string.
|
||||||
case unknownPedalType(String)
|
case unknownPedalType(String)
|
||||||
|
|
||||||
/// Thrown by `removePedal(at:from:)` / `movePedal(from:to:in:)` when a linear pedal index is
|
/// Thrown by `removePedal(at:from:)` / `movePedal(from:to:in:)` when a linear pedal index is
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ public struct BoardFlowView: View {
|
|||||||
|
|
||||||
private func append(type: String, lane: PedalLane) {
|
private func append(type: String, lane: PedalLane) {
|
||||||
guard let board: PedalBoard = board else { return }
|
guard let board: PedalBoard = board else { return }
|
||||||
do { _ = try shoeGaze.appendPedal(type: type, to: board, lane: lane) }
|
do { _ = try shoeGaze.appendPedal(PedalType(type), to: board, lane: lane) }
|
||||||
catch { print("[BoardFlowView] appendPedal failed: \(error)") }
|
catch { print("[BoardFlowView] appendPedal failed: \(error)") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import LyrebirdShoeGaze
|
|||||||
/// options, sized to sit in a narrow left sidebar.
|
/// options, sized to sit in a narrow left sidebar.
|
||||||
///
|
///
|
||||||
/// The pedal rows are tappable: selecting one invokes `onAdd(type)` with the pedal's
|
/// The pedal rows are tappable: selecting one invokes `onAdd(type)` with the pedal's
|
||||||
/// `displayName`, which the host wires to `ShoeGaze.appendPedal(type:to:)`. The routing cards
|
/// `displayName`, which the host wraps in a `PedalType` for `ShoeGaze.appendPedal(_:to:)`. The routing cards
|
||||||
/// (Parallel split, Stereo split, Chain router, Merge to mono) are informational only — they
|
/// (Parallel split, Stereo split, Chain router, Merge to mono) are informational only — they
|
||||||
/// describe the topologies the engine supports, which are built programmatically rather than via
|
/// describe the topologies the engine supports, which are built programmatically rather than via
|
||||||
/// linear add (see ``BoardBuilderView`` for the read-only display of existing branches).
|
/// linear add (see ``BoardBuilderView`` for the read-only display of existing branches).
|
||||||
@@ -20,7 +20,7 @@ import LyrebirdShoeGaze
|
|||||||
///
|
///
|
||||||
/// ```swift
|
/// ```swift
|
||||||
/// PedalPaletteView { type in
|
/// PedalPaletteView { type in
|
||||||
/// try? shoeGaze.appendPedal(type: type, to: board)
|
/// try? shoeGaze.appendPedal(PedalType(type), to: board)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public struct PedalPaletteView: View {
|
public struct PedalPaletteView: View {
|
||||||
@@ -47,7 +47,7 @@ public struct PedalPaletteView: View {
|
|||||||
private static let preferredOrder: [String] = [
|
private static let preferredOrder: [String] = [
|
||||||
"Overdrive", "Compressor", "Limiter", "Noise Gate", "Fuzz",
|
"Overdrive", "Compressor", "Limiter", "Noise Gate", "Fuzz",
|
||||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation",
|
"Graphic EQ", "Tremolo", "Phaser", "Modulation",
|
||||||
"Auto-Wah", "Mu-Tron", "Bass Octaver", "Octave Splitter",
|
"Auto-Wah", "Mutant", "Bass Octaver", "Octave Splitter",
|
||||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverb",
|
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverb",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ private func enclosureColor(for displayName: String) -> Color {
|
|||||||
case "Tremolo": return Color(red: 0.20, green: 0.38, blue: 0.72) // cobalt blue
|
case "Tremolo": return Color(red: 0.20, green: 0.38, blue: 0.72) // cobalt blue
|
||||||
case "Phaser": return Color(red: 0.60, green: 0.22, blue: 0.62) // violet
|
case "Phaser": return Color(red: 0.60, green: 0.22, blue: 0.62) // violet
|
||||||
case "Compressor": return Color(red: 0.18, green: 0.42, blue: 0.32) // forest green
|
case "Compressor": return Color(red: 0.18, green: 0.42, blue: 0.32) // forest green
|
||||||
case "Mu-Tron": return Color(red: 0.70, green: 0.12, blue: 0.48) // magenta / plum
|
case "Mutant": return Color(red: 0.70, green: 0.12, blue: 0.48) // magenta / plum
|
||||||
case "Auto-Wah": return Color(red: 0.80, green: 0.62, blue: 0.10) // gold
|
case "Auto-Wah": return Color(red: 0.80, green: 0.62, blue: 0.10) // gold
|
||||||
case "Feedback Delay": return Color(red: 0.48, green: 0.30, blue: 0.14) // tape sepia
|
case "Feedback Delay": return Color(red: 0.48, green: 0.30, blue: 0.14) // tape sepia
|
||||||
case "Multi-Tap Delay": return Color(red: 0.08, green: 0.48, blue: 0.68) // cyan
|
case "Multi-Tap Delay": return Color(red: 0.08, green: 0.48, blue: 0.68) // cyan
|
||||||
|
|||||||
@@ -160,6 +160,29 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
)
|
)
|
||||||
.background(boardSwitchShortcuts)
|
.background(boardSwitchShortcuts)
|
||||||
.onAppear { restoreInputSelection() }
|
.onAppear { restoreInputSelection() }
|
||||||
|
// Each presentation (sheet / importers / exporter / alert) lives on its own anchor
|
||||||
|
// node. SwiftUI reliably drives only one presentation per view node, so stacking them
|
||||||
|
// all on the root view silently swallowed some (e.g. the iOS Load file importer).
|
||||||
|
.background(boardsSheetAnchor)
|
||||||
|
.alert("Microphone Access Needed", isPresented: $showMicDeniedAlert) {
|
||||||
|
Button("OK", role: .cancel) { }
|
||||||
|
} message: {
|
||||||
|
Text("Live input needs microphone access. Enable it in System Settings › Privacy & "
|
||||||
|
+ "Security › Microphone, then select the input again.")
|
||||||
|
}
|
||||||
|
#if !os(macOS)
|
||||||
|
.background(rigImportAnchor)
|
||||||
|
.background(recordingFolderImportAnchor)
|
||||||
|
.background(rigExportAnchor)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Presentation anchors
|
||||||
|
|
||||||
|
/// Hosts the board-manager sheet on its own node so it does not collide with the file
|
||||||
|
/// importers / exporter (one presentation per view node).
|
||||||
|
private var boardsSheetAnchor: some View {
|
||||||
|
Color.clear
|
||||||
.sheet(isPresented: $showBoardsSheet) {
|
.sheet(isPresented: $showBoardsSheet) {
|
||||||
BoardsSheetView(
|
BoardsSheetView(
|
||||||
shoeGaze: shoeGaze,
|
shoeGaze: shoeGaze,
|
||||||
@@ -169,19 +192,28 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
)
|
)
|
||||||
.presentationDetents([.medium, .large])
|
.presentationDetents([.medium, .large])
|
||||||
}
|
}
|
||||||
.alert("Microphone Access Needed", isPresented: $showMicDeniedAlert) {
|
|
||||||
Button("OK", role: .cancel) { }
|
|
||||||
} message: {
|
|
||||||
Text("Live input needs microphone access. Enable it in System Settings › Privacy & "
|
|
||||||
+ "Security › Microphone, then select the input again.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
|
/// Hosts the rig-load (`.json`) importer on its own node.
|
||||||
|
private var rigImportAnchor: some View {
|
||||||
|
Color.clear
|
||||||
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in
|
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in
|
||||||
handleImport(result)
|
handleImport(result)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hosts the recording-folder importer on its own node.
|
||||||
|
private var recordingFolderImportAnchor: some View {
|
||||||
|
Color.clear
|
||||||
.fileImporter(isPresented: $showRecordingFolderImporter, allowedContentTypes: [.folder]) { result in
|
.fileImporter(isPresented: $showRecordingFolderImporter, allowedContentTypes: [.folder]) { result in
|
||||||
handleRecordingFolderImport(result)
|
handleRecordingFolderImport(result)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hosts the rig-save (`.json`) exporter on its own node.
|
||||||
|
private var rigExportAnchor: some View {
|
||||||
|
Color.clear
|
||||||
.fileExporter(
|
.fileExporter(
|
||||||
isPresented: $showExporter,
|
isPresented: $showExporter,
|
||||||
document: exportDocument,
|
document: exportDocument,
|
||||||
@@ -192,8 +224,8 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
print("[ShoeGazeBuilderView] export failed: \(error)")
|
print("[ShoeGazeBuilderView] export failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// MARK: - Transport row
|
// MARK: - Transport row
|
||||||
|
|
||||||
@@ -341,7 +373,7 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
guard !shoeGaze.boards.isEmpty else { return }
|
guard !shoeGaze.boards.isEmpty else { return }
|
||||||
let board: PedalBoard = shoeGaze.boards[clampedBoardIndex]
|
let board: PedalBoard = shoeGaze.boards[clampedBoardIndex]
|
||||||
do {
|
do {
|
||||||
_ = try shoeGaze.appendPedal(type: type, to: board)
|
_ = try shoeGaze.appendPedal(PedalType(type), to: board)
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
|
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ struct BoardEditAPITests {
|
|||||||
try makeRig(pedals: ["Overdrive", "Delay"])
|
try makeRig(pedals: ["Overdrive", "Delay"])
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
let edited: PedalBoard = try sg.appendPedal(type: "Reverb", to: board)
|
let edited: PedalBoard = try sg.appendPedal(.reverb, to: board)
|
||||||
#expect(names(edited) == ["Overdrive", "Delay", "Reverb"])
|
#expect(names(edited) == ["Overdrive", "Delay", "Reverb"])
|
||||||
#expect(sg.boards.count == 1, "append should not change board count")
|
#expect(sg.boards.count == 1, "append should not change board count")
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
#expect(throws: ShoeGazeError.unknownPedalType("Nope")) {
|
#expect(throws: ShoeGazeError.unknownPedalType("Nope")) {
|
||||||
try sg.appendPedal(type: "Nope", to: board)
|
try sg.appendPedal(PedalType("Nope"), to: board)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ struct BoardEditAPITests {
|
|||||||
try sg.finalizeBoard(board)
|
try sg.finalizeBoard(board)
|
||||||
|
|
||||||
// Append a linear pedal; the stereo split region must survive untouched.
|
// Append a linear pedal; the stereo split region must survive untouched.
|
||||||
let edited: PedalBoard = try sg.appendPedal(type: "Fuzz", to: board)
|
let edited: PedalBoard = try sg.appendPedal(.fuzz, to: board)
|
||||||
#expect(names(edited).contains("Fuzz"), "appended linear pedal should be present")
|
#expect(names(edited).contains("Fuzz"), "appended linear pedal should be present")
|
||||||
|
|
||||||
let after: BoardState = edited.captureState()
|
let after: BoardState = edited.captureState()
|
||||||
@@ -215,8 +215,8 @@ struct BoardEditAPITests {
|
|||||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||||
// The split region is the second top-level segment (after the Overdrive pedal).
|
// The split region is the second top-level segment (after the Overdrive pedal).
|
||||||
let region: Int = 1
|
let region: Int = 1
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: region))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: region))
|
||||||
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: region))
|
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: region))
|
||||||
|
|
||||||
guard let state: StereoSplitState = stereoState(live) else {
|
guard let state: StereoSplitState = stereoState(live) else {
|
||||||
Issue.record("No stereo split segment after building one")
|
Issue.record("No stereo split segment after building one")
|
||||||
@@ -236,8 +236,8 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.fuzz, to: live, lane: .left(region: 1))
|
||||||
live = try sg.removePedal(at: 0, from: live, lane: .left(region: 1))
|
live = try sg.removePedal(at: 0, from: live, lane: .left(region: 1))
|
||||||
|
|
||||||
#expect(stereoState(live)?.left.map { $0.type } == ["Fuzz"], "left lane should drop Delay")
|
#expect(stereoState(live)?.left.map { $0.type } == ["Fuzz"], "left lane should drop Delay")
|
||||||
@@ -249,7 +249,7 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
// Octave Splitter is a widener → board becomes stereo; a second split is then invalid.
|
// Octave Splitter is a widener → board becomes stereo; a second split is then invalid.
|
||||||
let live: PedalBoard = try sg.appendPedal(type: "Octave Splitter", to: board)
|
let live: PedalBoard = try sg.appendPedal(.octaveSplitter, to: board)
|
||||||
#expect(live.width == 2, "widener should make the board stereo")
|
#expect(live.width == 2, "widener should make the board stereo")
|
||||||
#expect(throws: ShoeGazeError.cannotSplitStereoChain) {
|
#expect(throws: ShoeGazeError.cannotSplitStereoChain) {
|
||||||
try sg.appendStereoSplit(to: live)
|
try sg.appendStereoSplit(to: live)
|
||||||
@@ -262,7 +262,7 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
#expect(stereoState(live) != nil, "split region present before removal")
|
#expect(stereoState(live) != nil, "split region present before removal")
|
||||||
|
|
||||||
live = try sg.removeSegment(at: 1, from: live)
|
live = try sg.removeSegment(at: 1, from: live)
|
||||||
@@ -319,8 +319,8 @@ struct BoardEditAPITests {
|
|||||||
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
||||||
#expect(sg.isStereoUnzip(afterSegment: 0, in: live), "toggle should report unzip present")
|
#expect(sg.isStereoUnzip(afterSegment: 0, in: live), "toggle should report unzip present")
|
||||||
|
|
||||||
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.fuzz, to: live, lane: .left(region: 1))
|
||||||
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: 1))
|
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
|
||||||
|
|
||||||
guard let state: StereoUnzipState = unzipState(live) else {
|
guard let state: StereoUnzipState = unzipState(live) else {
|
||||||
Issue.record("No stereo unzip segment")
|
Issue.record("No stereo unzip segment")
|
||||||
@@ -375,8 +375,8 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: 1))
|
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
|
||||||
if let section: StereoSplitSection = live.stereoUnzipSections.first {
|
if let section: StereoSplitSection = live.stereoUnzipSections.first {
|
||||||
section.route = .rightOnly
|
section.route = .rightOnly
|
||||||
}
|
}
|
||||||
@@ -410,8 +410,8 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
var live: PedalBoard = try sg.appendParallelSplit(to: board)
|
var live: PedalBoard = try sg.appendParallelSplit(to: board)
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .right(region: 1))
|
live = try sg.appendPedal(.fuzz, to: live, lane: .right(region: 1))
|
||||||
|
|
||||||
var foundParallel: Bool = false
|
var foundParallel: Bool = false
|
||||||
for segment: BoardSegmentState in live.captureState().segments {
|
for segment: BoardSegmentState in live.captureState().segments {
|
||||||
@@ -528,7 +528,7 @@ struct BoardEditAPITests {
|
|||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||||
|
|
||||||
// Edit the branch pedal's first knob via the node path.
|
// Edit the branch pedal's first knob via the node path.
|
||||||
guard let stereo: StereoSplitSection = live.stereoSplitSections.first,
|
guard let stereo: StereoSplitSection = live.stereoSplitSections.first,
|
||||||
@@ -562,7 +562,7 @@ struct BoardEditAPITests {
|
|||||||
try makeRig(pedals: ["Overdrive", "Delay"])
|
try makeRig(pedals: ["Overdrive", "Delay"])
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try sg.appendPedal(type: "Reverb", to: board)
|
try sg.appendPedal(.reverb, to: board)
|
||||||
try sg.removePedal(at: 0, from: sg.boards[0]) // drop Overdrive → [Delay, Reverb]
|
try sg.removePedal(at: 0, from: sg.boards[0]) // drop Overdrive → [Delay, Reverb]
|
||||||
|
|
||||||
let preset: URL = FileManager.default.temporaryDirectory
|
let preset: URL = FileManager.default.temporaryDirectory
|
||||||
|
|||||||
@@ -98,4 +98,64 @@ struct CompressorPedalTests {
|
|||||||
}
|
}
|
||||||
#expect(ssd > 0, "ratio=1 and ratio=20 produced identical output — ratio knob has no effect")
|
#expect(ssd > 0, "ratio=1 and ratio=20 produced identical output — ratio knob has no effect")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func exposesInputThresholdRatioKnobs() throws {
|
||||||
|
let pedal: CompressorPedal = CompressorPedal()
|
||||||
|
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||||
|
#expect(labels == ["Input", "Threshold", "Ratio"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func inputGainChangesOutput() throws {
|
||||||
|
// The pre-compression input gain stage must alter the output: boosting the input
|
||||||
|
// drives more of the signal past the threshold, changing the compressed result.
|
||||||
|
let renderDuration: Double = 0.1
|
||||||
|
let numAudioBuses: Int = 64
|
||||||
|
|
||||||
|
func renderWithInputGain(_ gainDB: Double) throws -> [Float] {
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: renderDuration,
|
||||||
|
numAudioBuses: numAudioBuses
|
||||||
|
)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||||
|
defer {
|
||||||
|
engine.busAllocator.releaseAudioBus(srcBus)
|
||||||
|
engine.busAllocator.releaseAudioBus(dstBus)
|
||||||
|
}
|
||||||
|
|
||||||
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
|
let pedal: CompressorPedal = CompressorPedal(
|
||||||
|
inputBus: srcBus.index,
|
||||||
|
outputBus: dstBus.index
|
||||||
|
)
|
||||||
|
pedal.inputGain = gainDB
|
||||||
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||||
|
try engine.add(source)
|
||||||
|
try engine.add(pedal, position: NodePosition.after(source))
|
||||||
|
try engine.add(master, position: NodePosition.after(pedal))
|
||||||
|
try engine.start()
|
||||||
|
return readStereoCAF(url: url)
|
||||||
|
}
|
||||||
|
|
||||||
|
let unitySamples: [Float] = try renderWithInputGain(0.0)
|
||||||
|
let boostedSamples: [Float] = try renderWithInputGain(24.0)
|
||||||
|
|
||||||
|
#expect(hasNonSilentOutput(unitySamples), "0 dB input-gain render was silent")
|
||||||
|
#expect(hasNonSilentOutput(boostedSamples), "+24 dB input-gain render was silent")
|
||||||
|
|
||||||
|
let skipSamples: Int = 1024
|
||||||
|
let windowSize: Int = 2048
|
||||||
|
guard unitySamples.count >= skipSamples + windowSize,
|
||||||
|
boostedSamples.count >= skipSamples + windowSize else { return }
|
||||||
|
|
||||||
|
let unityWindow: [Float] = Array(unitySamples[skipSamples..<(skipSamples + windowSize)])
|
||||||
|
let boostedWindow: [Float] = Array(boostedSamples[skipSamples..<(skipSamples + windowSize)])
|
||||||
|
let ssd: Double = zip(unityWindow, boostedWindow).reduce(0.0) { acc, pair in
|
||||||
|
let diff: Double = Double(pair.0 - pair.1)
|
||||||
|
return acc + diff * diff
|
||||||
|
}
|
||||||
|
#expect(ssd > 0, "input gain 0 dB and +24 dB produced identical output — input gain has no effect")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -1,4 +1,4 @@
|
|||||||
// MuTronPedalTests.swift
|
// MutantPedalTests.swift
|
||||||
// Lyrebird
|
// Lyrebird
|
||||||
//
|
//
|
||||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
@@ -11,8 +11,8 @@ import LyrebirdUI
|
|||||||
@testable import LyrebirdShoeGaze
|
@testable import LyrebirdShoeGaze
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@Suite("MuTronPedal")
|
@Suite("MutantPedal")
|
||||||
struct MuTronPedalTests {
|
struct MutantPedalTests {
|
||||||
|
|
||||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||||
let renderDuration: Double = 0.1
|
let renderDuration: Double = 0.1
|
||||||
@@ -27,7 +27,7 @@ struct MuTronPedalTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
let pedal: MuTronPedal = MuTronPedal(
|
let pedal: MutantPedal = MutantPedal(
|
||||||
inputBus: srcBus.index,
|
inputBus: srcBus.index,
|
||||||
outputBus: dstBus.index
|
outputBus: dstBus.index
|
||||||
)
|
)
|
||||||
@@ -40,7 +40,7 @@ struct MuTronPedalTests {
|
|||||||
|
|
||||||
let samples: [Float] = readStereoCAF(url: url)
|
let samples: [Float] = readStereoCAF(url: url)
|
||||||
#expect(!samples.isEmpty)
|
#expect(!samples.isEmpty)
|
||||||
#expect(hasNonSilentOutput(samples), "MuTronPedal produced silence")
|
#expect(hasNonSilentOutput(samples), "MutantPedal produced silence")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func filterModesProduceDifferentOutput() throws {
|
@Test func filterModesProduceDifferentOutput() throws {
|
||||||
@@ -62,7 +62,7 @@ struct MuTronPedalTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
let pedal: MuTronPedal = MuTronPedal(
|
let pedal: MutantPedal = MutantPedal(
|
||||||
inputBus: srcBus.index,
|
inputBus: srcBus.index,
|
||||||
outputBus: dstBus.index
|
outputBus: dstBus.index
|
||||||
)
|
)
|
||||||
@@ -96,27 +96,27 @@ struct MuTronPedalTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test func presetRoundTripPreservesSwitchPositions() throws {
|
@Test func presetRoundTripPreservesSwitchPositions() throws {
|
||||||
let pedal: MuTronPedal = MuTronPedal()
|
let pedal: MutantPedal = MutantPedal()
|
||||||
pedal.mode = 2.0 // highpass
|
pedal.mode = 2.0 // highpass
|
||||||
pedal.direction = 0.0 // down
|
pedal.direction = 0.0 // down
|
||||||
|
|
||||||
let state: PedalState = pedal.captureState()
|
let state: PedalState = pedal.captureState()
|
||||||
#expect(state.switchValues == [0.0, 2.0]) // [direction, mode]
|
#expect(state.switchValues == [0.0, 2.0]) // [direction, mode]
|
||||||
|
|
||||||
let restored: MuTronPedal = MuTronPedal()
|
let restored: MutantPedal = MutantPedal()
|
||||||
restored.applyState(state)
|
restored.applyState(state)
|
||||||
#expect(restored.mode == 2.0)
|
#expect(restored.mode == 2.0)
|
||||||
#expect(restored.direction == 0.0)
|
#expect(restored.direction == 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func exposesSensitivityAndResonanceKnobs() throws {
|
@Test func exposesSensitivityAndResonanceKnobs() throws {
|
||||||
let pedal: MuTronPedal = MuTronPedal()
|
let pedal: MutantPedal = MutantPedal()
|
||||||
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||||
#expect(labels == ["Sensitivity", "Resonance"])
|
#expect(labels == ["Sensitivity", "Resonance"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func exposesTwoStateSweepAndThreeStateModeSwitches() throws {
|
@Test func exposesTwoStateSweepAndThreeStateModeSwitches() throws {
|
||||||
let pedal: MuTronPedal = MuTronPedal()
|
let pedal: MutantPedal = MutantPedal()
|
||||||
let switches: [PedalSwitch] = pedal.effectSwitches
|
let switches: [PedalSwitch] = pedal.effectSwitches
|
||||||
#expect(switches.map { $0.label } == ["Sweep", "Mode"])
|
#expect(switches.map { $0.label } == ["Sweep", "Mode"])
|
||||||
// Two-state sweep (Down/Up), three-state mode (LP/BP/HP).
|
// Two-state sweep (Down/Up), three-state mode (LP/BP/HP).
|
||||||
@@ -143,7 +143,7 @@ struct MuTronPedalTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||||
let pedal: MuTronPedal = MuTronPedal(
|
let pedal: MutantPedal = MutantPedal(
|
||||||
inputBus: srcBus.index,
|
inputBus: srcBus.index,
|
||||||
outputBus: dstBus.index
|
outputBus: dstBus.index
|
||||||
)
|
)
|
||||||
@@ -423,9 +423,12 @@ struct PresetTests {
|
|||||||
// Apply the captured state (lightweight recall — no graph rebuild).
|
// Apply the captured state (lightweight recall — no graph rebuild).
|
||||||
sg.applyState(captured)
|
sg.applyState(captured)
|
||||||
|
|
||||||
// threshold is the first effectKnob; applyState calls knob.node.update(value)
|
// applyState calls knob.node.update(value) on each knob; the Threshold knob's
|
||||||
// which sets the UIParamNode. The UIParamNode.value should now reflect the restored value.
|
// UIParamNode.value should now reflect the restored value. Look up by label rather
|
||||||
let thresholdKnobValue: Double = compressor.knobs[0].node.value
|
// than position so the test is robust to knob additions.
|
||||||
|
let thresholdKnobValue: Double = try #require(
|
||||||
|
compressor.knobs.first(where: { $0.label == "Threshold" })?.node.value
|
||||||
|
)
|
||||||
#expect(
|
#expect(
|
||||||
abs(thresholdKnobValue - knownThreshold) < 1e-9,
|
abs(thresholdKnobValue - knownThreshold) < 1e-9,
|
||||||
"threshold knob should be \(knownThreshold) after applyState, got \(thresholdKnobValue)"
|
"threshold knob should be \(knownThreshold) after applyState, got \(thresholdKnobValue)"
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ struct ShoeGazeMultiBoardTests {
|
|||||||
let shoeGazeA: ShoeGaze = ShoeGaze(engine: engineA)
|
let shoeGazeA: ShoeGaze = ShoeGaze(engine: engineA)
|
||||||
let board1: PedalBoard = try shoeGazeA.addBoard()
|
let board1: PedalBoard = try shoeGazeA.addBoard()
|
||||||
board1.label = "Lead"
|
board1.label = "Lead"
|
||||||
try shoeGazeA.appendPedal(type: "Overdrive", to: board1)
|
try shoeGazeA.appendPedal(.overdrive, to: board1)
|
||||||
try shoeGazeA.finalizeBoard(board1)
|
try shoeGazeA.finalizeBoard(board1)
|
||||||
let board2: PedalBoard = try shoeGazeA.addBoard()
|
let board2: PedalBoard = try shoeGazeA.addBoard()
|
||||||
board2.label = "Clean"
|
board2.label = "Clean"
|
||||||
try shoeGazeA.appendPedal(type: "Graphic EQ", to: board2)
|
try shoeGazeA.appendPedal(.graphicEQ, to: board2)
|
||||||
try shoeGazeA.finalizeBoard(board2)
|
try shoeGazeA.finalizeBoard(board2)
|
||||||
|
|
||||||
let snapshot: Data = try shoeGazeA.rigData()
|
let snapshot: Data = try shoeGazeA.rigData()
|
||||||
@@ -86,6 +86,66 @@ struct ShoeGazeMultiBoardTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func testLoopBoardsShareGlobalSourceViaTaps() throws {
|
||||||
|
// In .testLoop mode every board reads one shared global source through a TestLoopTap,
|
||||||
|
// rather than owning an independently-phased TestLoopSource — this is what keeps the
|
||||||
|
// boards phase-locked. Verify the head input node of each board is a tap, and that a
|
||||||
|
// board removal leaves the others (and their signal) intact.
|
||||||
|
let renderDuration: Double = 0.05
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: renderDuration,
|
||||||
|
numAudioBuses: 64
|
||||||
|
)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
try board1.add(OverdrivePedal())
|
||||||
|
try shoeGaze.finalizeBoard(board1)
|
||||||
|
let board2: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
try board2.add(DelayPedal())
|
||||||
|
try shoeGaze.finalizeBoard(board2)
|
||||||
|
|
||||||
|
// Both boards feed from a shared tap, not their own source.
|
||||||
|
#expect(board1.headInputNode != nil)
|
||||||
|
#expect(board1.headInputNode is TestLoopTap)
|
||||||
|
#expect(board2.headInputNode is TestLoopTap)
|
||||||
|
#expect(!(board1.headInputNode is TestLoopSource))
|
||||||
|
|
||||||
|
// Removing one board does not disturb the other's input node.
|
||||||
|
shoeGaze.removeBoard(board1)
|
||||||
|
#expect(shoeGaze.boards.count == 1)
|
||||||
|
#expect(board2.headInputNode is TestLoopTap)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func teardownReleasesGlobalTestBusForReuse() throws {
|
||||||
|
// teardown() must remove the global source AND release its bus, so a later addBoard()
|
||||||
|
// can re-allocate cleanly (guards against the global test bus being leaked).
|
||||||
|
let renderDuration: Double = 0.05
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
duration: renderDuration,
|
||||||
|
numAudioBuses: 16
|
||||||
|
)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
|
||||||
|
// Repeatedly build a board then tear the whole rig down. With a small bus pool, a leaked
|
||||||
|
// global test bus on each cycle would eventually exhaust the allocator and throw.
|
||||||
|
for _ in 0 ..< 8 {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
try board.add(OverdrivePedal())
|
||||||
|
try shoeGaze.finalizeBoard(board)
|
||||||
|
#expect(board.headInputNode is TestLoopTap)
|
||||||
|
shoeGaze.teardown()
|
||||||
|
#expect(shoeGaze.boards.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still able to build after all the teardown cycles.
|
||||||
|
let finalBoard: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
#expect(finalBoard.headInputNode is TestLoopTap)
|
||||||
|
}
|
||||||
|
|
||||||
@Test func activeBoardIndexTracksReorderAndRemoval() throws {
|
@Test func activeBoardIndexTracksReorderAndRemoval() throws {
|
||||||
let renderDuration: Double = 0.05
|
let renderDuration: Double = 0.05
|
||||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Screenshots
|
||||||
|
|
||||||
|
Place README screenshots here as PNG:
|
||||||
|
|
||||||
|
- `builder-macos.png` — the macOS builder
|
||||||
|
- `board-mixer.png` — the multi-board mixer bar
|
||||||
|
|
||||||
|
Referenced by `README.md` via relative paths.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 884 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Reference in New Issue
Block a user