au.AllowAudioSpatialization
au.AllowAudioSpatialization
#Overview
name: au.AllowAudioSpatialization
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls if we allow spatialization of audio, normally this is enabled. If disabled all audio won\'t be spatialized, but will have attenuation.\n0: Disable, >0: Enable
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.AllowAudioSpatialization is to control whether audio spatialization is enabled in the Unreal Engine’s audio system. Spatialization refers to the process of creating a three-dimensional sound field, allowing sounds to be perceived as coming from specific locations in the game world.
This setting variable is primarily used in the audio subsystem of Unreal Engine, specifically within the Engine module. It’s referenced in the Audio.cpp file, which is part of the core audio implementation.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) but can be changed at runtime using console commands or through game code.
The au.AllowAudioSpatialization variable interacts directly with an associated integer variable named AllowAudioSpatializationCVar. They share the same value, with the CVar system providing a way to modify this value during runtime.
Developers must be aware that this variable acts as a global switch for audio spatialization. When disabled (set to 0), all audio in the game will not be spatialized, although attenuation will still be applied. This can significantly affect the perceived realism and immersion of the game’s audio landscape.
Best practices when using this variable include:
- Generally leaving it enabled (>0) for most games to maintain a realistic 3D audio environment.
- Only disabling it if there’s a specific need to remove all spatialization effects globally.
- Using it in conjunction with more granular audio settings for fine-tuning the audio experience.
- Testing the game thoroughly with both enabled and disabled states to ensure the audio experience is appropriate in both scenarios.
Regarding the associated variable AllowAudioSpatializationCVar:
The purpose of AllowAudioSpatializationCVar is to serve as the actual storage for the au.AllowAudioSpatialization setting. It’s an integer variable that directly controls whether audio spatialization is allowed.
This variable is used in the same audio subsystem within the Engine module. It’s referenced in functions like IsSpatializationCVarEnabled() and FWaveInstance::GetUseSpatialization(), which are likely called by various parts of the audio system to determine if spatialization should be applied.
The value of AllowAudioSpatializationCVar is set through the CVar system, mirroring the value of au.AllowAudioSpatialization.
It interacts directly with the au.AllowAudioSpatialization CVar and is used in conditional statements to enable or disable spatialization features.
Developers should be aware that this variable is the actual implementation detail behind the au.AllowAudioSpatialization setting. Changes to AllowAudioSpatializationCVar will directly affect the game’s audio spatialization behavior.
Best practices include:
- Not modifying AllowAudioSpatializationCVar directly, but instead using the CVar system to change au.AllowAudioSpatialization.
- Using the provided function IsSpatializationCVarEnabled() to check if spatialization is enabled, rather than accessing AllowAudioSpatializationCVar directly.
- Being aware of this variable when debugging audio spatialization issues, as it’s the core control point for this feature.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:72
Scope: file
Source code excerpt:
static int32 AllowAudioSpatializationCVar = 1;
FAutoConsoleVariableRef CVarAllowAudioSpatializationCVar(
TEXT("au.AllowAudioSpatialization"),
AllowAudioSpatializationCVar,
TEXT("Controls if we allow spatialization of audio, normally this is enabled. If disabled all audio won't be spatialized, but will have attenuation.\n")
TEXT("0: Disable, >0: Enable"),
ECVF_Default);
static int32 OcclusionFilterScaleEnabledCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named AllowAudioSpatializationCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:70
Scope: file
Source code excerpt:
ECVF_Default);
static int32 AllowAudioSpatializationCVar = 1;
FAutoConsoleVariableRef CVarAllowAudioSpatializationCVar(
TEXT("au.AllowAudioSpatialization"),
AllowAudioSpatializationCVar,
TEXT("Controls if we allow spatialization of audio, normally this is enabled. If disabled all audio won't be spatialized, but will have attenuation.\n")
TEXT("0: Disable, >0: Enable"),
ECVF_Default);
static int32 OcclusionFilterScaleEnabledCVar = 0;
FAutoConsoleVariableRef CVarOcclusionFilterScaleEnabled(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:176
Scope (from outer to inner):
file
function bool IsSpatializationCVarEnabled
Source code excerpt:
bool IsSpatializationCVarEnabled()
{
return AllowAudioSpatializationCVar != 0;
}
/*-----------------------------------------------------------------------------
FSoundBuffer implementation.
-----------------------------------------------------------------------------*/
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:1159
Scope (from outer to inner):
file
function bool FWaveInstance::GetUseSpatialization
Source code excerpt:
bool FWaveInstance::GetUseSpatialization() const
{
return AllowAudioSpatializationCVar && bUseSpatialization;
}
FString FWaveInstance::GetName() const
{
if (WaveData)
{