feat(amp): Bias X (push-pull balance) in the advanced pop-over
Phase 13. Add a shared power-amp Bias X control modelling push-pull tube balance. powerAmpStage(_:) runs two TriodeStage halves biased at powerAmpBiasInput ± (biasX·biasXMaxSpread) and averages them: at biasX = 0 both halves share the base bias, so the average is bit-identical to the prior single stage (default, no re-voicing); turning it up spreads the operating points, shifting the even/odd harmonic mix. Deliberately a character control on the single-ended power model, not a full push-pull topology rebuild — it reduces to the exact shipped tone at biasX = 0 (monotonic imbalance amount, default 0). Appended to advancedKnobs (Sag, Bias, Bias X) — append-only so Phase-11 presets (2 advancedValues) still load with Bias X defaulting. Tests: Bias X changes waveshape (RMS-normalized, not level), stays within ±1, is exposed in the pop-over, round-trips through state; neutral Sag/Bias/Bias X is bit-exact identity. 650 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -229,24 +229,49 @@ struct AmpVoicePedalTests {
|
||||
}
|
||||
|
||||
@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 = 22.0; $0.biasX = 0.0 }
|
||||
let imbalanced: [Float] = try render(voice.make) { $0.gain = 22.0; $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 = 30.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 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 +279,11 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user