You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(wave): replace damping division by power-of-two with arithmetic shift (refs #3073 §2) #3092
1D update line ~135: f = f - (f / dampening_factor);
2D update line ~285: same pattern.
dampening_factor = 1 << mDampening is always a power of two, so the division is equivalent to f >> mDampening modulo a 1-LSB asymmetry on negative values (signed / truncates toward zero; arithmetic >> rounds toward -infinity).
Cost (per cell, per step)
Target
/ cost
>> cost
AVR (no HW divider)
~150–200 cycles software div
~32 cycles
Cortex-M0 / RP2040 / Teensy-LC
similar — software div
~32 cycles
Cortex-M4/M7 / ESP32 / ESP32-S3
~2–12 cycles HW div
~1 cycle
This is the hottest line in the inner update loop on the Low-memory targets.
Change
f -= (f >> mDampening);
The 1-LSB negative-rounding asymmetry is invisible visually — the default setHalfDuplex(true) mode clamps negatives to zero anyway, and the wave settles toward steady-state from many small contributions where one LSB doesn't matter.
If exact backwards rounding is required (some test guards against bit-exact values), use the standard shift-with-round-to-zero idiom:
Activity
zackees commentedon Jun 15, 2026
Parent meta: #3098. Alternative path: #3096 (§6 precomputed Q15 damping multiplier).
perf(wave): replace damping division by arithmetic shift in update ke…