// CitrusAmpPedal.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import LyrebirdSynth import LyrebirdUI /// British **mid-forward crunch** — the Citrus voice: a thick, punchy midrange with a single /// **Shape** control that tilts the top end from dark to bright. /// /// A ``AmpVoicePedal`` on the `.marshall` stack with a fixed mid bump (the amp's signature push) /// and a Shape high-shelf whose gain sweeps from cut to boost. public final class CitrusAmpPedal: AmpVoicePedal { /// Shape in [0, 1]: `0` = dark (top cut), `0.5` = flat, `1` = bright (top boost). @UIParam public var shape: Double = 0.5 private let midFreqHz: Double = 800.0 private let midBumpDb: Double = 3.0 private let midQ: Double = 0.8 private let shapeFreqHz: Double = 2600.0 private let shapeMinDb: Double = -6.0 private let shapeMaxDb: Double = 6.0 private let shapeSlope: Double = 0.8 public override var toneStackModel: ToneStackModel { .marshall } public override var summaryText: String { "British mid-forward crunch with a single Shape control (dark ↔ bright top end)." } public override var signatureKnobs: [PedalKnob] { [PedalKnob(label: "Shape", node: $shape, range: signatureRange)] } /// Creates a Citrus amp. /// /// - 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: "Citrus", inputBus: inputBus, outputBus: outputBus) gain = 6.27 cab = 1.0 // British 4×12 } /// A fixed midrange bump (the Citrus push), then the Shape high-shelf tilt. public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { let midded: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio( input: signal, freq: midFreqHz, gain: midBumpDb, q: midQ) let shapeDb: LinLin.Audio = LinLin.Audio( $shape, inLo: 0.0, inHi: 1.0, outLo: shapeMinDb, outHi: shapeMaxDb) return RBJHighShelf.Audio(input: midded, freq: shapeFreqHz, gain: shapeDb, slope: shapeSlope) } }