feat(pedals): add Sustain Fuzz pedal + Gilmour/doom rigs
New "Sustain Fuzz": a mid-scooped, high-sustain fuzz distinct from the single-stage Fuzz. Two cascaded soft-clip (softClipNormalized) stages compress and stack harmonics for smooth violin-like sustain; a fixed midrange scoop (RBJPeakingEQ cut at 750 Hz) hollows the mids; a tone low-pass sets the top end. Sustain/Tone/Scoop knobs. Composed in effect(), no new RT generator. Registered in PedalType/PedalRegistry, enclosure colour, palette order. Tests cover build+non-silent, each knob changing output, knob listing, preset round-trip. Adds two factory rigs: Comfortably Numb Lead and Doom Riff Wall. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,7 @@ public extension PedalType {
|
||||
static let overdrive = PedalType("Overdrive")
|
||||
static let distortion = PedalType("Distortion")
|
||||
static let fuzz = PedalType("Fuzz")
|
||||
static let sustainFuzz = PedalType("Sustain Fuzz")
|
||||
static let compressor = PedalType("Compressor")
|
||||
static let limiter = PedalType("Limiter")
|
||||
static let noiseGate = PedalType("Noise Gate")
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// SustainFuzzPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Sustaining, mid-scooped fuzz: two cascaded soft-clipping stages into a scoop-and-tone filter.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → Saturator(soft, sustain) → Saturator(soft, sustain) → RBJPeakingEQ(−scoop @ 750 Hz) → RBJLowPass(tone) → out
|
||||
/// ```
|
||||
///
|
||||
/// This is the "wall of sustain" fuzz voice — distinct from the single-stage ``FuzzPedal``. Two
|
||||
/// cascaded *soft*-clipping stages compress and stack harmonics for long, smooth, violin-like
|
||||
/// sustain rather than the aggressive bite of a single hard `tanh` stage. A fixed mid **scoop**
|
||||
/// (a bell cut around 750 Hz) hollows the midrange — the defining character of this fuzz family —
|
||||
/// and the **tone** low-pass sets how dark or bright the top end sits.
|
||||
///
|
||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class; base `mix` is fully
|
||||
/// wet so the fuzz replaces the dry signal.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - sustain: Drive into both soft-clip stages. Higher = more sustain and compression.
|
||||
/// Range `[1, 30]`. Defaults to `6.0`.
|
||||
/// - tone: Low-pass tone cutoff in Hz. Range `[800, 6000]`. Defaults to `2500.0`.
|
||||
/// - scoop: Midrange cut depth in dB at 750 Hz (applied as a cut). Range `[0, 18]`. Defaults to `8.0`.
|
||||
public final class SustainFuzzPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Sustaining, mid-scooped fuzz for smooth, violin-like leads and thick walls of sound."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Drive into both cascaded soft-clip stages. Range [1, 30]; higher = more sustain.
|
||||
@UIParam public var sustain: Double = 6.0
|
||||
|
||||
/// Tone low-pass cutoff in Hz. Range [800, 6000].
|
||||
@UIParam public var tone: Double = 2500.0
|
||||
|
||||
/// Midrange cut depth in dB at 750 Hz. Range [0, 18].
|
||||
@UIParam public var scoop: Double = 8.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet so the fuzz completely replaces the dry signal.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Oversampling factor for the soft-clip stages — 2× keeps generated harmonics from folding back.
|
||||
private let oversampleFactor: Int = 2
|
||||
|
||||
/// Centre frequency of the midrange scoop in Hz.
|
||||
private let scoopFreq: Double = 750.0
|
||||
|
||||
/// Q of the midrange scoop bell. Moderately wide for a broad, hollow midrange.
|
||||
private let scoopQ: Double = 0.9
|
||||
|
||||
/// Q of the tone low-pass. Butterworth (no resonant peak).
|
||||
private let toneQ: Double = 0.707
|
||||
|
||||
/// Output trim after two soft-clip stages (each ≈ ±1) plus the mid cut, to sit at a sane level.
|
||||
private let outputTrim: Double = 0.6
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
/// Sustain knob range (drive into the soft-clip stages).
|
||||
private let sustainRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
|
||||
/// Tone knob range in Hz (low-pass cutoff).
|
||||
private let toneRange: ClosedRange<Double> = 800.0 ... 6000.0
|
||||
|
||||
/// Scoop knob range in dB (midrange cut depth).
|
||||
private let scoopRange: ClosedRange<Double> = 0.0 ... 18.0
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sustain", node: $sustain, range: sustainRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
PedalKnob(label: "Scoop", node: $scoop, range: scoopRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a sustain-fuzz 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: "Sustain Fuzz",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: SustainFuzzPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Cascades two soft-clip stages, scoops the mids, then rolls off the top with the tone control.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: Sustained, mid-scooped, tone-shaped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Two cascaded soft-clip stages. `softClipNormalized` keeps the level bounded as sustain
|
||||
// rises, so stacking two stages compresses and sustains rather than runs away.
|
||||
let stage1: OversampledSaturator = OversampledSaturator(
|
||||
dry,
|
||||
drive: $sustain,
|
||||
curve: .softClipNormalized,
|
||||
oversample: oversampleFactor
|
||||
)
|
||||
let stage2: OversampledSaturator = OversampledSaturator(
|
||||
stage1,
|
||||
drive: $sustain,
|
||||
curve: .softClipNormalized,
|
||||
oversample: oversampleFactor
|
||||
)
|
||||
|
||||
// Fixed midrange scoop (cut) — the hollow midrange that defines this fuzz family.
|
||||
let scoopCutDB: any ValidGeneratorInput = 0.0 - $scoop
|
||||
let scooped: RBJPeakingEQ.Audio = RBJPeakingEQ.Audio(
|
||||
input: stage2,
|
||||
freq: scoopFreq,
|
||||
gain: scoopCutDB,
|
||||
q: scoopQ
|
||||
)
|
||||
|
||||
// Tone low-pass rolls off the top end.
|
||||
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||
input: scooped,
|
||||
freq: $tone,
|
||||
q: toneQ
|
||||
)
|
||||
return toned * outputTrim
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,8 @@ public enum FactoryRigLibrary {
|
||||
ringModTexture,
|
||||
rockabillySlapback,
|
||||
psychVibeLead,
|
||||
comfortablyNumbLead,
|
||||
doomRiffWall,
|
||||
]
|
||||
|
||||
// MARK: Shoegaze walls
|
||||
@@ -539,6 +541,65 @@ public enum FactoryRigLibrary {
|
||||
}
|
||||
}
|
||||
|
||||
/// Compressed sustaining fuzz into a dotted delay and shimmer — a soaring, singing lead.
|
||||
static let comfortablyNumbLead: FactoryRig = FactoryRig(
|
||||
id: stableID("Comfortably Numb Lead"),
|
||||
name: "Comfortably Numb Lead",
|
||||
blurb: "Compressed, mid-scooped sustain fuzz into a dotted delay and octave-up shimmer — a "
|
||||
+ "soaring, singing lead that holds forever. Bend into long notes and let them bloom.",
|
||||
category: .classic
|
||||
) { _, board in
|
||||
try board.append(CompressorPedal()) { p in
|
||||
p.inputGain = 4.0
|
||||
p.threshold = -18.0
|
||||
p.ratio = 4.0
|
||||
}
|
||||
try board.append(SustainFuzzPedal()) { p in
|
||||
p.sustain = 14.0
|
||||
p.tone = 3000.0
|
||||
p.scoop = 10.0
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
// Dotted eighth at ~100 BPM.
|
||||
p.time = 0.45
|
||||
p.feedback = 2.2
|
||||
}
|
||||
try board.append(ShimmerReverbPedal()) { p in
|
||||
p.size = 0.09
|
||||
p.decay = 0.85
|
||||
p.shimmer = 0.5
|
||||
p.damp = 0.35
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-octave under a huge scooped fuzz into a cavernous room — heavy, slow doom.
|
||||
static let doomRiffWall: FactoryRig = FactoryRig(
|
||||
id: stableID("Doom Riff Wall"),
|
||||
name: "Doom Riff Wall",
|
||||
blurb: "A sub-octave stacked under a huge mid-scooped fuzz, into a cavernous room — crushing, "
|
||||
+ "slow doom. Down-tune, play half-time and let the low end swallow the room.",
|
||||
category: .experimental
|
||||
) { _, board in
|
||||
try board.append(BassOctaverPedal()) { p in
|
||||
p.oct1 = 0.8
|
||||
p.oct2 = 0.3
|
||||
p.direct = 0.9
|
||||
// Track mode: follow the played pitch.
|
||||
p.mode = 1.0
|
||||
}
|
||||
try board.append(SustainFuzzPedal()) { p in
|
||||
p.sustain = 22.0
|
||||
p.tone = 2200.0
|
||||
p.scoop = 6.0
|
||||
}
|
||||
try board.append(RoomReverbPedal()) { p in
|
||||
p.size = 70.0
|
||||
p.decay = 6.0
|
||||
p.damp = 0.55
|
||||
p.tail = 0.7
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Seeding
|
||||
|
||||
/// Builds every factory rig into a ``RigEntry`` snapshot suitable for the rig library.
|
||||
|
||||
@@ -66,6 +66,7 @@ public enum PedalRegistry {
|
||||
"Reverb": { ReverbPedal() },
|
||||
"Modulation": { ModulationPedal() },
|
||||
"Fuzz": { FuzzPedal() },
|
||||
"Sustain Fuzz": { SustainFuzzPedal() },
|
||||
"Tremolo": { TremoloPedal() },
|
||||
"Phaser": { PhaserPedal() },
|
||||
"Compressor": { CompressorPedal() },
|
||||
|
||||
@@ -54,7 +54,7 @@ public struct PedalPaletteView: View {
|
||||
/// 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] = [
|
||||
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Cabinet", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Cabinet", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", "Sustain Fuzz",
|
||||
"Volume",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Vibe", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
||||
"Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||
|
||||
@@ -54,6 +54,7 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Spring Reverb": return Color(red: 0.20, green: 0.46, blue: 0.64) // steel cyan
|
||||
case "Modulation": return Color(red: 0.12, green: 0.58, blue: 0.22) // green
|
||||
case "Fuzz": return Color(red: 0.55, green: 0.10, blue: 0.10) // deep crimson
|
||||
case "Sustain Fuzz": return Color(red: 0.72, green: 0.24, blue: 0.10) // rust / burnt orange
|
||||
case "Tremolo": return Color(red: 0.20, green: 0.38, blue: 0.72) // cobalt blue
|
||||
case "Phaser": return Color(red: 0.60, green: 0.22, blue: 0.62) // violet
|
||||
case "Vibe": return Color(red: 0.28, green: 0.20, blue: 0.62) // deep indigo
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
// SustainFuzzPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("SustainFuzzPedal")
|
||||
struct SustainFuzzPedalTests {
|
||||
|
||||
/// Renders the test loop through a sustain-fuzz configured by `configure`, returning stereo samples.
|
||||
private func render(configure: (SustainFuzzPedal) -> Void) throws -> [Float] {
|
||||
let renderDuration: Double = 0.2
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: renderDuration)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: SustainFuzzPedal = SustainFuzzPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url)
|
||||
}
|
||||
|
||||
/// Sum of squared differences over a mid-render window, guarding on length.
|
||||
private func windowSSD(_ a: [Float], _ b: [Float]) -> Double {
|
||||
let skip: Int = 1024
|
||||
let window: Int = 2048
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0 }
|
||||
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1)
|
||||
return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let samples: [Float] = try render { _ in }
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "SustainFuzzPedal produced silence")
|
||||
}
|
||||
|
||||
@Test func sustainChangesOutput() throws {
|
||||
let low: [Float] = try render { $0.sustain = 2.0 }
|
||||
let high: [Float] = try render { $0.sustain = 25.0 }
|
||||
#expect(hasNonSilentOutput(low))
|
||||
#expect(hasNonSilentOutput(high))
|
||||
#expect(windowSSD(low, high) > 0, "sustain did not change output")
|
||||
}
|
||||
|
||||
@Test func toneChangesOutput() throws {
|
||||
let dark: [Float] = try render { $0.tone = 900.0 }
|
||||
let bright: [Float] = try render { $0.tone = 5500.0 }
|
||||
#expect(windowSSD(dark, bright) > 0, "tone did not change output")
|
||||
}
|
||||
|
||||
@Test func scoopChangesOutput() throws {
|
||||
let flat: [Float] = try render { $0.scoop = 0.0 }
|
||||
let scooped: [Float] = try render { $0.scoop = 16.0 }
|
||||
#expect(windowSSD(flat, scooped) > 0, "scoop did not change output")
|
||||
}
|
||||
|
||||
@Test func exposesSustainToneScoopKnobs() {
|
||||
let pedal: SustainFuzzPedal = SustainFuzzPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Sustain", "Tone", "Scoop"])
|
||||
}
|
||||
|
||||
@Test func stateRoundTripsThroughPreset() {
|
||||
let pedal: SustainFuzzPedal = SustainFuzzPedal()
|
||||
pedal.sustain = 18.0
|
||||
pedal.tone = 3200.0
|
||||
pedal.scoop = 12.0
|
||||
|
||||
let state: PedalState = pedal.captureState()
|
||||
let restored: SustainFuzzPedal = SustainFuzzPedal()
|
||||
restored.applyState(state)
|
||||
|
||||
#expect(restored.sustain == 18.0)
|
||||
#expect(restored.tone == 3200.0)
|
||||
#expect(restored.scoop == 12.0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user