au.EnableBinauralAudioForAllSpatialSounds

au.EnableBinauralAudioForAllSpatialSounds

#Overview

name: au.EnableBinauralAudioForAllSpatialSounds

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of au.EnableBinauralAudioForAllSpatialSounds is to toggle binaural audio rendering for all spatial sounds in Unreal Engine 5, provided that binaural rendering is available.

This setting variable is primarily used by the audio system within Unreal Engine 5. Based on the callsites, it’s clear that this variable is part of the Engine module, specifically within the AudioDevice component.

The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 and can be changed at runtime through console commands or programmatically.

The associated variable EnableBinauralAudioForAllSpatialSoundsCVar directly interacts with au.EnableBinauralAudioForAllSpatialSounds. They share the same value, with EnableBinauralAudioForAllSpatialSoundsCVar being the actual integer variable that stores the setting’s value.

Developers must be aware that this variable affects all spatial sounds in the game. When enabled (set to 1), it will apply binaural audio rendering to all spatial sounds, which can significantly change the audio experience for players.

Best practices when using this variable include:

  1. Ensuring that binaural rendering is available and properly set up in the project before enabling this feature.
  2. Testing the audio experience with and without this feature enabled to determine the best setting for your game.
  3. Considering performance implications, as binaural audio rendering may have a higher computational cost.
  4. Using this in conjunction with other audio settings to achieve the desired spatial audio experience.

Regarding the associated variable EnableBinauralAudioForAllSpatialSoundsCVar:

The purpose of EnableBinauralAudioForAllSpatialSoundsCVar is to store the actual integer value of the au.EnableBinauralAudioForAllSpatialSounds setting.

This variable is used within the Engine module, specifically in the AudioDevice component. It’s referenced in the IsHRTFEnabledForAll() function to determine if HRTF (Head-Related Transfer Function) should be enabled for all audio sources.

The value of this variable is set through the console variable system and is initialized to 0. It can be changed at runtime through console commands or programmatically.

EnableBinauralAudioForAllSpatialSoundsCVar interacts directly with au.EnableBinauralAudioForAllSpatialSounds, serving as the storage for its value.

Developers should be aware that this variable is used in conditional statements to determine audio rendering behavior. A value of 1 enables binaural audio for all spatial sounds, while 0 (the default) does not.

Best practices for using this variable include:

  1. Avoiding direct manipulation of this variable; instead, use the au.EnableBinauralAudioForAllSpatialSounds console variable to change its value.
  2. Considering thread safety when accessing this variable, as it’s used in both the audio and game threads.
  3. Using this variable in conjunction with other audio settings and the IsSpatializationPluginEnabled() function to determine the final audio rendering behavior.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:142

Scope: file

Source code excerpt:

static int32 EnableBinauralAudioForAllSpatialSoundsCVar = 0;
FAutoConsoleVariableRef CVarEnableBinauralAudioForAllSpatialSounds(
	TEXT("au.EnableBinauralAudioForAllSpatialSounds"),
	EnableBinauralAudioForAllSpatialSoundsCVar,
	TEXT("Toggles binaural audio rendering for all spatial sounds if binaural rendering is available.\n"),
	ECVF_Default);

static int32 DisableBinauralSpatializationCVar = 0;
FAutoConsoleVariableRef CVarDisableBinauralSpatialization(

#Associated Variable and Callsites

This variable is associated with another variable named EnableBinauralAudioForAllSpatialSoundsCVar. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:140

Scope: file

Source code excerpt:

	ECVF_Default);

static int32 EnableBinauralAudioForAllSpatialSoundsCVar = 0;
FAutoConsoleVariableRef CVarEnableBinauralAudioForAllSpatialSounds(
	TEXT("au.EnableBinauralAudioForAllSpatialSounds"),
	EnableBinauralAudioForAllSpatialSoundsCVar,
	TEXT("Toggles binaural audio rendering for all spatial sounds if binaural rendering is available.\n"),
	ECVF_Default);

static int32 DisableBinauralSpatializationCVar = 0;
FAutoConsoleVariableRef CVarDisableBinauralSpatialization(
	TEXT("au.DisableBinauralSpatialization"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:2197

Scope (from outer to inner):

file
function     bool FAudioDevice::IsHRTFEnabledForAll

Source code excerpt:

	if (IsInAudioThread())
	{
		return (bHRTFEnabledForAll || EnableBinauralAudioForAllSpatialSoundsCVar == 1) && IsSpatializationPluginEnabled();
	}

	check(IsInGameThread());
	return (bHRTFEnabledForAll_OnGameThread || EnableBinauralAudioForAllSpatialSoundsCVar == 1) && IsSpatializationPluginEnabled();
}

bool FAudioDevice::IsHRTFDisabled() const
{
	if (IsInAudioThread())
	{