au.streamcache.SoundWaveDefaultLoadingBehavior
au.streamcache.SoundWaveDefaultLoadingBehavior
#Overview
name: au.streamcache.SoundWaveDefaultLoadingBehavior
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This can be set to define the default behavior when a USoundWave is loaded.\n1: Retain audio data on load, 2: prime audio data on load, 3: load on demand (No audio data is loaded until a USoundWave is played or primed).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.streamcache.SoundWaveDefaultLoadingBehavior is to define the default behavior when a USoundWave is loaded in Unreal Engine 5. This setting variable is part of the audio streaming system, specifically related to how sound waves are loaded and managed in memory.
This setting variable is primarily used in the Engine module, particularly within the SoundWave system. It is referenced in the SoundWave.cpp file, which is part of the audio subsystem of Unreal Engine.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of ESoundWaveLoadingBehavior::LoadOnDemand and can be changed at runtime through console commands.
The associated variable SoundWaveDefaultLoadingBehaviorCVar directly interacts with au.streamcache.SoundWaveDefaultLoadingBehavior. They share the same value, with SoundWaveDefaultLoadingBehaviorCVar being the actual integer storage for the enum value.
Developers must be aware that this variable affects the loading behavior of all USoundWave objects in the game. It can have significant implications on memory usage and loading times. The variable accepts three possible values:
- Retain audio data on load
- Prime audio data on load
- Load on demand (default)
Best practices when using this variable include:
- Consider the target platform and available memory when choosing a setting.
- Use “Load on demand” for most cases to optimize memory usage.
- Use “Retain on load” for frequently used, small sound files to reduce loading times.
- Use “Prime on load” for important sounds that need to play immediately without loading delays.
Regarding the associated variable SoundWaveDefaultLoadingBehaviorCVar:
- It’s an integer representation of the ESoundWaveLoadingBehavior enum.
- It’s used internally to store and manipulate the value set by au.streamcache.SoundWaveDefaultLoadingBehavior.
- The GetDefaultLoadingBehaviorCVar() function uses this variable to determine the current setting, ensuring it’s within the valid range and clamping it if necessary.
- Developers should not manipulate this variable directly, but instead use the console variable au.streamcache.SoundWaveDefaultLoadingBehavior to change the setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWave.cpp:40
Scope: file
Source code excerpt:
static int32 SoundWaveDefaultLoadingBehaviorCVar = static_cast<int32>(ESoundWaveLoadingBehavior::LoadOnDemand);
FAutoConsoleVariableRef CVarSoundWaveDefaultLoadingBehavior(
TEXT("au.streamcache.SoundWaveDefaultLoadingBehavior"),
SoundWaveDefaultLoadingBehaviorCVar,
TEXT("This can be set to define the default behavior when a USoundWave is loaded.\n")
TEXT("1: Retain audio data on load, 2: prime audio data on load, 3: load on demand (No audio data is loaded until a USoundWave is played or primed)."),
ECVF_Default);
static int32 ForceNonStreamingInEditorCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named SoundWaveDefaultLoadingBehaviorCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWave.cpp:38
Scope: file
Source code excerpt:
#endif
static int32 SoundWaveDefaultLoadingBehaviorCVar = static_cast<int32>(ESoundWaveLoadingBehavior::LoadOnDemand);
FAutoConsoleVariableRef CVarSoundWaveDefaultLoadingBehavior(
TEXT("au.streamcache.SoundWaveDefaultLoadingBehavior"),
SoundWaveDefaultLoadingBehaviorCVar,
TEXT("This can be set to define the default behavior when a USoundWave is loaded.\n")
TEXT("1: Retain audio data on load, 2: prime audio data on load, 3: load on demand (No audio data is loaded until a USoundWave is played or primed)."),
ECVF_Default);
static int32 ForceNonStreamingInEditorCVar = 0;
FAutoConsoleVariableRef CVarForceNonStreamingInEditor(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWave.cpp:97
Scope (from outer to inner):
file
namespace SoundWave_Private
function static ESoundWaveLoadingBehavior GetDefaultLoadingBehaviorCVar
Source code excerpt:
{
// query the default loading behavior CVar
ensureMsgf(SoundWaveDefaultLoadingBehaviorCVar >= static_cast<int32>(ESoundWaveLoadingBehavior::RetainOnLoad) &&
SoundWaveDefaultLoadingBehaviorCVar <= static_cast<int32>(ESoundWaveLoadingBehavior::LoadOnDemand),
TEXT("Invalid default loading behavior CVar value=%d:%s. Use value 1 (retain on load), 2 (prime on load) or 3 (load on demand)."),
SoundWaveDefaultLoadingBehaviorCVar, EnumToString(static_cast<ESoundWaveLoadingBehavior>(SoundWaveDefaultLoadingBehaviorCVar)));
// Clamp the value to make sure its in range.
const ESoundWaveLoadingBehavior DefaultLoadingBehavior = static_cast<ESoundWaveLoadingBehavior>(
FMath::Clamp<int32>(
SoundWaveDefaultLoadingBehaviorCVar,
static_cast<int32>(ESoundWaveLoadingBehavior::RetainOnLoad),
static_cast<int32>(ESoundWaveLoadingBehavior::LoadOnDemand)
));
return DefaultLoadingBehavior;
}