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>
180 lines
7.9 KiB
Swift
180 lines
7.9 KiB
Swift
// JazzCleanAmpPedal.swift
|
||
// Lyrebird
|
||
//
|
||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
import LyrebirdSynth
|
||
import LyrebirdUI
|
||
|
||
/// Ultra-clean solid-state combo with its signature lush **stereo chorus**, plus spring reverb and
|
||
/// a bright switch — the glassy "jazz clean" platform.
|
||
///
|
||
/// Unlike the mono amp voices, this amp is a ``PedalChannelKind/widener``: the real amp has two
|
||
/// power amps and two speakers fed by a stereo chorus, so it takes the mono guitar input and emits a
|
||
/// genuinely stereo pair. The chorus (mono → stereo) is the stereo splitter — its two taps become
|
||
/// the left and right channels, each then run through its own cabinet + output stage.
|
||
///
|
||
/// Signal path (inside `wideEffect(_:)`):
|
||
/// ```
|
||
/// dry → preCabinetCore (bright → preamp → tone → spring reverb → power amp) [mono]
|
||
/// → Chorus (mono → stereo) [stereo split]
|
||
/// → L: cabinetAndLimit R: cabinetAndLimit [per channel]
|
||
/// ```
|
||
/// A **Chorus** switch models the amp's chorus on/off footswitch: off collapses the chorus to a dry
|
||
/// pass-through (both channels identical), preserving the Rate/Depth settings.
|
||
public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||
|
||
// MARK: - Onboard-effect parameters
|
||
|
||
/// Spring-reverb wet mix in [0, 1].
|
||
@UIParam public var reverb: Double = 0.2
|
||
/// Chorus LFO rate in Hz. Range [0.1, 5.0].
|
||
@UIParam public var chorusRate: Double = 0.8
|
||
/// Chorus depth as a fraction of the base delay time. Kept in the classic-chorus band
|
||
/// (~0.001–0.01) so it adds width without pitch wobble.
|
||
@UIParam public var chorusDepth: Double = 0.005
|
||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||
@UIParam public var bright: Double = 0.0
|
||
/// Chorus footswitch: `1` = chorus engaged (stereo), `0` = bypassed (dry, mono-equivalent).
|
||
@UIParam public var chorusEnabled: Double = 1.0
|
||
/// Drive-channel preamp gain (the onboard distortion). Dial [1, 11], tapered to tube drive.
|
||
@UIParam public var drive: Double = 7.11
|
||
/// Channel select: `0` = Clean, `1` = Distortion (the cascaded onboard-distortion stage).
|
||
@UIParam public var channel: Double = 0.0
|
||
|
||
// MARK: - Constants
|
||
|
||
/// Bright-switch shelf corner in Hz.
|
||
private let brightFreqHz: Double = 3000.0
|
||
/// Bright-switch shelf lift in dB when engaged.
|
||
private let brightMaxGainDb: Double = 5.0
|
||
/// Bright-switch shelf slope.
|
||
private let brightSlope: Double = 0.9
|
||
/// Fixed chorus wet/dry blend when the chorus is engaged (the amp has no chorus-mix knob).
|
||
private let chorusMixValue: Double = 0.5
|
||
|
||
/// Grid bias of the cascaded distortion stage — solid-state-flavoured, near-symmetric.
|
||
private let driveBias: Double = 0.1
|
||
/// Channel-select threshold: `>= this` selects the Distortion channel.
|
||
private let channelThreshold: Double = 0.5
|
||
|
||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||
private let chorusRateRange: ClosedRange<Double> = 0.1 ... 5.0
|
||
private let chorusDepthRange: ClosedRange<Double> = 0.0005 ... 0.015
|
||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||
|
||
// MARK: - Voice configuration
|
||
|
||
public override var toneStackModel: ToneStackModel { .fender }
|
||
public override var summaryText: String {
|
||
"Solid-state clean — lush stereo chorus, spring reverb, a Bright switch, and a Distortion channel."
|
||
}
|
||
public override var signatureKnobs: [PedalKnob] {
|
||
[
|
||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||
PedalKnob(label: "Rate", node: $chorusRate, range: chorusRateRange),
|
||
PedalKnob(label: "Depth", node: $chorusDepth, range: chorusDepthRange),
|
||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||
]
|
||
}
|
||
|
||
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
|
||
public override var channelKind: PedalChannelKind { .widener }
|
||
|
||
/// Wider card for the reverb/chorus knobs plus the Bright and Chorus switches.
|
||
public override var widthUnits: Int { 3 }
|
||
|
||
// MARK: - Init
|
||
|
||
/// Creates a Jazz Clean 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: "Jazz Clean", inputBus: inputBus, outputBus: outputBus)
|
||
gain = 4.23 // clean, low-gain solid-state default
|
||
cab = 6.0 // Full-Range (FRFR) — the hi-fi, least-coloured voice
|
||
}
|
||
|
||
// MARK: - Switches
|
||
|
||
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: "Chorus",
|
||
node: $chorusEnabled,
|
||
options: [
|
||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||
]
|
||
),
|
||
PedalSwitch(
|
||
label: "Channel",
|
||
node: $channel,
|
||
options: [
|
||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||
PedalSwitch.Option(title: "Dist", value: switchOnValue),
|
||
],
|
||
rebuildsOnChange: true
|
||
),
|
||
]
|
||
}
|
||
|
||
/// Clean preamp, plus the onboard-distortion stage on the Distortion channel. The `channel`
|
||
/// value is read at board-build time (the switch is `rebuildsOnChange`), so only the selected
|
||
/// channel's stages exist in the graph.
|
||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||
guard channel >= channelThreshold else { return clean }
|
||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||
}
|
||
|
||
// MARK: - Hooks
|
||
|
||
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
|
||
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)
|
||
}
|
||
|
||
/// Spring reverb inside the mono core (before the stereo chorus split).
|
||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||
}
|
||
|
||
// MARK: - Stereo effect
|
||
|
||
/// Mono amp core → stereo chorus split → per-channel cabinet + output stage.
|
||
///
|
||
/// The `chorusEnabled` footswitch gates the chorus wet mix to `0` when off, so the chorus passes
|
||
/// the dry core to both channels (a mono-equivalent output) while preserving Rate/Depth.
|
||
///
|
||
/// - Parameter dry: Dry mono input signal.
|
||
/// - Returns: The stereo (left, right) amp output.
|
||
public override func wideEffect(
|
||
_ dry: any ValidGeneratorInput
|
||
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||
let core: any ValidGeneratorInput = preCabinetCore(dry)
|
||
let chorusMix: any ValidGeneratorInput = $chorusEnabled * chorusMixValue
|
||
let chorus: Chorus.Audio = Chorus.Audio(
|
||
input: core,
|
||
depth: $chorusDepth,
|
||
rate: $chorusRate,
|
||
mix: chorusMix,
|
||
sampleRate: sampleRate
|
||
)
|
||
return (cabinetAndLimit(chorus.left), cabinetAndLimit(chorus.right))
|
||
}
|
||
}
|