Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/BritishAmpPedal.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

70 lines
3.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.
// BritishAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// British-voiced amp (mid-forward crunch) with a **Presence** lift and a **Master** volume.
///
/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. The
/// Master control drives the power-amp stage (via ``AmpVoicePedal/powerAmpDriveInput``), so raising
/// it adds power-amp saturation — turn `Gain` up for preamp grind and use `Master` to set how hard
/// that hits the power amp, the classic master-volume interplay.
public final class BritishAmpPedal: AmpVoicePedal {
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
@UIParam public var presence: Double = 0.4
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`]. The
/// default maps to ≈1.5 drive — the amp's prior fixed power-amp drive — so the out-of-box tone
/// is unchanged; turn it up for power-amp saturation.
@UIParam public var master: Double = 0.22
private let presenceFreqHz: Double = 4500.0
private let presenceMaxGainDb: Double = 8.0
private let shelfSlope: Double = 0.7
/// Power-amp drive at `master = 0` — barely driven (cleanest power stage).
private let masterMinDrive: Double = 0.5
/// Power-amp drive at `master = 1` — hard into power-amp saturation.
private let masterMaxDrive: Double = 5.0
public override var toneStackModel: ToneStackModel { .marshall }
public override var summaryText: String {
"British crunch — forward mids and bite, with Presence and a Master volume."
}
public override var signatureKnobs: [PedalKnob] {
[
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
PedalKnob(label: "Master", node: $master, range: signatureRange),
]
}
/// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`.
public override var powerAmpDriveInput: any ValidGeneratorInput {
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
}
/// 4× oversampling on the power-amp stage — Master can drive it well past the fixed value used
/// by the non-master amps, so the extra anti-alias headroom keeps the added harmonics clean.
public override var powerAmpOversample: Int { 4 }
/// Creates a British 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: "British", inputBus: inputBus, outputBus: outputBus)
gain = 7.77 // crunch-leaning default
cab = 1.0 // default to the British 4×12 cab
}
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let gainDB: LinLin.Audio = LinLin.Audio(
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: shelfSlope)
}
}