feat(amps): analog-style tanh output stage (no digital clipping)
The cab convolution and signature shelves can push amp output past ±1, which would hard-clip the DAC. A real amp has no brickwall — the output transformer / speaker soft-compress. Add a symmetric tanh output stage (TriodeStage bias 0, 2× oversampled) as the final node of AmpVoicePedal.effect(), after the cab. Unit small-signal gain leaves clean playing untouched; peaks asymptote to ±1. Combined with the attenuate-only master Level and fully-wet mix, the amp can no longer overshoot into a hard digital clip. Test: every voice driven at max gain + tone stays within the digital ceiling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,21 @@ struct AmpVoicePedalTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinDigitalCeiling() throws {
|
||||
// The tanh output stage soft-limits to ±1 (a small margin allows for oversampling-filter
|
||||
// ripple on transients). Drive every voice hard and check nothing hard-clips the DAC.
|
||||
for voice in voices {
|
||||
let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.05, "\(voice.name) peak \(peak) exceeds the digital ceiling")
|
||||
#expect(peak > 0.3, "\(voice.name) unexpectedly quiet at max gain: \(peak)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Signature controls
|
||||
|
||||
@Test func californiaBrightChangesOutput() throws {
|
||||
|
||||
Reference in New Issue
Block a user