feat(pedals): add Vibe pedal + Psychedelic Vibe Lead rig
New "Vibe" pedal: a photocell-style vibe built as four staggered all-pass stages swept by one shared sine LFO (unequal centre frequencies give the uneven, vocal throb that distinguishes a vibe from a phaser). Speed and Intensity knobs, Chorus/Vibrato mode switch (chorus blends dry+swept, vibrato passes swept only). Composed from RBJAllPass in effect(), mirroring PhaserPedal — no new RT generator. Registered in PedalType/PedalRegistry, enclosure colour, and palette order. Tests cover build+non-silent, each control measurably changing output, the knob/switch listing, and preset round-trip. Adds the Psychedelic Vibe Lead factory rig (Fuzz -> Vibe -> Delay -> Plate). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
// VibePedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Photocell "vibe" pedal: four staggered all-pass stages swept by one shared LFO.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → RBJAllPass(freq₀(t)) → RBJAllPass(freq₁(t)) → RBJAllPass(freq₂(t)) → RBJAllPass(freq₃(t)) → wet
|
||||
/// out = wet·wetAmount + dry·dryAmount (mode: chorus blends dry+wet, vibrato is wet only)
|
||||
/// ```
|
||||
///
|
||||
/// Unlike a phaser (evenly-spaced stages producing symmetric notches), the vibe cascades all-pass
|
||||
/// stages at **staggered** centre frequencies, so the phase relationships between stages produce the
|
||||
/// characteristic uneven, vocal throb. A single low-frequency sine modulates every stage's centre
|
||||
/// frequency together; the `intensity` knob scales the sweep depth and the `speed` knob sets the LFO
|
||||
/// rate. In *chorus* mode the swept signal is blended 50/50 with the dry signal (comb-filter throb);
|
||||
/// in *vibrato* mode only the swept (phase-modulated) signal passes, for a pitch-vibrato-like warble.
|
||||
///
|
||||
/// The bypass switching is handled by the `Pedal` base class. The base `mix` is fixed fully wet — the
|
||||
/// chorus/vibrato dry blend is handled internally so the two modes behave correctly.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `bypass` and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - speed: LFO sweep rate in Hz. Range `[0.1, 12.0]`. Defaults to `3.0`.
|
||||
/// - intensity: Sweep depth as a fraction of each stage's centre frequency. Range `[0, 0.7]`.
|
||||
/// Defaults to `0.5`.
|
||||
/// - mode: `0` = chorus (dry + swept), `1` = vibrato (swept only). Defaults to chorus.
|
||||
public final class VibePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Throbbing photocell vibe — swirling chorus and warbling pitch-vibrato motion."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO sweep rate in Hz. Range [0.1, 12.0].
|
||||
@UIParam public var speed: Double = 3.0
|
||||
|
||||
/// Sweep depth as a fraction of each stage's centre frequency. Range [0, 0.7].
|
||||
@UIParam public var intensity: Double = 0.5
|
||||
|
||||
/// Mode select: `0` = chorus (dry + swept), `1` = vibrato (swept only).
|
||||
@UIParam public var mode: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the chorus/vibrato dry mix is handled inside `effect`.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Q for each all-pass stage. Gentle phase transition for a smooth, vocal vibe (not sharp notches).
|
||||
private let vibeQ: Double = 0.6
|
||||
|
||||
/// Staggered all-pass stage centre frequencies in Hz. Unequal spacing is what distinguishes the
|
||||
/// vibe's uneven throb from an evenly-spaced phaser.
|
||||
private let stageCenterFreqs: [Double] = [300.0, 620.0, 1300.0, 2200.0]
|
||||
|
||||
/// `mode` value selecting chorus (dry + swept).
|
||||
private let modeChorusValue: Double = 0.0
|
||||
|
||||
/// `mode` value selecting vibrato (swept only).
|
||||
private let modeVibratoValue: Double = 1.0
|
||||
|
||||
/// Wet gain at chorus mode (`mode == 0`); the swept signal sits 50/50 with dry.
|
||||
private let chorusWetGain: Double = 0.5
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Speed knob range in Hz (LFO sweep rate).
|
||||
private let speedRange: ClosedRange<Double> = 0.1 ... 12.0
|
||||
|
||||
/// Intensity knob range (sweep depth fraction). Capped below `1.0` so a stage's swept frequency
|
||||
/// never collapses toward `0 Hz` at the bottom of the sweep.
|
||||
private let intensityRange: ClosedRange<Double> = 0.0 ... 0.7
|
||||
|
||||
public override var tempoSyncableParams: [TempoSyncableParam] {
|
||||
[
|
||||
TempoSyncableParam(key: "speed", label: "Speed", node: $speed, kind: .rate, range: speedRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Speed", node: $speed, range: speedRange),
|
||||
PedalKnob(label: "Intensity", node: $intensity, range: intensityRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
label: "Mode",
|
||||
node: $mode,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Chorus", value: modeChorusValue),
|
||||
PedalSwitch.Option(title: "Vibrato", value: modeVibratoValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a vibe pedal.
|
||||
///
|
||||
/// - 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: "Vibe",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: VibePedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Cascades four staggered all-pass stages swept by a shared sine LFO, then blends per mode.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Wet mono vibe output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// One shared low-frequency sine drives every stage: ±1 scaled by intensity gives the sweep.
|
||||
let lfo: any ValidGeneratorInput = OscSin.Audio(freq: $speed)
|
||||
let sweep: any ValidGeneratorInput = lfo * $intensity // ±intensity
|
||||
|
||||
// Cascade the stages. Each stage's centre frequency is centre·(1 + sweep) = centre + centre·sweep.
|
||||
var signal: any ValidGeneratorInput = dry
|
||||
for center: Double in stageCenterFreqs {
|
||||
let stageFreq: any ValidGeneratorInput = sweep * center + center
|
||||
signal = RBJAllPass.Audio(input: signal, freq: stageFreq, q: vibeQ)
|
||||
}
|
||||
let wet: any ValidGeneratorInput = signal
|
||||
|
||||
// Blend by mode. Chorus (mode 0): 0.5·dry + 0.5·wet. Vibrato (mode 1): wet only.
|
||||
let wetAmount: any ValidGeneratorInput = $mode * chorusWetGain + chorusWetGain // 0.5 → 1.0
|
||||
let dryAmount: any ValidGeneratorInput = (modeVibratoValue - $mode) * chorusWetGain // 0.5 → 0.0
|
||||
return wet * wetAmount + dry * dryAmount
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user