feat(amps): master-volume Marshalls — British Master / Dual (Phase 5)
Add a shared AmpVoicePedal.masterDrive(_:minDrive:maxDrive:) helper (Master knob [0,1] → power-amp drive range) and route British's powerAmpDriveInput through it. Two new BritishComboAmpPedal subclasses (Presence + Bright inherited): - British Master — 800-series single-channel lead: preampStage cascades a second gain stage (both driven by Gain) + Master + 4× power-amp oversample. - British Dual — 900/DSL: rebuildsOnChange Clean/Lead Channel switch (Lead cascades a stage set by Drive), Master, spring reverb; widthUnits 4. Registered across 6 sites as .amp. 11 tests (Master drives power amp via RMS-normalized SSD, cascaded-vs-Plexi, channel switch + rebuildsOnChange, drive/ reverb, ceiling on lead channel at max, control surfaces, round-trips, registry). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,8 @@ public extension PedalType {
|
||||
static let britishPlexi = PedalType("British Plexi")
|
||||
static let britishJTM = PedalType("British JTM")
|
||||
static let britishBluesbreaker = PedalType("British Bluesbreaker")
|
||||
static let britishMaster = PedalType("British Master")
|
||||
static let britishDual = PedalType("British Dual")
|
||||
static let chime = PedalType("Chime")
|
||||
static let chimeFifteen = PedalType("Chime 15")
|
||||
static let chimeNormal = PedalType("Chime Normal")
|
||||
|
||||
@@ -111,6 +111,23 @@ open class AmpVoicePedal: Pedal {
|
||||
return signal * lfo
|
||||
}
|
||||
|
||||
/// Maps a `Master` knob `[0, 1]` to a power-amp drive range — the canonical body of a
|
||||
/// master-volume amp's ``powerAmpDriveInput`` override. Turning Master up drives the power-amp
|
||||
/// stage harder (real master-volume saturation, unlike `level`).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - master: The `Master` knob node (`[0, 1]`).
|
||||
/// - minDrive: Power-amp drive at `master = 0`.
|
||||
/// - maxDrive: Power-amp drive at `master = 1`.
|
||||
/// - Returns: The mapped drive to feed the power-amp stage.
|
||||
func masterDrive(
|
||||
_ master: any ValidGeneratorInput,
|
||||
minDrive: Double,
|
||||
maxDrive: Double
|
||||
) -> any ValidGeneratorInput {
|
||||
LinLin.Audio(master, inLo: 0.0, inHi: 1.0, outLo: minDrive, outHi: maxDrive)
|
||||
}
|
||||
|
||||
/// The preamp gain stage — the (post-`inputShaping`) input driven through the first tube stage
|
||||
/// at `Gain`. Default: one `TriodeStage`. A channel-switching amp overrides this to cascade an
|
||||
/// extra stage on its drive channel (call `super.preampStage(_:)` for the clean stage first).
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class BritishAmpPedal: AmpVoicePedal {
|
||||
|
||||
/// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
LinLin.Audio($master, inLo: 0.0, inHi: 1.0, outLo: masterMinDrive, outHi: masterMaxDrive)
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
|
||||
/// 4× oversampling on the power-amp stage — Master can drive it well past the fixed value used
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
// BritishDualAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **dual-channel master-volume** — the 900/DSL-era Marshall: a footswitchable Clean/Lead
|
||||
/// channel, a Master volume, spring reverb, Presence, and a Bright switch. The modern high-gain
|
||||
/// British workhorse.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that adds a `rebuildsOnChange` **Channel** switch —
|
||||
/// the Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||||
/// `Master` (power-amp drive), and spring reverb in the onboard-effects slot.
|
||||
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
|
||||
/// Spring-reverb wet mix in [0, 1].
|
||||
@UIParam public var reverb: Double = 0.2
|
||||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||||
@UIParam public var channel: Double = 0.0
|
||||
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
/// Grid bias of the cascaded lead stage — a little asymmetry for even-harmonic grind.
|
||||
private let leadBias: Double = 0.15
|
||||
/// 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 reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
public override var summaryText: String {
|
||||
"British dual-channel master-volume — Clean/Lead switching, reverb, Presence, and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [
|
||||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||||
]
|
||||
}
|
||||
|
||||
public override var effectSwitches: [PedalSwitch] {
|
||||
super.effectSwitches + [
|
||||
PedalSwitch(
|
||||
label: "Channel",
|
||||
node: $channel,
|
||||
options: [
|
||||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||||
],
|
||||
rebuildsOnChange: true
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
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:
|
||||
/// - 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: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0
|
||||
cab = 1.0 // British 4×12
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// BritishMasterAmpPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// British **master-volume lead** — the 800-series single-channel hot-rodded Marshall: a cascaded
|
||||
/// two-stage preamp for singing lead gain, a Master volume, Presence, and a Bright switch.
|
||||
///
|
||||
/// A ``BritishComboAmpPedal`` (Presence + Bright) whose ``preampStage(_:)`` cascades a second gain
|
||||
/// stage — both driven by `Gain`, so one knob sets the whole preamp grind — and whose `Master`
|
||||
/// drives the power-amp stage (via ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``).
|
||||
public final class BritishMasterAmpPedal: BritishComboAmpPedal {
|
||||
|
||||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||||
@UIParam public var master: Double = 0.5
|
||||
|
||||
private let masterMinDrive: Double = 0.5
|
||||
private let masterMaxDrive: Double = 5.0
|
||||
/// Grid bias of the cascaded second preamp stage — a little asymmetry for even-harmonic grind.
|
||||
private let leadBias: Double = 0.15
|
||||
|
||||
public override var summaryText: String {
|
||||
"British master-volume lead — cascaded 800-series gain with Presence, Master, and Bright."
|
||||
}
|
||||
public override var signatureKnobs: [PedalKnob] {
|
||||
super.signatureKnobs + [PedalKnob(label: "Master", node: $master, range: signatureRange)]
|
||||
}
|
||||
|
||||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||||
}
|
||||
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:
|
||||
/// - 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: "British Master", inputBus: inputBus, outputBus: outputBus)
|
||||
gain = 5.0 // 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)
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,8 @@ public enum PedalRegistry {
|
||||
"British Plexi": { BritishPlexiAmpPedal() },
|
||||
"British JTM": { BritishJTMAmpPedal() },
|
||||
"British Bluesbreaker": { BritishBluesbreakerAmpPedal() },
|
||||
"British Master": { BritishMasterAmpPedal() },
|
||||
"British Dual": { BritishDualAmpPedal() },
|
||||
"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, "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, "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", "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", "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",
|
||||
|
||||
@@ -22,6 +22,8 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "British Plexi": return Color(red: 0.34, green: 0.20, blue: 0.10) // gold-panel plexi
|
||||
case "British JTM": return Color(red: 0.36, green: 0.24, blue: 0.12) // warm JTM bronze
|
||||
case "British Bluesbreaker": return Color(red: 0.28, green: 0.22, blue: 0.12) // bluesbreaker tan
|
||||
case "British Master": return Color(red: 0.26, green: 0.14, blue: 0.09) // hot-rodded oxblood
|
||||
case "British Dual": return Color(red: 0.24, green: 0.13, blue: 0.11) // modern high-gain
|
||||
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,169 @@
|
||||
// BritishMasterAmpPedalTests.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("British master-volume amps")
|
||||
struct BritishMasterAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> 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: P = make()
|
||||
pedal.inputBus = srcBus.index
|
||||
pedal.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
|
||||
}
|
||||
}
|
||||
|
||||
/// RMS-normalized SSD — isolates a waveshape (saturation) change from a pure level change.
|
||||
private func rmsNormalizedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double {
|
||||
guard a.count >= skip + window, b.count >= skip + window else { return 0.0 }
|
||||
let aw: ArraySlice<Float> = a[skip..<(skip + window)]
|
||||
let bw: ArraySlice<Float> = b[skip..<(skip + window)]
|
||||
func rms(_ x: ArraySlice<Float>) -> Double {
|
||||
let sumSq: Double = x.reduce(0.0) { $0 + Double($1) * Double($1) }
|
||||
return (sumSq / Double(x.count)).squareRoot()
|
||||
}
|
||||
let ra: Double = rms(aw)
|
||||
let rb: Double = rms(bw)
|
||||
guard ra > 0.0, rb > 0.0 else { return 0.0 }
|
||||
return zip(aw, bw).reduce(0.0) { acc, pair in
|
||||
let d: Double = Double(pair.0) / ra - Double(pair.1) / rb
|
||||
return acc + d * d
|
||||
}
|
||||
}
|
||||
|
||||
private func peak(_ s: [Float]) -> Double { s.reduce(0.0) { Swift.max($0, abs(Double($1))) } }
|
||||
|
||||
// MARK: - British Master
|
||||
|
||||
@Test func masterBuildsAndDrivesPowerAmp() throws {
|
||||
let samples: [Float] = try render({ BritishMasterAmpPedal() })
|
||||
#expect(hasNonSilentOutput(samples) && samples.allSatisfy { $0.isFinite })
|
||||
// Master drives the power-amp stage → a waveshape change, not just level.
|
||||
let low: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 10.0; $0.master = 0.1 }
|
||||
let high: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 10.0; $0.master = 1.0 }
|
||||
#expect(rmsNormalizedSSD(low, high) > 1.0e-3, "Master changed level but not tone")
|
||||
}
|
||||
|
||||
@Test func masterHasCascadedGainVsPlexi() throws {
|
||||
// The cascaded two-stage preamp makes British Master hotter/different from the single-stage
|
||||
// non-master Plexi at the same Gain.
|
||||
let masterAmp: [Float] = try render({ BritishMasterAmpPedal() }) { $0.gain = 6.0 }
|
||||
let plexi: [Float] = try render({ BritishPlexiAmpPedal() }) { $0.gain = 6.0 }
|
||||
#expect(windowedSSD(masterAmp, plexi) > 0, "cascaded lead should differ from the Plexi")
|
||||
}
|
||||
|
||||
@Test func masterExposesControlSurface() throws {
|
||||
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.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
|
||||
}
|
||||
#expect(peak(hot) <= 1.0 + 1.0e-4, "British Master exceeds the ±1 ceiling")
|
||||
}
|
||||
|
||||
@Test func masterRoundTrips() throws {
|
||||
let pedal: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
pedal.master = 0.8; pedal.presence = 0.7; pedal.bright = 1.0; pedal.cab = 2.0
|
||||
let restored: BritishMasterAmpPedal = BritishMasterAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.master == 0.8 && restored.presence == 0.7 && restored.bright == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
// MARK: - British Dual
|
||||
|
||||
@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 }
|
||||
#expect(hasNonSilentOutput(clean) && hasNonSilentOutput(lead))
|
||||
#expect(windowedSSD(clean, lead) > 0, "channel switch had no effect")
|
||||
let channel: PedalSwitch? = BritishDualAmpPedal().effectSwitches.first { $0.label == "Channel" }
|
||||
#expect(channel?.rebuildsOnChange == true, "Channel switch should rebuild on change")
|
||||
}
|
||||
|
||||
@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 }
|
||||
#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 }
|
||||
#expect(windowedSSD(dry, wet) > 0, "reverb had no effect")
|
||||
let mLow: [Float] = try render({ BritishDualAmpPedal() }) { $0.gain = 10.0; $0.master = 0.1 }
|
||||
let mHigh: [Float] = try render({ BritishDualAmpPedal() }) { $0.gain = 10.0; $0.master = 1.0 }
|
||||
#expect(rmsNormalizedSSD(mLow, mHigh) > 1.0e-3, "Master changed level but not tone")
|
||||
}
|
||||
|
||||
@Test func dualExposesControlSurface() throws {
|
||||
let pedal: BritishDualAmpPedal = BritishDualAmpPedal()
|
||||
#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.toneStackModel == .marshall)
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
#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.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.channel == 1.0 && restored.presence == 0.6 && restored.bright == 1.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "British Master") is BritishMasterAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British Dual") is BritishDualAmpPedal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user