Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/CitrusAmpPedal.swift
T
josh f9ddd6b160 feat(amp): Gain/Drive become a 1–11 dial with a musical taper
Every amp's Gain (and the boutique/drive-channel Drive) is now a 1–11 dial —
yes, it goes to eleven — instead of the raw 1–30 tube-drive number.

- New AmpVoicePedal.taperedDrive(_:) maps the 1–11 dial to the 1–30 tube drive
  through an exponential LinExp taper, so 1 is nearly clean, 11 is full
  saturation, and the useful grind spreads across the dial (fine at the bottom,
  steep at the top) rather than bunching near the low end.
- Wired into the base preampStage and every override that feeds a drive:
  Boutique / Fullerton Drive / Jazz Clean / British Dual (Drive channel),
  Anaheim (SS preamp), British Master (cascaded stage).
- gainRange / driveRange → 1...11; every amp's default gain/drive reconverted
  from drive-space to the equivalent dial value (dial = 1 + 10·ln(drive)/ln(30)),
  so each amp's shipped voicing is preserved.
- No preset migration (nothing shipped — per product owner); all knob work
  stays within ShoeGaze (no core Lyrebird change).
- Tests updated to the 1–11 scale; added range + exponential-taper assertions.

671 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-04 10:42:35 -07:00

56 lines
2.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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)
}
}