Skip to content

EQ smoothing: replace pow(10, x/10) with exp(x · ln(10)/10)#2239

Merged
ten9876 merged 1 commit intomainfrom
fix/eq-smoothing-perf
May 1, 2026
Merged

EQ smoothing: replace pow(10, x/10) with exp(x · ln(10)/10)#2239
ten9876 merged 1 commit intomainfrom
fix/eq-smoothing-perf

Conversation

@ten9876
Copy link
Copy Markdown
Owner

@ten9876 ten9876 commented May 1, 2026

Mathematically identical (pow(10, x) == exp(x · ln(10))) but ~3-4× faster on most stdlib implementations — std::exp is dramatically simpler than the fully-general std::pow path.

Inner loop in applyFractionalOctaveSmoothing:

constexpr double kLn10Over10 = 0.23025850929940457;
sumLin += std::exp(static_cast<double>(binsDb[j]) * kLn10Over10);

Reverse direction (10 * log10(meanLin)) stays as-is — it's outside the inner loop and only runs once per output bin.

At 1/3 octave smoothing the savings are real but absolute cost is already low (~10K dB→linear calls per second). Cheap win.

Tests pass (./build/client_eq_smoothing_test — all 15 assertions).

Suggested by aethersdr-agent reviewing #2236 post-merge.

Mathematically equivalent (pow(10, x) == exp(x * ln(10))) but
typically 3-4× faster — std::exp is dramatically simpler than the
fully-general std::pow path.  At 1/3 octave smoothing this is the
dominant cost in the smoothing pass: ~200 bins × 2 traces × 25 Hz
analyzer ticks ≈ 10K calls/sec, so the saving is small in absolute
terms but free.

Suggested by aethersdr-agent reviewing #2236 post-merge.
@ten9876 ten9876 requested a review from jensenpat as a code owner May 1, 2026 08:17
@ten9876 ten9876 merged commit 4e9903b into main May 1, 2026
5 checks passed
@ten9876 ten9876 deleted the fix/eq-smoothing-perf branch May 1, 2026 15:36
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