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

69 lines
3.0 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.
// ModernHighGainAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Modern **high-gain rectifier** — the saturated, scooped metal voice: a hot cascaded lead on the
/// Mesa tone stack, with a **Sag** control (power-supply droop/bloom) and a **Tight** switch that
/// firms up the low end.
///
/// A ``BoutiqueAmpPedal`` (Clean/Lead channel, Master, Presence, Depth) voiced on the `.mesa` stack.
/// **Sag** models the power supply drooping under load: an envelope follower on the power-amp signal
/// reduces gain as it gets loud, then recovers slowly — the compression/"bloom" feel of a
/// tube-rectified amp. **Tight** high-passes the input to tighten the low end for fast riffing.
public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
/// Tight switch: `0` = full low end, `1` = low-cut engaged (tight riffing).
@UIParam public var tight: Double = 0.0
/// Tight low-cut: high-pass corner is ~20 Hz (loose, no cut) or `tightFreqHz` (tight).
private let tightLooseFreqHz: Double = 20.0
/// Tight-switch-on high-pass corner in Hz.
private let tightFreqHz: Double = 120.0
/// Tight high-pass Q (Butterworth).
private let tightQ: Double = 0.707
public override var toneStackModel: ToneStackModel { .mesa }
public override var summaryText: String {
"Modern high-gain rectifier — scooped Mesa lead with Sag (power-supply bloom) and a Tight switch."
}
public override var effectSwitches: [PedalSwitch] {
super.effectSwitches + [
PedalSwitch(
label: "Tight",
node: $tight,
options: [
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
]
}
/// Creates a Modern High-Gain 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: "Modern High-Gain", inputBus: inputBus, outputBus: outputBus)
gain = 6.72
drive = 9.50 // hottest lead of the lineup
cab = 1.0 // British 4×12 — tight, aggressive
sag = 0.3 // rectifier bloom on by default (shared power-amp Sag from AmpVoicePedal)
}
/// Tight switch: a pre-preamp high-pass whose corner switches between ~20 Hz (loose, negligible
/// cut) and `tightFreqHz` (tight), firming the low end — live, no rebuild.
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let cutoff: LinLin.Audio = LinLin.Audio(
$tight, inLo: 0.0, inHi: 1.0, outLo: tightLooseFreqHz, outHi: tightFreqHz)
return RBJHighPass.Audio(input: signal, freq: cutoff, q: tightQ)
}
}