au.streamcache.priming.PrimeRandomNodes
au.streamcache.priming.PrimeRandomNodes
#Overview
name: au.streamcache.priming.PrimeRandomNodes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set to 1, sounds will be loaded into the cache automatically when a random node is hit.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.streamcache.priming.PrimeRandomNodes is to control the automatic loading of sounds into the cache when a random node is encountered in the audio system of Unreal Engine 5.
This setting variable is primarily used in the audio system, specifically for managing the behavior of random sound nodes. It is part of the Engine module, as evidenced by its location in the SoundNodeRandom.cpp file within the Engine/Source/Runtime/Engine/Private directory.
The value of this variable is set through the console variable system in Unreal Engine. It is declared as a static integer (PrimeRandomSoundNodesCVar) and linked to the console variable “au.streamcache.priming.PrimeRandomNodes” using FAutoConsoleVariableRef.
The associated variable PrimeRandomSoundNodesCVar directly interacts with au.streamcache.priming.PrimeRandomNodes. They share the same value, and PrimeRandomSoundNodesCVar is used in the actual code logic.
Developers must be aware that setting this variable to 1 will cause sounds to be automatically loaded into the cache when a random node is encountered. This can have implications for memory usage and performance, especially in scenes with many random sound nodes.
Best practices when using this variable include:
- Only enable it when necessary, as it may increase memory usage.
- Monitor performance impact when enabled, especially in complex audio scenarios.
- Consider the trade-off between improved audio responsiveness and increased memory usage.
Regarding the associated variable PrimeRandomSoundNodesCVar:
The purpose of PrimeRandomSoundNodesCVar is to serve as the in-code representation of the au.streamcache.priming.PrimeRandomNodes console variable.
It is used within the USoundNodeRandom class, specifically in the ParseNodes function. When PrimeRandomSoundNodesCVar is non-zero, it triggers the PrimeChildWavePlayers function, which likely loads the potential sound options into the cache.
The value of PrimeRandomSoundNodesCVar is set indirectly through the console variable system, mirroring the value of au.streamcache.priming.PrimeRandomNodes.
Developers should be aware that changes to au.streamcache.priming.PrimeRandomNodes will directly affect the behavior controlled by PrimeRandomSoundNodesCVar. They should also note that this variable is checked during the parsing of sound nodes, which may occur frequently during gameplay.
Best practices for PrimeRandomSoundNodesCVar include:
- Treat it as read-only within the code, as its value is managed by the console variable system.
- Consider the performance implications of frequently checking this variable in performance-critical code paths.
- Document any code that relies on this variable to ensure future developers understand its impact on the audio system’s behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundNodeRandom.cpp:21
Scope: file
Source code excerpt:
static int32 PrimeRandomSoundNodesCVar = 0;
FAutoConsoleVariableRef CVarPrimeRandomSoundNodes(
TEXT("au.streamcache.priming.PrimeRandomNodes"),
PrimeRandomSoundNodesCVar,
TEXT("When set to 1, sounds will be loaded into the cache automatically when a random node is hit.\n"),
ECVF_Default);
/*-----------------------------------------------------------------------------
USoundNodeRandom implementation.
#Associated Variable and Callsites
This variable is associated with another variable named PrimeRandomSoundNodesCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundNodeRandom.cpp:19
Scope: file
Source code excerpt:
ECVF_Default);
static int32 PrimeRandomSoundNodesCVar = 0;
FAutoConsoleVariableRef CVarPrimeRandomSoundNodes(
TEXT("au.streamcache.priming.PrimeRandomNodes"),
PrimeRandomSoundNodesCVar,
TEXT("When set to 1, sounds will be loaded into the cache automatically when a random node is hit.\n"),
ECVF_Default);
/*-----------------------------------------------------------------------------
USoundNodeRandom implementation.
-----------------------------------------------------------------------------*/
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundNodeRandom.cpp:198
Scope (from outer to inner):
file
function void USoundNodeRandom::ParseNodes
Source code excerpt:
if (*RequiresInitialization)
{
if (PrimeRandomSoundNodesCVar != 0)
{
PrimeChildWavePlayers(true);
}
NodeIndex = ChooseNodeIndex(ActiveSound);
*RequiresInitialization = 0;