Files
Lyrebird/Sources/Lyrebird/Kinds/ToneStackModel.swift
T
2026-08-01 19:55:12 -07:00

49 lines
1.7 KiB
Swift

// ToneStackModel.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
/// A passive guitar-amplifier tone-stack topology, selecting the resistor/capacitor values
/// used by ``ToneStack``.
///
/// All three classic stacks share the same circuit; only the component values differ. The
/// values here match the widely-used Yeh/Smith reference set (the same set used by the Faust
/// `tonestacks` library).
///
/// - `fender`: Fender Bassman / Twin — scooped mids, bright.
/// - `marshall`: Marshall JCM800 — more mid, tighter low end.
/// - `vox`: Vox AC30 — a different taper, chimey top.
public enum ToneStackModel: String, CaseIterable, Sendable {
case fender
case marshall
case vox
/// Human-readable name for pickers.
public var displayName: String {
switch self {
case .fender: return "Fender"
case .marshall: return "Marshall"
case .vox: return "Vox"
}
}
/// Resistor values in ohms: `(R1, R2, R3, R4)`.
var resistors: (r1: Double, r2: Double, r3: Double, r4: Double) {
switch self {
case .fender: return (250_000.0, 1_000_000.0, 25_000.0, 56_000.0)
case .marshall: return (220_000.0, 1_000_000.0, 22_000.0, 33_000.0)
case .vox: return (1_000_000.0, 1_000_000.0, 10_000.0, 100_000.0)
}
}
/// Capacitor values in farads: `(C1, C2, C3)`.
var capacitors: (c1: Double, c2: Double, c3: Double) {
switch self {
case .fender: return (250.0e-12, 20.0e-9, 20.0e-9)
case .marshall: return (470.0e-12, 22.0e-9, 22.0e-9)
case .vox: return (50.0e-12, 22.0e-9, 22.0e-9)
}
}
}