Properly sum the channels being downmixed to mono

This commit is contained in:
Chris Robinson 2016-05-02 05:07:23 -07:00 committed by Christoph Oelckers
parent 12c9281a7e
commit c3cef91a4f

View file

@ -1045,7 +1045,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int
{ {
int sum = 0; int sum = 0;
for(int c = 0;c < channels;c++) for(int c = 0;c < channels;c++)
sum = ((short*)sfxdata)[i*channels + c]; sum += ((short*)sfxdata)[i*channels + c];
((short*)sfxdata)[i] = sum / channels; ((short*)sfxdata)[i] = sum / channels;
} }
} }
@ -1055,7 +1055,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int
{ {
int sum = 0; int sum = 0;
for(int c = 0;c < channels;c++) for(int c = 0;c < channels;c++)
sum = sfxdata[i*channels + c] - 128; sum += sfxdata[i*channels + c] - 128;
sfxdata[i] = (sum / channels) + 128; sfxdata[i] = (sum / channels) + 128;
} }
} }