Add s_alReverbGain CVar to reduce intensity of reverb effects, fix #365

It can be set to a value between 0.0 and 1.0.
1.0 sounds like it did before introducing this cvar; as many people
found the the effect way to strong, I made 0.5 the default value
This commit is contained in:
Daniel Gibson 2021-04-12 18:38:36 +02:00
parent 954ff88759
commit 5f346c7355
3 changed files with 20 additions and 0 deletions

View file

@ -601,6 +601,7 @@ public:
ALuint listenerSlot;
bool listenerAreFiltersInitialized;
ALuint listenerFilters[2]; // 0 - direct; 1 - send.
float listenerSlotReverbGain;
int gameMsec;
int game44kHz;
@ -751,6 +752,7 @@ public:
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
idEFXFile EFXDatabase;
bool efxloaded;
@ -793,6 +795,8 @@ public:
static idCVar s_useEAXReverb;
static idCVar s_decompressionLimit;
static idCVar s_alReverbGain;
static idCVar s_slowAttenuate;
static idCVar s_enviroSuitCutoffFreq;

View file

@ -77,6 +77,8 @@ idCVar idSoundSystemLocal::s_useEAXReverb( "s_useEAXReverb", "0", CVAR_SOUND | C
idCVar idSoundSystemLocal::s_decompressionLimit( "s_decompressionLimit", "6", CVAR_SOUND | CVAR_INTEGER | CVAR_ROM, "specifies maximum uncompressed sample length in seconds" );
#endif
idCVar idSoundSystemLocal::s_alReverbGain( "s_alReverbGain", "0.5", CVAR_SOUND | CVAR_FLOAT | CVAR_ARCHIVE, "reduce reverb strength (0.0 to 1.0)", 0.0f, 1.0f );
bool idSoundSystemLocal::useEFXReverb = false;
int idSoundSystemLocal::EFXAvailable = -1;
@ -429,6 +431,7 @@ void idSoundSystemLocal::Init() {
alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots");
alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot");;
alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti");
alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf");
} else {
common->Printf( "OpenAL: EFX extension not found\n" );
EFXAvailable = 0;
@ -449,6 +452,7 @@ void idSoundSystemLocal::Init() {
alDeleteAuxiliaryEffectSlots = NULL;
alIsAuxiliaryEffectSlot = NULL;
alAuxiliaryEffectSloti = NULL;
alAuxiliaryEffectSlotf = NULL;
}
ALuint handle;

View file

@ -93,6 +93,9 @@ void idSoundWorldLocal::Init( idRenderWorld *renderWorld ) {
// pow(10.0, (-1150*1.5)/2000.0)
soundSystemLocal.alFilterf(listenerFilters[1], AL_LOWPASS_GAINHF, 0.137246f);
}
// allow reducing the gain effect globally via s_alReverbGain CVar
listenerSlotReverbGain = soundSystemLocal.s_alReverbGain.GetFloat();
soundSystemLocal.alAuxiliaryEffectSlotf(listenerSlot, AL_EFFECTSLOT_GAIN, listenerSlotReverbGain);
}
}
@ -130,6 +133,7 @@ idSoundWorldLocal::idSoundWorldLocal() {
listenerEffect = 0;
listenerSlot = 0;
listenerAreFiltersInitialized = false;
listenerSlotReverbGain = 1.0f;
}
/*
@ -182,6 +186,7 @@ void idSoundWorldLocal::Shutdown() {
listenerFilters[1] = AL_FILTER_NULL;
}
}
listenerSlotReverbGain = 1.0f;
}
localSound = NULL;
@ -524,6 +529,13 @@ void idSoundWorldLocal::MixLoop( int current44kHz, int numSpeakers, float *final
ALuint effect = 0;
idStr s(listenerArea);
// allow reducing the gain effect globally via s_alReverbGain CVar
float gain = soundSystemLocal.s_alReverbGain.GetFloat();
if (listenerSlotReverbGain != gain) {
listenerSlotReverbGain = gain;
soundSystemLocal.alAuxiliaryEffectSlotf(listenerSlot, AL_EFFECTSLOT_GAIN, gain);
}
bool found = soundSystemLocal.EFXDatabase.FindEffect(s, &effect);
if (!found) {
s = listenerAreaName;