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>
96 lines
4.5 KiB
Swift
96 lines
4.5 KiB
Swift
// BoutiqueAmpPedal.swift
|
||
// Lyrebird
|
||
//
|
||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
import LyrebirdSynth
|
||
import LyrebirdUI
|
||
|
||
/// Shared base for the boutique high-gain amps (Boutique Lead / Boutique OD) — a footswitchable
|
||
/// Clean/Lead channel into a master-volume power section, with **Presence** (top-end) and **Depth**
|
||
/// (low-end resonance) shaping.
|
||
///
|
||
/// The Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||
/// `rebuildsOnChange` **Channel** switch, so only the selected channel is built. `Master` drives the
|
||
/// power-amp stage via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``. Concrete voices override
|
||
/// ``AmpVoicePedal/toneStackModel`` and gain defaults, and may extend the shaping (e.g. a mid boost).
|
||
open class BoutiqueAmpPedal: AmpVoicePedal {
|
||
|
||
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of top-end lift.
|
||
@UIParam public var presence: Double = 0.4
|
||
/// Depth amount in [0, 1] → 0…`depthMaxGainDb` of low-end resonance lift.
|
||
@UIParam public var depth: Double = 0.3
|
||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||
@UIParam public var master: Double = 0.5
|
||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||
@UIParam public var drive: Double = 7.77
|
||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||
@UIParam public var channel: Double = 0.0
|
||
|
||
private let presenceFreqHz: Double = 4500.0
|
||
private let presenceMaxGainDb: Double = 8.0
|
||
private let presenceSlope: Double = 0.7
|
||
private let depthFreqHz: Double = 120.0
|
||
private let depthMaxGainDb: Double = 6.0
|
||
private let depthSlope: Double = 0.7
|
||
private let masterMinDrive: Double = 0.5
|
||
private let masterMaxDrive: Double = 5.0
|
||
private let channelThreshold: Double = 0.5
|
||
|
||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||
|
||
public override var toneStackModel: ToneStackModel { .marshall }
|
||
public override var signatureKnobs: [PedalKnob] {
|
||
[
|
||
PedalKnob(label: "Presence", node: $presence, range: signatureRange),
|
||
PedalKnob(label: "Depth", node: $depth, range: signatureRange),
|
||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||
]
|
||
}
|
||
|
||
public override var effectSwitches: [PedalSwitch] {
|
||
[
|
||
PedalSwitch(
|
||
label: "Channel",
|
||
node: $channel,
|
||
options: [
|
||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||
],
|
||
rebuildsOnChange: true
|
||
),
|
||
]
|
||
}
|
||
|
||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||
}
|
||
public override var powerAmpOversample: Int { 4 }
|
||
|
||
/// Wider card for the Presence/Depth/Master/Drive knobs plus the Channel switch.
|
||
public override var widthUnits: Int { 4 }
|
||
|
||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||
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: leadBias, oversample: preampOversample)
|
||
}
|
||
|
||
/// Presence (top-end high-shelf) then Depth (low-end low-shelf), post power amp.
|
||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let presenceGainDb: LinLin.Audio = LinLin.Audio(
|
||
$presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb)
|
||
let presenced: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||
input: signal, freq: presenceFreqHz, gain: presenceGainDb, slope: presenceSlope)
|
||
let depthGainDb: LinLin.Audio = LinLin.Audio(
|
||
$depth, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: depthMaxGainDb)
|
||
return RBJLowShelf.Audio(
|
||
input: presenced, freq: depthFreqHz, gain: depthGainDb, slope: depthSlope)
|
||
}
|
||
}
|