]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
change clamping logic
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 23 Sep 2010 05:17:09 +0000 (05:17 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 23 Sep 2010 05:17:09 +0000 (05:17 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10483 d7cf8633-e32d-0410-b094-e92efae38249

snd_main.c

index f00f75dc38ba7421d684a3e0c21ddea843cf1870..a54591f1afeb67332fccc8181ce514d4cdc0d7fd 100644 (file)
@@ -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);