From ec4e7dc5a4be52fed7c3bcd56892686415772507 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Sun, 2 Aug 2026 18:49:08 -0700 Subject: [PATCH] feat(cab): 5 new cabinet voices + notch/breakup IR shaping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand CabinetVoice from 3 to 8 synthesized voicings (all original code, no captures): add Modern 4×12, Boutique 2×12, Bright 1×12, Full-Range (FRFR), and Lo-Fi 1×8. Extend the IR synthesis model with two per-voice stages so the voices reach character the old 4-band curve could not: - cone-"breakup" peak (narrow upper-mid bite/clank, breakupQ 2.0) - mid interference "notch" (comb-filter dip ~1.2–2.5 kHz, notchQ 2.5) Both are RBJ peaking biquads; gain 0 = identity, so a voice can disable either (Full-Range runs a flat notch). Chain is now HP → LP×2 → body → presence → breakup → notch. New tests: FRFR top-end extension, notch mid-dip, 8-voice name uniqueness. Co-Authored-By: Claude Opus 4.8 --- .../Cabinet/CabinetIRFactory.swift | 6 + .../Cabinet/CabinetVoice.swift | 109 +++++++++++++++++- .../CabinetIRFactoryTests.swift | 27 +++++ 3 files changed, 137 insertions(+), 5 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Cabinet/CabinetIRFactory.swift b/Sources/LyrebirdShoeGaze/Cabinet/CabinetIRFactory.swift index e4d11fe..a9760b6 100644 --- a/Sources/LyrebirdShoeGaze/Cabinet/CabinetIRFactory.swift +++ b/Sources/LyrebirdShoeGaze/Cabinet/CabinetIRFactory.swift @@ -32,6 +32,10 @@ public enum CabinetIRFactory { private static let lowPassCascadeQ: [Double] = [0.541_196_100_146_197, 1.306_562_964_876_377] /// Q for the resonant body / presence peaks. private static let peakQ: Double = 1.2 + /// Q for the narrower cone-breakup peak (higher than the body/presence peaks). + private static let breakupQ: Double = 2.0 + /// Q for the mid interference notch (narrow, so it dips without gutting the midrange). + private static let notchQ: Double = 2.5 /// Builds the impulse response for `voice` at `sampleRate`. /// @@ -51,6 +55,8 @@ public enum CabinetIRFactory { OfflineBiquad.lowPass(freq: voice.lowPassHz, q: lowPassCascadeQ[1], sampleRate: sampleRate), OfflineBiquad.peaking(freq: voice.bodyHz, q: peakQ, gainDb: voice.bodyGainDb, sampleRate: sampleRate), OfflineBiquad.peaking(freq: voice.presenceHz, q: peakQ, gainDb: voice.presenceGainDb, sampleRate: sampleRate), + OfflineBiquad.peaking(freq: voice.breakupHz, q: breakupQ, gainDb: voice.breakupGainDb, sampleRate: sampleRate), + OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate), ] var ir: [Double] = [Double](repeating: 0.0, count: frames) diff --git a/Sources/LyrebirdShoeGaze/Cabinet/CabinetVoice.swift b/Sources/LyrebirdShoeGaze/Cabinet/CabinetVoice.swift index d68c432..bd2eb2b 100644 --- a/Sources/LyrebirdShoeGaze/Cabinet/CabinetVoice.swift +++ b/Sources/LyrebirdShoeGaze/Cabinet/CabinetVoice.swift @@ -6,17 +6,23 @@ /// A built-in guitar-speaker-cabinet voicing. /// -/// Each voice is a compact set of target-response parameters (low/high rolloff, a low-mid -/// "body" bump, and a presence peak) from which ``CabinetIRFactory`` synthesizes a short -/// impulse response entirely in code. These IRs are **our own content** (MIT, generated, no -/// third-party capture), so they ship with the pedal without licensing concerns. (Loading a -/// user-supplied captured `.wav` cab IR is a planned follow-up.) +/// Each voice is a compact set of target-response parameters — low/high rolloff, a low-mid +/// "body" bump, an upper-mid "presence" peak, a higher cone-"breakup" peak, and a mid +/// interference "notch" — from which ``CabinetIRFactory`` synthesizes a short impulse response +/// entirely in code. These IRs are **our own content** (MIT, generated, no third-party capture), +/// so they ship with the pedal without licensing concerns. (Loading a user-supplied captured +/// `.wav` cab IR is a planned follow-up.) /// /// The values are deliberately broad-strokes voicings, not measurements of specific hardware. public enum CabinetVoice: String, CaseIterable, Sendable { case americanCombo case britishStack case vintageDark + case modernStack + case boutiqueOpen + case brightCombo + case fullRange + case loFiBox /// Human-readable name for pickers. public var displayName: String { @@ -24,6 +30,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return "American 1×12" case .britishStack: return "British 4×12" case .vintageDark: return "Vintage Dark" + case .modernStack: return "Modern 4×12" + case .boutiqueOpen: return "Boutique 2×12" + case .brightCombo: return "Bright 1×12" + case .fullRange: return "Full-Range (FRFR)" + case .loFiBox: return "Lo-Fi 1×8" } } @@ -33,6 +44,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 80.0 case .britishStack: return 95.0 case .vintageDark: return 90.0 + case .modernStack: return 100.0 + case .boutiqueOpen: return 70.0 + case .brightCombo: return 85.0 + case .fullRange: return 45.0 + case .loFiBox: return 180.0 } } @@ -43,6 +59,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 5500.0 case .britishStack: return 4500.0 case .vintageDark: return 3800.0 + case .modernStack: return 4000.0 + case .boutiqueOpen: return 6000.0 + case .brightCombo: return 6500.0 + case .fullRange: return 9000.0 + case .loFiBox: return 3000.0 } } @@ -52,6 +73,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 420.0 case .britishStack: return 700.0 case .vintageDark: return 500.0 + case .modernStack: return 900.0 + case .boutiqueOpen: return 450.0 + case .brightCombo: return 550.0 + case .fullRange: return 300.0 + case .loFiBox: return 900.0 } } @@ -61,6 +87,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 1.5 case .britishStack: return -2.0 case .vintageDark: return 2.0 + case .modernStack: return 2.0 + case .boutiqueOpen: return -1.0 + case .brightCombo: return 1.0 + case .fullRange: return 0.0 + case .loFiBox: return 4.0 } } @@ -70,6 +101,11 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 3000.0 case .britishStack: return 2500.0 case .vintageDark: return 2200.0 + case .modernStack: return 3200.0 + case .boutiqueOpen: return 3500.0 + case .brightCombo: return 3800.0 + case .fullRange: return 4000.0 + case .loFiBox: return 2400.0 } } @@ -79,6 +115,69 @@ public enum CabinetVoice: String, CaseIterable, Sendable { case .americanCombo: return 3.0 case .britishStack: return 4.0 case .vintageDark: return 2.0 + case .modernStack: return 5.0 + case .boutiqueOpen: return 2.0 + case .brightCombo: return 4.0 + case .fullRange: return 1.0 + case .loFiBox: return 1.0 + } + } + + /// Cone-"breakup" peak centre in Hz — the higher, narrower bite/clank a real driver adds as + /// the cone breaks up. Sits above the presence peak. + var breakupHz: Double { + switch self { + case .americanCombo: return 4200.0 + case .britishStack: return 3800.0 + case .vintageDark: return 3500.0 + case .modernStack: return 4500.0 + case .boutiqueOpen: return 5000.0 + case .brightCombo: return 5200.0 + case .fullRange: return 6000.0 + case .loFiBox: return 2600.0 + } + } + + /// Cone-breakup peak gain in dB. Small; `0` disables the peak (identity). + var breakupGainDb: Double { + switch self { + case .americanCombo: return 2.0 + case .britishStack: return 3.0 + case .vintageDark: return 1.5 + case .modernStack: return 3.0 + case .boutiqueOpen: return 1.5 + case .brightCombo: return 3.0 + case .fullRange: return 0.5 + case .loFiBox: return 2.0 + } + } + + /// Mid interference "notch" centre in Hz — the characteristic dip from cone/mic + /// comb-filtering, typically ~1.2–2.5 kHz. + var notchHz: Double { + switch self { + case .americanCombo: return 1800.0 + case .britishStack: return 1600.0 + case .vintageDark: return 1500.0 + case .modernStack: return 1700.0 + case .boutiqueOpen: return 2000.0 + case .brightCombo: return 2100.0 + case .fullRange: return 2000.0 + case .loFiBox: return 1200.0 + } + } + + /// Notch depth in dB (negative). `0` disables the notch (identity). + var notchGainDb: Double { + switch self { + case .americanCombo: return -3.0 + case .britishStack: return -4.0 + case .vintageDark: return -2.5 + case .modernStack: return -5.0 + case .boutiqueOpen: return -2.0 + case .brightCombo: return -2.0 + case .fullRange: return 0.0 + case .loFiBox: return -1.0 } } } diff --git a/Tests/LyrebirdShoeGazeTests/CabinetIRFactoryTests.swift b/Tests/LyrebirdShoeGazeTests/CabinetIRFactoryTests.swift index 6ef6e8e..2ba60f4 100644 --- a/Tests/LyrebirdShoeGazeTests/CabinetIRFactoryTests.swift +++ b/Tests/LyrebirdShoeGazeTests/CabinetIRFactoryTests.swift @@ -66,4 +66,31 @@ struct CabinetIRFactoryTests { let darkHigh: Double = responseMagnitude(dark, hz: 5000.0) #expect(americanHigh > darkHigh, "vintageDark should be darker at 5 kHz") } + + @Test func fullRangeExtendsHigherThanCombo() { + // Full-Range (FRFR) has a ~9 kHz low-pass vs the American combo's ~5.5 kHz, so it keeps + // markedly more energy at 8 kHz. + let frfr: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, sampleRate: sampleRate) + let combo: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, sampleRate: sampleRate) + let frfrHigh: Double = responseMagnitude(frfr, hz: 8000.0) + let comboHigh: Double = responseMagnitude(combo, hz: 8000.0) + #expect(frfrHigh > comboHigh * 2.0, "FRFR should keep more 8 kHz than the combo") + } + + @Test func notchCreatesMidDip() { + // Modern 4×12 has a deep interference notch at 1.7 kHz. Its response there should dip below + // the surrounding midrange (points chosen clear of the body / presence peaks). + let ir: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .modernStack, sampleRate: sampleRate) + let atNotch: Double = responseMagnitude(ir, hz: 1700.0) + let below: Double = responseMagnitude(ir, hz: 1100.0) + let above: Double = responseMagnitude(ir, hz: 2400.0) + #expect(atNotch < below, "notch did not dip below the lower midrange") + #expect(atNotch < above, "notch did not dip below the upper midrange") + } + + @Test func voiceNamesAreUnique() { + let names: [String] = CabinetVoice.allCases.map { $0.displayName } + #expect(Set(names).count == names.count, "duplicate cabinet display names") + #expect(names.count == 8, "expected 8 cabinet voices") + } }