perf(cab): instantiate only the selected cabinet convolver
The cab selector was a Select over one ConvolutionReverb per CabinetVoice, and Select evaluates every input each block — so all 8 voices' partitioned-FFT convolvers ran continuously (7/8 discarded), per CabinetPedal and per amp voice. Build only the selected voice's convolver. The cab selector is now rebuildsOnChange: committing a new stop asks the host to rebuild the board (same mechanism the Neural Amp model loader uses), which re-enters effect() with the new voice. One convolver runs instead of N; cost moves to a brief rebuild on cab switch (cabs are set-and-forget). - PedalSelectorKnob: add rebuildsOnChange flag. - PedalSelectorKnobView: fire onCommit on drag-end when the stop changed. - PedalView: wire onCommit → pedalRebuildAction for rebuildsOnChange selectors. - CabinetVoice.voice(atSelectorValue:): rounded/clamped index → voice. - CabinetPedal + AmpVoicePedal: single ConvolutionReverb for the selected voice. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -126,6 +126,8 @@ struct AmpVoicePedalTests {
|
||||
for voice in voices {
|
||||
let pedal: AmpVoicePedal = voice.make()
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(voice.name) selectors")
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true,
|
||||
"\(voice.name) cab selector should rebuild on change")
|
||||
#expect(pedal.widthUnits == 2, "\(voice.name) amp head should use a double-width card")
|
||||
#expect(pedal.showsMixControl == false, "\(voice.name) should be fully wet")
|
||||
}
|
||||
|
||||
@@ -68,6 +68,21 @@ struct CabinetPedalTests {
|
||||
#expect(stops == CabinetVoice.allCases.map { $0.displayName })
|
||||
}
|
||||
|
||||
@Test func cabinetSelectorRebuildsOnChange() throws {
|
||||
// Only the selected voice's convolver is built, so changing it must rebuild the board.
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
}
|
||||
|
||||
@Test func voiceAtSelectorValueClampsAndRounds() throws {
|
||||
let all: [CabinetVoice] = CabinetVoice.allCases
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 0.0) == all[0])
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 2.0) == all[2])
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 1.4) == all[1], "should round to nearest stop")
|
||||
#expect(CabinetVoice.voice(atSelectorValue: -5.0) == all[0], "clamp below 0")
|
||||
#expect(CabinetVoice.voice(atSelectorValue: 999.0) == all[all.count - 1], "clamp above max")
|
||||
}
|
||||
|
||||
@Test func cabinetSelectionRoundTripsThroughState() throws {
|
||||
// The selector value must survive capture/apply (preset round-trip).
|
||||
let pedal: CabinetPedal = CabinetPedal()
|
||||
|
||||
Reference in New Issue
Block a user