au.WorldlessGetAudioTimeBehavior
au.WorldlessGetAudioTimeBehavior
#Overview
name: au.WorldlessGetAudioTimeBehavior
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Determines the return value of GetAudioTime when an audio component does not belong to a world.\n0: 0.f (default), 1: Application\'s CurrentTime
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.WorldlessGetAudioTimeBehavior is to control the behavior of the GetAudioTime function when an audio component does not belong to a world in Unreal Engine 5.
This setting variable is primarily used in the audio system of Unreal Engine, specifically within the AudioComponent module. Based on the callsites, it’s clear that this variable is utilized in the Engine’s runtime, particularly in the AudioComponent.cpp file.
The value of this variable is set through a console variable system, as evidenced by the use of FAutoConsoleVariableRef. It’s initialized with a default value of 0.
The associated variable WorldlessGetAudioTimeBehaviorCVar interacts directly with au.WorldlessGetAudioTimeBehavior. They share the same value, with WorldlessGetAudioTimeBehaviorCVar being the actual integer variable used in the C++ code.
Developers must be aware that this variable affects the behavior of the GetAudioTimeSeconds function in the UAudioComponent class. When an audio component doesn’t belong to a world, this variable determines whether the function returns 0.0f (default behavior) or the application’s current time.
Best practices when using this variable include:
- Understanding the implications of changing its value, especially in scenarios where audio components might not belong to a world.
- Considering the potential impact on audio synchronization and timing in worldless contexts.
- Documenting any non-default usage of this variable to maintain code clarity.
Regarding the associated variable WorldlessGetAudioTimeBehaviorCVar:
- Its purpose is to provide a C++ accessible integer representation of the au.WorldlessGetAudioTimeBehavior console variable.
- It’s used directly in the GetAudioTimeSeconds function of the UAudioComponent class to determine the return value when an audio component doesn’t belong to a world.
- The value is set through the console variable system and can be changed at runtime.
- Developers should be aware that modifying this variable directly in C++ code might lead to inconsistencies with the console variable system.
- Best practice is to interact with this variable through the console variable system rather than modifying it directly in C++ code, ensuring consistency across the engine.
#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:57
Scope: file
Source code excerpt:
static int32 WorldlessGetAudioTimeBehaviorCVar = 0;
FAutoConsoleVariableRef CVarWorldlessGetAudioTimeBehavior(
TEXT("au.WorldlessGetAudioTimeBehavior"),
WorldlessGetAudioTimeBehaviorCVar,
TEXT("Determines the return value of GetAudioTime when an audio component does not belong to a world.\n")
TEXT("0: 0.f (default), 1: Application's CurrentTime"),
ECVF_Default);
uint64 UAudioComponent::AudioComponentIDCounter = 0;
#Associated Variable and Callsites
This variable is associated with another variable named WorldlessGetAudioTimeBehaviorCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:55
Scope: file
Source code excerpt:
static int32 WorldlessGetAudioTimeBehaviorCVar = 0;
FAutoConsoleVariableRef CVarWorldlessGetAudioTimeBehavior(
TEXT("au.WorldlessGetAudioTimeBehavior"),
WorldlessGetAudioTimeBehaviorCVar,
TEXT("Determines the return value of GetAudioTime when an audio component does not belong to a world.\n")
TEXT("0: 0.f (default), 1: Application's CurrentTime"),
ECVF_Default);
uint64 UAudioComponent::AudioComponentIDCounter = 0;
TMap<uint64, UAudioComponent*> UAudioComponent::AudioIDToComponentMap;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:391
Scope (from outer to inner):
file
function float UAudioComponent::GetAudioTimeSeconds
Source code excerpt:
}
if (WorldlessGetAudioTimeBehaviorCVar)
{
return FApp::GetCurrentTime();
}
return 0.f;
}