perf: cut audio-CPU on the voice path + LTO flash savings - #4
Merged
Conversation
No audible change; verified to build clean (FLASH 98.2% -> 97.1%). - Voice filter coefficients (Svf sinf+powf / Moog polynomial) are recomputed only when cutoff/resonance/filter-type change, not every sample -- a real saving for static-filter patches (cutoff held, no filter envelope). - Unison detune frequency multipliers + 1/u gain are precomputed per block instead of a per-sample division per oscillator. - The final hard clamp to [-1,1] is folded into the master limiter, dropping a whole extra per-block buffer pass in main.cpp. - master.h: the param-smoothing coefficient uses params::audio::kBlockSize instead of a hardcoded 48, so block size is a clean one-line lever. - Enable -flto (compile + link); keep usb_identity.c out of LTO so its descriptor override stays deterministic. Nets ~1.5 KB of internal flash back. Note: the original "hoist SetFreq out of the loop" idea was dropped -- DaisySP's SetFreq is the costly call, not the oscillator's, so the coefficient guard above is where the saving actually is. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
No audible change; verified to build clean (FLASH 98.2% -> 97.1%).
What this changes
Note: the original "hoist SetFreq out of the loop" idea was dropped -- DaisySP's SetFreq is the costly call, not the oscillator's, so the coefficient guard above is where the saving actually is.
Checklist
src/config/params.hdocs/MIDI_PROTOCOL.mdand theparams::midimap