Fix scaling down volume of sounds, again, #179 #326

Unsurprisingly the same problem (inconsistent weapon volumes due to
incorrect sound shaders setting the volume way to high and thus relying
on being clamped to 1.0) that occurred with my volume *= 0.333 hack
also happens when reducing the global volume.
So apply that global volume scale *after* clamping to 1.0

see https://github.com/bibendovsky/eaxefx/pull/28#issuecomment-1367436162
This commit is contained in:
Daniel Gibson 2022-12-29 17:28:54 +01:00
parent c2d4474ed8
commit c8321ddd1f

View file

@ -1734,8 +1734,7 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
volume = soundSystemLocal.dB2Scale( parms->volume );
}
// global volume scale
volume *= soundSystemLocal.dB2Scale( idSoundSystemLocal::s_volume.GetFloat() );
// DG: moved global volume scale down to after clamping to 1.0
// volume fading
float fadeDb = chan->channelFade.FadeDbAt44kHz( current44kHz );
@ -1802,13 +1801,20 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
// See also https://github.com/dhewm/dhewm3/issues/179
// First clamp it to 1.0 - that's done anyway when setting AL_GAIN below,
// for consistency it must be done before scaling, see
// https://github.com/dhewm/dhewm3/issues/326#issuecomment-1366833004
// for consistency it must be done before scaling, because many player-weapon
// sounds have a too high volume defined and only sound right (relative to
// other weapons) when clamped
// see https://github.com/dhewm/dhewm3/issues/326#issuecomment-1366833004
if(volume > 1.0f) {
volume = 1.0f;
}
volume *= 0.333f; // (0.333 worked fine, 0.5 didn't)
// global volume scale - DG: now done after clamping to 1.0, so reducing the
// global volume doesn't cause the different weapon volume issues described above
volume *= soundSystemLocal.dB2Scale( idSoundSystemLocal::s_volume.GetFloat() );
//
// do we have anything to add?
//