shithub: cstory

Download patch

ref: 9f002b618081265a0051110502710d414776e4c2
parent: d946cfd5793162c99f4bdf2aacfea4acc8b52a3e
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Sep 1 15:57:08 EDT 2020

Convert Lanczos resampler from double to float

Forgot that C++98 has a float version of `sin`.

--- a/src/Backends/Audio/SoftwareMixer.cpp
+++ b/src/Backends/Audio/SoftwareMixer.cpp
@@ -153,22 +153,22 @@
 				// Perform Lanczos resampling
 				const int kernel_radius = 2;
 
-				double accumulator = 0;
+				float accumulator = 0;
 
 				for (int i = -MIN(kernel_radius - 1, sound->position); i <= kernel_radius; ++i)
 				{
 					const signed char input_sample = sound->samples[(sound->position + i) % sound->frames];
 
-					const double kernel_input = ((double)sound->position_subsample / 0x10000) - i;
+					const float kernel_input = ((float)sound->position_subsample / 0x10000) - i;
 
-					if (kernel_input == 0.0)
+					if (kernel_input == 0.0f)
 					{
 						accumulator += input_sample;
 					}
 					else
 					{
-						const double nx = 3.14159265358979323846 * kernel_input;
-						const double nxa = nx / kernel_radius;
+						const float nx = 3.14159265358979323846f * kernel_input;
+						const float nxa = nx / kernel_radius;
 
 						accumulator += input_sample * (sin(nx) * sin(nxa) / (nx * nxa));
 					}