DSP perf: latch mode/shape enums, fuse matrix mul, skip FB math when …#372
Merged
Conversation
…idle OpSource now caches all mode/shape enums at attack time (waveform, extended mode, phase-map shape, resonant-sweep window/depth, noise mode/type/lfsr mode) and the dispatch + AUDIO_IN check read the cached values instead of round+casting the patch params every block. Heavy state (st waveform, stWindow, extendedLagM/N) was already latched at attack, so the dispatch now matches. MatrixNodeFrom::applyBlock fuses the prior `mul_block + scalar convert` two-pass into a single loop that computes modlev * fromOut inline, dropping the intermediate mod[8] buffer. Parenthesisation matches the original multiply order — bit-exact output. Self-feedback is now gated by a `UsesFB` template arg on innerLoopImpl. MatrixNodeSelf::applyBlock signals OpSource via hasActiveFeedback; the inner-loop dispatcher branches once at block start and picks the right template instantiation, which constexpr-skips the fb math and the fbv[] shift when self-feedback is off. The bigger win turns out to be that removing the per-sample backward dependency through fbv lets the compiler reorder/vectorize across the whole inner loop. -40 to -73% on no-feedback scenarios; flat on dense FB. std::signbit on int32 is also replaced with a plain int compare in the same path. Bit-exact audio confirmed on all non-NOISE scenarios via the six-sines-perf harness. Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…idle
OpSource now caches all mode/shape enums at attack time (waveform, extended mode, phase-map shape, resonant-sweep window/depth, noise mode/type/lfsr mode) and the dispatch + AUDIO_IN check read the cached values instead of round+casting the patch params every block. Heavy state (st waveform, stWindow, extendedLagM/N) was already latched at attack, so the dispatch now matches.
MatrixNodeFrom::applyBlock fuses the prior
mul_block + scalar converttwo-pass into a single loop that computes modlev * fromOut inline, dropping the intermediate mod[8] buffer. Parenthesisation matches the original multiply order — bit-exact output.Self-feedback is now gated by a
UsesFBtemplate arg on innerLoopImpl. MatrixNodeSelf::applyBlock signals OpSource via hasActiveFeedback; the inner-loop dispatcher branches once at block start and picks the right template instantiation, which constexpr-skips the fb math and the fbv[] shift when self-feedback is off. The bigger win turns out to be that removing the per-sample backward dependency through fbv lets the compiler reorder/vectorize across the whole inner loop. -40 to -73% on no-feedback scenarios; flat on dense FB. std::signbit on int32 is also replaced with a plain int compare in the same path.Bit-exact audio confirmed on all non-NOISE scenarios via the six-sines-perf harness.
Assisted-by: Claude Opus 4.7 noreply@anthropic.com