diff options
author | Chris Robinson <[email protected]> | 2010-04-08 15:23:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-04-08 15:23:03 -0700 |
commit | 19b8deba66528d4666377004637ec362ee4fac09 (patch) | |
tree | 4e57e4db3d2e35822e55712d21f0584a7251890a | |
parent | 068c0076afbaea28201d13e98e48f9e60d6c4a7d (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.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; + } } /* |