From: divverent Date: Thu, 23 Sep 2010 05:17:09 +0000 (+0000) Subject: change clamping logic X-Git-Tag: xonotic-v0.1.0preview~230^2~1 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=1d79fdc57d997d2b47031d5bbaaa1a4da378b52d;hp=1e4fe28814b6fcdaf1c8c35a805fb221dd860ec4;p=xonotic%2Fdarkplaces.git change clamping logic git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10483 d7cf8633-e32d-0410-b094-e92efae38249 --- 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);