au.streamcaching.PrimeSoundOnAudioComponents
au.streamcaching.PrimeSoundOnAudioComponents
#Overview
name: au.streamcaching.PrimeSoundOnAudioComponents
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set to 1, automatically primes a USoundBase when a UAudioComponent is spawned with that sound, or when UAudioComponent::SetSound is called.\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.streamcaching.PrimeSoundOnAudioComponents is to control automatic priming of USoundBase objects when a UAudioComponent is spawned or when its sound is set. This setting variable is part of Unreal Engine’s audio system, specifically related to sound streaming and caching.
This setting variable is primarily used in the Engine module, particularly within the AudioComponent subsystem. It’s referenced in the AudioComponent.cpp file, which is a core part of Unreal Engine’s audio system.
The value of this variable is set through the Unreal Engine Console Variable (CVar) system. It’s initialized to 0 by default but can be changed at runtime or through configuration files.
The associated variable PrimeSoundOnAudioComponentSpawnCVar directly interacts with au.streamcaching.PrimeSoundOnAudioComponents. They share the same value, with PrimeSoundOnAudioComponentSpawnCVar being the actual int32 variable used in the code.
Developers should be aware that when this variable is set to 1, it will automatically prime (preload) the USoundBase associated with a UAudioComponent when the component is spawned or when UAudioComponent::SetSound is called. This can affect performance and memory usage, as priming sounds means loading them into memory.
Best practices when using this variable include:
- Only enable it (set to 1) when you need to reduce latency in sound playback, especially for frequently used or critical sounds.
- Be mindful of memory usage, as priming sounds will increase memory consumption.
- Consider the trade-off between reduced latency and increased memory usage/load times.
- Use it in conjunction with other sound optimization techniques in Unreal Engine.
Regarding the associated variable PrimeSoundOnAudioComponentSpawnCVar:
The purpose of PrimeSoundOnAudioComponentSpawnCVar is to serve as the actual int32 variable that holds the value of the au.streamcaching.PrimeSoundOnAudioComponents setting.
This variable is used directly in the Engine module, specifically in the AudioComponent class implementation.
Its value is set through the CVar system, initialized to 0, and can be changed at runtime.
PrimeSoundOnAudioComponentSpawnCVar directly controls the behavior of sound priming in the UAudioComponent::PostLoad and UAudioComponent::SetSound functions.
Developers should be aware that this variable directly affects the behavior of AudioComponents and can impact performance and memory usage.
Best practices include monitoring this variable’s value when debugging audio-related issues and considering its impact on overall game performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:31
Scope: file
Source code excerpt:
static int32 PrimeSoundOnAudioComponentSpawnCVar = 0;
FAutoConsoleVariableRef CVarPrimeSoundOnAudioComponentSpawn(
TEXT("au.streamcaching.PrimeSoundOnAudioComponents"),
PrimeSoundOnAudioComponentSpawnCVar,
TEXT("When set to 1, automatically primes a USoundBase when a UAudioComponent is spawned with that sound, or when UAudioComponent::SetSound is called.\n"),
ECVF_Default);
//CVar for how long voiceslots should be taken up when queuing sounds
static int32 TimeToTakeUpVoiceSlotCVar = int32(EQuartzCommandQuantization::HalfNote);
#Associated Variable and Callsites
This variable is associated with another variable named PrimeSoundOnAudioComponentSpawnCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:29
Scope: file
Source code excerpt:
ECVF_Default);
static int32 PrimeSoundOnAudioComponentSpawnCVar = 0;
FAutoConsoleVariableRef CVarPrimeSoundOnAudioComponentSpawn(
TEXT("au.streamcaching.PrimeSoundOnAudioComponents"),
PrimeSoundOnAudioComponentSpawnCVar,
TEXT("When set to 1, automatically primes a USoundBase when a UAudioComponent is spawned with that sound, or when UAudioComponent::SetSound is called.\n"),
ECVF_Default);
//CVar for how long voiceslots should be taken up when queuing sounds
static int32 TimeToTakeUpVoiceSlotCVar = int32(EQuartzCommandQuantization::HalfNote);
FAutoConsoleVariableRef CVarTimeToTakeUpVoiceSlot(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:232
Scope (from outer to inner):
file
function void UAudioComponent::PostLoad
Source code excerpt:
#endif
if (PrimeSoundOnAudioComponentSpawnCVar && Sound)
{
UGameplayStatics::PrimeSound(Sound);
}
Super::PostLoad();
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:332
Scope (from outer to inner):
file
function void UAudioComponent::SetSound
Source code excerpt:
Sound = NewSound;
if (PrimeSoundOnAudioComponentSpawnCVar && Sound)
{
UGameplayStatics::PrimeSound(Sound);
}
if (bPlay && !bCanPlayMultipleInstances)
{