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:
@@ -29,6 +29,9 @@ struct PedalSelectorKnobView: View {
|
||||
// MARK: - Input
|
||||
|
||||
private let selector: PedalSelectorKnob
|
||||
/// Called once when a drag ends on a different stop than it began — used to trigger a board
|
||||
/// rebuild for `rebuildsOnChange` selectors. `nil` for plain live-value selectors.
|
||||
private let onCommit: (() -> Void)?
|
||||
|
||||
// MARK: - Drag state
|
||||
|
||||
@@ -37,8 +40,9 @@ struct PedalSelectorKnobView: View {
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
init(_ selector: PedalSelectorKnob) {
|
||||
init(_ selector: PedalSelectorKnob, onCommit: (() -> Void)? = nil) {
|
||||
self.selector = selector
|
||||
self.onCommit = onCommit
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
@@ -100,7 +104,11 @@ struct PedalSelectorKnobView: View {
|
||||
selector.node.update(value)
|
||||
}
|
||||
}
|
||||
.onEnded { _ in dragInProgress = false }
|
||||
.onEnded { _ in
|
||||
let changed: Bool = currentIndex != dragStartIndex
|
||||
dragInProgress = false
|
||||
if changed { onCommit?() }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
@@ -777,7 +777,12 @@ public struct PedalView: View {
|
||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||
Spacer(minLength: 0)
|
||||
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in
|
||||
PedalSelectorKnobView(pair.element)
|
||||
PedalSelectorKnobView(
|
||||
pair.element,
|
||||
onCommit: pair.element.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user