From a71c3c27c41e4c9347b37357a7dd2d6bc99e63ba Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 22 Aug 2020 02:19:14 -0700 Subject: [PATCH] Fix issue with mono -> stereo upsampling --- src/audio/impl/mixer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/impl/mixer.cpp b/src/audio/impl/mixer.cpp index 30ec35b..c996ccd 100644 --- a/src/audio/impl/mixer.cpp +++ b/src/audio/impl/mixer.cpp @@ -158,9 +158,9 @@ namespace audio::impl{ //copy data into the output buffer size_t real_floatcount = real_framecount * out_channels; size_t offset_float = offset * data.channels; - for(size_t j = 0;j < real_floatcount;j += out_channels){ - for(size_t k = 0;k < out_channels;++k){ - foutput[j+k] += ((data.data + offset_float)[j + (k % data.channels)] * data.volume); + for(size_t j = 0, k = 0;j < real_floatcount;j += out_channels, k += data.channels){ + for(size_t l = 0;l < out_channels;++l){ + foutput[j+l] += ((data.data + offset_float)[k + (l % data.channels)] * data.volume); } }