aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-04-08 15:23:03 -0700
committerChris Robinson <[email protected]>2010-04-08 15:23:03 -0700
commit19b8deba66528d4666377004637ec362ee4fac09 (patch)
tree4e57e4db3d2e35822e55712d21f0584a7251890a
parent068c0076afbaea28201d13e98e48f9e60d6c4a7d (diff)
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
-rw-r--r--Alc/ALc.c16
1 files changed, 16 insertions, 0 deletions
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;
+ }
}
/*