+ // 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;
+
+ // add in ReplayGain very late; prevent clipping when close
+ if(sfx)
+ if(sfx->volume_peak > 0)
+ {
+ // Replaygain support
+ // Con_DPrintf("Setting volume on ReplayGain-enabled track... %f -> ", fvol);
+ mastervol *= sfx->volume_mult;
+ if(mastervol * sfx->volume_peak > 65536)
+ mastervol = 65536 / sfx->volume_peak;
+ // Con_DPrintf("%f\n", fvol);
+ }
+