From 1d79fdc57d997d2b47031d5bbaaa1a4da378b52d Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 23 Sep 2010 05:17:09 +0000 Subject: [PATCH] change clamping logic git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10483 d7cf8633-e32d-0410-b094-e92efae38249 --- snd_main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/snd_main.c b/snd_main.c index f00f75dc..a54591f1 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1297,13 +1297,6 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic) mastervol = ch->master_vol; - // always apply "master" - mastervol *= mastervolume.value; - - // If this channel does not manage its own volume (like CD tracks) - if (!(ch->flags & CHANNELFLAG_FULLVOLUME)) - mastervol *= volume.value; - // Adjust volume of static sounds if (isstatic) mastervol *= snd_staticvolume.value; @@ -1371,6 +1364,16 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic) } } + // If this channel does not manage its own volume (like CD tracks) + if (!(ch->flags & CHANNELFLAG_FULLVOLUME)) + mastervol *= volume.value; + + // clamp HERE to allow to go at most 10dB past mastervolume (before clamping), when mastervolume < -10dB (so relative volumes don't get too messy) + mastervol = bound(0, mastervol, 655360); + + // always apply "master" + mastervol *= mastervolume.value; + // clamp HERE to keep relative volumes of the channels correct mastervol = bound(0, mastervol, 65536); -- 2.39.2