Skip to content

perf: cut audio-CPU on the voice path + LTO flash savings - #4

Merged
joak0068 merged 2 commits into
mainfrom
perf/tier2-cpu
Jun 25, 2026
Merged

perf: cut audio-CPU on the voice path + LTO flash savings#4
joak0068 merged 2 commits into
mainfrom
perf/tier2-cpu

Conversation

@joak0068

@joak0068 joak0068 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

No audible change; verified to build clean (FLASH 98.2% -> 97.1%).

What this changes

  • 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.

Checklist

  • New tunable values live in src/config/params.h
  • If a control changed, updated docs/MIDI_PROTOCOL.md and the params::midi map
  • Tested on hardware (Daisy Seed + Hothouse) — describe below, or note if untested

Joakim Langkilde and others added 2 commits June 25, 2026 11:47
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) <[email protected]>
@joak0068
joak0068 merged commit aa627be into main Jun 25, 2026
3 checks passed
@joak0068
joak0068 deleted the perf/tier2-cpu branch June 25, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant