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,111 @@
// CompressorPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Compressor pedal: feed-forward dynamic range compressor.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → 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.
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - threshold: 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.
/// Range `[1, 20]`. Defaults to `4.0`.
public final class CompressorPedal: Pedal {
// MARK: - Parameters
/// Compression threshold in dB. Range [-40, 0].
@UIParam public var threshold: Double = -12.0
/// Compression ratio. Range [1, 20].
@UIParam public var ratio: Double = 4.0
// MARK: - Constants
/// Default wet/dry blend — fully wet; the compressor is inserted in-line.
private static let defaultMix: Double = 1.0
/// Attack time constant in seconds — time to reach full gain reduction on a transient.
private let attackTime: Double = 0.01
/// Release time constant in seconds — time for gain to recover after level drops below threshold.
private let releaseTime: Double = 0.1
/// Soft-knee width in dB. Zero = hard knee for maximum punch.
private let kneeWidth: Double = 0.0
/// Makeup gain in dB applied after compression to restore perceived loudness.
private let makeupGainDB: Double = 4.0
// MARK: - UI knobs
/// Threshold knob range in dB.
private let thresholdRange: ClosedRange<Double> = -40.0 ... 0.0
/// Ratio knob range.
private let ratioRange: ClosedRange<Double> = 1.0 ... 20.0
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
PedalKnob(label: "Ratio", node: $ratio, range: ratioRange),
]
}
// MARK: - Init
/// Creates a compressor pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Compressor",
inputBus: inputBus,
outputBus: outputBus,
initialMix: CompressorPedal.defaultMix
)
}
// MARK: - Effect
/// 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,
threshold: $threshold,
ratio: $ratio,
attack: attackTime,
release: releaseTime,
kneeWidth: kneeWidth,
makeupGain: makeupGainDB
)
}
}
@@ -0,0 +1,103 @@
// DelayPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Delay pedal: feedback delay line.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → DelayLineFeedback(delay: time, decayTime: feedback) → mono wet out
/// ```
///
/// `effect` returns the pure wet delay signal. The base `Pedal` class handles
/// wet/dry blending via `mix`, so do not pre-blend inside `effect`.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - time: Delay time in seconds. Range `[0.01, 1.5]`. Defaults to `0.25`.
/// - feedback: Feedback amount expressed as decay time in seconds — the time
/// for echoes to fall to `targetAmp` (−60 dB). Longer values produce more
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
public final class DelayPedal: Pedal {
// MARK: - Parameters
/// Delay time in seconds. Range [0.01, 1.5].
@UIParam public var time: Double = 0.25
/// Feedback decay time in seconds (time to reach −60 dB amplitude).
@UIParam public var feedback: Double = 1.0
// MARK: - Constants
/// Maximum supported delay time in seconds. Sizes the delay line buffer at init.
private let maxDelayTime: Double = 1.5
/// Amplitude target for the `decayTime` calculation (−60 dB).
private let targetAmp: Double = 0.001
/// Default wet/dry blend — a partial mix so dry signal and echoes coexist.
private static let defaultMix: Double = 0.35
// MARK: - UI knobs
/// Delay-time knob range in seconds.
private let timeRange: ClosedRange<Double> = 0.01 ... 1.5
/// Feedback (decay-time) knob range in seconds.
private let feedbackRange: ClosedRange<Double> = 0.05 ... 6.0
// MARK: - Init
/// Creates a delay pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Delay",
inputBus: inputBus,
outputBus: outputBus,
initialMix: DelayPedal.defaultMix
)
}
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Time", node: $time, range: timeRange),
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
]
}
// MARK: - Effect
/// Applies a feedback delay line. Returns the pure wet (delayed) signal.
///
/// The base class `Pedal` mixes this with the dry signal via the `mix` parameter.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Pure wet mono delayed output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
DelayLineFeedback(
input: dry,
maxDelay: maxDelayTime,
delay: $time,
decayTime: $feedback,
targetAmp: targetAmp,
sampleRate: sampleRate,
interpolation: .linear
)
}
}
@@ -0,0 +1,112 @@
// FuzzPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Fuzz pedal: high-gain `tanh` saturation followed by a tonal low-pass filter.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → (× fuzz drive) → Tanh → RBJLowPass(freq: tone, q: 0.707) → mono out
/// ```
///
/// The `fuzz` knob is a pre-gain (drive): it multiplies the input hard before the
/// `tanh` saturator, which squares the waveform off into the thick, sustaining fuzz
/// texture. Because `tanh` saturates toward ±1, the output level stays roughly constant
/// as `fuzz` rises — more drive means more grit and sustain, never less signal. A tone
/// filter then rolls off high-frequency harshness.
///
/// > Note: This deliberately differs from the earlier crossover-distortion model, where
/// > the knob set a silent dead-zone width and large values muted quiet signals.
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - fuzz: Pre-gain drive into the `tanh` saturator. Higher = more saturation and
/// sustain. Range `[1, 60]`. Defaults to `20.0`.
/// - tone: Low-pass tone cutoff in Hz. Roll off high-frequency fuzz harshness.
/// Range `[200, 8000]` Hz. Defaults to `3500.0`.
public final class FuzzPedal: Pedal {
// MARK: - Parameters
/// Pre-gain drive into the saturator. Range [1, 60]; higher = more fuzz.
@UIParam public var fuzz: Double = 20.0
/// Tone filter cutoff frequency in Hz. Range [200, 8000].
@UIParam public var tone: Double = 3500.0
// MARK: - Constants
/// Default wet/dry blend — fully wet so fuzz completely replaces dry signal.
private static let defaultMix: Double = 1.0
/// Q factor for the tone low-pass filter. Butterworth response (no resonant peak).
private let toneQ: Double = 0.707
/// Output trim applied after the `tanh` saturator so the fuzz sits at a sane level
/// relative to the other pedals (`tanh` output is roughly ±1).
private let outputTrim: Double = 0.6
// MARK: - UI knobs
/// Fuzz knob range (saturator pre-gain / drive).
private let fuzzRange: ClosedRange<Double> = 1.0 ... 60.0
/// Tone knob range in Hz (low-pass cutoff).
private let toneRange: ClosedRange<Double> = 200.0 ... 8000.0
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Fuzz", node: $fuzz, range: fuzzRange),
PedalKnob(label: "Tone", node: $tone, range: toneRange),
]
}
// MARK: - Init
/// Creates a fuzz pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Fuzz",
inputBus: inputBus,
outputBus: outputBus,
initialMix: FuzzPedal.defaultMix
)
}
// MARK: - Effect
/// Drives the input hard into a `tanh` saturator, then applies a tonal low-pass.
///
/// Output is mono.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Fuzzed and tone-shaped mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Pre-gain the signal hard, then saturate. `tanh` squares the waveform off as the
// drive rises while keeping the level bounded — the hallmark of a fuzz.
let driven: any ValidGeneratorInput = dry * $fuzz
let saturated: Tanh.Audio = Tanh.Audio(driven, mul: outputTrim)
return RBJLowPass.Audio(
input: saturated,
freq: $tone,
q: toneQ
)
}
}
@@ -0,0 +1,121 @@
// ModulationPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Modulation pedal: stereo chorus folded to mono.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → Chorus.Audio(mix: 1.0, rate:, depth:) → stereo (2 ch)
/// → SumChannels.Audio(mul: 0.5) → mono
/// ```
///
/// `Chorus.Audio` has a built-in `mix` parameter that blends dry+wet internally.
/// Here it is set to `1.0` (fully wet) so the base `Pedal` class handles dry/wet
/// blending uniformly via its own `mix` parameter.
///
/// The stereo output from `Chorus` is summed to mono with a ×0.5 gain to compensate
/// for channel doubling.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - rate: Chorus LFO frequency in Hz. Range `[0.1, 10]`. Defaults to `1.5`.
/// - depth: Chorus modulation depth as a fraction of the delay time in [0, 1].
/// Smaller values (0.001–0.01) produce classic chorus width. Defaults to `0.002`.
public final class ModulationPedal: Pedal {
// MARK: - Parameters
/// Chorus LFO rate in Hz. Range [0.1, 10].
@UIParam public var rate: Double = 1.5
/// Chorus modulation depth as a fraction of delay time in [0, 1].
@UIParam public var depth: Double = 0.002
// MARK: - Constants
/// Chorus `mix` value. Set to 1.0 (fully wet) so the base `Pedal` handles
/// the dry/wet blend via its own `mix` parameter.
private let chorusWetMix: Double = 1.0
/// Base delay time for the chorus in seconds.
private let chorusDelayTime: Double = 0.025
/// Maximum delay time that the chorus delay line is allocated for.
private let chorusMaxDelayTime: Double = 0.1
/// Gain applied to the summed stereo→mono output to compensate for channel doubling.
private let stereoSumGain: Double = 0.5
/// Default wet/dry blend — an even mix for classic chorus width.
private static let defaultMix: Double = 0.5
// MARK: - UI knobs
/// Rate knob range in Hz (chorus LFO frequency).
private let rateRange: ClosedRange<Double> = 0.1 ... 8.0
/// Depth knob range (fraction of delay time).
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.01
// MARK: - Init
/// Creates a modulation (chorus) pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Modulation",
inputBus: inputBus,
outputBus: outputBus,
initialMix: ModulationPedal.defaultMix
)
}
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Rate", node: $rate, range: rateRange),
PedalKnob(label: "Depth", node: $depth, range: depthRange),
]
}
// MARK: - Effect
/// Applies stereo chorus and folds the result to mono.
///
/// Returns a mono wet signal. The base `Pedal` class mixes this with the
/// dry signal according to the `mix` parameter.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Wet mono chorus output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Chorus.Audio produces a 2-channel stereo output.
let stereoChorus: Chorus.Audio = Chorus.Audio(
input: dry,
delayTime: chorusDelayTime,
depth: $depth,
rate: $rate,
mix: chorusWetMix,
sampleRate: sampleRate,
maxDelayTime: chorusMaxDelayTime
)
// Sum stereo → mono with ×0.5 to avoid level doubling.
return SumChannels.Audio(
input: stereoChorus,
mul: stereoSumGain
)
}
}
@@ -0,0 +1,88 @@
// OverdrivePedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Overdrive pedal: soft-clipping saturation followed by a tonal low-pass filter.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → SoftClip(drive:) → RBJLowPass(freq: tone, q: 0.707) → mono out
/// ```
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - drive: Saturation amount. Higher values push more of the signal into soft-clip
/// territory. Range `[1, 20]`. Defaults to `4.0`.
/// - tone: Low-pass tone cutoff in Hz. Roll off high-frequency harshness.
/// Range `(0, 20000]`. Defaults to `4000.0`.
public final class OverdrivePedal: Pedal {
// MARK: - Parameters
/// Saturation drive amount. Range [1, 20]; higher = more clipping.
@UIParam public var drive: Double = 4.0
/// Tone filter cutoff frequency in Hz. Range (0, 20000].
@UIParam public var tone: Double = 4000.0
// MARK: - Constants
/// Q factor for the tone low-pass filter. Butterworth response (no resonant peak).
private let toneQ: Double = 0.707
// MARK: - Init
/// Creates an overdrive pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(name: "Overdrive", inputBus: inputBus, outputBus: outputBus)
}
// MARK: - UI knobs
/// Drive knob range (waveshaper input gain).
private let driveRange: ClosedRange<Double> = 1.0 ... 20.0
/// Tone knob range in Hz (low-pass cutoff).
private let toneRange: ClosedRange<Double> = 200.0 ... 8000.0
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Drive", node: $drive, range: driveRange),
PedalKnob(label: "Tone", node: $tone, range: toneRange),
]
}
// MARK: - Effect
/// Applies soft-clip saturation followed by a tonal low-pass filter.
///
/// Output is mono.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Saturated and tone-shaped mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let saturated: SoftClip.Audio = SoftClip.Audio(dry, drive: $drive)
return RBJLowPass.Audio(
input: saturated,
freq: $tone,
q: toneQ
)
}
}
@@ -0,0 +1,113 @@
// PhaserPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Phaser pedal: cascaded all-pass filter swept by a sine LFO.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → Phaser.Audio(rate:, feedback:, mix: 1.0) → mono out
/// ```
///
/// `Phaser.Audio` is mono-in / mono-out. Its internal `mix` is set to `1.0` (fully
/// wet) so the base `Pedal` class handles the dry/wet blend uniformly via its own
/// `mix` parameter.
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - rate: LFO sweep rate in Hz. Range `[0.05, 5.0]`. Defaults to `0.5`.
/// - feedback: Feedback gain in `[0, 0.9]`. Higher values deepen the notches.
/// Range `[0.0, 0.9]`. Defaults to `0.5`.
public final class PhaserPedal: Pedal {
// MARK: - Parameters
/// LFO sweep rate in Hz. Range [0.05, 5.0].
@UIParam public var rate: Double = 0.5
/// Feedback gain in [0, 0.9]. Deepens the all-pass notches.
@UIParam public var feedback: Double = 0.5
// MARK: - Constants
/// Default wet/dry blend — even mix for classic phaser comb-filter sweep.
private static let defaultMix: Double = 0.5
/// Internal `Phaser.Audio` mix — set to 1.0 so the base `Pedal` handles dry/wet.
private let phaserInternalMix: Double = 1.0
/// LFO depth fraction — sweeps the all-pass coefficient across its full range.
private let phaserDepth: Double = 0.9
/// Center frequency in Hz for the all-pass coefficient sweep.
private let phaserCenterFreq: Double = 800.0
/// Number of cascaded all-pass stages. Must be 4, 6, or 8.
private let phaserStages: Int = 6
// MARK: - UI knobs
/// Rate knob range in Hz (LFO sweep frequency).
private let rateRange: ClosedRange<Double> = 0.05 ... 5.0
/// Feedback knob range (all-pass feedback gain).
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.9
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Rate", node: $rate, range: rateRange),
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
]
}
// MARK: - Init
/// Creates a phaser pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Phaser",
inputBus: inputBus,
outputBus: outputBus,
initialMix: PhaserPedal.defaultMix
)
}
// MARK: - Effect
/// Applies cascaded all-pass phasing and returns the fully-wet signal.
///
/// `Phaser.Audio` is mono-in / mono-out. The base `Pedal` class mixes this with
/// the dry signal according to the `mix` parameter.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Wet mono phaser output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
Phaser.Audio(
input: dry,
rate: $rate,
depth: phaserDepth,
centerFreq: phaserCenterFreq,
feedback: $feedback,
stages: phaserStages,
mix: phaserInternalMix,
sampleRate: sampleRate
)
}
}
@@ -0,0 +1,110 @@
// ReverbPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Reverb pedal: Freeverb stereo reverb folded to mono.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → FreeVerb.Audio(mix: 1.0, roomSize:, damping:) → stereo (2 ch)
/// → SumChannels.Audio(mul: 0.5) → mono (fold + compensate)
/// ```
///
/// `FreeVerb` is driven at `mix: 1.0` so it produces a pure wet signal; the base
/// `Pedal` class handles the wet/dry blend via its `mix` parameter. The stereo
/// output from `FreeVerb` is summed to mono with a ×0.5 gain to compensate for
/// the channel doubling.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - roomSize: Room size in [0, 1]. Larger values produce longer, denser tails.
/// Defaults to `0.6`.
/// - damping: High-frequency damping in [0, 1]. Higher values produce darker,
/// shorter tails. Defaults to `0.5`.
public final class ReverbPedal: Pedal {
// MARK: - Parameters
/// Room size in [0, 1]. Larger = longer reverb tail.
@UIParam public var roomSize: Double = 0.6
/// High-frequency damping in [0, 1]. Higher = darker tail.
@UIParam public var damping: Double = 0.5
// MARK: - Constants
/// FreeVerb mix value. Set to 1.0 so FreeVerb produces pure wet output;
/// the base Pedal handles dry/wet blending via its own `mix` parameter.
private let freeVerbWetMix: Double = 1.0
/// Gain applied to the summed stereo→mono fold to compensate for the doubling
/// of energy when two channels are added together.
private let stereoSumGain: Double = 0.5
/// Default wet/dry blend — a partial mix so the dry signal stays up front.
private static let defaultMix: Double = 0.3
// MARK: - UI knobs
/// Room-size and damping knob range (both normalised [0, 1]).
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
// MARK: - Init
/// Creates a reverb pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Reverb",
inputBus: inputBus,
outputBus: outputBus,
initialMix: ReverbPedal.defaultMix
)
}
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Room", node: $roomSize, range: normalizedRange),
PedalKnob(label: "Damp", node: $damping, range: normalizedRange),
]
}
// MARK: - Effect
/// Applies Freeverb stereo reverb and folds the result to mono.
///
/// Returns a mono wet signal. The base `Pedal` class mixes this with the
/// dry signal according to the `mix` parameter.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Wet mono reverberated output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// FreeVerb produces a 2-channel stereo output.
let stereoVerb: FreeVerb.Audio = FreeVerb.Audio(
source: dry,
roomSize: $roomSize,
damping: $damping,
mix: freeVerbWetMix,
sampleRate: sampleRate
)
// Sum stereo → mono with ×0.5 to avoid level doubling.
return SumChannels.Audio(
input: stereoVerb,
mul: stereoSumGain
)
}
}
@@ -0,0 +1,110 @@
// TremoloPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Tremolo pedal: amplitude modulation via a unipolar sine LFO.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry × OscSin(freq: rate, mul: depth×0.5, add: 1−depth×0.5) → mono out
/// ```
///
/// The LFO oscillates between `[1 − depth, 1]` so full depth produces silence-to-unity
/// swells while zero depth leaves the signal unmodified. The result is a gain effect —
/// `defaultMix` is `1.0` (fully wet) so the base `Pedal` passes the tremolo signal through
/// unchanged; the `mix` knob can soften the wobble effect.
///
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
///
/// ## Parameters
///
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
///
/// - Parameters:
/// - rate: LFO modulation rate in Hz. Range `[0.5, 12]`. Defaults to `4.0`.
/// - depth: Modulation depth in `[0, 1]`. `0` = no modulation, `1` = full tremolo.
/// Defaults to `0.7`.
public final class TremoloPedal: Pedal {
// MARK: - Parameters
/// LFO rate in Hz. Range [0.5, 12].
@UIParam public var rate: Double = 4.0
/// Modulation depth in [0, 1].
@UIParam public var depth: Double = 0.7
// MARK: - Constants
/// Default wet/dry blend — fully wet; tremolo is a gain effect so dry/wet
/// blending does not apply in the same way as a parallel effect.
private static let defaultMix: Double = 1.0
/// Scale factor applied to `depth` to compute the LFO half-amplitude swing.
/// At full depth the LFO oscillates over half the normalised range, so the
/// peak gain is 1.0 and the trough is `1 − depth`.
private let lfoDepthScale: Double = 0.5
// MARK: - UI knobs
/// Rate knob range in Hz (LFO frequency).
private let rateRange: ClosedRange<Double> = 0.5 ... 12.0
/// Depth knob range (modulation fraction).
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Rate", node: $rate, range: rateRange),
PedalKnob(label: "Depth", node: $depth, range: depthRange),
]
}
// MARK: - Init
/// Creates a tremolo pedal.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
public init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: "Tremolo",
inputBus: inputBus,
outputBus: outputBus,
initialMix: TremoloPedal.defaultMix
)
}
// MARK: - Effect
/// Multiplies the dry signal by a unipolar sine LFO.
///
/// The LFO range is `[1 − depth, 1]`. At `depth = 0` the multiplier is constant 1.0;
/// at `depth = 1` it swings between `0.0` and `1.0`.
///
/// Output is mono.
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: Amplitude-modulated mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// lfoScale = depth × lfoDepthScale → LFO swing half-amplitude
// lfoOffset = 1 − depth × lfoDepthScale → LFO centre, so peak = 1.0, trough = 1 − depth
let lfoScale: any ValidGeneratorInput = $depth * lfoDepthScale
let lfoOffset: any ValidGeneratorInput = 1.0 - ($depth * lfoDepthScale)
let lfo: OscSin.Audio = OscSin.Audio(
freq: $rate,
mul: lfoScale,
add: lfoOffset
)
return dry * lfo
}
}