Muffled Audio/In game deafness


I have been experimenting with audio and just started working on custom C++ blueprint nodes as I believe that writing my own blueprint nodes will help me massively.

I want to hit a key, which applies a Low Pass Filter to muffle all audio, much like what you hear in this video.
The idea is that there will be a non-scripted trigger, one that is not in the level, one that is handled by the AI or something else dynamic and random, and this trigger will cause the player’s audio to become muffled, as if the player has gone partially deaf (can still hear, but everything is really muffled).

I have created custom blueprint nodes that allow for volume changes in a class, but I’m wondering if anybody knows a way to apply attenuation settings to an entire sound class (e.g. the “Master” class, or “Music” class) rather than just one base sound.

Or if anybody knows how to apply a Low Pass Filter to the final audio received by the player.
Or at least even know what class to look for that handles the final audio received.

Am I going to need a plugin like FMod to achieve this?
Since the audio muffling is part of the engine without a plugin, I presume I won’t need FMod or anything else to do what I’m after, but I’ve been spending most of the day trying to work this out, and have gotten nowhere :frowning:

If anybody can help me, that would be greatly appreciated, thank you :slight_smile:

Also, I had a thought today that one work-around would be to surround the entire level with an AudioVolume and set interior LPF to something low, however, that’s only if the player is on the outside of the volume and the sounds are on the inside of the volume, and since it surrounds the whole level, the player would on the inside of the volume with the audio source, so no filters would apply.

Which got me thinking that maybe I should check out the AudioVolume.h and cpp files and see what trickery and magic is happening in here, but so far, due to my limited knowledge in C++ programming, I am struggling to find out exactly what causes the muffled audio.

I feel like Fmod or Wwise and other plugins aren’t necessary to do this, since the engine is capable of muffling audio on it’s own, but I guess some custom code needs to be created in order for it to happen. I just need to find out what code it is that causes the muffling, and re-purpose that code to be able to do it dynamically, on a key press if need be.

I dug a little deeper and found a this little snippet of code inside of the ActiveSound.cpp file:

void FActiveSound::HandleInteriorVolumes( const FListener& Listener, FSoundParseParameters& ParseParams )

		CurrentInteriorLPF = FMath::Lerp(SourceInteriorLPF, MAX_FILTER_FREQUENCY, Listener.InteriorLPFInterp);
		ParseParams.AmbientZoneFilterFrequency = CurrentInteriorLPF;

I want to change the code to this, purely for the sake of testing. I presume this would mean that even if the the player (listener) and audio source are inside of an audio volume, that instead of doing a LERP to the MAX_FILTER_FREQUENCY, it would instead LERP to whatever the InteriorSettings Exterior LPF is using the alpha which is the listeners interior LPF Interp value.
So…it should, in my limited knowledge of C++ do a LERP from the max filter frequency (which I believe is 20000) to whatever I specify to be the interior LPF of the volume (e.g. 20).
I’m probably wrong, very wrong, but looks right to me :stuck_out_tongue:

void FActiveSound::HandleInteriorVolumes( const FListener& Listener, FSoundParseParameters& ParseParams )

		CurrentInteriorLPF = FMath::Lerp(MAX_FILTER_FREQUENCY, SourceInteriorLPF, Listener.InteriorLPFInterp);
		ParseParams.AmbientZoneFilterFrequency = CurrentInteriorLPF;

My problem is that I can’t test this, as I am not sure how I can modify the source files and have it update in the editor. Even if I completely delete the ActiveSound.cpp file, it doesn’t seem to have any problems, it’s as if it’s not really being read. But it’s my lack of knowledge here that is letting me down, so how would I go about modifying source files and having them update in the editor much the same way as if I was creating my own custom C++ classes?


So it seems I was just doing the crazy over-complicated method due to my lack of knowledge in audio.

It was suggested on a facebook UE4 developers group to use EQ to create the same effect.

So I toyed around, not really fully understanding the controls, and eventually changed the EQ Gains to something low like 0.16…that’s it.

I also stumbled across the Set Sound Mix Class Override, which I could use to transition between a normal sound mix and the deafness one, which is great. The things we learn :stuck_out_tongue: