// SpringReverbPedal.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import LyrebirdSynth import LyrebirdUI /// Spring reverb pedal: a Schroeder spring-tank, the classic surf/amp reverb voice. /// /// Runs `SpringReverb` in mono (`stereo: false`) so no channel fold is needed. The generator is /// driven at `mix: 1.0` (pure wet); the base `Pedal` handles the wet/dry blend via its own `mix`. /// /// ## Parameters /// /// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus: /// /// - Parameters: /// - decay: Tail length (RT60) in seconds, in [0.1, 5]. Defaults to `2`. /// - tension: Spring dispersion/chirp in [0, 1] — the boingy spring character. Defaults to `0.5`. /// - damp: High-frequency damping in [0, 1]. Higher = darker. Defaults to `0.3`. public final class SpringReverbPedal: Pedal { /// One-line description shown in the picker and info panel. public override var summary: String { "Vintage spring-tank reverb — drippy, boingy surf and amp-style ambience." } // MARK: - Parameters /// Tail length (RT60) in seconds, in [0.1, 5]. @UIParam public var decay: Double = 2.0 /// Spring dispersion/chirp in [0, 1] — the boingy spring character. @UIParam public var tension: Double = 0.5 /// High-frequency damping in [0, 1]. Higher = darker. @UIParam public var damp: Double = 0.3 // MARK: - Constants /// Spring mix value. `1.0` = pure wet; the base `Pedal` handles dry/wet blending. private let springWetMix: Double = 1.0 /// Default wet/dry blend — a partial mix so the dry signal stays up front. private static let defaultMix: Double = 0.3 // MARK: - Ranges private let decayRange: ClosedRange = 0.1 ... 5.0 private let normalizedRange: ClosedRange = 0.0 ... 1.0 // MARK: - UI knobs public override var effectKnobs: [PedalKnob] { [ PedalKnob(label: "Decay", node: $decay, range: decayRange), PedalKnob(label: "Tension", node: $tension, range: normalizedRange), PedalKnob(label: "Damp", node: $damp, range: normalizedRange), ] } // MARK: - Init /// Creates a spring 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: "Spring Reverb", inputBus: inputBus, outputBus: outputBus, initialMix: SpringReverbPedal.defaultMix ) } // MARK: - Effect public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput { // Mono spring tank — no channel fold needed. SpringReverb.Audio( input: dry, decay: $decay, tension: $tension, damping: $damp, mix: springWetMix, sampleRate: sampleRate, stereo: false ) } }