f9ddd6b160
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>
129 lines
5.8 KiB
Swift
129 lines
5.8 KiB
Swift
// AnaheimAmpPedal.swift
|
||
// Lyrebird
|
||
//
|
||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
import LyrebirdSynth
|
||
import LyrebirdUI
|
||
|
||
/// American **hybrid combo** — the Anaheim voice (Music Man lineage): a solid-state-flavoured
|
||
/// preamp into a tube power stage, with huge clean headroom, a **Bright** switch, a **Deep**
|
||
/// low-end switch, and a built-in **Limiter**.
|
||
///
|
||
/// Distinct from the all-tube voices: the preamp stage runs symmetric (grid `bias 0`) — no
|
||
/// even-harmonic tube warmth, for the cleaner/more clinical solid-state character — and a
|
||
/// `LookAheadLimiter` (the amp's onboard limiter) can be switched into the output.
|
||
///
|
||
/// > Note: the aggressive hard-knee solid-state clipping when pushed is approximated here by the
|
||
/// > symmetric preamp + high headroom; a true oversampled hard-clipper is a Lyrebird 1.7.x follow-up.
|
||
public final class AnaheimAmpPedal: AmpVoicePedal {
|
||
|
||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||
@UIParam public var bright: Double = 0.0
|
||
/// Deep switch: `0` = flat, `1` = low-end resonance boost engaged.
|
||
@UIParam public var deep: Double = 0.0
|
||
/// Limiter footswitch: `1` = the built-in output limiter is engaged, `0` = bypassed.
|
||
@UIParam public var limiter: Double = 1.0
|
||
|
||
/// Symmetric preamp bias (solid-state character — no even-harmonic tube warmth).
|
||
private let ssPreampBias: Double = 0.0
|
||
private let brightFreqHz: Double = 3200.0
|
||
private let brightMaxGainDb: Double = 6.0
|
||
private let brightSlope: Double = 1.0
|
||
private let deepFreqHz: Double = 100.0
|
||
private let deepMaxGainDb: Double = 6.0
|
||
private let deepSlope: Double = 0.7
|
||
/// Limiter ceiling when engaged — below full scale, so it actually tames peaks (a peak
|
||
/// compressor, the amp's built-in limiter); when bypassed the ceiling is raised so it never acts.
|
||
private let limiterOnCeiling: Double = 0.5
|
||
private let limiterOffCeiling: Double = 10.0
|
||
private let limiterLookAhead: Double = 0.005
|
||
private let limiterRelease: Double = 0.050
|
||
|
||
public override var toneStackModel: ToneStackModel { .fender }
|
||
public override var summaryText: String {
|
||
"American hybrid combo — solid-state-flavoured clean, huge headroom, Bright / Deep / Limiter."
|
||
}
|
||
|
||
public override var effectSwitches: [PedalSwitch] {
|
||
[
|
||
PedalSwitch(
|
||
label: "Bright",
|
||
node: $bright,
|
||
options: [
|
||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||
]
|
||
),
|
||
PedalSwitch(
|
||
label: "Deep",
|
||
node: $deep,
|
||
options: [
|
||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||
]
|
||
),
|
||
PedalSwitch(
|
||
label: "Limiter",
|
||
node: $limiter,
|
||
options: [
|
||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||
]
|
||
),
|
||
]
|
||
}
|
||
|
||
/// Wider card for the three switches.
|
||
public override var widthUnits: Int { 3 }
|
||
|
||
/// Creates an Anaheim 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: "Anaheim", inputBus: inputBus, outputBus: outputBus)
|
||
gain = 4.23 // huge clean headroom
|
||
cab = 0.0 // American 1×12
|
||
}
|
||
|
||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off).
|
||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb
|
||
return RBJHighShelf.Audio(
|
||
input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope)
|
||
}
|
||
|
||
/// Symmetric (solid-state-flavoured) preamp stage — `bias 0`, no even-harmonic tube warmth.
|
||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: ssPreampBias, oversample: preampOversample)
|
||
}
|
||
|
||
/// The built-in limiter, gated by the Limiter switch — placed *before* the power-amp stage (so
|
||
/// it limits the driven preamp/tone-stack signal, which can exceed the ceiling, rather than a
|
||
/// signal the power-amp `tanh` has already bounded). Off raises the ceiling so it never acts.
|
||
///
|
||
/// > Note: the `LookAheadLimiter` stays in the chain in both states (only its ceiling changes),
|
||
/// > so the amp carries its ~5 ms look-ahead latency whether or not the Limiter is engaged —
|
||
/// > a constant, not something the switch toggles.
|
||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let ceiling: LinLin.Audio = LinLin.Audio(
|
||
$limiter, inLo: 0.0, inHi: 1.0, outLo: limiterOffCeiling, outHi: limiterOnCeiling)
|
||
return LookAheadLimiter(
|
||
in: signal,
|
||
maxAmplitude: ceiling,
|
||
lookAheadTime: limiterLookAhead,
|
||
releaseTime: limiterRelease,
|
||
sampleRate: sampleRate
|
||
)
|
||
}
|
||
|
||
/// Deep low-shelf (gated by the Deep switch), post power amp.
|
||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let deepGainDb: any ValidGeneratorInput = $deep * deepMaxGainDb
|
||
return RBJLowShelf.Audio(input: signal, freq: deepFreqHz, gain: deepGainDb, slope: deepSlope)
|
||
}
|
||
}
|