From d4d187e27bb1d2a1f72b4cbb03971b6729cff329 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Oct 2020 21:28:20 +0100 Subject: [PATCH] - removed the limiter flags again and addressed the underlying problem properly. The real issue is that the number of unattenuated sounds was unchecked and the near limit never kicked in. To do this properly it is necessary to adjust the limit distance by the attenuation - zero attenuation must mean infinite distance and for high attenuations the distance must be lowered for limiting to work as intended. The limit for the Doom boss sounds was increased to 4 to compensate for this change. # Conflicts: # src/common/audio/sound/oalsound.cpp --- src/common/audio/sound/oalsound.cpp | 6 ------ src/common/audio/sound/s_sound.cpp | 10 ++++++---- src/common/audio/sound/s_soundinternal.h | 2 +- src/sound/s_doomsound.cpp | 4 ++-- wadsrc/static/filter/game-doomchex/sndinfo.txt | 5 +++++ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/common/audio/sound/oalsound.cpp b/src/common/audio/sound/oalsound.cpp index 0f0b1f35b09..d97c9d5a68e 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 269a491332b..9c2ad6ab1e1 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 b3292637f61..11dac776a17 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -234,7 +234,7 @@ class SoundEngine 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 ae331d497c6..40448275b6c 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 d90b8167f32..ac6d399219e 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