au.WorldlessGetAudioTimeBehavior

au.WorldlessGetAudioTimeBehavior

#Overview

name: au.WorldlessGetAudioTimeBehavior

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.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:

  1. Understanding the implications of changing its value, especially in scenarios where audio components might not belong to a world.
  2. Considering the potential impact on audio synchronization and timing in worldless contexts.
  3. Documenting any non-default usage of this variable to maintain code clarity.

Regarding the associated variable WorldlessGetAudioTimeBehaviorCVar:

#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;
}