From 19b8deba66528d4666377004637ec362ee4fac09 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 8 Apr 2010 15:23:03 -0700 Subject: [PATCH] Apply a scalar to the output downmix so channels don't get more than a 100% mix All channels get the same scalar so channel balance (should be) maintained --- Alc/ALc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Alc/ALc.c b/Alc/ALc.c index 2bb502eb..ebe7d199 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -509,6 +509,7 @@ void EnableRTPrio(ALint level) static void SetupChannelMatrix(ALCdevice *Device) { + ALfloat maxout; ALuint s, s2; for(s = 0;s < OUTPUTCHANNELS;s++) @@ -587,6 +588,21 @@ static void SetupChannelMatrix(ALCdevice *Device) default: assert(0); } + + for(s = 0;s < OUTPUTCHANNELS;s++) + { + ALfloat out = 0.0f; + for(s2 = 0;s2 < OUTPUTCHANNELS;s2++) + out += Device->ChannelMatrix[s2][s]; + maxout = __max(maxout, out); + } + + maxout = 1.0f/maxout; + for(s = 0;s < OUTPUTCHANNELS;s++) + { + for(s2 = 0;s2 < OUTPUTCHANNELS;s2++) + Device->ChannelMatrix[s2][s] *= maxout; + } } /* -- 2.11.4.GIT