From 9a79041c6c79453138f005107b481803c59e4659 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 31 Aug 2020 17:23:44 +0100 Subject: [PATCH] Optimise the Lanczos resampler a little Apprently floating-point divisions are slower than multiplications --- src/Backends/Audio/SoftwareMixer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Backends/Audio/SoftwareMixer.cpp b/src/Backends/Audio/SoftwareMixer.cpp index 3e2303f3..148f9db7 100644 --- a/src/Backends/Audio/SoftwareMixer.cpp +++ b/src/Backends/Audio/SoftwareMixer.cpp @@ -170,7 +170,7 @@ ATTRIBUTE_HOT void Mixer_MixSounds(long *stream, size_t frames_total) const double nx = 3.14159265358979323846 * kernel_input; const double nxa = nx / kernel_radius; - accumulator += input_sample * (sin(nx) / nx) * (sin(nxa) / nxa); + accumulator += input_sample * (sin(nx) * sin(nxa) / (nx * nxa)); } }