Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/BoutiqueAmpPedal.swift
T
josh 9c0f89bae6 feat(amps): boutique high-gain — Boutique Lead / OD (Phase 6)
Add a shared BoutiqueAmpPedal base: a rebuildsOnChange Clean/Lead channel switch
(Lead cascades a stage set by Drive), a Master (via masterDrive), and Presence
(top-end high-shelf) + Depth (low-end low-shelf, RBJLowShelf) power-amp shaping;
widthUnits 4, 4× power-amp oversample.

- Boutique Lead — SLO-style aggressive super-lead (.marshall, hot Lead drive).
- Boutique OD — D-style smooth overdrive (.fender) with a Mid Boost switch
  (RBJPeakingEQ peak scaled by the switch, identity when off) layered on the base
  Presence/Depth shaping.

Registered across 6 sites as .amp. 10 tests (channel switch + rebuildsOnChange,
presence/depth, master drives power amp via RMS-normalized SSD, drive, ceiling on
lead channel, control surfaces, OD mid boost, round-trip, registry).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-03 14:10:14 -07:00

101 lines
4.7 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.
// 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). Range [1, 30].
@UIParam public var drive: Double = 10.0
/// 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
/// Grid bias of the cascaded lead stage — a little asymmetry for even-harmonic grind.
let leadBias: Double = 0.15
private let channelThreshold: Double = 0.5
let signatureAmount: ClosedRange<Double> = 0.0 ... 1.0
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
let switchOffValue: Double = 0.0
let switchOnValue: Double = 1.0
public override var toneStackModel: ToneStackModel { .marshall }
public override var signatureKnobs: [PedalKnob] {
[
PedalKnob(label: "Presence", node: $presence, range: signatureAmount),
PedalKnob(label: "Depth", node: $depth, range: signatureAmount),
PedalKnob(label: "Master", node: $master, range: signatureAmount),
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: $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)
}
}