Add Chorus, Sustainer, Ring Modulator pedals + pedal-info UI
Pedals (each registered, with PedalType static, enclosure color, palette order, summary, and tests): - Chorus: true-stereo widener (two anti-phase modulated delay lines), distinct from the mono-summed Modulation chorus. - Sustainer: one-knob compressor (sustain drives threshold/ratio/makeup via LinLin) + tone low-pass. - Ring Modulator: dry × tunable sine carrier. Pedal-info UI: - Pedal.summary (open var, overridden by all 21 pedals; mandatory going forward). - PedalRegistry.summary(for:) for the picker. - PedalPaletteView rows show the summary as a subtitle. - PedalView gains an ⓘ button → PedalInfoView sheet showing the description and the effect controls (knobs/sliders/switches) with ranges/options — excludes the common Mix/Level/bypass. Tests: per-pedal build/param-change/knob-list; every built-in pedal has a non-empty summary; info excludes common controls. 183 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -128,6 +128,17 @@ open class Pedal: SynthesizerBase {
|
||||
self.mix = initialMix
|
||||
}
|
||||
|
||||
// MARK: - Description
|
||||
|
||||
/// One-line, user-facing description of what this pedal does.
|
||||
///
|
||||
/// Shown as a subtitle in the pedal picker and as the body of the pedal's info panel.
|
||||
/// **Every pedal must override this** with a short, non-proprietary sentence — the empty
|
||||
/// default is a placeholder only (a test asserts every registered pedal sets it).
|
||||
open var summary: String {
|
||||
""
|
||||
}
|
||||
|
||||
// MARK: - UI knob descriptors
|
||||
|
||||
/// Effect-specific knobs for this pedal, listed before the common knobs in the UI.
|
||||
|
||||
@@ -59,6 +59,11 @@ public extension PedalType {
|
||||
// Modulation
|
||||
static let tremolo = PedalType("Tremolo")
|
||||
static let modulation = PedalType("Modulation")
|
||||
static let chorus = PedalType("Chorus")
|
||||
static let ringModulator = PedalType("Ring Modulator")
|
||||
|
||||
// Dynamics (additional)
|
||||
static let sustainer = PedalType("Sustainer")
|
||||
|
||||
// Delay & reverb
|
||||
static let delay = PedalType("Delay")
|
||||
|
||||
@@ -27,6 +27,11 @@ import LyrebirdUI
|
||||
/// - `range`: Upper cutoff in Hz reached at full envelope. Sets the sweep span over `freqLo`.
|
||||
public final class AutoWahPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Touch-sensitive wah that sweeps a resonant filter from your playing dynamics."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Envelope drive into the cutoff sweep. Higher values open the filter on quieter input.
|
||||
|
||||
@@ -35,6 +35,11 @@ import LyrebirdUI
|
||||
/// - `mode` (two-state): `0` = Flip-flop (authentic OC-2), `1` = Tracking (pitch-tracked).
|
||||
public final class BassOctaverPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Adds a sub-octave below your note for bass-like weight."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// −1 octave voice level in `[0, 1]`.
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
// ChorusPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// True-stereo chorus pedal.
|
||||
///
|
||||
/// Two modulated delay lines, fed the same dry signal but driven by sine LFOs 180° apart,
|
||||
/// produce a wide left/right shimmer. Unlike `ModulationPedal` (which sums Lyrebird's
|
||||
/// `Chorus` to mono), this pedal is a ``PedalChannelKind/widener`` — it keeps the two voices
|
||||
/// on separate channels for genuine stereo width.
|
||||
///
|
||||
/// Signal path (per channel, inside `wideEffect(_:)`):
|
||||
/// ```
|
||||
/// dry → DelayLine(delay: base ± depth·sin(rate)) → wet L / wet R
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - rate: LFO rate in Hz. Range `[0.05, 6]`. Defaults to `0.8`.
|
||||
/// - depth: Delay-sweep depth in seconds (half-swing around the base delay). Range
|
||||
/// `[0.0005, 0.008]`. Defaults to `0.003`.
|
||||
public final class ChorusPedal: Pedal {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO rate in Hz. Range [0.05, 6].
|
||||
@UIParam public var rate: Double = 0.8
|
||||
|
||||
/// Delay-sweep depth in seconds. Range [0.0005, 0.008].
|
||||
@UIParam public var depth: Double = 0.003
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — chorus sits under the dry signal.
|
||||
private static let defaultMix: Double = 0.5
|
||||
|
||||
/// Base delay around which the LFO sweeps, in seconds.
|
||||
private let baseDelayTime: Double = 0.012
|
||||
|
||||
/// Maximum delay the lines are allocated for, in seconds. Covers `baseDelayTime + max depth`.
|
||||
private let maxDelayTime: Double = 0.03
|
||||
|
||||
/// LFO phase for the left voice, in cycles.
|
||||
private let leftPhase: Double = 0.0
|
||||
|
||||
/// LFO phase for the right voice, in cycles — a half cycle (180°) opposite the left.
|
||||
private let rightPhase: Double = 0.5
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
private let rateRange: ClosedRange<Double> = 0.05 ... 6.0
|
||||
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.008
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Channel topology
|
||||
|
||||
public override var channelKind: PedalChannelKind { .widener }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a stereo chorus 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: "Chorus",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: ChorusPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
public override var summary: String {
|
||||
"Lush stereo chorus: two detuned voices panned wide for shimmer and depth."
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Builds one modulated delay line per channel, with the two LFOs in anti-phase.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The left and right wet voices.
|
||||
public override func wideEffect(
|
||||
_ dry: any ValidGeneratorInput
|
||||
) -> (left: any ValidGeneratorInput, right: any ValidGeneratorInput) {
|
||||
(voice(dry, phase: leftPhase), voice(dry, phase: rightPhase))
|
||||
}
|
||||
|
||||
/// One chorus voice: a delay line whose time is swept by a sine LFO around `baseDelayTime`.
|
||||
private func voice(
|
||||
_ dry: any ValidGeneratorInput,
|
||||
phase: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
let sweep: OscSin.Audio = OscSin.Audio(
|
||||
freq: $rate,
|
||||
phase: phase,
|
||||
mul: $depth,
|
||||
add: baseDelayTime
|
||||
)
|
||||
return DelayLine(
|
||||
input: dry,
|
||||
maxDelay: maxDelayTime,
|
||||
delay: sweep,
|
||||
sampleRate: sampleRate,
|
||||
interpolation: .linear
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,11 @@ import LyrebirdUI
|
||||
/// Range `[1, 20]`. Defaults to `4.0`.
|
||||
public final class CompressorPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Feed-forward compressor that evens out dynamics, with a pre-gain input stage."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Pre-compression input gain in dB. Range [-12, 24]. `0` = unity.
|
||||
|
||||
@@ -28,6 +28,11 @@ import LyrebirdUI
|
||||
/// repeats. Range `[0.05, 6.0]` seconds. Defaults to `1.0`.
|
||||
public final class DelayPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Echo delay with adjustable time and decay, from slapback to long repeats."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Delay time in seconds. Range [0.01, 1.5].
|
||||
|
||||
@@ -26,6 +26,11 @@ import LyrebirdUI
|
||||
/// - `tone`: Lowpass cutoff in Hz applied to the wet signal; lower darkens the echoes.
|
||||
public final class FeedbackDelayPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Feedback delay with a tone-shaped repeat for dub-style echoes."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Delay time between repeats, in seconds.
|
||||
|
||||
@@ -36,6 +36,11 @@ import LyrebirdUI
|
||||
/// Range `[200, 8000]` Hz. Defaults to `3500.0`.
|
||||
public final class FuzzPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Thick, saturated fuzz for aggressive, sustaining distortion."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Pre-gain drive into the saturator. Range [1, 60]; higher = more fuzz.
|
||||
|
||||
@@ -39,6 +39,11 @@ import LyrebirdUI
|
||||
/// Defaults to `0.0`.
|
||||
public final class GraphicEQPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Five-band graphic EQ with per-band faders and a master output level."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Low-shelf gain in dB. Range [-12, 12].
|
||||
|
||||
@@ -31,6 +31,11 @@ import LyrebirdUI
|
||||
/// never exceeds this absolute value. Range `[0.1, 1.0]`. Defaults to `0.95`.
|
||||
public final class LimiterPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Brick-wall limiter with an input boost to push level safely to the ceiling."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Pre-limit input gain (linear multiplier). Range [1, 12].
|
||||
|
||||
@@ -32,6 +32,11 @@ import LyrebirdUI
|
||||
/// Smaller values (0.001–0.01) produce classic chorus width. Defaults to `0.002`.
|
||||
public final class ModulationPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Classic mono chorus for subtle thickening and shimmer."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Chorus LFO rate in Hz. Range [0.1, 10].
|
||||
|
||||
@@ -28,6 +28,11 @@ import LyrebirdUI
|
||||
/// - `vol1`, `vol2`, `vol3`: Linear output level of each tap in `[0, 1]`.
|
||||
public final class MultiTapDelayPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Multi-tap delay producing rhythmic patterns of echoes."
|
||||
}
|
||||
|
||||
// MARK: - Tap times
|
||||
|
||||
/// Tap 1 delay time, in seconds.
|
||||
|
||||
@@ -26,6 +26,11 @@ import LyrebirdUI
|
||||
/// - `mode` (three-state): `0` = lowpass, `1` = bandpass (classic vowel wah), `2` = highpass.
|
||||
public final class MutantPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Envelope-following auto-wah / funk filter that opens with your picking."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
|
||||
|
||||
@@ -37,6 +37,11 @@ import LyrebirdUI
|
||||
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
|
||||
public final class NoiseGatePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Noise gate that silences hiss and hum below a tunable threshold."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Gate close threshold (linear amplitude). Range [0, 0.2].
|
||||
|
||||
@@ -31,6 +31,11 @@ import LyrebirdUI
|
||||
/// - tone: Octave-channel low-pass cutoff in Hz. Range `[500, 8000]`. Defaults to `4000.0`.
|
||||
public final class OctaveUpSplitterPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Splits a clean octave-up voice alongside your dry signal in stereo."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Pre-gain into the octave-channel saturator. Range [1, 40]; higher = thicker octave fuzz.
|
||||
|
||||
@@ -27,6 +27,11 @@ import LyrebirdUI
|
||||
/// Range `(0, 20000]`. Defaults to `4000.0`.
|
||||
public final class OverdrivePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Warm soft-clip overdrive with a tone control, from gentle grit to singing sustain."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Saturation drive amount. Range [1, 20]; higher = more clipping.
|
||||
|
||||
@@ -30,6 +30,11 @@ import LyrebirdUI
|
||||
/// Range `[0.0, 0.9]`. Defaults to `0.5`.
|
||||
public final class PhaserPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Sweeping phase shifter for swirling, watery motion."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO sweep rate in Hz. Range [0.05, 5.0].
|
||||
|
||||
@@ -37,6 +37,11 @@ import LyrebirdUI
|
||||
/// Range `[0.05, 6.0]`. Defaults to `1.2`.
|
||||
public final class PingPongDelayPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Stereo ping-pong delay bouncing echoes between left and right."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Delay time per tap in seconds. Range [0.05, 1.0].
|
||||
|
||||
@@ -31,6 +31,11 @@ import LyrebirdUI
|
||||
/// shorter tails. Defaults to `0.5`.
|
||||
public final class ReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Reverb adding space and ambience, from small rooms to vast halls."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Room size in [0, 1]. Larger = longer reverb tail.
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// RingModulatorPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Ring modulator pedal.
|
||||
///
|
||||
/// Multiplies the input by a tunable sine carrier, producing sum-and-difference sidebands —
|
||||
/// metallic, bell-like, and robotic tones. Below ~30 Hz the carrier reads as tremolo-style
|
||||
/// amplitude modulation; in the audio range it becomes classic ring modulation.
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry × OscSin(frequency) → wet
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - frequency: Carrier frequency in Hz. Range `[20, 2000]`. Defaults to `220.0`.
|
||||
public final class RingModulatorPedal: Pedal {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Carrier frequency in Hz. Range [20, 2000].
|
||||
@UIParam public var frequency: Double = 220.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — ring mod is harsh, so keep the dry signal present.
|
||||
private static let defaultMix: Double = 0.5
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
private let frequencyRange: ClosedRange<Double> = 20.0 ... 2000.0
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Frequency", node: $frequency, range: frequencyRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a ring modulator 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: "Ring Modulator",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: RingModulatorPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
public override var summary: String {
|
||||
"Multiplies your signal by a tunable carrier for metallic, bell-like, and robotic tones."
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Multiplies the dry signal by the sine carrier.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The ring-modulated wet signal.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let carrier: OscSin.Audio = OscSin.Audio(freq: $frequency)
|
||||
return dry * carrier
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
// SustainerPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Sustainer pedal: a one-knob compressor tuned for long, even sustain.
|
||||
///
|
||||
/// A single `sustain` control drives a feed-forward compressor harder as it climbs — lowering
|
||||
/// the threshold, raising the ratio, and adding makeup gain together — so notes bloom and hold
|
||||
/// without the user juggling threshold/ratio (that's what the `Compressor` pedal is for). A
|
||||
/// `tone` low-pass rounds off the squashed top end.
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → Compressor(threshold↓, ratio↑, makeup↑ with sustain) → RBJLowPass(tone) → wet
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry blend and bypass are handled by the `Pedal` base class.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - sustain: Amount of sustain/compression. `0` = gentle, `10` = maximum squash and hold.
|
||||
/// Range `[0, 10]`. Defaults to `5.0`.
|
||||
/// - tone: Output low-pass cutoff in Hz. Range `[800, 8000]`. Defaults to `6000.0`.
|
||||
public final class SustainerPedal: Pedal {
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Sustain amount in [0, 10]. Higher = more compression, makeup, and hold.
|
||||
@UIParam public var sustain: Double = 5.0
|
||||
|
||||
/// Output low-pass cutoff in Hz. Range [800, 8000].
|
||||
@UIParam public var tone: Double = 6000.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Compressor envelope times, in seconds — fast attack to catch picks, slow release to hold.
|
||||
private let attackTime: Double = 0.005
|
||||
private let releaseTime: Double = 0.4
|
||||
|
||||
/// Hard knee for a defined, punchy sustain.
|
||||
private let kneeWidth: Double = 0.0
|
||||
|
||||
/// Butterworth tone low-pass (no resonant peak).
|
||||
private let toneQ: Double = 0.707
|
||||
|
||||
/// `sustain` knob span, mapped to the compressor settings below.
|
||||
private let sustainMin: Double = 0.0
|
||||
private let sustainMax: Double = 10.0
|
||||
|
||||
/// Threshold in dB at min / max sustain (lower threshold = more of the signal compressed).
|
||||
private let thresholdAtMin: Double = -6.0
|
||||
private let thresholdAtMax: Double = -36.0
|
||||
|
||||
/// Compression ratio at min / max sustain.
|
||||
private let ratioAtMin: Double = 2.0
|
||||
private let ratioAtMax: Double = 10.0
|
||||
|
||||
/// Makeup gain in dB at min / max sustain (compensates for the added gain reduction).
|
||||
private let makeupAtMin: Double = 0.0
|
||||
private let makeupAtMax: Double = 18.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
private let sustainRange: ClosedRange<Double> = 0.0 ... 10.0
|
||||
private let toneRange: ClosedRange<Double> = 800.0 ... 8000.0
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sustain", node: $sustain, range: sustainRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a sustainer 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: "Sustainer",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: SustainerPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
public override var summary: String {
|
||||
"Compressor tuned for long, even sustain — one knob to make notes bloom and hold."
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Drives a compressor from the single `sustain` knob, then rolls off the top with `tone`.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The sustained, tone-shaped wet signal.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let threshold: LinLin.Audio = mapSustain(to: thresholdAtMin, thresholdAtMax)
|
||||
let ratio: LinLin.Audio = mapSustain(to: ratioAtMin, ratioAtMax)
|
||||
let makeup: LinLin.Audio = mapSustain(to: makeupAtMin, makeupAtMax)
|
||||
|
||||
let compressed: Compressor.Audio = Compressor.Audio(
|
||||
in: dry,
|
||||
threshold: threshold,
|
||||
ratio: ratio,
|
||||
attack: attackTime,
|
||||
release: releaseTime,
|
||||
kneeWidth: kneeWidth,
|
||||
makeupGain: makeup
|
||||
)
|
||||
return RBJLowPass.Audio(
|
||||
input: compressed,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
}
|
||||
|
||||
/// Maps the `sustain` knob `[sustainMin, sustainMax]` to `[outLo, outHi]`.
|
||||
private func mapSustain(to outLo: Double, _ outHi: Double) -> LinLin.Audio {
|
||||
LinLin.Audio(
|
||||
$sustain,
|
||||
inLo: sustainMin,
|
||||
inHi: sustainMax,
|
||||
outLo: outLo,
|
||||
outHi: outHi
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,11 @@ import LyrebirdUI
|
||||
/// Defaults to `0.7`.
|
||||
public final class TremoloPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Rhythmic volume modulation, from a gentle throb to choppy stutter."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO rate in Hz. Range [0.5, 12].
|
||||
|
||||
@@ -49,6 +49,9 @@ public enum PedalRegistry {
|
||||
"Limiter": { LimiterPedal() },
|
||||
"Noise Gate": { NoiseGatePedal() },
|
||||
"Graphic EQ": { GraphicEQPedal() },
|
||||
"Chorus": { ChorusPedal() },
|
||||
"Sustainer": { SustainerPedal() },
|
||||
"Ring Modulator": { RingModulatorPedal() },
|
||||
]
|
||||
|
||||
/// Returns a new `Pedal` instance for the given type string, or `nil` if the type
|
||||
@@ -65,4 +68,17 @@ public enum PedalRegistry {
|
||||
guard let constructor: @MainActor () -> Pedal = builtIn[type] else { return nil }
|
||||
return constructor()
|
||||
}
|
||||
|
||||
/// Returns the `summary` description for a built-in pedal type, or `""` if unknown.
|
||||
///
|
||||
/// Instantiates the pedal to read its `summary` — cheap, since constructing a `Pedal`
|
||||
/// does not call `build()` or touch the engine. Intended for the pedal picker, which has
|
||||
/// only the type string; callers that render many rows should cache the result.
|
||||
///
|
||||
/// - Parameter type: The `displayName` of the pedal.
|
||||
/// - Returns: The pedal's one-line `summary`, or `""` for unknown types.
|
||||
@MainActor
|
||||
public static func summary(for type: String) -> String {
|
||||
makePedal(type: type)?.summary ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
// PedalInfoView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
/// An info panel for a single pedal: its description and the effect controls with their ranges.
|
||||
///
|
||||
/// Shows `pedal.summary` and lists the **effect** controls only — `effectKnobs` + `effectSliders`
|
||||
/// + `effectSwitches`, each with its value range or switch positions. The common Mix / Level /
|
||||
/// bypass controls are intentionally omitted (they behave the same on every pedal). Presented
|
||||
/// from the pedal's ⓘ button.
|
||||
public struct PedalInfoView: View {
|
||||
|
||||
// MARK: - Layout constants
|
||||
|
||||
private static let sectionSpacing: CGFloat = 16
|
||||
private static let rowSpacing: CGFloat = 8
|
||||
private static let labelColumnWidth: CGFloat = 110
|
||||
private static let summaryOpacity: Double = 0.85
|
||||
private static let valueOpacity: Double = 0.7
|
||||
private static let headerOpacity: Double = 0.5
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private let pedal: Pedal
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates an info panel for `pedal`.
|
||||
public init(pedal: Pedal) {
|
||||
self.pedal = pedal
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
public var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: PedalInfoView.sectionSpacing) {
|
||||
if !pedal.summary.isEmpty {
|
||||
Text(pedal.summary)
|
||||
.font(.body)
|
||||
.foregroundStyle(.primary.opacity(PedalInfoView.summaryOpacity))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
|
||||
if !controlRows.isEmpty {
|
||||
VStack(alignment: .leading, spacing: PedalInfoView.rowSpacing) {
|
||||
Text("CONTROLS")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.foregroundStyle(.secondary.opacity(PedalInfoView.headerOpacity))
|
||||
ForEach(Array(controlRows.enumerated()), id: \.offset) { pair in
|
||||
controlRow(pair.element)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.navigationTitle(pedal.displayName)
|
||||
#if !os(macOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button("Done") { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Control rows
|
||||
|
||||
private func controlRow(_ row: ControlRow) -> some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(row.label)
|
||||
.font(.callout.weight(.medium))
|
||||
.frame(width: PedalInfoView.labelColumnWidth, alignment: .leading)
|
||||
Text(row.value)
|
||||
.font(.callout.monospacedDigit())
|
||||
.foregroundStyle(.secondary.opacity(PedalInfoView.valueOpacity))
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
|
||||
/// One displayed control: a label and its range / options string.
|
||||
private struct ControlRow {
|
||||
let label: String
|
||||
let value: String
|
||||
}
|
||||
|
||||
/// Effect controls only (knobs + sliders + switches), in display order.
|
||||
private var controlRows: [ControlRow] {
|
||||
var rows: [ControlRow] = []
|
||||
for knob: PedalKnob in pedal.effectKnobs {
|
||||
rows.append(ControlRow(label: knob.label, value: PedalInfoView.rangeText(knob.range)))
|
||||
}
|
||||
for slider: PedalSlider in pedal.effectSliders {
|
||||
rows.append(ControlRow(label: slider.label, value: PedalInfoView.rangeText(slider.range)))
|
||||
}
|
||||
for pedalSwitch: PedalSwitch in pedal.effectSwitches {
|
||||
let options: String = pedalSwitch.options.map { $0.title }.joined(separator: " / ")
|
||||
rows.append(ControlRow(label: pedalSwitch.label, value: options))
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
// MARK: - Formatting
|
||||
|
||||
/// Formats a value range as `"lo – hi"`, using integers when both bounds are whole.
|
||||
private static func rangeText(_ range: ClosedRange<Double>) -> String {
|
||||
"\(number(range.lowerBound)) – \(number(range.upperBound))"
|
||||
}
|
||||
|
||||
private static func number(_ value: Double) -> String {
|
||||
if value == value.rounded() {
|
||||
return String(format: "%.0f", value)
|
||||
}
|
||||
return String(format: "%.3g", value)
|
||||
}
|
||||
}
|
||||
@@ -41,13 +41,17 @@ public struct PedalPaletteView: View {
|
||||
private static let routingCaptionOpacity: Double = 0.5
|
||||
private static let routingCaptionFontSize: CGFloat = 10
|
||||
private static let addGlyphOpacity: Double = 0.4
|
||||
/// Vertical gap between a pedal row's name and its description subtitle.
|
||||
private static let rowSubtitleSpacing: CGFloat = 2
|
||||
/// Opacity of the pedal-row description subtitle.
|
||||
private static let summaryOpacity: Double = 0.55
|
||||
|
||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||
private static let preferredOrder: [String] = [
|
||||
"Overdrive", "Compressor", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation",
|
||||
"Auto-Wah", "Mutant", "Bass Octaver", "Octave Splitter",
|
||||
"Overdrive", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus",
|
||||
"Auto-Wah", "Mutant", "Ring Modulator", "Bass Octaver", "Octave Splitter",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverb",
|
||||
]
|
||||
|
||||
@@ -128,18 +132,29 @@ public struct PedalPaletteView: View {
|
||||
/// A full-width pedal row: tap appends to the main chain; drag carries `"add:<name>"` so it can
|
||||
/// be dropped onto a stereo/parallel lane.
|
||||
private func pedalRow(_ name: String) -> some View {
|
||||
Button {
|
||||
let summary: String = PedalRegistry.summary(for: name)
|
||||
return Button {
|
||||
onAdd(name)
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Text(name)
|
||||
.font(.callout)
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 0)
|
||||
Image(systemName: "plus")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.addGlyphOpacity))
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSubtitleSpacing) {
|
||||
HStack(spacing: 4) {
|
||||
Text(name)
|
||||
.font(.callout)
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 0)
|
||||
Image(systemName: "plus")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.addGlyphOpacity))
|
||||
}
|
||||
if !summary.isEmpty {
|
||||
Text(summary)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.summaryOpacity))
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, PedalPaletteView.cardPaddingH)
|
||||
.padding(.vertical, PedalPaletteView.cardPaddingV)
|
||||
|
||||
@@ -31,6 +31,9 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Limiter": return Color(red: 0.62, green: 0.16, blue: 0.20) // brick red
|
||||
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
||||
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
||||
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
||||
case "Sustainer": return Color(red: 0.22, green: 0.46, blue: 0.30) // pine green
|
||||
case "Ring Modulator": return Color(red: 0.64, green: 0.30, blue: 0.10) // burnt amber
|
||||
default: return Color(red: 0.36, green: 0.36, blue: 0.38) // steel gray
|
||||
}
|
||||
}
|
||||
@@ -212,6 +215,8 @@ public struct PedalView: View {
|
||||
private static let screwHalfSize: CGFloat = 4
|
||||
private static let namePlateBackgroundOpacity: Double = 0.35
|
||||
private static let fontSizeNamePlate: CGFloat = 13
|
||||
/// Opacity of the trailing ⓘ info button on the name plate.
|
||||
private static let infoButtonOpacity: Double = 0.7
|
||||
private static let outerBorderLineWidth: CGFloat = 1.5
|
||||
private static let innerHighlightLineWidth: CGFloat = 1
|
||||
private static let innerHighlightPadding: CGFloat = 1
|
||||
@@ -221,6 +226,9 @@ public struct PedalView: View {
|
||||
|
||||
private let pedal: Pedal
|
||||
|
||||
/// Presentation flag for the pedal info panel (description + control ranges).
|
||||
@State private var showInfo: Bool = false
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a stompbox pedal view for the given pedal.
|
||||
@@ -282,11 +290,15 @@ public struct PedalView: View {
|
||||
x: PedalView.shadowXOffset,
|
||||
y: PedalView.shadowYOffset
|
||||
)
|
||||
.sheet(isPresented: $showInfo) {
|
||||
PedalInfoView(pedal: pedal)
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subviews
|
||||
|
||||
/// Capsule name plate near the top of the enclosure.
|
||||
/// Capsule name plate near the top of the enclosure, with a trailing info button.
|
||||
private var namePlate: some View {
|
||||
Text(pedal.displayName)
|
||||
.font(.system(size: PedalView.fontSizeNamePlate, weight: .bold, design: .rounded))
|
||||
@@ -295,6 +307,18 @@ public struct PedalView: View {
|
||||
.padding(.vertical, PedalView.namePlatePaddingV)
|
||||
.background(Color.black.opacity(PedalView.namePlateBackgroundOpacity))
|
||||
.clipShape(RoundedRectangle(cornerRadius: PedalView.namePlateCornerRadius))
|
||||
.frame(maxWidth: .infinity)
|
||||
.overlay(alignment: .trailing) {
|
||||
Button {
|
||||
showInfo = true
|
||||
} label: {
|
||||
Image(systemName: "info.circle")
|
||||
.font(.system(size: PedalView.fontSizeNamePlate))
|
||||
.foregroundStyle(Color.white.opacity(PedalView.infoButtonOpacity))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("About this pedal")
|
||||
}
|
||||
}
|
||||
|
||||
/// Grid of the effect knobs, in rows of up to `knobColumnCount`.
|
||||
|
||||
Reference in New Issue
Block a user