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_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
@@ -176,7 +176,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 0.9;
|
||||
MARKETING_VERSION = 0.91;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -194,7 +194,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = HE5VJFE9E4;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@@ -206,7 +206,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 0.9;
|
||||
MARKETING_VERSION = 0.91;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -46,7 +46,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
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: String = "Overdrive"
|
||||
private static let seedPedalType: PedalType = .overdrive
|
||||
|
||||
// MARK: - Owned objects
|
||||
|
||||
@@ -92,7 +92,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
created = board
|
||||
try shoeGaze.appendPedal(type: AppDelegate.seedPedalType, to: board)
|
||||
try shoeGaze.appendPedal(AppDelegate.seedPedalType, to: board)
|
||||
} catch {
|
||||
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||
print("[ShoeGazeBuilder] seed board failed: \(error)")
|
||||
|
||||
@@ -31,7 +31,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
// 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: String = "Overdrive"
|
||||
private static let seedPedalType: PedalType = .overdrive
|
||||
|
||||
/// UserDefaults key persisting the input selection. Must match the key written by the
|
||||
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
||||
@@ -64,7 +64,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Board 1"
|
||||
try shoeGaze.appendPedal(type: ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||
try shoeGaze.appendPedal(ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderiOS] seed board failed: \(error)")
|
||||
}
|
||||
@@ -182,7 +182,7 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
do {
|
||||
let board: PedalBoard = try shoeGaze.addBoard()
|
||||
board.label = "Board 1"
|
||||
try shoeGaze.appendPedal(type: ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||
try shoeGaze.appendPedal(ShoeGazeBuilderiOSAppModel.seedPedalType, to: board)
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderiOS] fallback seed board failed: \(error)")
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ final class ShoeGazeDemoController {
|
||||
///
|
||||
/// Board 1: Overdrive → Delay → Reverb → Modulation
|
||||
/// 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() {
|
||||
do {
|
||||
let board1: PedalBoard = try shoeGaze.addBoard()
|
||||
@@ -269,7 +269,7 @@ final class ShoeGazeDemoController {
|
||||
|
||||
let board3: PedalBoard = try shoeGaze.addBoard()
|
||||
board3.label = "Board 3"
|
||||
try board3.add(MuTronPedal())
|
||||
try board3.add(MutantPedal())
|
||||
try board3.add(AutoWahPedal())
|
||||
try board3.add(FeedbackDelayPedal())
|
||||
try board3.add(MultiTapDelayPedal())
|
||||
|
||||
@@ -1,3 +1,117 @@
|
||||
# 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.
|
||||
///
|
||||
/// 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,
|
||||
/// 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.
|
||||
|
||||
@@ -11,11 +11,13 @@ import LyrebirdUI
|
||||
///
|
||||
/// 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.
|
||||
/// Knobs expose the two most-musical parameters: threshold and ratio.
|
||||
/// An input gain stage boosts (or cuts) the signal *before* compression, so driving the
|
||||
/// 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.
|
||||
///
|
||||
@@ -24,6 +26,8 @@ import LyrebirdUI
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - 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
|
||||
/// compressed. Range `[-40, 0]` dB. Defaults to `-12.0`.
|
||||
/// - ratio: Compression ratio `≥ 1.0`. `1.0` = bypass, `4.0` = 4:1 compression.
|
||||
@@ -32,6 +36,9 @@ public final class CompressorPedal: Pedal {
|
||||
|
||||
// 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].
|
||||
@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.
|
||||
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.
|
||||
private let attackTime: Double = 0.01
|
||||
|
||||
@@ -57,6 +68,9 @@ public final class CompressorPedal: Pedal {
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Input-gain knob range in dB.
|
||||
private let inputGainRange: ClosedRange<Double> = -12.0 ... 24.0
|
||||
|
||||
/// Threshold knob range in dB.
|
||||
private let thresholdRange: ClosedRange<Double> = -40.0 ... 0.0
|
||||
|
||||
@@ -65,6 +79,7 @@ public final class CompressorPedal: Pedal {
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Input", node: $inputGain, range: inputGainRange),
|
||||
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
||||
PedalKnob(label: "Ratio", node: $ratio, range: ratioRange),
|
||||
]
|
||||
@@ -91,15 +106,18 @@ public final class CompressorPedal: Pedal {
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Applies feed-forward dynamic range compression.
|
||||
/// Boosts the input by `inputGain` dB, then applies feed-forward dynamic range compression.
|
||||
///
|
||||
/// Output is mono.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Compressed mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
Compressor.Audio(
|
||||
in: dry,
|
||||
// Convert the input-gain dB to a linear multiplier (10^(dB/20)) and apply before compression.
|
||||
let inputGainLinear: Exp.Audio = Exp.Audio($inputGain * dbToLinExpScale)
|
||||
let boosted: any ValidGeneratorInput = dry * inputGainLinear
|
||||
return Compressor.Audio(
|
||||
in: boosted,
|
||||
threshold: $threshold,
|
||||
ratio: $ratio,
|
||||
attack: attackTime,
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
// MuTronPedal.swift
|
||||
// MutantPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
@@ -7,7 +7,7 @@
|
||||
import LyrebirdSynth
|
||||
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
|
||||
/// cutoff sweep through a resonant Chamberlin state-variable filter. Because `MuTronIII`
|
||||
@@ -24,7 +24,7 @@ import LyrebirdUI
|
||||
/// ## Switches
|
||||
/// - `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.
|
||||
public final class MuTronPedal: Pedal {
|
||||
public final class MutantPedal: Pedal {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
@@ -107,10 +107,10 @@ public final class MuTronPedal: Pedal {
|
||||
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(
|
||||
name: "Mu-Tron",
|
||||
name: "Mutant",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: MuTronPedal.defaultMix
|
||||
initialMix: MutantPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/// 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
|
||||
/// 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`).
|
||||
/// > When a registered widener (e.g. Octave Splitter) or stereo-native pedal (e.g.
|
||||
@@ -39,7 +39,7 @@ public enum PedalRegistry {
|
||||
"Tremolo": { TremoloPedal() },
|
||||
"Phaser": { PhaserPedal() },
|
||||
"Compressor": { CompressorPedal() },
|
||||
"Mu-Tron": { MuTronPedal() },
|
||||
"Mutant": { MutantPedal() },
|
||||
"Auto-Wah": { AutoWahPedal() },
|
||||
"Feedback Delay": { FeedbackDelayPedal() },
|
||||
"Multi-Tap Delay": { MultiTapDelayPedal() },
|
||||
|
||||
@@ -21,7 +21,8 @@ extension ShoeGaze {
|
||||
/// running engine with at most one block of glitch (see ``rebuildBoard(_:from:)``).
|
||||
///
|
||||
/// - 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.
|
||||
/// - lane: Where to append. Defaults to ``PedalLane/main``.
|
||||
/// - Returns: The rebuilt board occupying the same slot in `boards`.
|
||||
@@ -29,10 +30,11 @@ extension ShoeGaze {
|
||||
/// any error from ``rebuildBoard(_:from:)``.
|
||||
@discardableResult
|
||||
public func appendPedal(
|
||||
type: String,
|
||||
_ kind: PedalType,
|
||||
to board: PedalBoard,
|
||||
lane: PedalLane = .main
|
||||
) throws -> PedalBoard {
|
||||
let type: String = kind.rawValue
|
||||
guard PedalRegistry.builtIn[type] != nil else {
|
||||
throw ShoeGazeError.unknownPedalType(type)
|
||||
}
|
||||
|
||||
@@ -34,9 +34,10 @@ import LyrebirdUI
|
||||
///
|
||||
/// ## Input routing
|
||||
///
|
||||
/// When `inputSource == .testLoop`, a `TestLoopSource` is added to the engine
|
||||
/// **before** the first pedal on each board (plain `engine.add` places it at the
|
||||
/// head of `mainGroup`, so it evaluates first).
|
||||
/// When `inputSource == .testLoop`, a **single** shared `TestLoopSource` writes a global
|
||||
/// test bus, and each board gets a `TestLoopTap` (added `.after(_:)` the source) copying that
|
||||
/// 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
|
||||
/// copies hardware input `channel` (engine bus `numOutputChannels + channel`) to the
|
||||
@@ -96,7 +97,14 @@ public final class ShoeGaze {
|
||||
|
||||
// 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 outputMasters: [BoardOutputMaster] = []
|
||||
|
||||
@@ -149,16 +157,19 @@ public final class ShoeGaze {
|
||||
// Route the input source to the board head bus.
|
||||
switch inputSource {
|
||||
case .testLoop:
|
||||
let source: TestLoopSource = TestLoopSource(
|
||||
targetBus: board.headBus.index,
|
||||
sampleRate: engine.sampleRate
|
||||
// All boards share one global test source so they stay phase-locked. Each board
|
||||
// gets a tap copying the shared test bus into its head bus, added `.after(_:)` the
|
||||
// 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(source)
|
||||
testLoopSources.append(source)
|
||||
// Record the source as the head input node so PedalBoard.add(_:) can chain
|
||||
// the first pedal after it automatically (without needing an explicit `after:`).
|
||||
board.headInputNode = source
|
||||
try engine.add(tap, position: NodePosition.after(source))
|
||||
testLoopTaps.append(tap)
|
||||
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
|
||||
// pedal after it automatically (without needing an explicit `after:`).
|
||||
board.headInputNode = tap
|
||||
|
||||
case .liveInput(let channel):
|
||||
// Hardware input channel `channel` lives at bus numOutputChannels + channel.
|
||||
@@ -181,6 +192,36 @@ public final class ShoeGaze {
|
||||
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.
|
||||
///
|
||||
/// 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 }
|
||||
}
|
||||
|
||||
// Remove the board's input source (writer of the head bus).
|
||||
if let testLoop: TestLoopSource = board.headInputNode as? TestLoopSource {
|
||||
engine.remove(testLoop)
|
||||
testLoopSources.removeAll { $0 === testLoop }
|
||||
// Remove the board's input node (writer of the head bus). In `.testLoop` mode this is a
|
||||
// tap; the shared global source is left running so the remaining boards keep their
|
||||
// phase-locked test signal.
|
||||
if let tap: TestLoopTap = board.headInputNode as? TestLoopTap {
|
||||
engine.remove(tap)
|
||||
testLoopTaps.removeAll { $0 === tap }
|
||||
} else if let passThrough: HardwareInputPassThrough = board.headInputNode as? HardwareInputPassThrough {
|
||||
engine.remove(passThrough)
|
||||
inputPassThroughs.removeAll { $0 === passThrough }
|
||||
@@ -377,6 +420,13 @@ public final class ShoeGaze {
|
||||
/// 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.
|
||||
/// - Throws:
|
||||
/// - `ShoeGazeError.liveInputRequiresInputChannels` when `inputSource == .liveInput`
|
||||
@@ -440,10 +490,21 @@ public final class ShoeGaze {
|
||||
|
||||
// Step 1: Remove all engine nodes that write to board buses.
|
||||
// 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)
|
||||
}
|
||||
testLoopSources.removeAll()
|
||||
globalTestSource = nil
|
||||
if let testBus: AudioBus = globalTestBus {
|
||||
engine.busAllocator.releaseAudioBus(testBus)
|
||||
}
|
||||
globalTestBus = nil
|
||||
|
||||
for passThrough: HardwareInputPassThrough in inputPassThroughs {
|
||||
engine.remove(passThrough)
|
||||
|
||||
@@ -48,8 +48,8 @@ public enum ShoeGazeError: Error, LocalizedError, Equatable, Sendable {
|
||||
/// Narrow the chain with `mergeToMono()` before adding another widener.
|
||||
case stereoWidthExceeded
|
||||
|
||||
/// Thrown by the linear pedal-edit API (`appendPedal(type:to:)`) when `type` is not a
|
||||
/// known pedal in `PedalRegistry.builtIn`. The associated value is the requested type string.
|
||||
/// Thrown by the linear pedal-edit API (`appendPedal(_:to:)`) when the kind's `rawValue` is
|
||||
/// not a known pedal in `PedalRegistry.builtIn`. The associated value is the requested type string.
|
||||
case unknownPedalType(String)
|
||||
|
||||
/// 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) {
|
||||
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)") }
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import LyrebirdShoeGaze
|
||||
/// options, sized to sit in a narrow left sidebar.
|
||||
///
|
||||
/// 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
|
||||
/// 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).
|
||||
@@ -20,7 +20,7 @@ import LyrebirdShoeGaze
|
||||
///
|
||||
/// ```swift
|
||||
/// PedalPaletteView { type in
|
||||
/// try? shoeGaze.appendPedal(type: type, to: board)
|
||||
/// try? shoeGaze.appendPedal(PedalType(type), to: board)
|
||||
/// }
|
||||
/// ```
|
||||
public struct PedalPaletteView: View {
|
||||
@@ -47,7 +47,7 @@ public struct PedalPaletteView: View {
|
||||
private static let preferredOrder: [String] = [
|
||||
"Overdrive", "Compressor", "Limiter", "Noise Gate", "Fuzz",
|
||||
"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",
|
||||
]
|
||||
|
||||
|
||||
@@ -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 "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 "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 "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
|
||||
|
||||
@@ -160,15 +160,10 @@ public struct ShoeGazeBuilderView: View {
|
||||
)
|
||||
.background(boardSwitchShortcuts)
|
||||
.onAppear { restoreInputSelection() }
|
||||
.sheet(isPresented: $showBoardsSheet) {
|
||||
BoardsSheetView(
|
||||
shoeGaze: shoeGaze,
|
||||
editingBoardIndex: $selectedBoardIndex,
|
||||
crossfadeSeconds: $crossfadeSeconds,
|
||||
onAddBoard: { addBoard() }
|
||||
)
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
// 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: {
|
||||
@@ -176,25 +171,62 @@ public struct ShoeGazeBuilderView: View {
|
||||
+ "Security › Microphone, then select the input again.")
|
||||
}
|
||||
#if !os(macOS)
|
||||
.fileImporter(isPresented: $showImporter, allowedContentTypes: [.json]) { result in
|
||||
handleImport(result)
|
||||
}
|
||||
.fileImporter(isPresented: $showRecordingFolderImporter, allowedContentTypes: [.folder]) { result in
|
||||
handleRecordingFolderImport(result)
|
||||
}
|
||||
.fileExporter(
|
||||
isPresented: $showExporter,
|
||||
document: exportDocument,
|
||||
contentType: .json,
|
||||
defaultFilename: ShoeGazeBuilderView.defaultRigFileName
|
||||
) { result in
|
||||
if case .failure(let error) = result {
|
||||
print("[ShoeGazeBuilderView] export failed: \(error)")
|
||||
}
|
||||
}
|
||||
.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) {
|
||||
BoardsSheetView(
|
||||
shoeGaze: shoeGaze,
|
||||
editingBoardIndex: $selectedBoardIndex,
|
||||
crossfadeSeconds: $crossfadeSeconds,
|
||||
onAddBoard: { addBoard() }
|
||||
)
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
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
|
||||
handleRecordingFolderImport(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Hosts the rig-save (`.json`) exporter on its own node.
|
||||
private var rigExportAnchor: some View {
|
||||
Color.clear
|
||||
.fileExporter(
|
||||
isPresented: $showExporter,
|
||||
document: exportDocument,
|
||||
contentType: .json,
|
||||
defaultFilename: ShoeGazeBuilderView.defaultRigFileName
|
||||
) { result in
|
||||
if case .failure(let error) = result {
|
||||
print("[ShoeGazeBuilderView] export failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - Transport row
|
||||
|
||||
private var transportRow: some View {
|
||||
@@ -341,7 +373,7 @@ public struct ShoeGazeBuilderView: View {
|
||||
guard !shoeGaze.boards.isEmpty else { return }
|
||||
let board: PedalBoard = shoeGaze.boards[clampedBoardIndex]
|
||||
do {
|
||||
_ = try shoeGaze.appendPedal(type: type, to: board)
|
||||
_ = try shoeGaze.appendPedal(PedalType(type), to: board)
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderView] appendPedal failed: \(error)")
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ struct BoardEditAPITests {
|
||||
try makeRig(pedals: ["Overdrive", "Delay"])
|
||||
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(sg.boards.count == 1, "append should not change board count")
|
||||
|
||||
@@ -64,7 +64,7 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
#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)
|
||||
|
||||
// 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")
|
||||
|
||||
let after: BoardState = edited.captureState()
|
||||
@@ -215,8 +215,8 @@ struct BoardEditAPITests {
|
||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||
// The split region is the second top-level segment (after the Overdrive pedal).
|
||||
let region: Int = 1
|
||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: region))
|
||||
live = try sg.appendPedal(type: "Reverb", to: live, lane: .right(region: region))
|
||||
live = try sg.appendPedal(.delay, to: live, lane: .left(region: region))
|
||||
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: region))
|
||||
|
||||
guard let state: StereoSplitState = stereoState(live) else {
|
||||
Issue.record("No stereo split segment after building one")
|
||||
@@ -236,8 +236,8 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(.delay, 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))
|
||||
|
||||
#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) }
|
||||
|
||||
// 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(throws: ShoeGazeError.cannotSplitStereoChain) {
|
||||
try sg.appendStereoSplit(to: live)
|
||||
@@ -262,7 +262,7 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
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")
|
||||
|
||||
live = try sg.removeSegment(at: 1, from: live)
|
||||
@@ -319,8 +319,8 @@ struct BoardEditAPITests {
|
||||
var live: PedalBoard = try sg.insertStereoUnzip(afterSegment: 0, in: board)
|
||||
#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(type: "Reverb", to: live, lane: .right(region: 1))
|
||||
live = try sg.appendPedal(.fuzz, to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
|
||||
|
||||
guard let state: StereoUnzipState = unzipState(live) else {
|
||||
Issue.record("No stereo unzip segment")
|
||||
@@ -375,8 +375,8 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
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(type: "Reverb", to: live, lane: .right(region: 1))
|
||||
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(.reverb, to: live, lane: .right(region: 1))
|
||||
if let section: StereoSplitSection = live.stereoUnzipSections.first {
|
||||
section.route = .rightOnly
|
||||
}
|
||||
@@ -410,8 +410,8 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
var live: PedalBoard = try sg.appendParallelSplit(to: board)
|
||||
live = try sg.appendPedal(type: "Delay", to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(type: "Fuzz", to: live, lane: .right(region: 1))
|
||||
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||
live = try sg.appendPedal(.fuzz, to: live, lane: .right(region: 1))
|
||||
|
||||
var foundParallel: Bool = false
|
||||
for segment: BoardSegmentState in live.captureState().segments {
|
||||
@@ -528,7 +528,7 @@ struct BoardEditAPITests {
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
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.
|
||||
guard let stereo: StereoSplitSection = live.stereoSplitSections.first,
|
||||
@@ -562,7 +562,7 @@ struct BoardEditAPITests {
|
||||
try makeRig(pedals: ["Overdrive", "Delay"])
|
||||
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]
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@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
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
@@ -11,8 +11,8 @@ import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("MuTronPedal")
|
||||
struct MuTronPedalTests {
|
||||
@Suite("MutantPedal")
|
||||
struct MutantPedalTests {
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let renderDuration: Double = 0.1
|
||||
@@ -27,7 +27,7 @@ struct MuTronPedalTests {
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: MuTronPedal = MuTronPedal(
|
||||
let pedal: MutantPedal = MutantPedal(
|
||||
inputBus: srcBus.index,
|
||||
outputBus: dstBus.index
|
||||
)
|
||||
@@ -40,7 +40,7 @@ struct MuTronPedalTests {
|
||||
|
||||
let samples: [Float] = readStereoCAF(url: url)
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "MuTronPedal produced silence")
|
||||
#expect(hasNonSilentOutput(samples), "MutantPedal produced silence")
|
||||
}
|
||||
|
||||
@Test func filterModesProduceDifferentOutput() throws {
|
||||
@@ -62,7 +62,7 @@ struct MuTronPedalTests {
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: MuTronPedal = MuTronPedal(
|
||||
let pedal: MutantPedal = MutantPedal(
|
||||
inputBus: srcBus.index,
|
||||
outputBus: dstBus.index
|
||||
)
|
||||
@@ -96,27 +96,27 @@ struct MuTronPedalTests {
|
||||
}
|
||||
|
||||
@Test func presetRoundTripPreservesSwitchPositions() throws {
|
||||
let pedal: MuTronPedal = MuTronPedal()
|
||||
let pedal: MutantPedal = MutantPedal()
|
||||
pedal.mode = 2.0 // highpass
|
||||
pedal.direction = 0.0 // down
|
||||
|
||||
let state: PedalState = pedal.captureState()
|
||||
#expect(state.switchValues == [0.0, 2.0]) // [direction, mode]
|
||||
|
||||
let restored: MuTronPedal = MuTronPedal()
|
||||
let restored: MutantPedal = MutantPedal()
|
||||
restored.applyState(state)
|
||||
#expect(restored.mode == 2.0)
|
||||
#expect(restored.direction == 0.0)
|
||||
}
|
||||
|
||||
@Test func exposesSensitivityAndResonanceKnobs() throws {
|
||||
let pedal: MuTronPedal = MuTronPedal()
|
||||
let pedal: MutantPedal = MutantPedal()
|
||||
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(labels == ["Sensitivity", "Resonance"])
|
||||
}
|
||||
|
||||
@Test func exposesTwoStateSweepAndThreeStateModeSwitches() throws {
|
||||
let pedal: MuTronPedal = MuTronPedal()
|
||||
let pedal: MutantPedal = MutantPedal()
|
||||
let switches: [PedalSwitch] = pedal.effectSwitches
|
||||
#expect(switches.map { $0.label } == ["Sweep", "Mode"])
|
||||
// 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 pedal: MuTronPedal = MuTronPedal(
|
||||
let pedal: MutantPedal = MutantPedal(
|
||||
inputBus: srcBus.index,
|
||||
outputBus: dstBus.index
|
||||
)
|
||||
@@ -423,9 +423,12 @@ struct PresetTests {
|
||||
// Apply the captured state (lightweight recall — no graph rebuild).
|
||||
sg.applyState(captured)
|
||||
|
||||
// threshold is the first effectKnob; applyState calls knob.node.update(value)
|
||||
// which sets the UIParamNode. The UIParamNode.value should now reflect the restored value.
|
||||
let thresholdKnobValue: Double = compressor.knobs[0].node.value
|
||||
// applyState calls knob.node.update(value) on each knob; the Threshold knob's
|
||||
// UIParamNode.value should now reflect the restored value. Look up by label rather
|
||||
// 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(
|
||||
abs(thresholdKnobValue - knownThreshold) < 1e-9,
|
||||
"threshold knob should be \(knownThreshold) after applyState, got \(thresholdKnobValue)"
|
||||
|
||||
@@ -55,11 +55,11 @@ struct ShoeGazeMultiBoardTests {
|
||||
let shoeGazeA: ShoeGaze = ShoeGaze(engine: engineA)
|
||||
let board1: PedalBoard = try shoeGazeA.addBoard()
|
||||
board1.label = "Lead"
|
||||
try shoeGazeA.appendPedal(type: "Overdrive", to: board1)
|
||||
try shoeGazeA.appendPedal(.overdrive, to: board1)
|
||||
try shoeGazeA.finalizeBoard(board1)
|
||||
let board2: PedalBoard = try shoeGazeA.addBoard()
|
||||
board2.label = "Clean"
|
||||
try shoeGazeA.appendPedal(type: "Graphic EQ", to: board2)
|
||||
try shoeGazeA.appendPedal(.graphicEQ, to: board2)
|
||||
try shoeGazeA.finalizeBoard(board2)
|
||||
|
||||
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 {
|
||||
let renderDuration: Double = 0.05
|
||||
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