2 Commits

Author SHA1 Message Date
josh 27fb6e6898 fix(amps): disambiguate Reverb footswitch label; comment bypass test
Review nits: rename the reverb-enable switch "Reverb" → "Reverb FX" so it no
longer collides with the "Reverb" level knob in the flat control surface
(clearer, better for VoiceOver). Note in the vibrato bypass test why the
differing speed between the two renders is intentional (depth gated to 0 makes
the LFO a constant regardless of frequency).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-03 07:59:12 -07:00
josh a9e91ef08c feat(amps): Reverb + Vibrato footswitches on Fullerton Reverb
Model the amp's two-button footswitch: Reverb and Vibrato switches that bypass
each onboard effect to a dry pass-through while preserving the knob positions.
Both gate live by scaling the wet amount to zero — reverb mix → 0 (SpringReverb
passes dry), tremolo depth → 0 (LFO collapses to a constant 1.0) — so Off is a
true identity and no rebuild is needed.

reverbEnabled / vibratoEnabled default on. Tests assert each footswitch-off is a
bit-exact pass-through (equals the knob-at-zero render) and differs when engaged;
state round-trip and control-surface exposure updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-03 07:52:23 -07:00
2 changed files with 68 additions and 9 deletions
@@ -18,6 +18,10 @@ import LyrebirdUI
/// The amp's "vibrato" channel is historically amplitude modulation (tremolo), not pitch vibrato,
/// so `Intensity` drives a unipolar-sine gain LFO. Tremolo defaults off (`Intensity = 0`) so the
/// amp opens as a clean, reverbed platform.
///
/// A **Reverb** and a **Vibrato** switch model the amp's two-button footswitch: each bypasses its
/// effect (dry pass-through) while preserving the knob positions, so a player can stomp the FX in
/// and out without losing their settings.
public final class FullertonReverbAmpPedal: AmpVoicePedal {
// MARK: - Onboard-effect parameters
@@ -30,6 +34,12 @@ public final class FullertonReverbAmpPedal: AmpVoicePedal {
@UIParam public var intensity: Double = 0.0
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
@UIParam public var bright: Double = 0.0
/// Reverb footswitch: `1` = reverb engaged, `0` = bypassed (dry pass-through, `Reverb` knob
/// setting preserved). Models the amp's reverb footswitch.
@UIParam public var reverbEnabled: Double = 1.0
/// Vibrato footswitch: `1` = tremolo engaged, `0` = bypassed (`Speed`/`Intensity` preserved).
/// Models the amp's vibrato footswitch.
@UIParam public var vibratoEnabled: Double = 1.0
// MARK: - Constants
@@ -46,8 +56,8 @@ public final class FullertonReverbAmpPedal: AmpVoicePedal {
private let reverbRange: 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 brightOffValue: Double = 0.0
private let brightOnValue: Double = 1.0
private let switchOffValue: Double = 0.0
private let switchOnValue: Double = 1.0
// MARK: - Voice configuration
@@ -86,8 +96,24 @@ public final class FullertonReverbAmpPedal: AmpVoicePedal {
label: "Bright",
node: $bright,
options: [
PedalSwitch.Option(title: "Off", value: brightOffValue),
PedalSwitch.Option(title: "On", value: brightOnValue),
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
PedalSwitch(
label: "Reverb FX", // disambiguated from the "Reverb" level knob
node: $reverbEnabled,
options: [
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
PedalSwitch(
label: "Vibrato",
node: $vibratoEnabled,
options: [
PedalSwitch.Option(title: "Off", value: switchOffValue),
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
]
@@ -104,12 +130,20 @@ public final class FullertonReverbAmpPedal: AmpVoicePedal {
}
/// Spring reverb → tremolo, inserted after the tone stack and before the power amp.
///
/// The `reverbEnabled` / `vibratoEnabled` footswitches gate each effect live by scaling its wet
/// amount to zero: reverb collapses to a dry pass-through and the tremolo LFO collapses to a
/// constant `1.0` (identity), each while preserving its knob positions and needing no rebuild.
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Footswitch gates the wet mix to 0 → SpringReverb passes the dry signal through.
let reverbMix: any ValidGeneratorInput = $reverb * $reverbEnabled
let reverbed: SpringReverb.Audio = SpringReverb.Audio(
input: signal, mix: $reverb, sampleRate: sampleRate)
// Unipolar sine LFO over [1 − intensity, 1]: peak gain 1.0, trough 1 − intensity.
let lfoScale: any ValidGeneratorInput = $intensity * tremoloDepthScale
let lfoOffset: any ValidGeneratorInput = 1.0 - ($intensity * tremoloDepthScale)
input: signal, mix: reverbMix, sampleRate: sampleRate)
// Footswitch gates depth to 0 → LFO is a constant 1.0. Unipolar sine over [1 − depth, 1]:
// peak gain 1.0, trough 1 − depth.
let depth: any ValidGeneratorInput = $intensity * $vibratoEnabled
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 reverbed * lfo
}
@@ -79,6 +79,27 @@ struct FullertonReverbAmpPedalTests {
#expect(windowedSSD(flat, bright) > 0, "bright switch had no effect")
}
@Test func reverbFootswitchBypassesToDry() throws {
// Footswitch off with the Reverb knob up must equal the dry signal (knob at 0), and must
// differ from the same knob with the footswitch on.
let bypassed: [Float] = try render { $0.reverb = 0.9; $0.reverbEnabled = 0.0 }
let dry: [Float] = try render { $0.reverb = 0.0; $0.reverbEnabled = 1.0 }
#expect(windowedSSD(bypassed, dry) == 0.0, "reverb footswitch off should be a dry pass-through")
let engaged: [Float] = try render { $0.reverb = 0.9; $0.reverbEnabled = 1.0 }
#expect(windowedSSD(bypassed, engaged) > 0, "reverb footswitch had no effect")
}
@Test func vibratoFootswitchBypassesToIdentity() throws {
// Footswitch off with Intensity up must equal no tremolo (Intensity 0), and must differ
// from the same Intensity with the footswitch on. The differing `speed` is intentional and
// harmless: with depth gated to 0 the LFO is a constant 1.0 regardless of its frequency.
let bypassed: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.vibratoEnabled = 0.0 }
let noTremolo: [Float] = try render { $0.intensity = 0.0 }
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "vibrato footswitch off should be identity")
let engaged: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.vibratoEnabled = 1.0 }
#expect(windowedSSD(bypassed, engaged) > 0, "vibrato footswitch had no effect")
}
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
let ceilingEpsilon: Double = 1.0e-4
let hot: [Float] = try render { (pedal: FullertonReverbAmpPedal) in
@@ -99,7 +120,7 @@ struct FullertonReverbAmpPedalTests {
let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal()
#expect(pedal.effectKnobs.map { $0.label }
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"])
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
#expect(pedal.widthUnits == 3)
@@ -115,6 +136,8 @@ struct FullertonReverbAmpPedalTests {
pedal.intensity = 0.6
pedal.bright = 1.0
pedal.cab = 2.0
pedal.reverbEnabled = 0.0
pedal.vibratoEnabled = 0.0
let restored: FullertonReverbAmpPedal = FullertonReverbAmpPedal()
restored.applyState(pedal.captureState())
#expect(restored.gain == 8.0)
@@ -123,6 +146,8 @@ struct FullertonReverbAmpPedalTests {
#expect(restored.intensity == 0.6)
#expect(restored.bright == 1.0)
#expect(restored.cab == 2.0)
#expect(restored.reverbEnabled == 0.0)
#expect(restored.vibratoEnabled == 0.0)
}
@Test func registeredInBuiltInRegistry() throws {