Compare commits
22 Commits
9c0122f199
..
v3.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fd7eaee57 | |||
| 654e80e9c8 | |||
| 292261a088 | |||
| a1ce308082 | |||
| 685bf5833e | |||
| 5a3cbeb372 | |||
| 11ce3f47d2 | |||
| da68864f36 | |||
| ebc660898d | |||
| f9ddd6b160 | |||
| da2c3328ee | |||
| 9b23f99a58 | |||
| d7eb0690ff | |||
| 35ae16040a | |||
| f67a5370ff | |||
| 96ab2a0586 | |||
| 99649c2d89 | |||
| 7f1856e8e5 | |||
| a2fcd59e1b | |||
| 594c501039 | |||
| e8b858f1aa | |||
| 9daffbbdf3 |
@@ -4,6 +4,71 @@ All notable changes to ShoeGaze are recorded here. The format follows
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
||||
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.0.0] — 2026-08-04
|
||||
|
||||
The big one: ShoeGaze becomes an amp-modeling rig. This release adds a full lineup of
|
||||
tube-amp voices — each with its own tone stack, onboard effects, and control surface —
|
||||
plus a deep speaker-cabinet and microphone section. Everything is original DSP built in
|
||||
code from the Lyrebird engine; there are no third-party captures or IR packs.
|
||||
|
||||
### Added
|
||||
|
||||
- **26 amp-model pedals**, grouped in their own **Amp Model** palette category:
|
||||
- **Fullerton** blackface combos — Fullerton Reverb, Deluxe, Ivy League, Drive — with
|
||||
spring reverb, tremolo, and a Bright switch.
|
||||
- **California** and **Jazz Clean** clean machines.
|
||||
- **British** stack and combo voices — British, Plexi, JTM, Bluesbreaker, Master, Dual —
|
||||
from early crunch to hot-rodded master-volume lead.
|
||||
- **Chime** top-boost family — Chime, Chime 15, Chime Normal, Chime Baby, Chime Top
|
||||
Boost — with the classic Cut control.
|
||||
- **Boutique and high-gain** — Boutique Lead, Boutique OD, Cali Hi-Gain (with an onboard
|
||||
5-band graphic EQ), and Modern High-Gain (Sag + Tight).
|
||||
- **Character amps** — Command, Citrus, Sixties Combo, Magna Vibrato (true pitch
|
||||
vibrato), and Anaheim (a solid-state-preamp / tube-power-amp hybrid with a built-in
|
||||
limiter).
|
||||
|
||||
Each amp carries its own tone-stack voicing, a selectable speaker cabinet, and a real
|
||||
**master volume** that drives the power-amp stage — not just an output trim.
|
||||
- **Analog-style output limiting.** Every amp ends in a soft `tanh` saturation into a hard
|
||||
±1 ceiling, so a driven amp compresses like the real thing instead of digitally clipping.
|
||||
- **Power-amp feel controls**, tucked behind an advanced pop-over (the sliders button at the
|
||||
top-right of the amp card): **Sag** (power-supply droop and bloom), **Bias**, and **Bias X**
|
||||
(bias balance).
|
||||
- **A full speaker-cabinet and microphone section** on the Cabinet pedal, now in its own
|
||||
**Cabinet** palette category next to the amps:
|
||||
- **Cabinet voices** — eight synthesized speaker voicings.
|
||||
- **Microphone modeling** — No Mic / Dynamic / Ribbon / Condenser, folded into the cab
|
||||
response.
|
||||
- **Mic placement** — Position (on-axis ↔ cone edge) and Proximity (distance / bass lift).
|
||||
- **Dual-mic blend** — add a second mic with its own blend and spacing (comb) control,
|
||||
the classic two-mic technique.
|
||||
- A transparent look-ahead limiter on the cabinet output.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Gain and Drive now read 1–11** — yes, they go to eleven — with a musical taper: fine
|
||||
control at the bottom of the dial, full saturation at the top, instead of a raw internal
|
||||
number.
|
||||
- **The cabinet is now a separate pedal you place in the chain.** Amps keep a built-in cab,
|
||||
plus a **None (direct)** option so you can run a dedicated Cabinet block (and, later, your
|
||||
own impulse response) after the amp.
|
||||
- **Palette:** the Amp Model and Cabinet categories sit together, and the Cabinet card is
|
||||
double-width to fit its cab / mic / second-mic selectors.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Noise Gate no longer pops as a note decays.** The gate now opens fast and closes gently
|
||||
(a slow, tunable fade) instead of snapping shut when a sustained note falls through the
|
||||
threshold — previously that abrupt step, amplified by downstream gain (e.g. a fuzz), was
|
||||
audible as a pop / sudden tone change. New **Attack** and **Release** timing knobs (in the
|
||||
gate's advanced pop-over) dial the close from tight to a gradual swell.
|
||||
|
||||
### Notes
|
||||
|
||||
- All amp, cabinet, and microphone models are original DSP generated in code — not captures
|
||||
of any specific hardware, speaker, microphone, or IR pack. Tube tone stacks follow the
|
||||
published Yeh & Smith analysis of the classic passive tone-stack circuit.
|
||||
|
||||
## [2.1.3] — 2026-07-13
|
||||
|
||||
A tuner fix. Engaging the chromatic tuner could crackle or pop through the output —
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 14;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@@ -175,7 +175,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 2.1.6;
|
||||
MARKETING_VERSION = 3.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -193,7 +193,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 14;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = ShoeGazeBuilder/Info.plist;
|
||||
@@ -204,7 +204,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||
MARKETING_VERSION = 2.1.6;
|
||||
MARKETING_VERSION = 3.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
CURRENT_PROJECT_VERSION = 8;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
@@ -175,7 +175,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 3.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
@@ -194,7 +194,7 @@
|
||||
CODE_SIGNING_REQUIRED = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = ShoeGazeBuilderiOS/ShoeGazeBuilderiOS.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
CURRENT_PROJECT_VERSION = 8;
|
||||
INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = ShoeGaze;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
@@ -203,7 +203,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.0.0;
|
||||
MARKETING_VERSION = 3.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// CabIRStage.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// One filter stage in an off-RT cabinet-IR cascade, as a kind plus parameters.
|
||||
///
|
||||
/// Consumed by ``CabinetIRFactory`` when it bakes an impulse response: the cab voice contributes a
|
||||
/// fixed cascade, and a ``MicVoice`` contributes extra stages (presence bump, top-end/low-end
|
||||
/// shelving) appended to it. `q` is used by high-pass / low-pass / peaking stages; `gainDb` by
|
||||
/// peaking and the shelves; shelves use a fixed slope set by the factory.
|
||||
struct CabIRStage {
|
||||
|
||||
/// The biquad kind this stage bakes into.
|
||||
enum Kind {
|
||||
case highPass
|
||||
case lowPass
|
||||
case peaking
|
||||
case lowShelf
|
||||
case highShelf
|
||||
}
|
||||
|
||||
let kind: Kind
|
||||
let freq: Double
|
||||
let q: Double
|
||||
let gainDb: Double
|
||||
|
||||
/// A resonant peak/dip at `freq`.
|
||||
static func peaking(_ freq: Double, q: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .peaking, freq: freq, q: q, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A low-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func lowShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .lowShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
|
||||
/// A high-frequency shelf at `freq` (slope fixed by the factory).
|
||||
static func highShelf(_ freq: Double, gainDb: Double) -> CabIRStage {
|
||||
CabIRStage(kind: .highShelf, freq: freq, q: 0.0, gainDb: gainDb)
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import Darwin
|
||||
/// Fraction of the sample rate above which a filter centre frequency is clamped, so the RBJ
|
||||
/// coefficients stay well-behaved below Nyquist even at low sample rates.
|
||||
private let cabinetBiquadNyquistFraction: Double = 0.49
|
||||
/// RBJ-cookbook divisor converting a peaking-filter gain in dB to its `A` amplitude term.
|
||||
private let cabinetPeakingGainDivisor: Double = 40.0
|
||||
/// RBJ-cookbook divisor converting a filter gain in dB to its `A` amplitude term (peaking + shelves).
|
||||
private let cabinetDbToAmplitudeDivisor: Double = 40.0
|
||||
|
||||
/// Synthesizes a short cabinet impulse response for a ``CabinetVoice`` by running a unit
|
||||
/// impulse through a cascade of RBJ biquads (high-pass → two-stage low-pass → low-mid body
|
||||
@@ -37,16 +37,24 @@ public enum CabinetIRFactory {
|
||||
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
|
||||
/// Fixed shelf slope for the ``MicVoice`` low-/high-shelf stages (gentle, like the amp shelves).
|
||||
private static let micShelfSlope: Double = 0.7
|
||||
|
||||
/// Builds the impulse response for `voice` at `sampleRate`.
|
||||
/// Builds the impulse response for `voice` (optionally mic'd by `mic`) at `sampleRate`.
|
||||
///
|
||||
/// The cab voice's fixed cascade is baked first; any ``MicVoice`` stages are appended before the
|
||||
/// impulse is run, so the mic colour is folded into the same single IR (no extra render-time
|
||||
/// cost). ``MicVoice/off`` appends nothing, so the result is byte-for-byte the raw cab voice.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - voice: The cabinet voicing to synthesize.
|
||||
/// - mic: The microphone voicing layered on top. Defaults to ``MicVoice/off`` (no mic).
|
||||
/// - sampleRate: Engine sample rate in Hz.
|
||||
/// - frames: IR length in frames. Defaults to ``defaultFrames``.
|
||||
/// - Returns: A mono `LyrebirdBuffer` holding the normalized IR, tagged with `sampleRate`.
|
||||
public static func makeIR(
|
||||
voice: CabinetVoice,
|
||||
mic: MicVoice = .off,
|
||||
sampleRate: Double,
|
||||
frames: Int = CabinetIRFactory.defaultFrames
|
||||
) -> LyrebirdBuffer {
|
||||
@@ -60,6 +68,25 @@ public enum CabinetIRFactory {
|
||||
OfflineBiquad.peaking(freq: voice.notchHz, q: notchQ, gainDb: voice.notchGainDb, sampleRate: sampleRate),
|
||||
]
|
||||
|
||||
// Append the mic voicing's stages (none for `.off`) so its colour bakes into the same IR.
|
||||
for stage: CabIRStage in mic.stages {
|
||||
switch stage.kind {
|
||||
case .highPass:
|
||||
chain.append(OfflineBiquad.highPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .lowPass:
|
||||
chain.append(OfflineBiquad.lowPass(freq: stage.freq, q: stage.q, sampleRate: sampleRate))
|
||||
case .peaking:
|
||||
chain.append(OfflineBiquad.peaking(
|
||||
freq: stage.freq, q: stage.q, gainDb: stage.gainDb, sampleRate: sampleRate))
|
||||
case .lowShelf:
|
||||
chain.append(OfflineBiquad.lowShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
case .highShelf:
|
||||
chain.append(OfflineBiquad.highShelf(
|
||||
freq: stage.freq, gainDb: stage.gainDb, slope: micShelfSlope, sampleRate: sampleRate))
|
||||
}
|
||||
}
|
||||
|
||||
var ir: [Double] = [Double](repeating: 0.0, count: frames)
|
||||
for n: Int in 0..<frames {
|
||||
var sample: Double = n == 0 ? 1.0 : 0.0
|
||||
@@ -149,7 +176,7 @@ private struct OfflineBiquad {
|
||||
|
||||
static func peaking(freq: Double, q: Double, gainDb: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetPeakingGainDivisor)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let alpha: Double = sin(w0) / (2.0 * q)
|
||||
@@ -161,4 +188,44 @@ private struct OfflineBiquad {
|
||||
let a2: Double = 1.0 - alpha / amplitude
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ low-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func lowShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 - am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = 2.0 * amplitude * (am1 - ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 - am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 + am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = -2.0 * (am1 + ap1 * cosW0)
|
||||
let a2: Double = ap1 + am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
|
||||
/// RBJ high-shelf. `slope` is the cookbook `S` (1.0 = steepest without overshoot).
|
||||
static func highShelf(freq: Double, gainDb: Double, slope: Double, sampleRate: Double) -> OfflineBiquad {
|
||||
let f: Double = clampedFreq(freq, sampleRate: sampleRate)
|
||||
let amplitude: Double = pow(10.0, gainDb / cabinetDbToAmplitudeDivisor)
|
||||
let w0: Double = 2.0 * Double.pi * f / sampleRate
|
||||
let cosW0: Double = cos(w0)
|
||||
let sinW0: Double = sin(w0)
|
||||
let alpha: Double = sinW0 / 2.0 * sqrt((amplitude + 1.0 / amplitude) * (1.0 / slope - 1.0) + 2.0)
|
||||
let twoSqrtAAlpha: Double = 2.0 * sqrt(amplitude) * alpha
|
||||
let ap1: Double = amplitude + 1.0
|
||||
let am1: Double = amplitude - 1.0
|
||||
let b0: Double = amplitude * (ap1 + am1 * cosW0 + twoSqrtAAlpha)
|
||||
let b1: Double = -2.0 * amplitude * (am1 + ap1 * cosW0)
|
||||
let b2: Double = amplitude * (ap1 + am1 * cosW0 - twoSqrtAAlpha)
|
||||
let a0: Double = ap1 - am1 * cosW0 + twoSqrtAAlpha
|
||||
let a1: Double = 2.0 * (am1 - ap1 * cosW0)
|
||||
let a2: Double = ap1 - am1 * cosW0 - twoSqrtAAlpha
|
||||
return OfflineBiquad(b0: b0 / a0, b1: b1 / a0, b2: b2 / a0, a1: a1 / a0, a2: a2 / a0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// MicVoice.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// A microphone voicing baked into the cabinet impulse response — the frequency signature of the
|
||||
/// mic in front of the speaker, layered on top of the ``CabinetVoice`` cab curve.
|
||||
///
|
||||
/// Each voice is a compact set of ``CabIRStage`` filter stages (a presence bump, low-end and
|
||||
/// top-end shelving) that ``CabinetIRFactory`` appends to the cab cascade before baking, so mic
|
||||
/// choice costs nothing extra at render time — it is folded into the single convolution IR. These
|
||||
/// are **broad-strokes synthesized curves** (our own MIT content, not captures of any specific
|
||||
/// microphone), analogous to ``CabinetVoice``.
|
||||
///
|
||||
/// ``off`` contributes no stages, so a cab with no mic bakes exactly the raw cab voice — the
|
||||
/// original, mic-less behaviour.
|
||||
public enum MicVoice: String, CaseIterable, Sendable {
|
||||
case off
|
||||
case dynamic
|
||||
case ribbon
|
||||
case condenser
|
||||
|
||||
/// The voice at a selector value (an index into ``allCases``), rounded and clamped to the valid
|
||||
/// range. Mirrors ``CabinetVoice/voice(atSelectorValue:)`` so a huge / NaN selector never traps.
|
||||
///
|
||||
/// - Parameter selectorValue: The live selector node value (nominally an integer index).
|
||||
/// - Returns: The corresponding voice, clamped to `allCases`.
|
||||
public static func voice(atSelectorValue selectorValue: Double) -> MicVoice {
|
||||
let all: [MicVoice] = allCases
|
||||
guard selectorValue.isFinite else { return all[0] }
|
||||
let bounded: Double = Swift.min(Swift.max(selectorValue, 0.0), Double(all.count - 1))
|
||||
let index: Int = Int(bounded.rounded())
|
||||
return all[index]
|
||||
}
|
||||
|
||||
/// Human-readable name for pickers.
|
||||
public var displayName: String {
|
||||
switch self {
|
||||
case .off: return "No Mic"
|
||||
case .dynamic: return "Dynamic"
|
||||
case .ribbon: return "Ribbon"
|
||||
case .condenser: return "Condenser"
|
||||
}
|
||||
}
|
||||
|
||||
/// The mic's filter stages, appended to the cab cascade before baking. Empty for ``off``.
|
||||
///
|
||||
/// Broad-strokes voicings: the **dynamic** (moving-coil, close-mic staple) adds an upper-mid
|
||||
/// presence bump with a tightened low end and rolled-off extreme top; the **ribbon** is dark and
|
||||
/// smooth (warm low-mid, steep top rolloff, no presence spike); the **condenser** is the most
|
||||
/// extended and airy (gentle top-end lift, light presence sheen).
|
||||
var stages: [CabIRStage] {
|
||||
switch self {
|
||||
case .off:
|
||||
return []
|
||||
case .dynamic:
|
||||
return [
|
||||
CabIRStage.lowShelf(120.0, gainDb: -2.0),
|
||||
CabIRStage.peaking(5500.0, q: 1.0, gainDb: 4.0),
|
||||
CabIRStage.highShelf(9000.0, gainDb: -3.0),
|
||||
]
|
||||
case .ribbon:
|
||||
return [
|
||||
CabIRStage.lowShelf(200.0, gainDb: 2.5),
|
||||
CabIRStage.peaking(2500.0, q: 0.8, gainDb: -1.5),
|
||||
CabIRStage.highShelf(6500.0, gainDb: -7.0),
|
||||
]
|
||||
case .condenser:
|
||||
return [
|
||||
CabIRStage.peaking(8000.0, q: 1.0, gainDb: 1.5),
|
||||
CabIRStage.highShelf(11000.0, gainDb: 3.0),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,12 @@ open class Pedal: SynthesizerBase {
|
||||
open func rigWillTeardown() {}
|
||||
|
||||
/// Number of standard enclosure widths this pedal's card occupies in the UI. Defaults
|
||||
/// to `1`. A control-dense pedal (e.g. the looper) overrides to `2` for a wider card.
|
||||
/// The UI multiplies its base enclosure width by this factor; `1` is the normal stompbox.
|
||||
/// to `1`. This sets the card's **base width in knob columns**: `1` = a three-wide card, `≥ 2` =
|
||||
/// four-wide (and the knob grid packs that many across). It is both the grid's column count and
|
||||
/// the card's minimum width, so a `2` pedal is a four-wide card even with few knobs (e.g. the
|
||||
/// Cabinet, to keep its selector captions readable). A pedal whose selector/switch row is wider
|
||||
/// still pushes wider; values above `2` add nothing. (The looper is the sole exception: it
|
||||
/// overrides the UI to a fixed multi-column layout scaled by this value.)
|
||||
open var widthUnits: Int { 1 }
|
||||
|
||||
/// `true` when the board has placed this pedal in a stereo (width-2) region.
|
||||
|
||||
@@ -17,10 +17,13 @@ import LyrebirdUI
|
||||
/// → TriodeStage(drive: gain) (preamp)
|
||||
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
|
||||
/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity)
|
||||
/// → TriodeStage(power-amp drive) (power-amp warmth)
|
||||
/// → powerAmpStage(_:) (power amp — two TriodeStage halves blended by
|
||||
/// Bias X; single-stage tone at biasX = 0)
|
||||
/// → shapeVoice(_:) (subclass signature filter)
|
||||
/// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, rebuild on change)
|
||||
/// → TriodeStage(bias: 0) → Clip(±1) (output soft-limit + hard safety ceiling)
|
||||
/// → applySag(_:) (shared power-supply Sag droop; identity at sag = 0)
|
||||
/// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, or None for a
|
||||
/// separate cab block; rebuild on change)
|
||||
/// → TriodeStage(bias: 0) → Clip(±1) (output soft-limit + hard safety ceiling — always on)
|
||||
/// ```
|
||||
/// Fully wet (the amp replaces the dry signal); `Level` is the master. Double-width amp-head card.
|
||||
///
|
||||
@@ -38,8 +41,10 @@ open class AmpVoicePedal: Pedal {
|
||||
|
||||
// MARK: - Common parameters
|
||||
|
||||
/// Preamp drive into the first tube stage. Range [1, 30].
|
||||
@UIParam public var gain: Double = 6.0
|
||||
/// Preamp **Gain** dial in `[1, 11]` (yes, it goes to eleven). Mapped to the tube-drive range
|
||||
/// `[1, 30]` through a musical exponential taper — see ``taperedDrive(_:)`` — so low settings give
|
||||
/// fine control and the top of the dial pushes hard into saturation.
|
||||
@UIParam public var gain: Double = 6.27
|
||||
/// Tone-stack bass control in [0, 1].
|
||||
@UIParam public var bass: Double = 0.5
|
||||
/// Tone-stack mid control in [0, 1].
|
||||
@@ -56,6 +61,12 @@ open class AmpVoicePedal: Pedal {
|
||||
/// hotter (warmer, more even harmonics). Surfaced in the advanced pop-over. See
|
||||
/// ``powerAmpBiasInput``.
|
||||
@UIParam public var bias: Double = 0.5
|
||||
/// Power-amp **Bias X** (bias balance) in `[0, 1]`, default `0` = balanced. At `0` the power amp
|
||||
/// is a single stage — the shipped tone, exactly. Turning it up spreads the two power-amp
|
||||
/// half-stages' bias operating points and averages them, re-shaping the saturation knee for a
|
||||
/// distinct power-amp character (named after the "bias balance" trim on amps that expose one).
|
||||
/// Surfaced in the advanced pop-over. See `powerAmpStage(_:)`.
|
||||
@UIParam public var biasX: Double = 0.0
|
||||
|
||||
// MARK: - Subclass configuration
|
||||
|
||||
@@ -143,7 +154,19 @@ open class AmpVoicePedal: Pedal {
|
||||
/// - Parameter signal: The post-`inputShaping` input signal.
|
||||
/// - Returns: The preamp output fed into the tone stack.
|
||||
open func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: $gain, bias: preampBias, oversample: preampOversample)
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: preampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Maps a `Gain` / `Drive` dial `[1, 11]` to the tube-drive range `[dialDriveMin, dialDriveMax]`
|
||||
/// through an exponential (musical) taper: `drive = dialDriveMin · (dialDriveMax/dialDriveMin) ^
|
||||
/// ((dial − 1) / 10)`. A live node, so the dial stays a smooth knob. Every amp's preamp and
|
||||
/// drive-channel stage runs its dial through this so `1` is nearly clean, `11` is full saturation,
|
||||
/// and the useful grind spreads across the dial rather than bunching at the bottom.
|
||||
///
|
||||
/// - Parameter dial: A `[1, 11]` Gain/Drive knob node.
|
||||
/// - Returns: The mapped tube drive to feed a `TriodeStage`.
|
||||
func taperedDrive(_ dial: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
LinExp.Audio(dial, inLo: dialMin, inHi: dialMax, outLo: dialDriveMin, outHi: dialDriveMax)
|
||||
}
|
||||
|
||||
/// Drive into the power-amp `TriodeStage`. Defaults to the fixed power-amp drive. Two kinds of
|
||||
@@ -168,6 +191,36 @@ open class AmpVoicePedal: Pedal {
|
||||
LinLin.Audio($bias, inLo: 0.0, inHi: 1.0, outLo: coldPowerAmpBias, outHi: hotPowerAmpBias)
|
||||
}
|
||||
|
||||
/// The power-amp stage. **Bias X** (``biasX``) spreads the two `TriodeStage` halves' bias
|
||||
/// operating points to `powerAmpBiasInput ± (biasX · biasXMaxSpread)` and averages them. At
|
||||
/// `biasX = 0` both halves share the base bias, so the average is bit-identical to a single stage
|
||||
/// (the shipped tone); turning `biasX` up widens the spread, re-shaping the saturation character.
|
||||
///
|
||||
/// > Note: a deliberate approximation — a *character* control on the single-ended power-stage
|
||||
/// > model, not a literal push-pull topology (which would re-voice every amp). It reduces to the
|
||||
/// > exact prior tone at `biasX = 0`. Both halves are always built, so an amp pays two oversampled
|
||||
/// > stages even at `biasX = 0` — a smooth, live knob was preferred over a rebuild-on-change
|
||||
/// > single-stage fast path.
|
||||
///
|
||||
/// - Parameter signal: The post-`onboardEffects` signal into the power amp.
|
||||
/// - Returns: The blended power-amp output.
|
||||
func powerAmpStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let imbalance: any ValidGeneratorInput = $biasX * biasXMaxSpread
|
||||
let hotHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput + imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
let coldHalf: TriodeStage = TriodeStage(
|
||||
input: signal,
|
||||
drive: powerAmpDriveInput,
|
||||
bias: powerAmpBiasInput - imbalance,
|
||||
oversample: powerAmpOversample
|
||||
)
|
||||
return (hotHalf + coldHalf) * powerAmpHalfBlend
|
||||
}
|
||||
|
||||
/// Applies power-supply **Sag**: an `AmplitudeFollower` on `signal` reduces gain as it gets loud
|
||||
/// (droop) and recovers slowly (bloom). `Sag` scales the depth; at `sag = 0` the droop is `0` and
|
||||
/// the gain is a constant `1.0` (an identity multiply), so a sag-less amp is unchanged.
|
||||
@@ -199,6 +252,13 @@ open class AmpVoicePedal: Pedal {
|
||||
/// Generic `PedalSwitch` off / on values, shared by every amp that publishes switches.
|
||||
let switchOffValue: Double = 0.0
|
||||
let switchOnValue: Double = 1.0
|
||||
/// Gain/Drive dial endpoints and the tube-drive range they taper onto (see ``taperedDrive(_:)``).
|
||||
/// `11` is the top of the dial; `30` is the maximum tube drive it reaches. `dialDriveMin > 0` is
|
||||
/// required by `LinExp`.
|
||||
let dialMin: Double = 1.0
|
||||
let dialMax: Double = 11.0
|
||||
let dialDriveMin: Double = 1.0
|
||||
let dialDriveMax: Double = 30.0
|
||||
/// Fixed power-amp stage drive (gentler than the preamp).
|
||||
private let powerAmpDrive: Double = 1.5
|
||||
/// Power-amp grid bias at `bias = 0` (coldest) and `bias = 1` (hottest). Symmetric about `0`, so
|
||||
@@ -207,6 +267,12 @@ open class AmpVoicePedal: Pedal {
|
||||
/// drastically re-voicing the amp.
|
||||
private let coldPowerAmpBias: Double = -0.25
|
||||
private let hotPowerAmpBias: Double = 0.25
|
||||
/// Maximum push-pull bias imbalance at `biasX = 1` — the offset applied oppositely to the two
|
||||
/// power-amp half-stages. Modest so the control colours the harmonics without destabilising the amp.
|
||||
private let biasXMaxSpread: Double = 0.35
|
||||
/// Equal-weight blend of the two power-amp half-stages. `0.5·(hot + cold)` averages them, so at
|
||||
/// `biasX = 0` (identical halves) the result is bit-identical to a single stage.
|
||||
private let powerAmpHalfBlend: Double = 0.5
|
||||
/// Sag envelope-follower attack — moderately fast (the supply starts drooping under load).
|
||||
private let sagAttackSeconds: Double = 0.02
|
||||
/// Sag envelope-follower release — slow, so the sag lingers and blooms back (supply recovery).
|
||||
@@ -229,23 +295,29 @@ open class AmpVoicePedal: Pedal {
|
||||
/// just above ±1, guaranteeing the amp stage never emits a sample the DAC would clip.
|
||||
private let outputCeiling: Double = 1.0
|
||||
|
||||
let gainRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
let gainRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
let toneRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
/// Range for a signature control that maps [0, 1] (Bright / Presence / Cut amount).
|
||||
let signatureRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Cab selector value for the "None (direct)" stop — no speaker convolution. Placed one past the
|
||||
/// last `CabinetVoice` index so every existing voice keeps its saved index (append-only).
|
||||
static let cabinetBypassValue: Double = Double(CabinetVoice.allCases.count)
|
||||
|
||||
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, voice: CabinetVoice) in
|
||||
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||
}
|
||||
+ [PedalSelectorKnob.Stop(title: "None (direct)", value: cabinetBypassValue)]
|
||||
|
||||
// MARK: - Chrome
|
||||
|
||||
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
|
||||
public override var showsMixControl: Bool { false }
|
||||
|
||||
/// Amp-head-style double-width card.
|
||||
/// Amps use a four-wide knob grid for their Gain/Bass/Mid/Treble + signature controls (the card
|
||||
/// width is sized to content — see `PedalView.enclosureWidth`).
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
public override var summary: String { summaryText }
|
||||
@@ -290,32 +362,32 @@ open class AmpVoicePedal: Pedal {
|
||||
}
|
||||
|
||||
/// Power-amp deep-cut controls, tucked behind the pedal card's advanced pop-over: **Sag**
|
||||
/// (power-supply droop/bloom) and **Bias** (power-amp grid-bias operating point). Neither is a
|
||||
/// topology control — both are live nodes that round-trip through the rig save format.
|
||||
/// (power-supply droop/bloom), **Bias** (power-amp grid-bias operating point), and **Bias X**
|
||||
/// (power-amp bias balance). None is a topology control — all are live nodes that round-trip
|
||||
/// through the rig save format. Order is append-only (persisted positionally in `advancedValues`).
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Sag", node: $sag, range: signatureRange),
|
||||
PedalKnob(label: "Bias", node: $bias, range: toneRange),
|
||||
PedalKnob(label: "Bias X", node: $biasX, range: signatureRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet → output soft-limit.
|
||||
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet (or None) → output
|
||||
/// soft-limit.
|
||||
///
|
||||
/// > Note: only the voice named by the live `cab` selector is instantiated, so exactly one
|
||||
/// > `ConvolutionReverb` runs. The `cab` selector is `rebuildsOnChange`, so switching cabs
|
||||
/// > rebuilds the board (re-entering `effect(_:)` with the new voice) rather than running every
|
||||
/// > voice at once.
|
||||
/// > Note: at most one `ConvolutionReverb` runs — only the voice named by the live `cab` selector
|
||||
/// > is instantiated, and the "None (direct)" stop instantiates none. The `cab` selector is
|
||||
/// > `rebuildsOnChange`, so switching cabs (or to/from None) rebuilds the board rather than
|
||||
/// > running every voice at once.
|
||||
///
|
||||
/// The closing `TriodeStage(bias: 0)` is a symmetric `tanh` output limiter: the cab convolution
|
||||
/// and signature shelves can push peaks past ±1, which a real analog output would soft-compress
|
||||
/// rather than hard-clip. Unit small-signal gain keeps clean tones intact; peaks soft-limit
|
||||
/// toward ±1. The trailing `Clip(±1)` is a hard safety clamp for the sub-percent overshoot the
|
||||
/// `tanh`'s DC-blocker and the halfband filters can leave — so no sample can clip the DAC.
|
||||
/// The output soft-limit (``outputLimit(_:)``) always runs, cabinet or not, so the ±1 ceiling
|
||||
/// holds even when the cabinet is bypassed for a separate downstream cab block.
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The amped, cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
/// - Returns: The amped, (optionally) cab-convolved, soft-limited, ceiling-clamped mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
cabinetAndLimit(preCabinetCore(dry))
|
||||
}
|
||||
@@ -332,32 +404,69 @@ open class AmpVoicePedal: Pedal {
|
||||
let toned: ToneStack = ToneStack(
|
||||
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
|
||||
let processed: any ValidGeneratorInput = onboardEffects(toned)
|
||||
let powerAmp: TriodeStage = TriodeStage(
|
||||
input: processed, drive: powerAmpDriveInput, bias: powerAmpBiasInput, oversample: powerAmpOversample)
|
||||
let powerAmp: any ValidGeneratorInput = powerAmpStage(processed)
|
||||
return applySag(shapeVoice(powerAmp))
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: the selected `CabinetVoice` convolver → `tanh`
|
||||
/// soft-limit → `Clip(±1)` safety clamp. Applied once in mono, or once per channel by a
|
||||
/// widener amp.
|
||||
/// True when the `Cab` selector is on the "None (direct)" stop — the amp emits its limited
|
||||
/// power-amp signal with **no** speaker convolution, so the player can place a separate cabinet
|
||||
/// block (the standalone `Cabinet` pedal, or a future IR loader) downstream. Read at board-build
|
||||
/// time; the selector is `rebuildsOnChange`, so toggling it rebuilds the graph.
|
||||
///
|
||||
/// > Warning: with no cabinet, the amp sounds raw and fizzy (the power-amp `tanh` with no speaker
|
||||
/// > low-pass) — expected; a cabinet is what tames the top end.
|
||||
var isCabinetBypassed: Bool {
|
||||
guard cab.isFinite else { return false }
|
||||
// Clamp in Double space before converting: a huge finite `cab` (from a corrupted/hand-edited
|
||||
// rig) would otherwise trap `Int(_:)` — same defense as `CabinetVoice.voice(atSelectorValue:)`.
|
||||
let bounded: Double = Swift.min(Swift.max(cab, 0.0), Double(CabinetVoice.allCases.count))
|
||||
return Int(bounded.rounded()) >= CabinetVoice.allCases.count
|
||||
}
|
||||
|
||||
/// The per-channel cabinet + output stage: cabinet convolver (or a straight pass at the "None"
|
||||
/// stop) → `tanh` soft-limit → `Clip(±1)` safety clamp. Applied once in mono, or once per channel
|
||||
/// by a widener amp.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The cab-convolved, soft-limited, ceiling-clamped signal.
|
||||
/// - Returns: The (optionally) cab-convolved, soft-limited, ceiling-clamped signal.
|
||||
func cabinetAndLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
outputLimit(cabinet(signal))
|
||||
}
|
||||
|
||||
/// The selected `CabinetVoice` speaker convolver, or `signal` unchanged when the `Cab` selector
|
||||
/// is on "None (direct)". Only the voice named by the live `cab` selector is instantiated, so at
|
||||
/// most one `ConvolutionReverb` runs.
|
||||
///
|
||||
/// - Parameter signal: The post-core signal for one channel.
|
||||
/// - Returns: The cab-convolved signal, or `signal` unchanged when the cabinet is bypassed.
|
||||
func cabinet(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
guard !isCabinetBypassed else { return signal }
|
||||
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cab)
|
||||
let cabinet: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
return ConvolutionReverb.Audio(
|
||||
input: signal,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate),
|
||||
mix: cabinetMix
|
||||
)
|
||||
}
|
||||
|
||||
/// The output soft-limit + hard `Clip(±1)` safety ceiling — **always** applied on the amp,
|
||||
/// cabinet or not, so the ±1 guarantee holds even at the "None (direct)" stop.
|
||||
///
|
||||
/// The `TriodeStage(bias: 0)` is a symmetric `tanh` output limiter: cab convolution and signature
|
||||
/// shelves can push peaks past ±1, which a real analog output soft-compresses rather than
|
||||
/// hard-clips. Unit small-signal gain keeps clean tones intact; peaks soft-limit toward ±1. The
|
||||
/// trailing `Clip(±1)` hard-clamps the sub-percent overshoot the `tanh`'s DC-blocker and the
|
||||
/// halfband filters can leave, so no sample can clip the DAC.
|
||||
///
|
||||
/// - Parameter signal: The (optionally cab-convolved) signal for one channel.
|
||||
/// - Returns: The soft-limited, ceiling-clamped signal.
|
||||
func outputLimit(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let softLimited: TriodeStage = TriodeStage(
|
||||
input: cabinet,
|
||||
input: signal,
|
||||
drive: outputStageDrive,
|
||||
bias: outputStageBias,
|
||||
oversample: outputStageOversample
|
||||
)
|
||||
// Hard safety clamp: the tanh keeps the signal near ±1, but its DC-blocker and the halfband
|
||||
// filters can leave a sub-percent transient overshoot — clamp it so no sample can clip the DAC.
|
||||
return Clip.Audio(softLimited, lo: -outputCeiling, hi: outputCeiling)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,6 @@ public final class AnaheimAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the three switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// Creates an Anaheim amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -85,7 +82,7 @@ public final class AnaheimAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Anaheim", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 3.0 // huge clean headroom
|
||||
gain = 4.23 // huge clean headroom
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
@@ -98,7 +95,7 @@ public final class AnaheimAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Symmetric (solid-state-flavoured) preamp stage — `bias 0`, no even-harmonic tube warmth.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
TriodeStage(input: signal, drive: $gain, bias: ssPreampBias, oversample: preampOversample)
|
||||
TriodeStage(input: signal, drive: taperedDrive($gain), bias: ssPreampBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// The built-in limiter, gated by the Limiter switch — placed *before* the power-amp stage (so
|
||||
|
||||
@@ -23,8 +23,8 @@ open class BoutiqueAmpPedal: AmpVoicePedal {
|
||||
@UIParam public var depth: Double = 0.3
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Range [1, 30].
|
||||
@UIParam public var drive: Double = 10.0
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.77
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
@@ -38,7 +38,7 @@ open class BoutiqueAmpPedal: AmpVoicePedal {
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .marshall }
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
@@ -70,15 +70,12 @@ open class BoutiqueAmpPedal: AmpVoicePedal {
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Wider card for the Presence/Depth/Master/Drive knobs plus the Channel switch.
|
||||
public override var widthUnits: Int { 4 }
|
||||
|
||||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: $drive, bias: leadBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Presence (top-end high-shelf) then Depth (low-end low-shelf), post power amp.
|
||||
|
||||
@@ -25,8 +25,8 @@ public final class BoutiqueLeadAmpPedal: BoutiqueAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique Lead", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0
|
||||
drive = 14.0 // hot singing lead
|
||||
gain = 6.27
|
||||
drive = 8.76 // hot singing lead
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ public final class BoutiqueODAmpPedal: BoutiqueAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Boutique OD", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
drive = 10.0
|
||||
gain = 5.73
|
||||
drive = 7.77
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class BritishAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 10.0 // crunch-leaning default
|
||||
gain = 7.77 // crunch-leaning default
|
||||
cab = 1.0 // default to the British 4×12 cab
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the extra tremolo knobs plus the Bright and Tremolo switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// The base Bright switch plus a Tremolo footswitch (compose `super` so Bright stays in sync).
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
@@ -60,7 +57,7 @@ public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Bluesbreaker", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12 voice (combo 2×12 tonally close enough among our cabs)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
/// Lead-channel preamp gain (the cascaded stage). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.0
|
||||
/// Lead-channel preamp gain (the cascaded stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.2
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@@ -29,7 +29,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
/// Channel-select threshold: `>= this` selects the Lead channel.
|
||||
private let channelThreshold: Double = 0.5
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
@@ -63,9 +63,6 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Wider card for the extra Master/Drive/Reverb knobs plus the Bright and Channel switches.
|
||||
public override var widthUnits: Int { 4 }
|
||||
|
||||
/// Creates a British Dual amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -73,7 +70,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
gain = 5.73
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
@@ -82,7 +79,7 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: $drive, bias: leadBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class BritishJTMAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British JTM", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0 // warmer, lower-gain than the plexi
|
||||
gain = 5.73 // warmer, lower-gain than the plexi
|
||||
treble = 0.5 // a shade rounder on top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
}
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
|
||||
/// Wider card for the Presence/Master knobs plus the Bright switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// Creates a British Master amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -44,13 +41,13 @@ public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Master", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0 // cascaded, so already a hot lead at moderate Gain
|
||||
gain = 5.73 // cascaded, so already a hot lead at moderate Gain
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// Cascaded two-stage preamp: the base stage, then a second `TriodeStage` also driven by `Gain`.
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let stage1: any ValidGeneratorInput = super.preampStage(signal)
|
||||
return TriodeStage(input: stage1, drive: $gain, bias: leadBias, oversample: preampOversample)
|
||||
return TriodeStage(input: stage1, drive: taperedDrive($gain), bias: leadBias, oversample: preampOversample)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class BritishPlexiAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "British Plexi", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.0 // clean-ish until pushed
|
||||
gain = 6.72 // clean-ish until pushed
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,12 @@ import LyrebirdUI
|
||||
///
|
||||
/// Signal path (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → ConvolutionReverb(ir: selectedVoice) → mono out
|
||||
/// dry → ConvolutionReverb(ir: cab voice + mic voice) (one IR — mic colour baked in)
|
||||
/// ├─ (optional) ConvolutionReverb(ir: cab + mic B) → DelayLine(Mic Offset) (parallel 2nd mic)
|
||||
/// │ blended A·(1−Mic Blend) + Bdelayed·(Mic Blend) (comb of two mics)
|
||||
/// → RBJHighShelf (Position) → RBJLowShelf (Proximity) (live mic-placement shelves)
|
||||
/// → LookAheadLimiter(±1) (transparent peak safety)
|
||||
/// → mono out
|
||||
/// ```
|
||||
///
|
||||
/// The wet/dry mix and bypass are handled by the `Pedal` base class.
|
||||
@@ -32,6 +37,13 @@ import LyrebirdUI
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - `cabinet`: Selects the built-in cabinet voicing (stepped selector over ``CabinetVoice``).
|
||||
/// - `mic`: Selects the microphone voicing baked into the IR (stepped selector over ``MicVoice``).
|
||||
/// - `micB`: Optional second mic (stepped selector over ``MicVoice``; No Mic = single mic). When set,
|
||||
/// a parallel convolver blends in for the classic two-mic technique.
|
||||
/// - `position` / `proximity`: Live mic-placement shelves in the advanced pop-over (on-axis ↔ edge,
|
||||
/// distant ↔ close).
|
||||
/// - `micBlend` / `micOffset`: Advanced pop-over — the A/B balance and the mic-B time offset (comb
|
||||
/// spacing) when a second mic is engaged.
|
||||
public final class CabinetPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -39,12 +51,42 @@ public final class CabinetPedal: Pedal {
|
||||
"Speaker-cabinet impulse-response convolution with selectable built-in voicings."
|
||||
}
|
||||
|
||||
/// Four-wide card (same as the amps), so the Cab / Mic / Mic B selector captions — cabinet and
|
||||
/// mic voice names — stay readable rather than crowding.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Selected cabinet voicing as an index into ``CabinetVoice/allCases``. Snaps to integer
|
||||
/// stops via the ``cabinet`` selector; read at board-build time by `effect(_:)`, which
|
||||
/// instantiates only that voice's convolver (the selector is `rebuildsOnChange`).
|
||||
@UIParam public var cabinet: Double = 0.0
|
||||
/// Selected microphone voicing as an index into ``MicVoice/allCases`` (`0` = No Mic). Baked into
|
||||
/// the same IR as the cab voice, so it costs nothing extra at render time. `rebuildsOnChange`.
|
||||
@UIParam public var mic: Double = 0.0
|
||||
/// Mic **Position** on the speaker in `[0, 1]`: `0` = on-axis (bright, centred on the dust cap),
|
||||
/// `1` = cone edge / off-axis (progressively darker). A live high-shelf cut, so it is a smooth
|
||||
/// knob (no rebake); `0` is a bit-exact 0 dB identity. Surfaced in the advanced pop-over.
|
||||
@UIParam public var position: Double = 0.0
|
||||
/// Mic **Proximity** in `[0, 1]`: `0` = distant (flat lows), `1` = close-mic'd (proximity-effect
|
||||
/// low-end boost). A live low-shelf boost, so it is a smooth knob (no rebake); `0` is a bit-exact
|
||||
/// 0 dB identity. Surfaced in the advanced pop-over.
|
||||
@UIParam public var proximity: Double = 0.0
|
||||
/// Second microphone voicing as an index into ``MicVoice/allCases`` (`0` = No Mic → single mic,
|
||||
/// the default). When engaged, a **second** convolver runs in parallel and blends with the first
|
||||
/// (the classic two-mic technique). `rebuildsOnChange` — toggling it adds/removes the convolver.
|
||||
@UIParam public var micB: Double = 0.0
|
||||
/// **Mic Blend** in `[0, 1]` between mic A (`0`) and mic B (`1`); `0.5` = equal. Only active when
|
||||
/// ``micB`` ≠ No Mic. A live blend, so it is a smooth knob. Surfaced in the advanced pop-over.
|
||||
@UIParam public var micBlend: Double = 0.5
|
||||
/// **Mic Offset** in `[0, 1]`: the relative time offset of mic B, `0` = aligned, `1` = the maximum
|
||||
/// spacing. A short live delay on mic B; summing it with the aligned mic A produces the comb
|
||||
/// filtering of two spaced mics. Only active when ``micB`` ≠ No Mic. Surfaced in the pop-over.
|
||||
///
|
||||
/// > Note: intended as a **set-and-leave** spacing control (dial in the comb, then play). It is a
|
||||
/// > live delay, so *sweeping* it during playback moves the comb — a flanger-like effect rather
|
||||
/// > than a static mic position.
|
||||
@UIParam public var micOffset: Double = 0.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
@@ -54,6 +96,33 @@ public final class CabinetPedal: Pedal {
|
||||
/// Convolution is taken fully wet here; the `Pedal` base class provides the user wet/dry mix.
|
||||
private let convolutionMix: Double = 1.0
|
||||
|
||||
/// Output peak ceiling. A true look-ahead limiter holds `|output| ≤` this, taming the peaks a
|
||||
/// speaker convolution can push past ±1 (an analog cab can't digital-clip) while leaving signals
|
||||
/// below the ceiling **untouched** — no always-on saturation of clean, below-ceiling material.
|
||||
private let outputCeiling: Double = 1.0
|
||||
/// Limiter look-ahead / output delay. Short (2 ms) so the added latency is negligible in-line
|
||||
/// while still catching the brief convolution-overshoot transients.
|
||||
private let limiterLookAheadSeconds: Double = 0.002
|
||||
/// Limiter gain-release time constant — slow enough not to modulate sustained low frequencies.
|
||||
private let limiterReleaseSeconds: Double = 0.050
|
||||
|
||||
/// Mic-position high-shelf corner (Hz) and its maximum cut (dB) at the cone edge (`position = 1`).
|
||||
/// Moving off-axis toward the cone rolls the top off; on-axis (`0`) is a 0 dB identity.
|
||||
private let positionShelfFreqHz: Double = 3500.0
|
||||
private let positionMaxCutDb: Double = 9.0
|
||||
/// Mic-proximity low-shelf corner (Hz) and its maximum boost (dB) up close (`proximity = 1`) —
|
||||
/// the proximity-effect bass lift; distant (`0`) is a 0 dB identity.
|
||||
private let proximityShelfFreqHz: Double = 150.0
|
||||
private let proximityMaxBoostDb: Double = 6.0
|
||||
/// Shelf slope for the position / proximity live shelves (gentle, like the amp shelves).
|
||||
private let placementShelfSlope: Double = 0.7
|
||||
/// `[0, 1]` range for the Position / Proximity / Mic Blend / Mic Offset pop-over knobs.
|
||||
private static let placementRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
/// Maximum mic-B time offset (seconds) at `micOffset = 1` — a spaced-mic offset (~0.5 m of path
|
||||
/// difference). Sets both the delay-line size and the comb range: the first notch is at
|
||||
/// `1 / (2·offset)` Hz, so full offset places it near 330 Hz (`micOffset = 0` = aligned, no comb).
|
||||
private let maxMicOffsetSeconds: Double = 0.0015
|
||||
|
||||
/// Selector stops, one per ``CabinetVoice`` in `allCases` order (value == index).
|
||||
private static let voiceStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
|
||||
.enumerated()
|
||||
@@ -61,6 +130,13 @@ public final class CabinetPedal: Pedal {
|
||||
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
|
||||
}
|
||||
|
||||
/// Selector stops, one per ``MicVoice`` in `allCases` order (value == index).
|
||||
private static let micStops: [PedalSelectorKnob.Stop] = MicVoice.allCases
|
||||
.enumerated()
|
||||
.map { (index: Int, mic: MicVoice) in
|
||||
PedalSelectorKnob.Stop(title: mic.displayName, value: Double(index))
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a cabinet pedal.
|
||||
@@ -86,28 +162,119 @@ public final class CabinetPedal: Pedal {
|
||||
[
|
||||
PedalSelectorKnob(
|
||||
label: "Cab", node: $cabinet, stops: CabinetPedal.voiceStops, rebuildsOnChange: true),
|
||||
PedalSelectorKnob(
|
||||
label: "Mic", node: $mic, stops: CabinetPedal.micStops, rebuildsOnChange: true),
|
||||
PedalSelectorKnob(
|
||||
label: "Mic B", node: $micB, stops: CabinetPedal.micStops, rebuildsOnChange: true),
|
||||
]
|
||||
}
|
||||
|
||||
/// Mic-placement + dual-mic deep-cut controls, tucked behind the pedal card's advanced pop-over:
|
||||
/// **Position** (on-axis ↔ cone edge), **Proximity** (distance / bass lift), and — when a second
|
||||
/// mic is engaged — **Mic Blend** (A/B) and **Mic Offset** (comb spacing). All live (not baked),
|
||||
/// so they are smooth knobs; none is a topology control. Persisted positionally in
|
||||
/// `advancedValues` (append-only order).
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Position", node: $position, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Proximity", node: $proximity, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Mic Blend", node: $micBlend, range: CabinetPedal.placementRange),
|
||||
PedalKnob(label: "Mic Offset", node: $micOffset, range: CabinetPedal.placementRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
/// Convolves the dry signal against the single selected cabinet IR.
|
||||
/// Convolves the dry signal against the single selected cabinet + mic IR, then soft-limits.
|
||||
///
|
||||
/// Only the voice named by the live `cabinet` selector is instantiated, so exactly one
|
||||
/// partitioned-FFT convolver runs. Changing the selector triggers a board rebuild (the selector
|
||||
/// is `rebuildsOnChange`), which re-enters `effect(_:)` with the new voice — so switching cabs
|
||||
/// costs a brief rebuild rather than running every voice at once. Synthesizing the short IR
|
||||
/// happens off the RT thread in `build()`.
|
||||
/// Only the voice/mic named by the live selectors is baked, so exactly one partitioned-FFT
|
||||
/// convolver runs; the mic colour is folded into that same IR at no extra render cost. Changing
|
||||
/// either selector triggers a board rebuild (both are `rebuildsOnChange`). Synthesizing the short
|
||||
/// IR happens off the RT thread in `build()`.
|
||||
///
|
||||
/// The closing `LookAheadLimiter` is a transparent peak limiter on the **wet** convolution
|
||||
/// output: a speaker cab is analog and can't digital-clip, and the convolution can push peaks
|
||||
/// past ±1. Unlike a `tanh` saturator, a look-ahead limiter leaves signals **below** the ceiling
|
||||
/// bit-for-bit untouched (no coloration of clean, below-ceiling material) and only pulls gain
|
||||
/// down for the brief peaks that would exceed ±1. It adds a short (2 ms) output delay. At the
|
||||
/// default fully-wet `mix` this bounds the pedal output to ±1 (e.g. a decoupled amp → cabinet
|
||||
/// chain); a partial `mix` re-introduces the dry signal via the base class's equal-power
|
||||
/// crossfade, so at intermediate settings final level is the board's output-stage concern. The
|
||||
/// 2 ms wet delay is uniform at the default fully-wet mix; at a partial mix it sits against the
|
||||
/// undelayed dry path, so a slight comb is expected there (a cab is normally run fully wet).
|
||||
///
|
||||
/// - Parameter dry: Dry mono input signal.
|
||||
/// - Returns: The cabinet-convolved mono output.
|
||||
/// - Returns: The cabinet-convolved, mic-voiced, peak-limited mono output.
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let sr: Double = sampleRate
|
||||
let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cabinet)
|
||||
return ConvolutionReverb.Audio(
|
||||
let micVoice: MicVoice = MicVoice.voice(atSelectorValue: mic)
|
||||
let convolved: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
input: dry,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, mic: micVoice, sampleRate: sr),
|
||||
mix: convolutionMix
|
||||
)
|
||||
let mixed: any ValidGeneratorInput = blendSecondMic(dry: dry, primary: convolved, voice: voice, sr: sr)
|
||||
let placed: any ValidGeneratorInput = applyPlacement(mixed)
|
||||
return LookAheadLimiter(
|
||||
in: placed,
|
||||
maxAmplitude: outputCeiling,
|
||||
lookAheadTime: limiterLookAheadSeconds,
|
||||
releaseTime: limiterReleaseSeconds,
|
||||
sampleRate: sr
|
||||
)
|
||||
}
|
||||
|
||||
/// Blends a second microphone into the primary convolution when ``micB`` ≠ No Mic — the classic
|
||||
/// two-mic technique. A parallel convolver (same cab voice, mic B's IR) is delayed by up to
|
||||
/// ``maxMicOffsetSeconds`` (``micOffset``) and summed with the aligned primary at the ``micBlend``
|
||||
/// balance; the time offset between the two coherent copies produces comb filtering. When ``micB``
|
||||
/// is No Mic (the default) the primary is returned unchanged — no second convolver is built, so
|
||||
/// the single-mic path costs exactly one convolution and is bit-identical to before this feature.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - dry: The dry input (fed to the second convolver).
|
||||
/// - primary: The primary (mic A) convolution output.
|
||||
/// - voice: The cabinet voice (shared by both mics).
|
||||
/// - sr: Engine sample rate.
|
||||
/// - Returns: The single- or dual-mic blended signal.
|
||||
private func blendSecondMic(
|
||||
dry: any ValidGeneratorInput,
|
||||
primary: any ValidGeneratorInput,
|
||||
voice: CabinetVoice,
|
||||
sr: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
let micBVoice: MicVoice = MicVoice.voice(atSelectorValue: micB)
|
||||
guard micBVoice != .off else { return primary }
|
||||
let secondary: ConvolutionReverb.Audio = ConvolutionReverb.Audio(
|
||||
input: dry,
|
||||
ir: CabinetIRFactory.makeIR(voice: voice, mic: micBVoice, sampleRate: sr),
|
||||
mix: convolutionMix
|
||||
)
|
||||
let delaySeconds: LinLin.Audio = LinLin.Audio(
|
||||
$micOffset, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: maxMicOffsetSeconds)
|
||||
let delayedSecondary: DelayLine = DelayLine(
|
||||
input: secondary, maxDelay: maxMicOffsetSeconds, delay: delaySeconds, sampleRate: sr)
|
||||
// Coherent (same-source) mics sum linearly: A·(1−blend) + Bdelayed·blend.
|
||||
return primary * (1.0 - $micBlend) + delayedSecondary * $micBlend
|
||||
}
|
||||
|
||||
/// Applies the live mic-placement shelves to the convolved signal: a **Position** high-shelf that
|
||||
/// rolls the top off as the mic moves off-axis toward the cone edge, then a **Proximity**
|
||||
/// low-shelf that lifts the low end as the mic moves closer. Both map their knob `[0, 1]` to a
|
||||
/// shelf gain in dB with `0` → `0` dB, so at the default (`0, 0`) each shelf is a bit-exact
|
||||
/// identity and the cabinet sounds exactly as it did before placement existed.
|
||||
///
|
||||
/// - Parameter signal: The (single- or dual-mic) convolved signal.
|
||||
/// - Returns: The placement-shaped signal.
|
||||
private func applyPlacement(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let positionCutDb: LinLin.Audio = LinLin.Audio(
|
||||
$position, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: -positionMaxCutDb)
|
||||
let positioned: RBJHighShelf.Audio = RBJHighShelf.Audio(
|
||||
input: signal, freq: positionShelfFreqHz, gain: positionCutDb, slope: placementShelfSlope)
|
||||
let proximityBoostDb: LinLin.Audio = LinLin.Audio(
|
||||
$proximity, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: proximityMaxBoostDb)
|
||||
return RBJLowShelf.Audio(
|
||||
input: positioned, freq: proximityShelfFreqHz, gain: proximityBoostDb, slope: placementShelfSlope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ public final class CaliHiGainAmpPedal: BoutiqueAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Cali Hi-Gain", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0
|
||||
drive = 16.0 // hot Mark-style lead
|
||||
gain = 6.27
|
||||
drive = 9.15 // hot Mark-style lead
|
||||
cab = 1.0 // British 4×12 — tight and aggressive
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class CaliforniaAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "California", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.0 // clean-leaning default
|
||||
gain = 5.08 // clean-leaning default
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
|
||||
@@ -41,7 +41,7 @@ open class ChimeAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
self.init(name: "Chime", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
gain = 5.73
|
||||
}
|
||||
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class ChimeBabyAmpPedal: ChimeAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Baby", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0
|
||||
gain = 6.27
|
||||
bass = 0.4 // small speaker, less low end
|
||||
cab = 7.0 // Lo-Fi 1×8 — the small, boxy voice
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime 15", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0 // grittier starting point than the big AC voice
|
||||
gain = 6.27 // grittier starting point than the big AC voice
|
||||
cab = 5.0 // Bright 1×12
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class ChimeNormalAmpPedal: ChimeAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Normal", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
gain = 5.73
|
||||
treble = 0.5 // rounder top than the top-boost voice
|
||||
cut = 0.3 // a shade darker by default
|
||||
cab = 0.0 // American 1×12 — plainer than the bright cab
|
||||
|
||||
@@ -65,9 +65,6 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the extra Cut/tremolo knobs plus the Brilliant and Tremolo switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Chime Top Boost amp.
|
||||
@@ -77,7 +74,7 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Chime Top Boost", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
gain = 5.73
|
||||
cab = 5.0 // Bright 1×12 — the chimey, top-end-forward cab voice
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class CitrusAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Citrus", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 6.0
|
||||
gain = 6.27
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class CommandAmpPedal: BritishComboAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Command", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.0 // headroom-rich clean
|
||||
gain = 5.08 // headroom-rich clean
|
||||
treble = 0.55 // a touch of hi-fi top
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class FullertonDeluxeAmpPedal: FullertonReverbAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Deluxe", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.5 // slightly hotter starting point than the Twin
|
||||
gain = 5.42 // slightly hotter starting point than the Twin
|
||||
bass = 0.45 // a touch less low end than the 2×12
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.25
|
||||
/// Drive-channel preamp gain (the cascaded overdrive stage). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.0
|
||||
/// Drive-channel preamp gain (the cascaded overdrive stage). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Channel select: `0` = Clean, `1` = Drive (the cascaded overdrive stage).
|
||||
@@ -35,7 +35,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
private let channelThreshold: Double = 0.5
|
||||
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .fender }
|
||||
public override var summaryText: String {
|
||||
@@ -48,9 +48,6 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the Reverb/Drive knobs plus the Bright and Channel switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
[
|
||||
PedalSwitch(
|
||||
@@ -80,7 +77,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Drive", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.0
|
||||
gain = 5.08
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
@@ -97,7 +94,7 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: $drive, bias: driveBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class FullertonPrincetonAmpPedal: FullertonReverbAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Fullerton Ivy League", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0 // hotter still — the small combo grits up soonest
|
||||
gain = 5.73 // hotter still — the small combo grits up soonest
|
||||
bass = 0.4 // least low end of the trio
|
||||
treble = 0.55 // a shade darker
|
||||
cab = 2.0 // Vintage Dark — the small, dark 1×10 voice
|
||||
|
||||
@@ -68,9 +68,6 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card to hold the extra reverb/tremolo knobs plus the Bright switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Fullerton Reverb amp.
|
||||
@@ -83,7 +80,7 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
|
||||
/// inheriting the shared reverb + tremolo + bright control surface.
|
||||
public convenience init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
self.init(name: "Fullerton Reverb", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.0 // headroom-rich clean default
|
||||
gain = 5.08 // headroom-rich clean default
|
||||
}
|
||||
|
||||
// MARK: - Switches
|
||||
|
||||
@@ -38,8 +38,8 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
@UIParam public var bright: Double = 0.0
|
||||
/// Chorus footswitch: `1` = chorus engaged (stereo), `0` = bypassed (dry, mono-equivalent).
|
||||
@UIParam public var chorusEnabled: Double = 1.0
|
||||
/// Drive-channel preamp gain (the onboard distortion). Range [1, 30].
|
||||
@UIParam public var drive: Double = 8.0
|
||||
/// Drive-channel preamp gain (the onboard distortion). Dial [1, 11], tapered to tube drive.
|
||||
@UIParam public var drive: Double = 7.11
|
||||
/// Channel select: `0` = Clean, `1` = Distortion (the cascaded onboard-distortion stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let chorusRateRange: ClosedRange<Double> = 0.1 ... 5.0
|
||||
private let chorusDepthRange: ClosedRange<Double> = 0.0005 ... 0.015
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 11.0
|
||||
|
||||
// MARK: - Voice configuration
|
||||
|
||||
@@ -82,9 +82,6 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
|
||||
public override var channelKind: PedalChannelKind { .widener }
|
||||
|
||||
/// Wider card for the reverb/chorus knobs plus the Bright and Chorus switches.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a Jazz Clean amp.
|
||||
@@ -94,7 +91,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Jazz Clean", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 3.0 // clean, low-gain solid-state default
|
||||
gain = 4.23 // clean, low-gain solid-state default
|
||||
cab = 6.0 // Full-Range (FRFR) — the hi-fi, least-coloured voice
|
||||
}
|
||||
|
||||
@@ -136,7 +133,7 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
|
||||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||||
guard channel >= channelThreshold else { return clean }
|
||||
return TriodeStage(input: clean, drive: $drive, bias: driveBias, oversample: preampOversample)
|
||||
return TriodeStage(input: clean, drive: taperedDrive($drive), bias: driveBias, oversample: preampOversample)
|
||||
}
|
||||
|
||||
// MARK: - Hooks
|
||||
|
||||
@@ -57,9 +57,6 @@ public final class MagnaVibratoAmpPedal: AmpVoicePedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Wider card for the vibrato knobs plus the Vibrato switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// Creates a Magna Vibrato amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -67,7 +64,7 @@ public final class MagnaVibratoAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Magna Vibrato", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 4.0 // clean platform for the vibrato
|
||||
gain = 5.08 // clean platform for the vibrato
|
||||
cab = 0.0 // American 1×12
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Modern High-Gain", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.0
|
||||
drive = 18.0 // hottest lead of the lineup
|
||||
gain = 6.72
|
||||
drive = 9.50 // hottest lead of the lineup
|
||||
cab = 1.0 // British 4×12 — tight, aggressive
|
||||
sag = 0.3 // rectifier bloom on by default (shared power-amp Sag from AmpVoicePedal)
|
||||
}
|
||||
|
||||
@@ -31,10 +31,6 @@ public final class MutantPedal: Pedal {
|
||||
"Envelope-following auto-wah / funk filter that opens with your picking."
|
||||
}
|
||||
|
||||
/// Double-width so the two switches — Sweep (2-way) and the 3-way Mode — sit side by side
|
||||
/// without cramping now that switches lay out horizontally.
|
||||
public override var widthUnits: Int { 2 }
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
|
||||
|
||||
@@ -14,15 +14,17 @@ import LyrebirdUI
|
||||
/// dry ─┬─────────────────────────────────────────────────────────┐
|
||||
/// └→ AmplitudeFollower → Schmidt(lo: thr, hi: thr×ratio) │
|
||||
/// → LinLin(0…1 → floor…1) │
|
||||
/// → Lag(smooth) ───────────── × ──┴→ mono out
|
||||
/// → LagUpDown(fast open/slow close) × ─┴→ mono out
|
||||
/// ```
|
||||
///
|
||||
/// An `AmplitudeFollower` tracks the dry signal level. A Schmitt trigger turns that
|
||||
/// envelope into an open/closed gate with hysteresis (opens above `threshold × openRatio`,
|
||||
/// closes below `threshold`) so the gate does not chatter around the threshold. The 0/1
|
||||
/// gate is mapped to a gain in `[floor, 1]` and smoothed before multiplying the dry signal:
|
||||
/// when the gate is closed the signal is attenuated to `floor` rather than hard-muted, so
|
||||
/// `floor` sets how much of the quiet signal/noise tail bleeds through.
|
||||
/// gate is mapped to a gain in `[floor, 1]` and smoothed **asymmetrically** — opening fast so a
|
||||
/// note's attack isn't softened, closing slowly so the gate fades shut instead of snapping (a fast
|
||||
/// close popped audibly when heavy downstream gain amplified the step). When the gate is closed the
|
||||
/// signal is attenuated to `floor` rather than hard-muted, so `floor` sets how much of the quiet
|
||||
/// signal/noise tail bleeds through.
|
||||
///
|
||||
/// The wet/dry mix and bypass switching are handled by the `Pedal` base class.
|
||||
///
|
||||
@@ -35,6 +37,8 @@ import LyrebirdUI
|
||||
/// the gate. Range `[0, 0.2]`. Defaults to `0.02`.
|
||||
/// - floor: Residual gain applied while the gate is closed, in `[0, 1]`. `0` = full
|
||||
/// mute, `1` = no gating. Range `[0, 1]`. Defaults to `0.0`.
|
||||
/// - attack: Gate open time in seconds (advanced pop-over). Range `[0.001, 0.05]`. Defaults to `0.005`.
|
||||
/// - release: Gate close time in seconds (advanced pop-over). Range `[0.01, 0.5]`. Defaults to `0.08`.
|
||||
public final class NoiseGatePedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
@@ -50,6 +54,15 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// Residual gain while closed, [0, 1]. Range [0, 1].
|
||||
@UIParam public var floor: Double = 0.0
|
||||
|
||||
/// Gate **Attack** (open time) in seconds — how fast the gate opens on a note. Short keeps
|
||||
/// transients crisp. Range `[0.001, 0.05]`. Surfaced in the advanced pop-over.
|
||||
@UIParam public var attack: Double = 0.005
|
||||
|
||||
/// Gate **Release** (close time) in seconds — how gradually the gate fades shut as a note decays
|
||||
/// through the threshold. Short = a tight, fast gate; long = a gentle swell-down (and it rides
|
||||
/// out chatter at the threshold). Range `[0.01, 0.5]`. Surfaced in the advanced pop-over.
|
||||
@UIParam public var release: Double = 0.08
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — fully wet; the gate sits in-line.
|
||||
@@ -65,8 +78,11 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// below `threshold`, giving hysteresis that prevents chatter near the threshold.
|
||||
private let openRatio: Double = 2.0
|
||||
|
||||
/// Gain-smoothing lag time, in seconds — removes the click of an instantaneous 0↔1 gate.
|
||||
private let gainSmoothTime: Double = 0.01
|
||||
// Gate-gain smoothing is **asymmetric** (``attack`` open / ``release`` close) so the gate opens
|
||||
// promptly (a new note's attack isn't softened) but closes gently. A fast symmetric close
|
||||
// snapped the gain from unity to `floor` in ~10 ms, which — with heavy downstream gain
|
||||
// (fuzz/boost) amplifying the step — read as an audible "pop" as a sustained note decayed
|
||||
// through the threshold. A slower `release` fades the gate shut instead and rides out chatter.
|
||||
|
||||
/// Gate signal bounds for the `LinLin` floor map.
|
||||
private let gateLo: Double = 0.0
|
||||
@@ -83,6 +99,12 @@ public final class NoiseGatePedal: Pedal {
|
||||
/// Floor knob range (residual gain).
|
||||
private let floorRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
/// Attack (open-time) knob range, seconds.
|
||||
private let attackRange: ClosedRange<Double> = 0.001 ... 0.05
|
||||
|
||||
/// Release (close-time) knob range, seconds.
|
||||
private let releaseRange: ClosedRange<Double> = 0.01 ... 0.5
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Threshold", node: $threshold, range: thresholdRange),
|
||||
@@ -90,6 +112,16 @@ public final class NoiseGatePedal: Pedal {
|
||||
]
|
||||
}
|
||||
|
||||
/// Timing controls, tucked behind the pedal card's advanced pop-over: **Attack** (open time) and
|
||||
/// **Release** (close time). Live nodes, append-only in `advancedValues` — a gate saved before
|
||||
/// these existed loads with them at their defaults, no migration.
|
||||
public override var advancedKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Attack", node: $attack, range: attackRange),
|
||||
PedalKnob(label: "Release", node: $release, range: releaseRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a noise-gate pedal.
|
||||
@@ -141,10 +173,12 @@ public final class NoiseGatePedal: Pedal {
|
||||
outHi: openGain
|
||||
)
|
||||
|
||||
// Smooth the gain to remove the click of an instantaneous gate transition.
|
||||
let smoothed: Lag.Audio = Lag.Audio(
|
||||
// Smooth the gain asymmetrically: open fast (prompt on a note), close slowly (gentle fade,
|
||||
// no pop, and it rides out chatter as the envelope hovers at the threshold).
|
||||
let smoothed: LagUpDown.Audio = LagUpDown.Audio(
|
||||
input: gain,
|
||||
time: gainSmoothTime
|
||||
lagUp: $attack,
|
||||
lagDown: $release
|
||||
)
|
||||
|
||||
return dry * smoothed
|
||||
|
||||
@@ -54,9 +54,6 @@ public final class SixtiesComboAmpPedal: AmpVoicePedal {
|
||||
public override var powerAmpOversample: Int { 4 }
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput { grittyPowerDrive }
|
||||
|
||||
/// Wider card for the tremolo knobs plus the Tremolo switch.
|
||||
public override var widthUnits: Int { 3 }
|
||||
|
||||
/// Creates a Sixties Combo amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -64,7 +61,7 @@ public final class SixtiesComboAmpPedal: AmpVoicePedal {
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Sixties Combo", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.0 // gritty starting point
|
||||
gain = 6.72 // gritty starting point
|
||||
cab = 2.0 // Vintage Dark — small, dark
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,57 @@ public struct HelpView: View {
|
||||
+ "the top ten map to ⌘⇧1–⌘⇧0.",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "amplifier",
|
||||
title: "Amp Models",
|
||||
intro: "Amp Model pedals are complete guitar amplifiers — preamp, tone stack, power "
|
||||
+ "amp, and a built-in speaker cabinet in one pedal. They live in the Amp Model "
|
||||
+ "row of the palette.",
|
||||
steps: [
|
||||
"Pick an amp from the Amp Model category. Each has its own voice: Gain (preamp "
|
||||
+ "drive), a Bass / Mid / Treble tone stack, and a Cab selector for its "
|
||||
+ "built-in speaker. Full-surface amps add signature controls — Master, "
|
||||
+ "Presence, Reverb, Tremolo, a channel switch, and so on.",
|
||||
"Gain (and a drive channel's Drive) read 1–11 with a musical taper: most of the "
|
||||
+ "usable grit spreads across the dial, with full saturation at the top.",
|
||||
"Master vs Level: Master drives the power-amp stage — turning it up saturates the "
|
||||
+ "amp like a real master volume. Level is a clean output trim applied after "
|
||||
+ "the amp; it changes loudness, not tone.",
|
||||
"No digital clipping: every amp ends in an analog-style soft limiter, so a driven "
|
||||
+ "amp compresses toward its ceiling instead of clipping harshly.",
|
||||
"Advanced controls (the sliders button at the top-right of the amp card open a "
|
||||
+ "pop-over): Sag, Bias, and Bias X — power-amp \"feel\" controls kept off the "
|
||||
+ "main face. Sag models power-supply droop and bloom (compression and touch "
|
||||
+ "response as you dig in); Bias sets the power tubes' operating point (cold = "
|
||||
+ "tighter, more bite; hot = warmer, rounder); Bias X balances the push-pull "
|
||||
+ "pair to shift the harmonic character. All are subtle set-and-leave voicing "
|
||||
+ "controls that default to neutral.",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "hifispeaker",
|
||||
title: "Cabinets & Microphones",
|
||||
intro: "Every amp has a built-in cabinet, but you can also run a dedicated Cabinet "
|
||||
+ "pedal for full speaker-and-microphone control.",
|
||||
steps: [
|
||||
"Built-in vs standalone: an amp's Cab selector picks its onboard speaker voicing "
|
||||
+ "— the quick path, one knob. For deeper control, set the amp's Cab to "
|
||||
+ "\"None (direct)\" and add a Cabinet pedal after it. (On \"None\" the amp "
|
||||
+ "sounds raw and fizzy by itself — expected; the Cabinet pedal is what "
|
||||
+ "supplies the speaker.)",
|
||||
"The Cabinet pedal's Cab selector chooses the speaker voicing, and Mic chooses the "
|
||||
+ "microphone — Dynamic, Ribbon, Condenser, or No Mic. The mic colour is baked "
|
||||
+ "into the same speaker response, so it costs nothing extra.",
|
||||
"Mic placement (the Cabinet's advanced pop-over, again via the top-right sliders "
|
||||
+ "button): Position moves the mic from on-axis (bright, on the dust cap) "
|
||||
+ "toward the cone edge (darker, smoother); Proximity runs from a distant, "
|
||||
+ "flat low end to a close-mic'd bass lift.",
|
||||
"Dual-mic (same pop-over): set Mic B to a second microphone to blend two mics. "
|
||||
+ "Mic Blend sets the A/B balance; Mic Offset spaces them apart for the comb "
|
||||
+ "colour of a real two-mic setup (a set-and-leave spacing control — sweeping "
|
||||
+ "it live acts like a flanger).",
|
||||
]
|
||||
)
|
||||
topicSection(
|
||||
icon: "repeat",
|
||||
title: "The Looper Pedal",
|
||||
@@ -176,8 +227,9 @@ public struct HelpView: View {
|
||||
"Filter design follows the RBJ Audio EQ Cookbook by Robert Bristow-Johnson — the "
|
||||
+ "standard biquad coefficient formulas, used to synthesize the Cabinet pedal's "
|
||||
+ "built-in speaker impulse responses.",
|
||||
"The Cabinet pedal's built-in cab voicings are original impulse responses generated in "
|
||||
+ "code — not captures of any third-party hardware or IR pack.",
|
||||
"The Cabinet pedal's built-in cab and microphone voicings are original impulse "
|
||||
+ "responses generated in code — not captures of any third-party speaker, "
|
||||
+ "microphone, or IR pack.",
|
||||
"The tube-amp voice pedals' tone stacks "
|
||||
+ "follow the Yeh & Smith analysis of the classic passive tone-stack circuit (\"Discretization "
|
||||
+ "of the '59 Fender Bassman Tone Stack\", DAFx-06); their models are original code, not "
|
||||
|
||||
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
/// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order.
|
||||
public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
case amp = "Amp Model"
|
||||
case cabinet = "Cabinet"
|
||||
case gain = "Gain"
|
||||
case dynamics = "Dynamics"
|
||||
case filter = "EQ & Filter"
|
||||
@@ -26,6 +27,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .amp: return Color(red: 0.70, green: 0.45, blue: 0.18) // warm valve-glow copper
|
||||
case .cabinet: return Color(red: 0.50, green: 0.36, blue: 0.18) // tweed / cabinet tan
|
||||
case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12)
|
||||
case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32)
|
||||
case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55)
|
||||
@@ -48,7 +50,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
"Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain,
|
||||
"Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics,
|
||||
"Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter,
|
||||
"Cabinet": .filter,
|
||||
"Cabinet": .cabinet,
|
||||
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
|
||||
"Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .modulation,
|
||||
"Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch,
|
||||
|
||||
@@ -54,10 +54,10 @@ 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", "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",
|
||||
"Volume",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
|
||||
"Auto-Wah", "Wah", "Mutant", "Cabinet", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||
"Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
|
||||
"Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb",
|
||||
@@ -160,15 +160,21 @@ public struct PedalPaletteView: View {
|
||||
}
|
||||
|
||||
/// The `.amp` bucket on its own, or `nil` when no amp models are visible. Split out so the
|
||||
/// horizontal picker can drop the (large) amp list into the ROUTING row instead of letting it
|
||||
/// stretch the head of the effects row.
|
||||
/// horizontal picker can drop the (large) amp list into the second row (with Routing and the
|
||||
/// Cabinet) instead of letting it stretch the head of the effects row.
|
||||
private var ampGroup: (category: PedalCategory, names: [String])? {
|
||||
groupedVisiblePedals.first { $0.category == .amp }
|
||||
}
|
||||
|
||||
/// Visible pedal groups excluding the amp models — everything the effects row shows.
|
||||
/// The `.cabinet` bucket on its own, or `nil` when no cabinet is visible. Sits on the second row
|
||||
/// between Routing and the amp models (rig-structure controls grouped together).
|
||||
private var cabinetGroup: (category: PedalCategory, names: [String])? {
|
||||
groupedVisiblePedals.first { $0.category == .cabinet }
|
||||
}
|
||||
|
||||
/// Visible pedal groups excluding the amp models and the cabinet — the actual effects row (row 1).
|
||||
private var effectGroups: [(category: PedalCategory, names: [String])] {
|
||||
groupedVisiblePedals.filter { $0.category != .amp }
|
||||
groupedVisiblePedals.filter { $0.category != .amp && $0.category != .cabinet }
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
@@ -232,6 +238,16 @@ public struct PedalPaletteView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let cabinet: (category: PedalCategory, names: [String]) = cabinetGroup {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
categoryLabel(cabinet.category)
|
||||
HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) {
|
||||
ForEach(cabinet.names, id: \.self) { name in
|
||||
pedalRow(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let amps: (category: PedalCategory, names: [String]) = ampGroup {
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) {
|
||||
categoryLabel(amps.category)
|
||||
|
||||
@@ -422,9 +422,12 @@ public struct PedalView: View {
|
||||
|
||||
// MARK: - Layout constants
|
||||
|
||||
/// Wide enough for three ~55 pt knobs (dial + label + value) plus padding in a
|
||||
/// single row, so the effect controls never overlap.
|
||||
/// Base card width — used by the looper's fixed multi-unit layout. Other pedals size to content
|
||||
/// via ``enclosureColumnWidth`` (see `enclosureWidth(for:)`).
|
||||
private static let enclosureWidth: CGFloat = 220
|
||||
/// Per-column width for the content-sized enclosure — one knob/selector/switch slot (a ~50 pt
|
||||
/// dial plus its caption). Card width = `2·padding + columns·this + (columns−1)·knobSpacing`.
|
||||
private static let enclosureColumnWidth: CGFloat = 68
|
||||
private static let enclosureCornerRadius: CGFloat = 12
|
||||
private static let enclosurePadding: CGFloat = 14
|
||||
private static let screwInset: CGFloat = 6
|
||||
@@ -874,10 +877,13 @@ public struct PedalView: View {
|
||||
if !selectors.isEmpty {
|
||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||
Spacer(minLength: 0)
|
||||
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in
|
||||
// Keyed by the (unique-per-pedal) selector label, not the array offset, so each
|
||||
// selector keeps a stable SwiftUI identity across board rebuilds — a rebuildsOnChange
|
||||
// selector must not inherit a sibling's drag @State.
|
||||
ForEach(selectors, id: \.label) { selector in
|
||||
PedalSelectorKnobView(
|
||||
pair.element,
|
||||
onCommit: pair.element.rebuildsOnChange
|
||||
selector,
|
||||
onCommit: selector.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
@@ -955,19 +961,35 @@ public struct PedalView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Enclosure width — the base stompbox width scaled by the pedal's `widthUnits`
|
||||
/// (a control-dense pedal such as the looper asks for a double-width card), widened
|
||||
/// further to fit a wide vertical-fader bank (e.g. a multi-band graphic EQ) so its
|
||||
/// faders are never clipped.
|
||||
/// Enclosure width, sized to the pedal's **content** rather than a flat `widthUnits × base`
|
||||
/// multiple (which left control-sparse multi-unit cards — amps, the Cabinet — mostly empty).
|
||||
///
|
||||
/// The card is `columns` wide, where `columns` is the pedal's base knob-grid width from
|
||||
/// `widthUnits` (`1` → `knobColumnCount`, `≥ 2` → `wideKnobColumnCount`) — so a `widthUnits: 2`
|
||||
/// pedal is always a four-wide card even if it carries fewer knobs (this is how the Cabinet
|
||||
/// matches the amps so its selector captions stay readable). A pedal whose selector or switch row
|
||||
/// is wider than that pushes wider still. It is widened further to fit a vertical-fader bank
|
||||
/// (e.g. a multi-band graphic EQ) so its faders are never clipped.
|
||||
///
|
||||
/// The looper is the exception: its bespoke three-column layout (timeline · knobs · transport)
|
||||
/// genuinely needs the full multi-unit width, so it keeps the flat multiple.
|
||||
private func enclosureWidth(for sliders: [PedalSlider]) -> CGFloat {
|
||||
let unitWidth: CGFloat = PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits))
|
||||
if pedal is LooperPedal {
|
||||
return PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits))
|
||||
}
|
||||
let gridColumns: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount
|
||||
let columns: Int = max(gridColumns, inlineSelectors.count, pedal.effectSwitches.count)
|
||||
let contentWidth: CGFloat = 2 * PedalView.enclosurePadding
|
||||
+ CGFloat(columns) * PedalView.enclosureColumnWidth
|
||||
+ CGFloat(max(0, columns - 1)) * PedalView.knobSpacing
|
||||
|
||||
let sliderCount: Int = sliders.count
|
||||
guard sliderCount > 0 else { return unitWidth }
|
||||
guard sliderCount > 0 else { return contentWidth }
|
||||
let bankContentWidth: CGFloat =
|
||||
CGFloat(sliderCount) * PedalView.sliderBankItemWidth
|
||||
+ CGFloat(max(0, sliderCount - 1)) * PedalView.sliderBankSpacing
|
||||
let needed: CGFloat = bankContentWidth + 2 * PedalView.enclosurePadding
|
||||
return max(unitWidth, needed)
|
||||
return max(contentWidth, needed)
|
||||
}
|
||||
|
||||
/// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,
|
||||
|
||||
@@ -87,11 +87,35 @@ struct AmpVoicePedalTests {
|
||||
@Test func gainChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let clean: [Float] = try render(voice.make) { $0.gain = 2.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 25.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 10.5 }
|
||||
#expect(windowedSSD(clean, hot) > 0, "\(voice.name) gain had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func gainDialRunsOneToEleven() throws {
|
||||
// The Gain knob is a 1–11 dial (it goes to eleven), mapped to tube drive via a taper.
|
||||
for voice in voices {
|
||||
let gainKnob: PedalKnob? = voice.make().effectKnobs.first { $0.label == "Gain" }
|
||||
#expect(gainKnob?.range == 1.0 ... 11.0, "\(voice.name) Gain range should be 1...11")
|
||||
}
|
||||
// The Boutique amps' Drive channel is the same 1–11 dial.
|
||||
let driveKnob: PedalKnob? = BoutiqueLeadAmpPedal().effectKnobs.first { $0.label == "Drive" }
|
||||
#expect(driveKnob?.range == 1.0 ... 11.0, "Drive range should be 1...11")
|
||||
}
|
||||
|
||||
@Test func gainTaperIsMonotonicAndSaturatesMore() throws {
|
||||
// Turning the dial up must add saturation (waveshape change), and the exponential taper means
|
||||
// the jump from 9→11 shapes the wave more than 1→3 — most grind lives up top. Use the
|
||||
// California voice; RMS-normalize so level differences don't masquerade as waveshape change.
|
||||
let low: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 1.0 }
|
||||
let mid: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 3.0 }
|
||||
let hi: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 9.0 }
|
||||
let top: [Float] = try render({ CaliforniaAmpPedal() }) { $0.gain = 11.0 }
|
||||
#expect(rmsNormalizedSSD(low, mid) > 0, "1→3 should change the waveshape")
|
||||
#expect(rmsNormalizedSSD(hi, top) > rmsNormalizedSSD(low, mid),
|
||||
"the top of the taper should shape more than the bottom (exponential)")
|
||||
}
|
||||
|
||||
@Test func toneControlsChangeOutput() throws {
|
||||
for voice in voices {
|
||||
let dark: [Float] = try render(voice.make) { $0.treble = 0.0; $0.bass = 1.0 }
|
||||
@@ -122,7 +146,7 @@ struct AmpVoicePedalTests {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
}
|
||||
@@ -151,8 +175,8 @@ struct AmpVoicePedalTests {
|
||||
// just the level (which is what `level` would do). RMS-normalize each window before diffing:
|
||||
// a pure level change collapses to ~0, so a clearly-positive normalized SSD proves genuine
|
||||
// power-amp saturation.
|
||||
let low: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 0.1 }
|
||||
let high: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 1.0 }
|
||||
let low: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 8.3; $0.master = 0.1 }
|
||||
let high: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 8.3; $0.master = 1.0 }
|
||||
#expect(hasNonSilentOutput(low) && hasNonSilentOutput(high))
|
||||
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "Master changed level but not tone (no power-amp saturation)")
|
||||
}
|
||||
@@ -160,7 +184,7 @@ struct AmpVoicePedalTests {
|
||||
@Test func britishStaysWithinCeilingAtMaxMaster() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render({ BritishAmpPedal() }) { (pedal: BritishAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.master = 1.0
|
||||
@@ -187,8 +211,8 @@ struct AmpVoicePedalTests {
|
||||
|
||||
@Test func sagChangesOutput() throws {
|
||||
for voice in voices {
|
||||
let stiff: [Float] = try render(voice.make) { $0.gain = 20.0; $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render(voice.make) { $0.gain = 20.0; $0.sag = 1.0 }
|
||||
let stiff: [Float] = try render(voice.make) { $0.gain = 9.8; $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render(voice.make) { $0.gain = 9.8; $0.sag = 1.0 }
|
||||
#expect(windowedSSD(stiff, saggy) > 0, "\(voice.name) Sag had no effect")
|
||||
}
|
||||
}
|
||||
@@ -201,7 +225,7 @@ struct AmpVoicePedalTests {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let cfg: (AmpVoicePedal) -> Void = { (p: AmpVoicePedal) in
|
||||
p.gain = 25.0; p.bass = 1.0; p.treble = 1.0
|
||||
p.gain = 10.5; p.bass = 1.0; p.treble = 1.0
|
||||
}
|
||||
let stiff: [Float] = try render(voice.make) { cfg($0); $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render(voice.make) { cfg($0); $0.sag = 1.0 }
|
||||
@@ -221,32 +245,71 @@ struct AmpVoicePedalTests {
|
||||
// Bias shifts the power-amp tanh operating point → changes the even/odd harmonic mix (a
|
||||
// waveshape change), not merely the level. RMS-normalize so a pure level difference collapses.
|
||||
for voice in voices {
|
||||
let cold: [Float] = try render(voice.make) { $0.gain = 22.0; $0.bias = 0.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 22.0; $0.bias = 1.0 }
|
||||
let cold: [Float] = try render(voice.make) { $0.gain = 10.2; $0.bias = 0.0 }
|
||||
let hot: [Float] = try render(voice.make) { $0.gain = 10.2; $0.bias = 1.0 }
|
||||
#expect(hasNonSilentOutput(cold) && hasNonSilentOutput(hot))
|
||||
#expect(rmsNormalizedSSD(cold, hot) > 1.0e-4, "\(voice.name) Bias changed level but not waveshape")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func neutralBiasAndZeroSagAreIdentityDefault() throws {
|
||||
// The shipped defaults are sag = 0 and bias = 0.5 (neutral). Setting them explicitly to those
|
||||
// values must be bit-for-bit identical to leaving them at their defaults — proof the new
|
||||
// controls don't perturb any existing amp's voice at their neutral position.
|
||||
// The shipped defaults are sag = 0, bias = 0.5, biasX = 0 (all neutral). Setting them
|
||||
// explicitly to those values must be bit-for-bit identical to leaving them at their defaults
|
||||
// — proof the pop-over controls don't perturb any existing amp's voice at their neutral point.
|
||||
for voice in voices {
|
||||
let byDefault: [Float] = try render(voice.make)
|
||||
let explicit: [Float] = try render(voice.make) { $0.sag = 0.0; $0.bias = 0.5 }
|
||||
#expect(windowedSSD(byDefault, explicit) == 0, "\(voice.name) neutral Sag/Bias is not identity")
|
||||
let explicit: [Float] = try render(voice.make) { $0.sag = 0.0; $0.bias = 0.5; $0.biasX = 0.0 }
|
||||
#expect(windowedSSD(byDefault, explicit) == 0, "\(voice.name) neutral Sag/Bias/Bias X is not identity")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func advancedKnobsExposeSagAndBias() throws {
|
||||
@Test func biasXChangesWaveshape() throws {
|
||||
// Bias X spreads the two power-amp half-stages' operating points → changes the even/odd
|
||||
// harmonic mix (a waveshape change), not merely the level. RMS-normalize so a pure level
|
||||
// difference collapses.
|
||||
for voice in voices {
|
||||
let balanced: [Float] = try render(voice.make) { $0.gain = 10.2; $0.biasX = 0.0 }
|
||||
let imbalanced: [Float] = try render(voice.make) { $0.gain = 10.2; $0.biasX = 1.0 }
|
||||
#expect(hasNonSilentOutput(balanced) && hasNonSilentOutput(imbalanced))
|
||||
#expect(rmsNormalizedSSD(balanced, imbalanced) > 1.0e-4,
|
||||
"\(voice.name) Bias X changed level but not waveshape")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func biasXStaysWithinCeiling() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0; pedal.biasX = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) Bias X peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func extremeBiasAndBiasXStayWithinCeiling() throws {
|
||||
// Bias (hot) + Bias X (max) together drive a half-stage bias to ±0.6 (base ±0.25 ± spread
|
||||
// 0.35). The tanh stays bounded and outputLimit clamps — output must stay finite and ≤ ±1.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0; pedal.bias = 1.0; pedal.biasX = 1.0
|
||||
}
|
||||
#expect(hot.allSatisfy { $0.isFinite }, "\(voice.name) bias+biasX produced non-finite output")
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) bias+biasX peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func advancedKnobsExposeSagBiasAndBiasX() throws {
|
||||
for voice in voices {
|
||||
let pedal: AmpVoicePedal = voice.make()
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias"], "\(voice.name) advanced knobs")
|
||||
// Sag/Bias are pop-over-only — they must NOT also appear on the pedal face.
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias", "Bias X"],
|
||||
"\(voice.name) advanced knobs")
|
||||
// These are pop-over-only — they must NOT also appear on the pedal face.
|
||||
let faceLabels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(!faceLabels.contains("Sag") && !faceLabels.contains("Bias"),
|
||||
"\(voice.name) leaked Sag/Bias onto the pedal face")
|
||||
#expect(!faceLabels.contains("Sag") && !faceLabels.contains("Bias") && !faceLabels.contains("Bias X"),
|
||||
"\(voice.name) leaked an advanced knob onto the pedal face")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,9 +317,88 @@ struct AmpVoicePedalTests {
|
||||
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
pedal.sag = 0.7
|
||||
pedal.bias = 0.2
|
||||
pedal.biasX = 0.6
|
||||
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.sag == 0.7 && restored.bias == 0.2, "Sag/Bias did not round-trip through state")
|
||||
#expect(restored.sag == 0.7 && restored.bias == 0.2 && restored.biasX == 0.6,
|
||||
"Sag/Bias/Bias X did not round-trip through state")
|
||||
}
|
||||
|
||||
// MARK: - Cabinet decoupling
|
||||
|
||||
@Test func cabNoneBypassesConvolution() throws {
|
||||
for voice in voices {
|
||||
let withCab: [Float] = try render(voice.make) { $0.cab = 0.0 }
|
||||
let none: [Float] = try render(voice.make) { $0.cab = AmpVoicePedal.cabinetBypassValue }
|
||||
#expect(hasNonSilentOutput(none) && none.allSatisfy { $0.isFinite },
|
||||
"\(voice.name) None-cab output silent or non-finite")
|
||||
#expect(windowedSSD(withCab, none) > 0, "\(voice.name) None did not bypass the cabinet")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabNoneStillLimitsToCeiling() throws {
|
||||
// With the cabinet bypassed the output soft-limit must still run — the ±1 ceiling has to hold.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 11.0; pedal.bass = 1.0; pedal.treble = 1.0
|
||||
pedal.cab = AmpVoicePedal.cabinetBypassValue
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon,
|
||||
"\(voice.name) None-cab peak \(peak) exceeds ±1 (output limiter lost)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func extremeCabValuesDoNotTrap() throws {
|
||||
// A corrupted/hand-edited rig can restore any Double into `cab`. Neither the bypass check nor
|
||||
// the voice lookup may trap `Int(_:)` — every value must resolve to a defined, finite render.
|
||||
let extremes: [Double] = [.infinity, -.infinity, 1.0e20, -1.0e20, .nan, 999.0]
|
||||
for cabValue: Double in extremes {
|
||||
let out: [Float] = try render({ CaliforniaAmpPedal() }) { $0.cab = cabValue }
|
||||
#expect(out.allSatisfy { $0.isFinite }, "cab=\(cabValue) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func cabSelectorExposesNoneStop() throws {
|
||||
let stops: [PedalSelectorKnob.Stop] = CaliforniaAmpPedal().effectSelectors
|
||||
.first { $0.label == "Cab" }?.stops ?? []
|
||||
#expect(stops.last?.title == "None (direct)", "Cab selector missing the None stop")
|
||||
#expect(stops.last?.value == AmpVoicePedal.cabinetBypassValue, "None stop has the wrong value")
|
||||
}
|
||||
|
||||
@Test func ampWithNoneCabIntoStandaloneCabinetWorks() throws {
|
||||
// Decoupled chain: amp (Cab = None) → standalone Cabinet pedal. The amp emits its limited,
|
||||
// cab-less signal; the separate Cabinet block does the speaker convolution downstream.
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.2, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let midBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(midBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let amp: CaliforniaAmpPedal = CaliforniaAmpPedal(inputBus: srcBus.index, outputBus: midBus.index)
|
||||
amp.sampleRate = sampleRate
|
||||
amp.cab = AmpVoicePedal.cabinetBypassValue
|
||||
let cabinet: CabinetPedal = CabinetPedal(inputBus: midBus.index, outputBus: dstBus.index)
|
||||
cabinet.sampleRate = sampleRate
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(amp, position: NodePosition.after(source))
|
||||
try engine.add(cabinet, position: NodePosition.after(amp))
|
||||
try engine.add(master, position: NodePosition.after(cabinet))
|
||||
try engine.start()
|
||||
let out: [Float] = readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
#expect(hasNonSilentOutput(out) && out.allSatisfy { $0.isFinite }, "decoupled amp+cabinet silent/non-finite")
|
||||
// Note: the amp guarantees its OWN output ≤ ±1 (see `cabNoneStillLimitsToCeiling`), but a
|
||||
// downstream standalone Cabinet convolves that signal and — like any post-amp pedal — may
|
||||
// overshoot ±1. The board's final output stage, not the amp, owns end-of-chain level. So this
|
||||
// asserts the decoupled chain works (non-silent, finite), not a ±1 ceiling it never promised.
|
||||
}
|
||||
|
||||
// MARK: - Chrome / config
|
||||
@@ -283,12 +425,12 @@ struct AmpVoicePedalTests {
|
||||
|
||||
@Test func selectionsRoundTripThroughState() throws {
|
||||
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
pedal.gain = 12.0
|
||||
pedal.gain = 8.3
|
||||
pedal.cab = 2.0
|
||||
pedal.bright = 0.8
|
||||
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.gain == 12.0 && restored.cab == 2.0 && restored.bright == 0.8,
|
||||
#expect(restored.gain == 8.3 && restored.cab == 2.0 && restored.bright == 0.8,
|
||||
"California controls did not round-trip")
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ struct BoutiqueAmpPedalTests {
|
||||
@Test func channelSwitchChangesOutputAndRebuilds() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let clean: [Float] = try render(v.make) { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 18.0 }
|
||||
let lead: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 9.5 }
|
||||
#expect(windowedSSD(clean, lead) > 0, "\(v.name) channel switch had no effect")
|
||||
let channel: PedalSwitch? = v.make().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true, "\(v.name) Channel should rebuild on change")
|
||||
@@ -113,7 +113,7 @@ struct BoutiqueAmpPedalTests {
|
||||
@Test func driveKnobChangesLeadChannel() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let low: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 2.0 }
|
||||
let high: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 25.0 }
|
||||
let high: [Float] = try render(v.make) { $0.channel = 1.0; $0.drive = 10.5 }
|
||||
#expect(windowedSSD(low, high) > 0, "\(v.name) Drive had no effect on the lead channel")
|
||||
}
|
||||
}
|
||||
@@ -121,8 +121,8 @@ struct BoutiqueAmpPedalTests {
|
||||
@Test func stayWithinCeilingOnLeadChannel() throws {
|
||||
for v: (name: String, make: () -> BoutiqueAmpPedal) in voices {
|
||||
let hot: [Float] = try render(v.make) { (p: BoutiqueAmpPedal) in
|
||||
p.gain = 30.0; p.bass = 1.0; p.treble = 1.0
|
||||
p.presence = 1.0; p.depth = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 30.0
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0
|
||||
p.presence = 1.0; p.depth = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 11.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "\(v.name) exceeds the ±1 ceiling on the lead channel")
|
||||
}
|
||||
@@ -133,7 +133,7 @@ struct BoutiqueAmpPedalTests {
|
||||
#expect(lead.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
|
||||
#expect(lead.effectSwitches.map { $0.label } == ["Channel"])
|
||||
#expect(lead.widthUnits == 4)
|
||||
#expect(lead.widthUnits == 2)
|
||||
#expect(lead.toneStackModel == .soldano)
|
||||
#expect(lead.powerAmpOversample == 4)
|
||||
|
||||
@@ -150,12 +150,12 @@ struct BoutiqueAmpPedalTests {
|
||||
|
||||
@Test func roundTripsThroughState() throws {
|
||||
let pedal: BoutiqueODAmpPedal = BoutiqueODAmpPedal()
|
||||
pedal.presence = 0.6; pedal.depth = 0.7; pedal.master = 0.8; pedal.drive = 12.0
|
||||
pedal.presence = 0.6; pedal.depth = 0.7; pedal.master = 0.8; pedal.drive = 8.3
|
||||
pedal.channel = 1.0; pedal.midBoost = 1.0; pedal.cab = 2.0
|
||||
let restored: BoutiqueODAmpPedal = BoutiqueODAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.presence == 0.6 && restored.depth == 0.7 && restored.master == 0.8)
|
||||
#expect(restored.drive == 12.0 && restored.channel == 1.0 && restored.midBoost == 1.0 && restored.cab == 2.0)
|
||||
#expect(restored.drive == 8.3 && restored.channel == 1.0 && restored.midBoost == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
|
||||
@@ -108,7 +108,7 @@ struct BritishComboAmpPedalTests {
|
||||
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Speed", "Intensity"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Tremolo"])
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
}
|
||||
|
||||
@Test func bluesbreakerTremoloIntensityChangesOutput() throws {
|
||||
@@ -129,7 +129,7 @@ struct BritishComboAmpPedalTests {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let hot: [Float] = try render(v.make) { (pedal: BritishComboAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.presence = 1.0
|
||||
|
||||
@@ -92,14 +92,14 @@ struct BritishMasterAmpPedalTests {
|
||||
let pedal: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .marshall)
|
||||
#expect(pedal.powerAmpOversample == 4)
|
||||
}
|
||||
|
||||
@Test func masterStaysWithinCeiling() throws {
|
||||
let hot: [Float] = try render({ BritishMasterAmpPedal() }) { (p: BritishMasterAmpPedal) in
|
||||
p.gain = 30.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0; p.master = 1.0
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0; p.master = 1.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "British Master exceeds the ±1 ceiling")
|
||||
}
|
||||
@@ -116,7 +116,7 @@ struct BritishMasterAmpPedalTests {
|
||||
|
||||
@Test func dualChannelSwitchChangesOutput() throws {
|
||||
let clean: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 15.0 }
|
||||
let lead: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 9.0 }
|
||||
#expect(hasNonSilentOutput(clean) && hasNonSilentOutput(lead))
|
||||
#expect(windowedSSD(clean, lead) > 0, "channel switch had no effect")
|
||||
let channel: PedalSwitch? = BritishDualAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
@@ -125,7 +125,7 @@ struct BritishMasterAmpPedalTests {
|
||||
|
||||
@Test func dualDriveAndReverbAndMasterWork() throws {
|
||||
let low: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 2.0 }
|
||||
let high: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 25.0 }
|
||||
let high: [Float] = try render({ BritishDualAmpPedal() }) { $0.channel = 1.0; $0.drive = 10.5 }
|
||||
#expect(windowedSSD(low, high) > 0, "Drive had no effect on the lead channel")
|
||||
let dry: [Float] = try render({ BritishDualAmpPedal() }) { $0.reverb = 0.0 }
|
||||
let wet: [Float] = try render({ BritishDualAmpPedal() }) { $0.reverb = 0.9 }
|
||||
@@ -140,26 +140,26 @@ struct BritishMasterAmpPedalTests {
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Master", "Drive", "Reverb"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Channel"])
|
||||
#expect(pedal.widthUnits == 4)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .marshall)
|
||||
#expect(pedal.powerAmpOversample == 4)
|
||||
}
|
||||
|
||||
@Test func dualStaysWithinCeilingOnLeadChannel() throws {
|
||||
let hot: [Float] = try render({ BritishDualAmpPedal() }) { (p: BritishDualAmpPedal) in
|
||||
p.gain = 30.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0
|
||||
p.master = 1.0; p.channel = 1.0; p.drive = 30.0; p.reverb = 1.0
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.presence = 1.0; p.bright = 1.0
|
||||
p.master = 1.0; p.channel = 1.0; p.drive = 11.0; p.reverb = 1.0
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "British Dual exceeds the ±1 ceiling on the lead channel")
|
||||
}
|
||||
|
||||
@Test func dualRoundTrips() throws {
|
||||
let pedal: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
pedal.master = 0.7; pedal.drive = 12.0; pedal.reverb = 0.5; pedal.channel = 1.0
|
||||
pedal.master = 0.7; pedal.drive = 8.3; pedal.reverb = 0.5; pedal.channel = 1.0
|
||||
pedal.presence = 0.6; pedal.bright = 1.0; pedal.cab = 2.0
|
||||
let restored: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.master == 0.7 && restored.drive == 12.0 && restored.reverb == 0.5)
|
||||
#expect(restored.master == 0.7 && restored.drive == 8.3 && restored.reverb == 0.5)
|
||||
#expect(restored.channel == 1.0 && restored.presence == 0.6 && restored.bright == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
|
||||
@@ -110,4 +110,57 @@ struct CabinetIRFactoryTests {
|
||||
let names: [String] = CabinetVoice.allCases.map { $0.displayName }
|
||||
#expect(Set(names).count == names.count, "duplicate cabinet display names")
|
||||
}
|
||||
|
||||
// MARK: - Mic voicing
|
||||
|
||||
/// Ratio of the IR's magnitude at `hz` to a mid-band reference (800 Hz). Peak-normalization
|
||||
/// scales the whole IR, so it cancels in this ratio — letting a mic's *relative* boost/cut at a
|
||||
/// frequency be compared across IRs regardless of their independent normalization.
|
||||
private func tiltRatio(_ ir: LyrebirdBuffer, hz: Double) -> Double {
|
||||
let reference: Double = responseMagnitude(ir, hz: 800.0)
|
||||
guard reference > 0.0 else { return 0.0 }
|
||||
return responseMagnitude(ir, hz: hz) / reference
|
||||
}
|
||||
|
||||
@Test func noMicMatchesRawCabIR() {
|
||||
// MicVoice.off must append no stages, so the IR is byte-identical to the mic-less default —
|
||||
// the backward-compatible path for cabs saved before mic voicing existed.
|
||||
for voice: CabinetVoice in CabinetVoice.allCases {
|
||||
let raw: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, sampleRate: sampleRate)
|
||||
let offMic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: voice, mic: .off, sampleRate: sampleRate)
|
||||
#expect(raw.count == offMic.count)
|
||||
var identical: Bool = true
|
||||
for i: Int in 0..<raw.count where raw[i, 0] != offMic[i, 0] { identical = false; break }
|
||||
#expect(identical, "\(voice) No-Mic IR differs from the raw cab IR")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func dynamicMicLiftsPresence() {
|
||||
// The dynamic mic adds a presence bump at ~5.5 kHz → a higher 5.5 kHz-to-mid tilt than no mic.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .off, sampleRate: sampleRate)
|
||||
let dynamic: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .americanCombo, mic: .dynamic, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(dynamic, hz: 5500.0) > tiltRatio(off, hz: 5500.0),
|
||||
"dynamic mic did not lift the presence region")
|
||||
}
|
||||
|
||||
@Test func ribbonMicDarkensTop() {
|
||||
// The ribbon mic rolls the top off (−7 dB shelf @ 6.5 kHz) → a lower 8 kHz-to-mid tilt.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
|
||||
let ribbon: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .ribbon, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(ribbon, hz: 8000.0) < tiltRatio(off, hz: 8000.0),
|
||||
"ribbon mic did not darken the top end")
|
||||
}
|
||||
|
||||
@Test func condenserMicAddsAir() {
|
||||
// The condenser mic lifts the extreme top (+3 dB shelf @ 11 kHz) → a higher 10 kHz-to-mid tilt.
|
||||
let off: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .off, sampleRate: sampleRate)
|
||||
let condenser: LyrebirdBuffer = CabinetIRFactory.makeIR(voice: .fullRange, mic: .condenser, sampleRate: sampleRate)
|
||||
#expect(tiltRatio(condenser, hz: 10000.0) > tiltRatio(off, hz: 10000.0),
|
||||
"condenser mic did not add top-end air")
|
||||
}
|
||||
|
||||
@Test func micNamesAreUnique() {
|
||||
let names: [String] = MicVoice.allCases.map { $0.displayName }
|
||||
#expect(Set(names).count == names.count, "duplicate mic display names")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,180 @@ struct CabinetPedalTests {
|
||||
#expect(ssd > 0, "cabinet selection had no effect on output")
|
||||
}
|
||||
|
||||
@Test func exposesCabinetSelector() throws {
|
||||
@Test func exposesCabinetAndMicSelectors() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
let labels: [String] = pedal.effectSelectors.map { $0.label }
|
||||
#expect(labels == ["Cab"])
|
||||
// One stop per voice, in allCases order.
|
||||
let stops: [String] = pedal.effectSelectors.first?.stops.map { $0.title } ?? []
|
||||
#expect(stops == CabinetVoice.allCases.map { $0.displayName })
|
||||
#expect(labels == ["Cab", "Mic", "Mic B"])
|
||||
// One Cab stop per voice, and one stop per mic voice for both Mic and Mic B, in allCases order.
|
||||
let cabStops: [String] = pedal.effectSelectors.first { $0.label == "Cab" }?.stops.map { $0.title } ?? []
|
||||
#expect(cabStops == CabinetVoice.allCases.map { $0.displayName })
|
||||
let micStops: [String] = pedal.effectSelectors.first { $0.label == "Mic" }?.stops.map { $0.title } ?? []
|
||||
#expect(micStops == MicVoice.allCases.map { $0.displayName })
|
||||
let micBStops: [String] = pedal.effectSelectors.first { $0.label == "Mic B" }?.stops.map { $0.title } ?? []
|
||||
#expect(micBStops == MicVoice.allCases.map { $0.displayName })
|
||||
}
|
||||
|
||||
@Test func micSelectionChangesOutput() throws {
|
||||
// Mic 0 = No Mic, mic 1 = Dynamic — different baked IRs, different output.
|
||||
let noMic: [Float] = try render { $0.mic = 0.0 }
|
||||
let dynamic: [Float] = try render { $0.mic = 1.0 }
|
||||
#expect(hasNonSilentOutput(noMic) && hasNonSilentOutput(dynamic))
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
guard noMic.count >= skip + window, dynamic.count >= skip + window else { return }
|
||||
let ssd: Double = zip(noMic[skip..<(skip + window)], dynamic[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic selection had no effect on output")
|
||||
}
|
||||
|
||||
@Test func micSelectionRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.cabinet = 2.0
|
||||
pedal.mic = 3.0
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.cabinet == 2.0 && restored.mic == 3.0, "cab/mic selection did not round-trip")
|
||||
}
|
||||
|
||||
@Test func positionChangesOutput() throws {
|
||||
// Position sweeps a live high-shelf cut (on-axis → cone edge), so it must change the output.
|
||||
let onAxis: [Float] = try render { $0.position = 0.0 }
|
||||
let edge: [Float] = try render { $0.position = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(onAxis.count >= skip + window && edge.count >= skip + window, "render too short")
|
||||
guard onAxis.count >= skip + window, edge.count >= skip + window else { return }
|
||||
let ssd: Double = zip(onAxis[skip..<(skip + window)], edge[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic Position had no effect on output")
|
||||
}
|
||||
|
||||
@Test func proximityChangesOutput() throws {
|
||||
// Proximity sweeps a live low-shelf boost (distant → close), so it must change the output.
|
||||
let distant: [Float] = try render { $0.proximity = 0.0 }
|
||||
let close: [Float] = try render { $0.proximity = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(distant.count >= skip + window && close.count >= skip + window, "render too short")
|
||||
guard distant.count >= skip + window, close.count >= skip + window else { return }
|
||||
let ssd: Double = zip(distant[skip..<(skip + window)], close[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "mic Proximity had no effect on output")
|
||||
}
|
||||
|
||||
@Test func explicitDefaultPlacementMatchesImplicit() throws {
|
||||
// A default-consistency guard: the shipped defaults are position = 0 / proximity = 0, so
|
||||
// setting them explicitly must reproduce the default render exactly. (That those defaults are
|
||||
// a *no-op* on the tone follows from the RBJ shelves collapsing to unity at 0 dB — a Lyrebird
|
||||
// property; this test pins that the defaults are those values and the render is deterministic.)
|
||||
let byDefault: [Float] = try render()
|
||||
let explicit: [Float] = try render { $0.position = 0.0; $0.proximity = 0.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(byDefault.count >= skip + window && explicit.count >= skip + window, "render too short")
|
||||
guard byDefault.count >= skip + window, explicit.count >= skip + window else { return }
|
||||
let ssd: Double = zip(byDefault[skip..<(skip + window)], explicit[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd == 0, "explicit default placement did not match the default render")
|
||||
}
|
||||
|
||||
@Test func advancedKnobsExposePlacementAndDualMic() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Position", "Proximity", "Mic Blend", "Mic Offset"])
|
||||
}
|
||||
|
||||
// MARK: - Dual mic
|
||||
|
||||
@Test func secondMicChangesOutput() throws {
|
||||
// Engaging Mic B (a second parallel convolver) must change the output vs the single mic.
|
||||
let single: [Float] = try render { $0.micB = 0.0 }
|
||||
let dual: [Float] = try render { $0.micB = 2.0 } // Ribbon as the second mic
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(single.count >= skip + window && dual.count >= skip + window, "render too short")
|
||||
guard single.count >= skip + window, dual.count >= skip + window else { return }
|
||||
let ssd: Double = zip(single[skip..<(skip + window)], dual[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd > 0, "engaging Mic B had no effect")
|
||||
}
|
||||
|
||||
@Test func micBOffMakesBlendAndOffsetInert() throws {
|
||||
// With Mic B = No Mic, the second convolver is not built, so Mic Blend / Mic Offset must have
|
||||
// no effect — proving the single-mic default path is untouched by the dual-mic controls.
|
||||
let a: [Float] = try render { $0.micB = 0.0; $0.micBlend = 0.0; $0.micOffset = 0.0 }
|
||||
let b: [Float] = try render { $0.micB = 0.0; $0.micBlend = 1.0; $0.micOffset = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
#expect(a.count >= skip + window && b.count >= skip + window, "render too short")
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return }
|
||||
let ssd: Double = zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
#expect(ssd == 0, "Mic Blend/Offset changed output while Mic B was Off")
|
||||
}
|
||||
|
||||
@Test func micBlendAndOffsetChangeOutputWhenEngaged() throws {
|
||||
// With Mic B engaged, both the blend balance and the comb offset must change the output.
|
||||
let blendA: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.0 }
|
||||
let blendB: [Float] = try render { $0.micB = 2.0; $0.micBlend = 1.0 }
|
||||
let offset0: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.5; $0.micOffset = 0.0 }
|
||||
let offset1: [Float] = try render { $0.micB = 2.0; $0.micBlend = 0.5; $0.micOffset = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
func ssd(_ x: [Float], _ y: [Float]) -> Double {
|
||||
guard x.count >= skip + window, y.count >= skip + window else { return 0.0 }
|
||||
return zip(x[skip..<(skip + window)], y[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
||||
}
|
||||
}
|
||||
#expect(ssd(blendA, blendB) > 0, "Mic Blend had no effect when engaged")
|
||||
#expect(ssd(offset0, offset1) > 0, "Mic Offset (comb) had no effect when engaged")
|
||||
}
|
||||
|
||||
@Test func dualMicRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.micB = 3.0
|
||||
pedal.micBlend = 0.3
|
||||
pedal.micOffset = 0.6
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.micB == 3.0 && restored.micBlend == 0.3 && restored.micOffset == 0.6,
|
||||
"dual-mic controls did not round-trip")
|
||||
}
|
||||
|
||||
@Test func dualMicStaysWithinCeiling() throws {
|
||||
// Two convolvers summed can exceed ±1 pre-limiter; the look-ahead limiter must still bound it.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let out: [Float] = try render { $0.micB = 1.0; $0.micBlend = 0.5; $0.micOffset = 0.5 }
|
||||
#expect(out.allSatisfy { $0.isFinite })
|
||||
let peak: Double = out.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "dual-mic peak \(peak) exceeds ±1")
|
||||
}
|
||||
|
||||
@Test func placementRoundTripsThroughState() throws {
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
pedal.position = 0.7
|
||||
pedal.proximity = 0.4
|
||||
let restored: CabinetPedal = CabinetPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.position == 0.7 && restored.proximity == 0.4, "placement did not round-trip")
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinCeiling() throws {
|
||||
// The tanh soft-limit + Clip(±1) bound the output so a decoupled amp → cabinet chain can't
|
||||
// clip the DAC. No render may exceed ±1.
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for cab: Double in [0.0, 2.0, 6.0] {
|
||||
for micValue: Double in [0.0, 1.0, 2.0, 3.0] {
|
||||
let out: [Float] = try render { $0.cabinet = cab; $0.mic = micValue }
|
||||
#expect(out.allSatisfy { $0.isFinite })
|
||||
let peak: Double = out.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "cab=\(cab) mic=\(micValue) peak \(peak) exceeds ±1")
|
||||
}
|
||||
}
|
||||
// Placement extremes (max proximity bass lift) must still be caught by the limiter.
|
||||
let placed: [Float] = try render { $0.position = 1.0; $0.proximity = 1.0 }
|
||||
#expect(placed.allSatisfy { $0.isFinite })
|
||||
let placedPeak: Double = placed.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(placedPeak <= 1.0 + ceilingEpsilon, "placement extremes peak \(placedPeak) exceeds ±1")
|
||||
}
|
||||
|
||||
@Test func cabinetSelectorRebuildsOnChange() throws {
|
||||
|
||||
@@ -72,7 +72,7 @@ struct CaliHiGainAmpPedalTests {
|
||||
|
||||
@Test func staysWithinCeilingWithEQAndGainMaxed() throws {
|
||||
let hot: [Float] = try render { (p: CaliHiGainAmpPedal) in
|
||||
p.gain = 30.0; p.bass = 1.0; p.treble = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 30.0
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.master = 1.0; p.channel = 1.0; p.drive = 11.0
|
||||
p.eq80 = 12.0; p.eq240 = 12.0; p.eq750 = 12.0; p.eq2200 = 12.0; p.eq6600 = 12.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
@@ -85,7 +85,7 @@ struct CaliHiGainAmpPedalTests {
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
|
||||
#expect(pedal.effectSliders.map { $0.label } == ["80", "240", "750", "2.2k", "6.6k"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Channel"])
|
||||
#expect(pedal.widthUnits == 4)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .mesa)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ struct CharacterAmpsTests {
|
||||
|
||||
@Test func allBuildNonSilentFiniteWithinCeiling() throws {
|
||||
for a: (name: String, make: () -> AmpVoicePedal) in all {
|
||||
let hot: [Float] = try render(a.make) { $0.gain = 30.0; $0.bass = 1.0; $0.treble = 1.0 }
|
||||
let hot: [Float] = try render(a.make) { $0.gain = 11.0; $0.bass = 1.0; $0.treble = 1.0 }
|
||||
#expect(hasNonSilentOutput(hot), "\(a.name) silent")
|
||||
#expect(hot.allSatisfy { $0.isFinite }, "\(a.name) non-finite")
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "\(a.name) exceeds ±1 ceiling: \(peak(hot))")
|
||||
@@ -139,8 +139,8 @@ struct CharacterAmpsTests {
|
||||
|
||||
@Test func anaheimLimiterActsWhenDrivenHot() throws {
|
||||
// Driven hard, the built-in limiter (on) compresses vs bypassed (off) → different output.
|
||||
let limited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 25.0; $0.limiter = 1.0 }
|
||||
let unlimited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 25.0; $0.limiter = 0.0 }
|
||||
let limited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 10.5; $0.limiter = 1.0 }
|
||||
let unlimited: [Float] = try render({ AnaheimAmpPedal() }) { $0.gain = 10.5; $0.limiter = 0.0 }
|
||||
#expect(windowedSSD(limited, unlimited) > 0, "Anaheim limiter had no effect")
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ struct ChimeTopBoostAmpPedalTests {
|
||||
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render { (pedal: ChimeTopBoostAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.brilliant = 1.0
|
||||
@@ -111,7 +111,7 @@ struct ChimeTopBoostAmpPedalTests {
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Brilliant", "Tremolo"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.showsMixControl == false)
|
||||
#expect(pedal.toneStackModel == .vox)
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ struct ChimeVariantsTests {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> ChimeAmpPedal) in variants {
|
||||
let hot: [Float] = try render(v.make) { (pedal: ChimeAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.cut = 0.0
|
||||
|
||||
@@ -58,14 +58,14 @@ struct FullertonDriveAmpPedalTests {
|
||||
// The value is read at build time (rebuildsOnChange); configure runs before build, so the
|
||||
// Drive channel cascades its extra stage.
|
||||
let clean: [Float] = try render { $0.channel = 0.0 }
|
||||
let drive: [Float] = try render { $0.channel = 1.0; $0.drive = 15.0 }
|
||||
let drive: [Float] = try render { $0.channel = 1.0; $0.drive = 9.0 }
|
||||
#expect(hasNonSilentOutput(clean) && hasNonSilentOutput(drive))
|
||||
#expect(windowedSSD(clean, drive) > 0, "channel switch had no effect")
|
||||
}
|
||||
|
||||
@Test func driveKnobChangesDriveChannel() throws {
|
||||
let low: [Float] = try render { $0.channel = 1.0; $0.drive = 2.0 }
|
||||
let high: [Float] = try render { $0.channel = 1.0; $0.drive = 25.0 }
|
||||
let high: [Float] = try render { $0.channel = 1.0; $0.drive = 10.5 }
|
||||
#expect(windowedSSD(low, high) > 0, "Drive knob had no effect on the drive channel")
|
||||
}
|
||||
|
||||
@@ -87,13 +87,13 @@ struct FullertonDriveAmpPedalTests {
|
||||
@Test func outputStaysWithinCeilingOnDriveChannel() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render { (pedal: FullertonDriveAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.reverb = 1.0
|
||||
pedal.bright = 1.0
|
||||
pedal.channel = 1.0
|
||||
pedal.drive = 30.0
|
||||
pedal.drive = 11.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "peak \(peak) exceeds the ±1 ceiling on the drive channel")
|
||||
@@ -105,20 +105,20 @@ struct FullertonDriveAmpPedalTests {
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Reverb", "Drive"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Channel"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .fender)
|
||||
}
|
||||
|
||||
@Test func controlsRoundTripThroughState() throws {
|
||||
let pedal: FullertonDriveAmpPedal = FullertonDriveAmpPedal()
|
||||
pedal.reverb = 0.6
|
||||
pedal.drive = 12.0
|
||||
pedal.drive = 8.3
|
||||
pedal.bright = 1.0
|
||||
pedal.channel = 1.0
|
||||
pedal.cab = 2.0
|
||||
let restored: FullertonDriveAmpPedal = FullertonDriveAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.reverb == 0.6 && restored.drive == 12.0)
|
||||
#expect(restored.reverb == 0.6 && restored.drive == 8.3)
|
||||
#expect(restored.bright == 1.0 && restored.channel == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ struct FullertonReverbAmpPedalTests {
|
||||
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render { (pedal: FullertonReverbAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.reverb = 1.0
|
||||
@@ -123,7 +123,7 @@ struct FullertonReverbAmpPedalTests {
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.showsMixControl == false)
|
||||
#expect(pedal.toneStackModel == .fender)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ struct FullertonVariantsTests {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> FullertonReverbAmpPedal) in variants {
|
||||
let hot: [Float] = try render(v.make) { (pedal: FullertonReverbAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.reverb = 1.0
|
||||
@@ -105,7 +105,7 @@ struct FullertonVariantsTests {
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"], "\(v.name) knobs")
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"], "\(v.name) switches")
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(v.name) selectors")
|
||||
#expect(pedal.widthUnits == 3, "\(v.name) width")
|
||||
#expect(pedal.widthUnits == 2, "\(v.name) width")
|
||||
#expect(pedal.toneStackModel == .fender, "\(v.name) tone stack")
|
||||
#expect(pedal.powerAmpOversample == 4, "\(v.name) should oversample the harder-driven power amp at 4×")
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ struct JazzCleanAmpPedalTests {
|
||||
// Channel is read at build time (rebuildsOnChange); configure runs before build, so the
|
||||
// Distortion channel cascades its extra gain stage.
|
||||
let clean: [Float] = try renderStereo { $0.channel = 0.0 }.left
|
||||
let dist: [Float] = try renderStereo { $0.channel = 1.0; $0.drive = 18.0 }.left
|
||||
let dist: [Float] = try renderStereo { $0.channel = 1.0; $0.drive = 9.5 }.left
|
||||
#expect(windowedSSD(clean, dist) > 0, "distortion channel had no effect")
|
||||
let channel: PedalSwitch? = JazzCleanAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true, "Channel switch should rebuild on change")
|
||||
@@ -136,7 +136,7 @@ struct JazzCleanAmpPedalTests {
|
||||
@Test func bothChannelsStayWithinCeilingWithFXEngaged() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let (left, right): ([Float], [Float]) = try renderStereo { (pedal: JazzCleanAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.gain = 11.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.reverb = 1.0
|
||||
@@ -155,7 +155,7 @@ struct JazzCleanAmpPedalTests {
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Chorus", "Channel"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.showsMixControl == false)
|
||||
#expect(pedal.channelKind == .widener, "Jazz Clean should be a stereo widener")
|
||||
#expect(pedal.toneStackModel == .fender)
|
||||
|
||||
@@ -49,8 +49,8 @@ struct ModernHighGainAmpPedalTests {
|
||||
|
||||
@Test func buildsNonSilentFiniteWithinCeiling() throws {
|
||||
let hot: [Float] = try render { (p: ModernHighGainAmpPedal) in
|
||||
p.gain = 30.0; p.bass = 1.0; p.treble = 1.0; p.master = 1.0; p.channel = 1.0
|
||||
p.drive = 30.0; p.sag = 1.0; p.tight = 1.0
|
||||
p.gain = 11.0; p.bass = 1.0; p.treble = 1.0; p.master = 1.0; p.channel = 1.0
|
||||
p.drive = 11.0; p.sag = 1.0; p.tight = 1.0
|
||||
}
|
||||
#expect(hasNonSilentOutput(hot) && hot.allSatisfy { $0.isFinite })
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
@@ -58,8 +58,8 @@ struct ModernHighGainAmpPedalTests {
|
||||
}
|
||||
|
||||
@Test func sagChangesOutput() throws {
|
||||
let stiff: [Float] = try render { $0.gain = 20.0; $0.channel = 1.0; $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render { $0.gain = 20.0; $0.channel = 1.0; $0.sag = 1.0 }
|
||||
let stiff: [Float] = try render { $0.gain = 9.8; $0.channel = 1.0; $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render { $0.gain = 9.8; $0.channel = 1.0; $0.sag = 1.0 }
|
||||
#expect(windowedSSD(stiff, saggy) > 0, "Sag had no effect")
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ struct ModernHighGainAmpPedalTests {
|
||||
// must stay positive (attenuation), never go negative (phase inversion). Assert the sag'd
|
||||
// output correlates positively with the stiff one (not an inverted copy).
|
||||
let cfg: (ModernHighGainAmpPedal) -> Void = { (p: ModernHighGainAmpPedal) in
|
||||
p.gain = 20.0; p.channel = 1.0; p.presence = 1.0; p.depth = 1.0
|
||||
p.gain = 9.8; p.channel = 1.0; p.presence = 1.0; p.depth = 1.0
|
||||
}
|
||||
let stiff: [Float] = try render { cfg($0); $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render { cfg($0); $0.sag = 1.0 }
|
||||
@@ -101,9 +101,9 @@ struct ModernHighGainAmpPedalTests {
|
||||
// Sag now lives in the shared advanced pop-over (with Bias), not on the pedal face.
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias"])
|
||||
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias", "Bias X"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Channel", "Tight"])
|
||||
#expect(pedal.widthUnits == 4)
|
||||
#expect(pedal.widthUnits == 2)
|
||||
#expect(pedal.toneStackModel == .mesa)
|
||||
#expect(pedal.sag == 0.3, "Modern High-Gain keeps rectifier sag on by default")
|
||||
}
|
||||
@@ -111,11 +111,11 @@ struct ModernHighGainAmpPedalTests {
|
||||
@Test func controlsRoundTripThroughState() throws {
|
||||
let pedal: ModernHighGainAmpPedal = ModernHighGainAmpPedal()
|
||||
pedal.sag = 0.8; pedal.tight = 1.0; pedal.channel = 1.0
|
||||
pedal.drive = 20.0; pedal.master = 0.7; pedal.cab = 2.0
|
||||
pedal.drive = 9.8; pedal.master = 0.7; pedal.cab = 2.0
|
||||
let restored: ModernHighGainAmpPedal = ModernHighGainAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.sag == 0.8 && restored.tight == 1.0 && restored.channel == 1.0)
|
||||
#expect(restored.drive == 20.0 && restored.master == 0.7 && restored.cab == 2.0)
|
||||
#expect(restored.drive == 9.8 && restored.master == 0.7 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
@@ -140,7 +140,8 @@ struct ModernHighGainAmpPedalTests {
|
||||
// Gain…Drive, then Mix (0.8), Level (0.9) — the old Sag (0.7) is gone from knobValues.
|
||||
#expect(restored.knobValues == [10.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 15.0, 0.8, 0.9],
|
||||
"legacy Sag shifted Mix/Level: \(restored.knobValues)")
|
||||
// Sag lifted into advanced slot 0; Bias had no legacy value → default 0.5.
|
||||
#expect(restored.advancedValues == [0.7, 0.5], "Sag/Bias advanced values wrong: \(restored.advancedValues)")
|
||||
// Sag lifted into advanced slot 0; Bias (0.5) and Bias X (0.0) had no legacy value → defaults.
|
||||
#expect(restored.advancedValues == [0.7, 0.5, 0.0],
|
||||
"Sag/Bias/Bias X advanced values wrong: \(restored.advancedValues)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,85 @@ struct NoiseGatePedalTests {
|
||||
let samples: [Float] = try render(threshold: 0.95, floor: 1.0)
|
||||
#expect(hasNonSilentOutput(samples), "Unity-floor gate muted the signal")
|
||||
}
|
||||
|
||||
/// A sine that steps from loud (0.3, gate open) down to a constant below-threshold level (0.03)
|
||||
/// over 50 ms and holds there — so the gate opens, then closes, while the source level stays
|
||||
/// constant. That isolates the gate's close fade (release-dependent) from any source decay.
|
||||
/// `Line` holds its `end` value after `dur`, giving the sustained low tail.
|
||||
private final class DecaySineSource: SynthesizerBase {
|
||||
private let bus: Int
|
||||
init(bus: Int) { self.bus = bus; super.init() }
|
||||
override func build() {
|
||||
output(bus: bus, source: OscSin.Audio(freq: 220.0) * Line.Control(start: 0.3, end: 0.03, dur: 0.05))
|
||||
}
|
||||
}
|
||||
|
||||
/// Energy in the gate's *close window* — the source steps down through the threshold ~50 ms in
|
||||
/// then holds a constant below-threshold level, so the output energy after that reflects only how
|
||||
/// long the gate lingers before it finishes fading shut. A longer `release` = more lingering
|
||||
/// energy; a snap close = little. (floor 0, so once fully closed the tail is silent.)
|
||||
private func closeWindowEnergy(release: Double) throws -> Double {
|
||||
let sampleRate: Double = 48000.0
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.6, sampleRate: sampleRate)
|
||||
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: DecaySineSource = DecaySineSource(bus: srcBus.index)
|
||||
let gate: NoiseGatePedal = NoiseGatePedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
gate.sampleRate = sampleRate
|
||||
gate.threshold = 0.06
|
||||
gate.floor = 0.0
|
||||
gate.release = release
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(gate, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(gate))
|
||||
try engine.start()
|
||||
let inter: [Float] = readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
let mono: [Double] = stride(from: 0, to: inter.count, by: 2).map { Double(inter[$0]) }
|
||||
let start: Int = Int(0.12 * sampleRate) // after the step-down; the gate is closing/closed
|
||||
var energy: Double = 0.0
|
||||
for i: Int in start..<mono.count { energy += mono[i] * mono[i] }
|
||||
return energy
|
||||
}
|
||||
|
||||
@Test func releaseTunesCloseTime() throws {
|
||||
// A long Release lets the gate linger (more energy through the close) vs a short Release that
|
||||
// snaps shut — and the shipped default (0.08) lingers well past a near-instant close, so the
|
||||
// gate fades rather than pops. Guards both the Release control and the pop fix.
|
||||
let fast: Double = try closeWindowEnergy(release: 0.02)
|
||||
let slow: Double = try closeWindowEnergy(release: 0.4)
|
||||
let deflt: Double = try closeWindowEnergy(release: 0.08)
|
||||
#expect(slow > fast * 1.5, "long Release did not linger longer than short (fast=\(fast) slow=\(slow))")
|
||||
#expect(deflt > fast * 1.2, "default close is nearly as abrupt as the fast close (\(deflt) vs \(fast))")
|
||||
}
|
||||
|
||||
@Test func exposesAttackReleaseInAdvancedPopover() throws {
|
||||
#expect(NoiseGatePedal().advancedKnobs.map { $0.label } == ["Attack", "Release"])
|
||||
// Attack/Release are pop-over only — not on the face.
|
||||
let face: [String] = NoiseGatePedal().effectKnobs.map { $0.label }
|
||||
#expect(face == ["Threshold", "Floor"])
|
||||
}
|
||||
|
||||
@Test func attackReleaseRoundTripThroughState() throws {
|
||||
let pedal: NoiseGatePedal = NoiseGatePedal()
|
||||
pedal.attack = 0.02
|
||||
pedal.release = 0.3
|
||||
let restored: NoiseGatePedal = NoiseGatePedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.attack == 0.02 && restored.release == 0.3, "Attack/Release did not round-trip")
|
||||
}
|
||||
|
||||
@Test func legacyGateWithoutAdvancedValuesDefaultsTiming() throws {
|
||||
// A gate saved before Attack/Release existed has empty advancedValues → timing defaults, and
|
||||
// Threshold/Floor still restore correctly (append-only, no migration).
|
||||
let legacy: PedalState = PedalState(
|
||||
id: UUID(), type: "Noise Gate",
|
||||
knobValues: [0.03, 0.4, 1.0, 0.7], selectorValues: [], advancedValues: [], bypass: 0.0)
|
||||
let pedal: NoiseGatePedal = NoiseGatePedal()
|
||||
pedal.applyState(legacy)
|
||||
#expect(pedal.threshold == 0.03 && pedal.floor == 0.4, "legacy Threshold/Floor mis-mapped")
|
||||
#expect(pedal.attack == 0.005 && pedal.release == 0.08, "legacy gate should default Attack/Release")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user