Compare commits
3 Commits
8a8cac3823
...
3cdb8d9ddb
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cdb8d9ddb | |||
| b4a04f6dc8 | |||
| f7787c4ba3 |
@@ -59,6 +59,7 @@ public extension PedalType {
|
||||
static let sixtiesCombo = PedalType("Sixties Combo")
|
||||
static let magnaVibrato = PedalType("Magna Vibrato")
|
||||
static let anaheim = PedalType("Anaheim")
|
||||
static let modernHighGain = PedalType("Modern High-Gain")
|
||||
static let chime = PedalType("Chime")
|
||||
static let chimeFifteen = PedalType("Chime 15")
|
||||
static let chimeNormal = PedalType("Chime Normal")
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// ModernHighGainAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Modern **high-gain rectifier** — the saturated, scooped metal voice: a hot cascaded lead on the
|
||||
/// Mesa tone stack, with a **Sag** control (power-supply droop/bloom) and a **Tight** switch that
|
||||
/// firms up the low end.
|
||||
///
|
||||
/// A ``BoutiqueAmpPedal`` (Clean/Lead channel, Master, Presence, Depth) voiced on the `.mesa` stack.
|
||||
/// **Sag** models the power supply drooping under load: an envelope follower on the power-amp signal
|
||||
/// reduces gain as it gets loud, then recovers slowly — the compression/"bloom" feel of a
|
||||
/// tube-rectified amp. **Tight** high-passes the input to tighten the low end for fast riffing.
|
||||
public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
|
||||
|
||||
/// Sag amount in [0, 1]: `0` = stiff (no droop), `1` = heavy power-supply sag/bloom.
|
||||
@UIParam public var sag: Double = 0.3
|
||||
/// Tight switch: `0` = full low end, `1` = low-cut engaged (tight riffing).
|
||||
@UIParam public var tight: Double = 0.0
|
||||
|
||||
/// 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).
|
||||
private let sagReleaseSeconds: Double = 0.30
|
||||
/// Tight low-cut: high-pass corner is ~20 Hz (loose, no cut) or `tightFreqHz` (tight).
|
||||
private let tightLooseFreqHz: Double = 20.0
|
||||
/// Tight-switch-on high-pass corner in Hz.
|
||||
private let tightFreqHz: Double = 120.0
|
||||
/// Tight high-pass Q (Butterworth).
|
||||
private let tightQ: Double = 0.707
|
||||
/// Lowest the sag gain can droop to (~-16 dB — the deepest droop before the tone reads as
|
||||
/// obviously gated rather than sagging). Bounds sag depth and — crucially — keeps the gain
|
||||
/// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped
|
||||
/// `1 − sag·env` would go negative and phase-invert loud content instead of drooping.
|
||||
private let sagGainFloor: Double = 0.15
|
||||
|
||||
public override var toneStackModel: ToneStackModel { .mesa }
|
||||
public override var summaryText: String {
|
||||
"Modern high-gain rectifier — scooped Mesa lead with Sag (power-supply bloom) and a Tight switch."
|
||||
}
|
||||
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [PedalKnob(label: "Sag", node: $sag, range: signatureRange)]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Tight",
|
||||
node: $tight,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Off", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "On", value: switchOnValue),
|
||||
]
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Creates a Modern High-Gain amp.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||||
super.init(name: "Modern High-Gain", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 7.0
|
||||
drive = 18.0 // hottest lead of the lineup
|
||||
cab = 1.0 // British 4×12 — tight, aggressive
|
||||
}
|
||||
|
||||
/// Tight switch: a pre-preamp high-pass whose corner switches between ~20 Hz (loose, negligible
|
||||
/// cut) and `tightFreqHz` (tight), firming the low end — live, no rebuild.
|
||||
public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let cutoff: LinLin.Audio = LinLin.Audio(
|
||||
$tight, inLo: 0.0, inHi: 1.0, outLo: tightLooseFreqHz, outHi: tightFreqHz)
|
||||
return RBJHighPass.Audio(input: signal, freq: cutoff, q: tightQ)
|
||||
}
|
||||
|
||||
/// Base Presence/Depth shaping, then power-supply Sag: an envelope follower reduces gain as the
|
||||
/// signal gets loud (droop) and recovers slowly (bloom). `Sag` scales the depth; `0` = stiff.
|
||||
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
|
||||
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
|
||||
in: shaped, attackTime: sagAttackSeconds, releaseTime: sagReleaseSeconds)
|
||||
// Gain droops toward `sagGainFloor` as the envelope rises. The Presence/Depth shelves can
|
||||
// push the envelope above 1, so clamp to `[sagGainFloor, 1]` — an unclamped `1 − sag·env`
|
||||
// would go negative and phase-invert loud content instead of attenuating it.
|
||||
let sagGain: any ValidGeneratorInput = Clip.Audio(
|
||||
1.0 - ($sag * envelope), lo: sagGainFloor, hi: 1.0)
|
||||
return shaped * sagGain
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public enum PedalRegistry {
|
||||
"Sixties Combo": { SixtiesComboAmpPedal() },
|
||||
"Magna Vibrato": { MagnaVibratoAmpPedal() },
|
||||
"Anaheim": { AnaheimAmpPedal() },
|
||||
"Modern High-Gain": { ModernHighGainAmpPedal() },
|
||||
"Chime": { ChimeAmpPedal() },
|
||||
"Chime 15": { ChimeFifteenAmpPedal() },
|
||||
"Chime Normal": { ChimeNormalAmpPedal() },
|
||||
|
||||
@@ -44,7 +44,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
|
||||
}
|
||||
|
||||
private static let mapping: [String: PedalCategory] = [
|
||||
"California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "British Master": .amp, "British Dual": .amp, "Boutique Lead": .amp, "Boutique OD": .amp, "Cali Hi-Gain": .amp, "Command": .amp, "Citrus": .amp, "Sixties Combo": .amp, "Magna Vibrato": .amp, "Anaheim": .amp, "Chime": .amp, "Chime 15": .amp, "Chime Normal": .amp, "Chime Baby": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Princeton": .amp, "Fullerton Drive": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp,
|
||||
"California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "British Master": .amp, "British Dual": .amp, "Boutique Lead": .amp, "Boutique OD": .amp, "Cali Hi-Gain": .amp, "Command": .amp, "Citrus": .amp, "Sixties Combo": .amp, "Magna Vibrato": .amp, "Anaheim": .amp, "Modern High-Gain": .amp, "Chime": .amp, "Chime 15": .amp, "Chime Normal": .amp, "Chime Baby": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Princeton": .amp, "Fullerton Drive": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp,
|
||||
"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,
|
||||
|
||||
@@ -54,7 +54,7 @@ public struct PedalPaletteView: View {
|
||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||
private static let preferredOrder: [String] = [
|
||||
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Princeton", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Neural Amp", "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 Princeton", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Neural Amp", "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",
|
||||
|
||||
@@ -32,6 +32,7 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Sixties Combo": return Color(red: 0.42, green: 0.30, blue: 0.16) // tweed brown
|
||||
case "Magna Vibrato": return Color(red: 0.34, green: 0.26, blue: 0.44) // vibrato violet
|
||||
case "Anaheim": return Color(red: 0.24, green: 0.30, blue: 0.32) // hybrid slate
|
||||
case "Modern High-Gain": return Color(red: 0.12, green: 0.12, blue: 0.14) // recto black
|
||||
case "Chime": return Color(red: 0.16, green: 0.24, blue: 0.22) // vintage green
|
||||
case "Chime 15": return Color(red: 0.18, green: 0.28, blue: 0.22) // brighter vox green
|
||||
case "Chime Normal": return Color(red: 0.20, green: 0.26, blue: 0.20) // warm vox green
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// ModernHighGainAmpPedalTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
@testable import LyrebirdShoeGaze
|
||||
|
||||
@MainActor
|
||||
@Suite("ModernHighGainAmpPedal")
|
||||
struct ModernHighGainAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render(configure: (ModernHighGainAmpPedal) -> Void = { _ in }) throws -> [Float] {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
defer {
|
||||
engine.busAllocator.releaseAudioBus(srcBus)
|
||||
engine.busAllocator.releaseAudioBus(dstBus)
|
||||
}
|
||||
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
||||
let pedal: ModernHighGainAmpPedal = ModernHighGainAmpPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
||||
pedal.sampleRate = sampleRate
|
||||
configure(pedal)
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
||||
try engine.add(source)
|
||||
try engine.add(pedal, position: NodePosition.after(source))
|
||||
try engine.add(master, position: NodePosition.after(pedal))
|
||||
try engine.start()
|
||||
return readStereoCAF(url: url, sampleRate: sampleRate)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
return 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
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
#expect(hasNonSilentOutput(hot) && hot.allSatisfy { $0.isFinite })
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + 1.0e-4, "Modern High-Gain exceeds the ±1 ceiling: \(peak)")
|
||||
}
|
||||
|
||||
@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 }
|
||||
#expect(windowedSSD(stiff, saggy) > 0, "Sag had no effect")
|
||||
}
|
||||
|
||||
@Test func sagAttenuatesWithoutPhaseInversion() throws {
|
||||
// With Presence/Depth maxed the shelf boosts push the sag envelope above 1; the sag gain
|
||||
// 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
|
||||
}
|
||||
let stiff: [Float] = try render { cfg($0); $0.sag = 0.0 }
|
||||
let saggy: [Float] = try render { cfg($0); $0.sag = 1.0 }
|
||||
let skip: Int = 4096, window: Int = 4096
|
||||
guard stiff.count >= skip + window, saggy.count >= skip + window else {
|
||||
Issue.record("render too short"); return
|
||||
}
|
||||
// Unnormalized dot product — its sign is what matters: negative ⇒ phase-inverted copy.
|
||||
let dotProduct: Double = zip(stiff[skip..<(skip + window)], saggy[skip..<(skip + window)])
|
||||
.reduce(0.0) { acc, pair in acc + Double(pair.0) * Double(pair.1) }
|
||||
#expect(dotProduct > 0, "sag phase-inverted the signal (dot product \(dotProduct) < 0)")
|
||||
}
|
||||
|
||||
@Test func tightSwitchChangesOutput() throws {
|
||||
let loose: [Float] = try render { $0.tight = 0.0 }
|
||||
let tight: [Float] = try render { $0.tight = 1.0 }
|
||||
#expect(windowedSSD(loose, tight) > 0, "Tight switch had no effect")
|
||||
}
|
||||
|
||||
@Test func channelSwitchInherited() throws {
|
||||
let clean: [Float] = try render { $0.channel = 0.0 }
|
||||
let lead: [Float] = try render { $0.channel = 1.0 }
|
||||
#expect(windowedSSD(clean, lead) > 0, "channel switch had no effect")
|
||||
let channel: PedalSwitch? = ModernHighGainAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true)
|
||||
}
|
||||
|
||||
@Test func exposesControlSurface() throws {
|
||||
let pedal: ModernHighGainAmpPedal = ModernHighGainAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive", "Sag"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Channel", "Tight"])
|
||||
#expect(pedal.widthUnits == 4)
|
||||
#expect(pedal.toneStackModel == .mesa)
|
||||
}
|
||||
|
||||
@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
|
||||
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)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Modern High-Gain") is ModernHighGainAmpPedal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user