MCPcopy Create free account
hub / github.com/FastLED/FastLED / compute_damp_decay_q15

Function compute_damp_decay_q15

src/fl/math/wave/wave_simulation_real.cpp.hpp:49–53  ·  view source on GitHub ↗

Precompute the Q15 damping decay factor for a power-of-two exponent. The damping update is `f_new = f * (1 - 1/2^damp)`, equivalent to the arithmetic-shift form `f -= f >> damp` (modulo 1-LSB rounding). Caching it as Q15 here lets the kernel use a single Q15 multiply per cell and opens the door to non-power-of-two damping if the public API ever needs it (today it's still int-only). damp <= 0 means

Source from the content-addressed store, hash-verified

47// opens the door to non-power-of-two damping if the public API ever
48// needs it (today it's still int-only). damp <= 0 means no decay.
49i16 compute_damp_decay_q15(int damp) FL_NOEXCEPT {
50 if (damp <= 0) return INT16_POS; // ~1.0 — no decay
51 const float decay = 1.0f - 1.0f / static_cast<float>(1 << damp);
52 return float_to_fixed(decay);
53}
54} // namespace wave_detail
55
56WaveSimulation1D_Real::WaveSimulation1D_Real(u32 len, float courantSq,

Callers 3

WaveSimulation1D_RealMethod · 0.85
setDampeningMethod · 0.85
WaveSimulation2D_RealMethod · 0.85

Calls 1

float_to_fixedFunction · 0.85

Tested by

no test coverage detected