au.VirtualLoops.UpdateRate.Max

au.VirtualLoops.UpdateRate.Max

#Overview

name: au.VirtualLoops.UpdateRate.Max

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.UpdateRate.Max is to set the maximum rate at which the audio system checks if a virtualized sound loop becomes audible again. This setting is part of Unreal Engine’s audio system, specifically the virtual loop subsystem.

Based on the callsites, this setting variable is primarily used in the Engine module, specifically in the AudioVirtualLoop.cpp file. This suggests that it’s a core part of the audio engine’s virtual loop functionality.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 3.0f and can be modified at runtime using console commands or through configuration files.

The associated variable VirtualLoopsUpdateRateMaxCVar directly interacts with au.VirtualLoops.UpdateRate.Max. They share the same value, with VirtualLoopsUpdateRateMaxCVar being the actual C++ variable used in the code, while au.VirtualLoops.UpdateRate.Max is the console variable name used for external access and configuration.

Developers should be aware that this variable affects the performance and behavior of virtual audio loops. It determines how frequently the system checks for audibility of sounds that are currently virtualized (i.e., not actively playing due to being too far from the listener). A higher value means less frequent checks, which can improve performance but might lead to slightly delayed reactivation of sounds as they come back into audible range.

Best practices when using this variable include:

  1. Balancing it with au.VirtualLoops.UpdateRate.Min for optimal performance and audio behavior.
  2. Considering the game’s audio requirements and performance constraints when adjusting this value.
  3. Testing thoroughly after modifying this value to ensure it doesn’t negatively impact the game’s audio experience or performance.

Regarding the associated variable VirtualLoopsUpdateRateMaxCVar:

The purpose of VirtualLoopsUpdateRateMaxCVar is to serve as the C++ representation of the au.VirtualLoops.UpdateRate.Max console variable within the engine’s code.

This variable is used directly in the Engine module, specifically in the AudioVirtualLoop.cpp file. It’s part of the audio engine’s virtual loop system.

The value of VirtualLoopsUpdateRateMaxCVar is set when the au.VirtualLoops.UpdateRate.Max console variable is modified, either through console commands or configuration files.

VirtualLoopsUpdateRateMaxCVar interacts directly with au.VirtualLoops.UpdateRate.Max, effectively mirroring its value. It’s also used in calculations within the FAudioVirtualLoop::CalculateUpdateInterval function, where it’s lerped with VirtualLoopsUpdateRateMinCVar based on the distance ratio of the sound to the listener.

Developers should be aware that modifying VirtualLoopsUpdateRateMaxCVar directly in the code is not recommended. Instead, they should use the au.VirtualLoops.UpdateRate.Max console variable to ensure consistency across the engine.

Best practices include using the console variable system for modifying this value rather than hard-coding changes, and considering its impact on both performance and audio behavior when adjusting it.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static float VirtualLoopsUpdateRateMaxCVar = 3.0f;
FAutoConsoleVariableRef CVarVirtualLoopsUpdateRateMax(
	TEXT("au.VirtualLoops.UpdateRate.Max"),
	VirtualLoopsUpdateRateMaxCVar,
	TEXT("Sets maximum rate to check if sound becomes audible again (at beyond sound's max audible distance + perf scaling distance).\n"),
	ECVF_Default);


#if UE_AUDIO_PROFILERTRACE_ENABLED

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

static float VirtualLoopsUpdateRateMaxCVar = 3.0f;
FAutoConsoleVariableRef CVarVirtualLoopsUpdateRateMax(
	TEXT("au.VirtualLoops.UpdateRate.Max"),
	VirtualLoopsUpdateRateMaxCVar,
	TEXT("Sets maximum rate to check if sound becomes audible again (at beyond sound's max audible distance + perf scaling distance).\n"),
	ECVF_Default);


#if UE_AUDIO_PROFILERTRACE_ENABLED
UE_TRACE_EVENT_BEGIN(Audio, VirtualLoopVirtualize)

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

Scope (from outer to inner):

file
function     void FAudioVirtualLoop::CalculateUpdateInterval

Source code excerpt:

	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
{
	return TimeVirtualized;
}