au.VirtualLoops.PerfDistance

au.VirtualLoops.PerfDistance

#Overview

name: au.VirtualLoops.PerfDistance

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.VirtualLoops.PerfDistance is to set the distance used for scaling the update rate of virtual audio loops beyond the maximum audible distance of a sound. This setting is part of the audio system in Unreal Engine 5, specifically related to the performance optimization of virtual audio loops.

The Unreal Engine subsystem that relies on this setting variable is the Audio System, particularly the virtual audio loop functionality. This can be seen from the file location (AudioVirtualLoop.cpp) and the context of the code.

The value of this variable is set through the console variable system. It’s initialized with a default value of 15000.0f and can be modified at runtime using console commands.

This variable interacts with another variable named VirtualLoopsPerfDistanceCVar. They share the same value, with au.VirtualLoops.PerfDistance being the console-accessible name and VirtualLoopsPerfDistanceCVar being the actual C++ variable used in the code.

Developers should be aware that this variable affects the performance and behavior of virtual audio loops. It’s used to calculate the update interval for these loops based on their distance from the listener.

Best practices when using this variable include:

  1. Adjusting it carefully to balance performance and audio quality.
  2. Testing different values to find the optimal setting for your specific game scenario.
  3. Considering the scale of your game world when setting this value.

Regarding the associated variable VirtualLoopsPerfDistanceCVar:

The purpose of VirtualLoopsPerfDistanceCVar is to store the actual value used in the C++ code for the au.VirtualLoops.PerfDistance setting.

This variable is used directly in the Audio System’s code, specifically in the FAudioVirtualLoop::CalculateUpdateInterval function.

The value of this variable is set through the console variable system, mirroring the value of au.VirtualLoops.PerfDistance.

It interacts with other variables in the calculation of the update interval for virtual audio loops, including ActiveSound->MaxDistance, VirtualLoopsUpdateRateMinCVar, and VirtualLoopsUpdateRateMaxCVar.

Developers should be aware that modifying au.VirtualLoops.PerfDistance will directly affect this variable.

Best practices include:

  1. Avoiding direct modification of VirtualLoopsPerfDistanceCVar in code, instead use the console variable au.VirtualLoops.PerfDistance.
  2. Considering the impact on performance when adjusting this value, as it affects how frequently virtual audio loops are updated based on distance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioVirtualLoop.cpp:15

Scope: file

Source code excerpt:

static float VirtualLoopsPerfDistanceCVar = 15000.0f;
FAutoConsoleVariableRef CVarVirtualLoopsPerfDistance(
	TEXT("au.VirtualLoops.PerfDistance"),
	VirtualLoopsPerfDistanceCVar,
	TEXT("Sets virtual loop distance to scale update rate between min and max beyond max audible distance of sound.\n"),
	ECVF_Default);

static float VirtualLoopsForceUpdateListenerMoveDistanceCVar = 2500.0f;
FAutoConsoleVariableRef CVarVirtualLoopsForceUpdateListenerMoveDistance(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioVirtualLoop.cpp:13

Scope: file

Source code excerpt:

	ECVF_Default);

static float VirtualLoopsPerfDistanceCVar = 15000.0f;
FAutoConsoleVariableRef CVarVirtualLoopsPerfDistance(
	TEXT("au.VirtualLoops.PerfDistance"),
	VirtualLoopsPerfDistanceCVar,
	TEXT("Sets virtual loop distance to scale update rate between min and max beyond max audible distance of sound.\n"),
	ECVF_Default);

static float VirtualLoopsForceUpdateListenerMoveDistanceCVar = 2500.0f;
FAutoConsoleVariableRef CVarVirtualLoopsForceUpdateListenerMoveDistance(
	TEXT("au.VirtualLoops.ForceUpdateListenerMoveDistance"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioVirtualLoop.cpp:155

Scope (from outer to inner):

file
function     void FAudioVirtualLoop::CalculateUpdateInterval

Source code excerpt:


	const float DistanceToListener = AudioDevice->GetDistanceToNearestListener(ActiveSound->Transform.GetLocation());
	const float DistanceRatio = (DistanceToListener - ActiveSound->MaxDistance) / FMath::Max(VirtualLoopsPerfDistanceCVar, 1.0f);
	const float DistanceRatioClamped = FMath::Clamp(DistanceRatio, 0.0f, 1.0f);
	UpdateInterval = FMath::Lerp(VirtualLoopsUpdateRateMinCVar, VirtualLoopsUpdateRateMaxCVar, DistanceRatioClamped);
}

float FAudioVirtualLoop::GetTimeVirtualized() const
{