From c15ecbf7280c4b6714412f0ce5ce40b29c1b5aa4 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 29 Jan 2020 12:47:02 +0100 Subject: [PATCH] Used fmodf instead of fmod for a 0.5% performance increase in MixSounds Signed-off-by: Gabriel Ravier --- src/Backends/Audio/SDL2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Backends/Audio/SDL2.cpp b/src/Backends/Audio/SDL2.cpp index e511d5e3..64b3413b 100644 --- a/src/Backends/Audio/SDL2.cpp +++ b/src/Backends/Audio/SDL2.cpp @@ -85,7 +85,7 @@ static void MixSounds(float *stream, unsigned int frames_total) const float sample2 = (sound->samples[(size_t)sound->position + 1] - 128.0f) / 128.0f; // Perform linear interpolation - const float interpolated_sample = sample1 + ((sample2 - sample1) * (float)fmod(sound->position, 1.0)); + const float interpolated_sample = sample1 + ((sample2 - sample1) * fmodf(sound->position, 1.0)); *steam_pointer++ += interpolated_sample * sound->volume_l; *steam_pointer++ += interpolated_sample * sound->volume_r; @@ -96,7 +96,7 @@ static void MixSounds(float *stream, unsigned int frames_total) { if (sound->looping) { - sound->position = fmod(sound->position, (double)sound->frames); + sound->position = fmodf(sound->position, sound->frames); } else {