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

57 lines
2.5 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.
// BritishMasterAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// British **master-volume lead** — the 800-series single-channel hot-rodded Marshall: a cascaded
/// two-stage preamp for singing lead gain, a Master volume, Presence, and a Bright switch.
///
/// A ``BritishComboAmpPedal`` (Presence + Bright) whose ``preampStage(_:)`` cascades a second gain
/// stage — both driven by `Gain`, so one knob sets the whole preamp grind — and whose `Master`
/// drives the power-amp stage (via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``).
public final class BritishMasterAmpPedal: BritishComboAmpPedal {
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
@UIParam public var master: Double = 0.5
private let masterMinDrive: Double = 0.5
private let masterMaxDrive: Double = 5.0
public override var summaryText: String {
"British master-volume lead — cascaded 800-series gain with Presence, Master, and Bright."
}
public override var signatureKnobs: [PedalKnob] {
super.signatureKnobs + [PedalKnob(label: "Master", node: $master, range: signatureRange)]
}
/// 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/Master knobs plus the Bright switch.
public override var widthUnits: Int { 3 }
/// Creates a British Master 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: "British Master", inputBus: inputBus, outputBus: outputBus)
gain = 5.73 // cascaded, so already a hot lead at moderate Gain
cab = 1.0 // British 4×12
}
/// Cascaded two-stage preamp: the base stage, then a second `TriodeStage` also driven by `Gain`.
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let stage1: any ValidGeneratorInput = super.preampStage(signal)
return TriodeStage(input: stage1, drive: taperedDrive($gain), bias: leadBias, oversample: preampOversample)
}
}