Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/ChimeTopBoostAmpPedal.swift
T
josh 5d8e655dab feat(amps): Chime Top Boost — full Vox-style control surface
Full-surface counterpart to the basic Chime voice, modeling the AC-style top-boost
combo. Reuses the AmpVoicePedal hooks:
- inputShaping: Brilliant switch (pre-preamp treble shelf, identity when off).
- onboardEffects: tremolo (Speed/Intensity), gated by a Tremolo footswitch. No
  onboard reverb (always outboard on these amps).
- shapeVoice: the Cut control (post-power-amp low-pass swept 9k→2.5k).

ChimeTopBoostAmpPedal (.vox): Gain/Bass/Mid/Treble + Cut/Speed/Intensity knobs,
Brilliant + Tremolo switches, Cab selector (defaults to Bright 1×12); widthUnits 3.
Registered across registry/type/category/palette/enclosure; Help acknowledgment
lists its tone stack. 10 tests (Cut, tremolo intensity/speed, brilliant, tremolo
footswitch bit-exact bypass, ceiling with FX, control surface, round-trip, registry).

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

141 lines
6.2 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.
// ChimeTopBoostAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// British-invasion "top boost" combo with a full control surface: the chimey top-boost EQ, a
/// **Cut** control that tames the highs, onboard **tremolo** (Speed / Intensity), and a
/// **Brilliant** switch — the jangly clean-to-edge-of-breakup voice.
///
/// A ``AmpVoicePedal`` fixed to the chime tone stack that fills both subclass hooks:
/// - ``inputShaping(_:)`` applies the Brilliant switch as a pre-preamp treble shelf.
/// - ``onboardEffects(_:)`` inserts the tremolo between the tone stack and the power amp.
///
/// Unlike the American blackface combo this amp has no built-in reverb (that was always outboard),
/// so the onboard-effects slot holds only the tremolo. Tremolo defaults off (`Intensity = 0`).
public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
// MARK: - Signature / onboard-effect parameters
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest (the top-boost "Cut" control,
/// which rolls off the highs as it's turned up).
@UIParam public var cut: Double = 0.2
/// Tremolo LFO rate in Hz. Range [0.5, 12].
@UIParam public var speed: Double = 4.0
/// Tremolo depth in [0, 1]. `0` = off, `1` = full swing.
@UIParam public var intensity: Double = 0.0
/// Brilliant switch: `0` = flat, `1` = treble shelf engaged (the brilliant/top-boost sparkle).
@UIParam public var brilliant: Double = 0.0
/// Tremolo footswitch: `1` = engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
@UIParam public var tremoloEnabled: Double = 1.0
// MARK: - Constants
/// Cut low-pass cutoff when fully open (`cut = 0`), in Hz.
private let cutOpenHz: Double = 9000.0
/// Cut low-pass cutoff when fully dark (`cut = 1`), in Hz.
private let cutDarkHz: Double = 2500.0
/// Cut low-pass Q (Butterworth).
private let cutQ: Double = 0.707
/// Brilliant-switch shelf corner in Hz.
private let brilliantFreqHz: Double = 4000.0
/// Brilliant-switch shelf lift in dB when engaged.
private let brilliantMaxGainDb: Double = 6.0
/// Brilliant-switch shelf slope.
private let brilliantSlope: Double = 0.7
/// Tremolo depth scaling — at full `intensity` the LFO swings over half the normalised range so
/// the peak gain is 1.0 and the trough is `1 − intensity`.
private let tremoloDepthScale: Double = 0.5
private let cutRange: ClosedRange<Double> = 0.0 ... 1.0
private let speedRange: ClosedRange<Double> = 0.5 ... 12.0
private let intensityRange: ClosedRange<Double> = 0.0 ... 1.0
private let switchOffValue: Double = 0.0
private let switchOnValue: Double = 1.0
// MARK: - Voice configuration
public override var toneStackModel: ToneStackModel { .vox }
public override var summaryText: String {
"Chimey top-boost jangle — Cut control, tremolo, and a Brilliant switch."
}
public override var signatureKnobs: [PedalKnob] {
[
PedalKnob(label: "Cut", node: $cut, range: cutRange),
PedalKnob(label: "Speed", node: $speed, range: speedRange),
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
]
}
/// Wider card for the extra Cut/tremolo knobs plus the Brilliant and Tremolo switches.
public override var widthUnits: Int { 3 }
// MARK: - Init
/// Creates a Chime Top Boost 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: "Chime Top Boost", inputBus: inputBus, outputBus: outputBus)
gain = 5.0
cab = 5.0 // Bright 1×12 — the chimey, top-end-forward cab voice
}
// MARK: - Switches
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
label: "Brilliant",
node: $brilliant,
options: [
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
PedalSwitch(
label: "Tremolo",
node: $tremoloEnabled,
options: [
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
]
}
// MARK: - Hooks
/// Brilliant 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 = $brilliant * brilliantMaxGainDb
return RBJHighShelf.Audio(
input: signal, freq: brilliantFreqHz, gain: shelfGainDb, slope: brilliantSlope)
}
/// Tremolo (gated by the Tremolo footswitch), inserted after the tone stack. No onboard reverb.
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Footswitch gates depth to 0 → LFO is a constant 1.0 (identity). Unipolar sine over
// [1 − depth, 1]: peak gain 1.0, trough 1 − depth.
let depth: any ValidGeneratorInput = $intensity * $tremoloEnabled
let lfoScale: any ValidGeneratorInput = depth * tremoloDepthScale
let lfoOffset: any ValidGeneratorInput = 1.0 - (depth * tremoloDepthScale)
let lfo: OscSin.Audio = OscSin.Audio(freq: $speed, mul: lfoScale, add: lfoOffset)
return signal * lfo
}
/// Cut control: a low-pass whose cutoff sweeps from `cutOpenHz` (bright) down to `cutDarkHz`
/// (dark) as `cut` rises — the top-boost "Cut" behaviour, applied post-power-amp.
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let cutoff: LinLin.Audio = LinLin.Audio(
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
}
}