mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-21 08:50:49 +00:00
Calculate EFX occlusion as in Creative's EFX-Util
This commit is contained in:
parent
432b86fdeb
commit
fa51007a6f
2 changed files with 37 additions and 15 deletions
|
@ -593,7 +593,8 @@ public:
|
||||||
idStr listenerAreaName;
|
idStr listenerAreaName;
|
||||||
ALuint listenerEffect;
|
ALuint listenerEffect;
|
||||||
ALuint listenerSlot;
|
ALuint listenerSlot;
|
||||||
ALuint listenerFilter;
|
bool listenerAreFiltersInitialized;
|
||||||
|
ALuint listenerFilters[2]; // 0 - direct; 1 - send.
|
||||||
|
|
||||||
int gameMsec;
|
int gameMsec;
|
||||||
int game44kHz;
|
int game44kHz;
|
||||||
|
|
|
@ -61,23 +61,37 @@ void idSoundWorldLocal::Init( idRenderWorld *renderWorld ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!soundSystemLocal.alIsFilter(listenerFilter)) {
|
if (!listenerAreFiltersInitialized) {
|
||||||
alGetError();
|
listenerAreFiltersInitialized = true;
|
||||||
|
|
||||||
soundSystemLocal.alGenFilters(1, &listenerFilter);
|
alGetError();
|
||||||
|
soundSystemLocal.alGenFilters(2, listenerFilters);
|
||||||
ALuint e = alGetError();
|
ALuint e = alGetError();
|
||||||
if (e != AL_NO_ERROR) {
|
if (e != AL_NO_ERROR) {
|
||||||
common->Warning("idSoundWorldLocal::Init: alGenFilters failed: 0x%x", e);
|
common->Warning("idSoundWorldLocal::Init: alGenFilters failed: 0x%x", e);
|
||||||
listenerFilter = AL_FILTER_NULL;
|
listenerFilters[0] = AL_FILTER_NULL;
|
||||||
|
listenerFilters[1] = AL_FILTER_NULL;
|
||||||
} else {
|
} else {
|
||||||
soundSystemLocal.alFilteri(listenerFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
|
soundSystemLocal.alFilteri(listenerFilters[0], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
|
||||||
// original EAX occusion value was -1150
|
// original EAX occusion value was -1150
|
||||||
// default OCCLUSIONLFRATIO is 0.25
|
// default OCCLUSIONLFRATIO is 0.25
|
||||||
|
// default OCCLUSIONDIRECTRATIO is 1.0
|
||||||
|
|
||||||
// pow(10.0, (-1150*0.25)/2000.0)
|
// pow(10.0, (-1150*0.25*1.0)/2000.0)
|
||||||
soundSystemLocal.alFilterf(listenerFilter, AL_LOWPASS_GAIN, 0.718208f);
|
soundSystemLocal.alFilterf(listenerFilters[0], AL_LOWPASS_GAIN, 0.718208f);
|
||||||
// pow(10.0, -1150/2000.0)
|
// pow(10.0, (-1150*1.0)/2000.0)
|
||||||
soundSystemLocal.alFilterf(listenerFilter, AL_LOWPASS_GAINHF, 0.266073f);
|
soundSystemLocal.alFilterf(listenerFilters[0], AL_LOWPASS_GAINHF, 0.266073f);
|
||||||
|
|
||||||
|
|
||||||
|
soundSystemLocal.alFilteri(listenerFilters[1], AL_FILTER_TYPE, AL_FILTER_LOWPASS);
|
||||||
|
// original EAX occusion value was -1150
|
||||||
|
// default OCCLUSIONLFRATIO is 0.25
|
||||||
|
// default OCCLUSIONROOMRATIO is 1.5
|
||||||
|
|
||||||
|
// pow(10.0, (-1150*(0.25+1.5-1.0))/2000.0)
|
||||||
|
soundSystemLocal.alFilterf(listenerFilters[1], AL_LOWPASS_GAIN, 0.370467f);
|
||||||
|
// pow(10.0, (-1150*1.5)/2000.0)
|
||||||
|
soundSystemLocal.alFilterf(listenerFilters[1], AL_LOWPASS_GAINHF, 0.137246f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +127,7 @@ idSoundWorldLocal::idSoundWorldLocal
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
idSoundWorldLocal::idSoundWorldLocal() {
|
idSoundWorldLocal::idSoundWorldLocal() {
|
||||||
|
listenerAreFiltersInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -147,9 +162,14 @@ void idSoundWorldLocal::Shutdown() {
|
||||||
listenerSlot = AL_EFFECTSLOT_NULL;
|
listenerSlot = AL_EFFECTSLOT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (soundSystemLocal.alIsFilter(listenerFilter)) {
|
if (listenerAreFiltersInitialized) {
|
||||||
soundSystemLocal.alDeleteFilters(1, &listenerFilter);
|
listenerAreFiltersInitialized = false;
|
||||||
listenerFilter = AL_FILTER_NULL;
|
|
||||||
|
if (listenerFilters[0] != AL_FILTER_NULL && listenerFilters[1] != AL_FILTER_NULL) {
|
||||||
|
soundSystemLocal.alDeleteFilters(2, listenerFilters);
|
||||||
|
listenerFilters[0] = AL_FILTER_NULL;
|
||||||
|
listenerFilters[1] = AL_FILTER_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1792,9 +1812,10 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
|
||||||
|
|
||||||
if (idSoundSystemLocal::useEFXReverb) {
|
if (idSoundSystemLocal::useEFXReverb) {
|
||||||
if (enviroSuitActive) {
|
if (enviroSuitActive) {
|
||||||
alSourcei(chan->openalSource, AL_DIRECT_FILTER, listenerFilter);
|
alSourcei(chan->openalSource, AL_DIRECT_FILTER, listenerFilters[0]);
|
||||||
alSource3i(chan->openalSource, AL_AUXILIARY_SEND_FILTER, listenerSlot, 0, listenerFilter);
|
alSource3i(chan->openalSource, AL_AUXILIARY_SEND_FILTER, listenerSlot, 0, listenerFilters[1]);
|
||||||
} else {
|
} else {
|
||||||
|
alSourcei(chan->openalSource, AL_DIRECT_FILTER, AL_FILTER_NULL);
|
||||||
alSource3i(chan->openalSource, AL_AUXILIARY_SEND_FILTER, listenerSlot, 0, AL_FILTER_NULL);
|
alSource3i(chan->openalSource, AL_AUXILIARY_SEND_FILTER, listenerSlot, 0, AL_FILTER_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue