1.0 release

This commit is contained in:
2026-06-21 12:25:18 -07:00
parent b7973cba9a
commit 6f55615d7b
81 changed files with 10968 additions and 0 deletions
@@ -0,0 +1,48 @@
// HardwareInputPassThrough.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
/// Internal synthesizer that copies one hardware input bus to a board head bus.
///
/// When `ShoeGaze` is configured with `.liveInput`, a `HardwareInputPassThrough` is
/// added to the engine before the first pedal. It reads the hardware input bus at
/// `inputBusIndex` and writes its samples to the board's head bus at `outputBusIndex`.
/// This ensures the first pedal reads from a user-space bus that the board controls,
/// rather than from the raw hardware input bus directly.
///
/// - Note: The synthesizer must be removed from the engine before the board's
/// `teardown()` releases the head bus back to the allocator.
final class HardwareInputPassThrough: SynthesizerBase {
// MARK: - Routing
/// Index of the hardware input bus to read from (typically `engine.numOutputChannels`).
private let inputBusIndex: Int
/// Index of the board head bus to write to.
private let outputBusIndex: Int
// MARK: - Init
/// Creates a pass-through that copies `inputBusIndex` to `outputBusIndex`.
///
/// - Parameters:
/// - inputBusIndex: Hardware input bus index to read from.
/// Typically `engine.numOutputChannels` for the first input channel.
/// - 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,52 @@
// InputSource.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
/// Selects how the pedalboard's head bus is fed with audio.
///
/// - `.testLoop`: A synthesized test tone (`TestLoopSource`) writes to the head bus.
/// Suitable for testing the pedalboard with no hardware connected.
/// - `.liveInput(channel:)`: A hardware input channel feeds the head bus. `channel` is
/// the zero-based hardware input channel index (`0` = first input). It maps to engine
/// audio-bus index `numOutputChannels + channel` (hardware input buses follow the
/// output buses). Requires the engine to be created with `numInputChannels > channel`.
public enum InputSource {
/// Synthesized test signal — no hardware required.
case testLoop
/// Live hardware input from the given zero-based input channel. The engine must be
/// created with `numInputChannels > channel`.
case liveInput(channel: Int)
}
/// Validates a `.liveInput` channel against the engine and returns the engine audio-bus
/// index of that hardware input channel.
///
/// Hardware input buses occupy indices `numOutputChannels ..< (numOutputChannels +
/// numInputChannels)`, so input channel `channel` lives at `numOutputChannels + channel`.
///
/// - Parameters:
/// - channel: Zero-based hardware input channel index.
/// - engine: The engine whose bus layout is queried.
/// - Returns: The audio-bus index to read the requested input channel from.
/// - Throws:
/// - `ShoeGazeError.liveInputRequiresInputChannels` if the engine has no input channels.
/// - `ShoeGazeError.inputChannelOutOfRange` if `channel` is negative or `>= numInputChannels`.
internal func liveInputBusIndex(
channel: Int,
engine: SynthesisEngine
) throws -> Int {
guard engine.numInputChannels > 0 else {
throw ShoeGazeError.liveInputRequiresInputChannels
}
guard channel >= 0, channel < engine.numInputChannels else {
throw ShoeGazeError.inputChannelOutOfRange(
requested: channel,
available: engine.numInputChannels
)
}
return engine.numOutputChannels + channel
}
@@ -0,0 +1,76 @@
// TestLoopSource.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A synthesized test signal source that writes to a target audio bus.
///
/// Produces two detuned sine oscillators at 110 Hz and 165 Hz — an approximation
/// of a guitar's A2 and E3 strings — with a slow amplitude envelope driven by a
/// low-frequency sine LFO. This makes the board audible immediately without any
/// hardware connection.
///
/// The output is written to `targetBus` so downstream pedals read it from that bus.
/// `TestLoopSource` should be added to the engine **before** the first pedal in the
/// chain to ensure signal-order correctness (source evaluates first).
///
/// ## Parameters
///
/// - Parameters:
/// - targetBus: Audio bus index to write the test signal to. Typically the
/// pedalboard's head bus index.
/// - amplitude: Output amplitude in [0, 1]. Defaults to `0.25`.
public final class TestLoopSource: SynthesizerBase {
// MARK: - Parameters
/// Output amplitude in [0, 1].
@UIParam public var amplitude: Double = 0.25
// MARK: - Constants
/// Frequency of the first oscillator in Hz (approximates guitar A2 string).
private let freqA: Double = 110.0
/// Frequency of the second oscillator in Hz (approximates guitar E3 string, slightly detuned).
private let freqB: Double = 165.75
/// LFO frequency in Hz for amplitude modulation (slow tremolo).
private let lfoFreq: Double = 0.5
/// LFO depth as a fraction of base amplitude [0, 1].
private let lfoDepth: Double = 0.3
/// Gain for each individual oscillator before summing. Two oscillators × 0.5 = unity.
private let oscGain: Double = 0.5
// MARK: - Routing
/// The bus this source writes its output to.
private let targetBus: Int
// MARK: - Init
/// Creates a test loop source that writes to `targetBus`.
///
/// - Parameters:
/// - targetBus: Audio bus index to write the synthesized test signal to.
public init(targetBus: Int) {
self.targetBus = targetBus
super.init()
}
// MARK: - Build
public override func build() {
let oscA: OscSin.Audio = OscSin.Audio(freq: freqA, mul: oscGain)
let oscB: OscSin.Audio = OscSin.Audio(freq: freqB, phase: 0.25, mul: oscGain)
let lfo: OscSin.Audio = OscSin.Audio(freq: lfoFreq, mul: lfoDepth, add: 1.0 - lfoDepth)
let signal: any ValidGeneratorInput = (oscA + oscB) * lfo * $amplitude
output(bus: targetBus, source: signal)
}
}