diff --git a/src/common/audio/sound/oalsound.cpp b/src/common/audio/sound/oalsound.cpp index 0f0b1f35b0..d97c9d5a68 100644 --- a/src/common/audio/sound/oalsound.cpp +++ b/src/common/audio/sound/oalsound.cpp @@ -556,7 +556,6 @@ OpenALSoundRenderer::OpenALSoundRenderer() ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect"); ALC.SOFT_HRTF = !!alcIsExtensionPresent(Device, "ALC_SOFT_HRTF"); ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device"); - ALC.SOFT_output_limiter = !!alcIsExtensionPresent(Device, "ALC_SOFT_output_limiter"); const ALCchar *current = NULL; if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT")) @@ -593,11 +592,6 @@ OpenALSoundRenderer::OpenALSoundRenderer() else attribs.Push(ALC_DONT_CARE_SOFT); } - if (ALC.SOFT_output_limiter) - { - attribs.Push(ALC_OUTPUT_LIMITER_SOFT); - attribs.Push(ALC_TRUE /* or ALC_FALSE or ALC_DONT_CARE_SOFT */); - } // Other attribs..? attribs.Push(0); diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index 269a491332..9c2ad6ab1e 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -463,7 +463,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, } // If this sound doesn't like playing near itself, don't play it if that's what would happen. - if (near_limit > 0 && CheckSoundLimit(sfx, pos, near_limit, limit_range, type, source, channel)) + if (near_limit > 0 && CheckSoundLimit(sfx, pos, near_limit, limit_range, type, source, channel, attenuation)) { chanflags |= CHANF_EVICTED; } @@ -675,7 +675,7 @@ void SoundEngine::RestartChannel(FSoundChan *chan) // If this sound doesn't like playing near itself, don't play it if // that's what would happen. - if (chan->NearLimit > 0 && CheckSoundLimit(&S_sfx[chan->SoundID], pos, chan->NearLimit, chan->LimitRange, 0, NULL, 0)) + if (chan->NearLimit > 0 && CheckSoundLimit(&S_sfx[chan->SoundID], pos, chan->NearLimit, chan->LimitRange, 0, NULL, 0, chan->DistanceScale)) { return; } @@ -816,7 +816,7 @@ bool SoundEngine::CheckSingular(int sound_id) //========================================================================== bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range, - int sourcetype, const void *actor, int channel) + int sourcetype, const void *actor, int channel, float attenuation) { FSoundChan *chan; int count; @@ -835,7 +835,9 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_ } CalcPosVel(chan, &chanorigin, NULL); - if ((chanorigin - pos).LengthSquared() <= limit_range) + // scale the limit distance with the attenuation. An attenuation of 0 means the limit distance is infinite and all sounds within the level are inside the limit. + float attn = std::min(chan->DistanceScale, attenuation); + if (attn <= 0 || (chanorigin - pos).LengthSquared() <= limit_range / attn) { count++; } diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index b3292637f6..11dac776a1 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -234,7 +234,7 @@ private: bool CheckSingular(int sound_id); virtual TArray ReadSound(int lumpnum) = 0; protected: - virtual bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel); + virtual bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel, float attenuation); virtual FSoundID ResolveSound(const void *ent, int srctype, FSoundID soundid, float &attenuation); public: diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index ae331d497c..40448275b6 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -95,10 +95,10 @@ class DoomSoundEngine : public SoundEngine S_sfx[ndx].UserData[0] = 0; return ndx; } - bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel) override + bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel, float attenuation) override { if (sourcetype != SOURCE_Actor) actor = nullptr; //ZDoom did this. - return SoundEngine::CheckSoundLimit(sfx, pos, near_limit, limit_range, sourcetype, actor, channel); + return SoundEngine::CheckSoundLimit(sfx, pos, near_limit, limit_range, sourcetype, actor, channel, attenuation); } diff --git a/wadsrc/static/filter/game-doomchex/sndinfo.txt b/wadsrc/static/filter/game-doomchex/sndinfo.txt index d90b8167f3..ac6d399219 100644 --- a/wadsrc/static/filter/game-doomchex/sndinfo.txt +++ b/wadsrc/static/filter/game-doomchex/sndinfo.txt @@ -321,6 +321,9 @@ spider/attack dsshotgn spider/death dsspidth spider/walk dsmetal +$limit spider/sight 4 +$limit spider/death 4 + // Arachnotron baby/sight dsbspsit @@ -341,6 +344,8 @@ cyber/pain dsdmpain cyber/death dscybdth cyber/hoof dshoof +$limit cyber/sight 4 +$limit cyber/death 4 // Pain Elemental pain/sight dspesit