au.AnalysisTimeShift
au.AnalysisTimeShift
#Overview
name: au.AnalysisTimeShift
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Shifts the timeline for baked analysis playback.\nValue: The time in seconds to shift the timeline.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.AnalysisTimeShift
is to shift the timeline for baked analysis playback in the audio system of Unreal Engine 5. This setting variable is primarily used in the audio component subsystem of the engine.
The Unreal Engine subsystem that relies on this setting variable is the Audio Component, which is part of the Engine module. This can be seen from the file path where the variable is referenced: Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp
.
The value of this variable is set through the console variable system in Unreal Engine. It’s declared as a console variable using FAutoConsoleVariableRef
, which allows it to be modified at runtime through console commands or configuration files.
This variable interacts directly with BakedAnalysisTimeShiftCVar
, which is the C++ variable that actually stores the value. They share the same value, with au.AnalysisTimeShift
being the console-accessible name and BakedAnalysisTimeShiftCVar
being the internal C++ variable.
Developers must be aware that this variable affects the playback time of baked audio analysis data. It’s used to offset the playback time, which can be useful for synchronizing audio analysis with other game elements or for debugging purposes.
Best practices when using this variable include:
- Use it cautiously, as it can affect the timing of audio playback and analysis.
- Document any non-zero values used in production to ensure consistency across the development team.
- Consider exposing this setting in a user-friendly way if it’s meant to be adjusted frequently during development or by end-users.
Regarding the associated variable BakedAnalysisTimeShiftCVar
:
The purpose of BakedAnalysisTimeShiftCVar
is to store the actual float value of the time shift for baked analysis playback. It’s the C++ representation of the console variable au.AnalysisTimeShift
.
This variable is used directly in the UAudioComponent::SetPlaybackTimes
function to adjust the playback time of audio elements. The code subtracts BakedAnalysisTimeShiftCVar
from the original playback time, ensuring it doesn’t go below zero.
The value of BakedAnalysisTimeShiftCVar
is set through the console variable system, mirroring the value of au.AnalysisTimeShift
.
Developers should be aware that modifying BakedAnalysisTimeShiftCVar
directly in C++ code is not recommended. Instead, they should use the console variable au.AnalysisTimeShift
to ensure proper synchronization between the two.
Best practices for BakedAnalysisTimeShiftCVar
include:
- Treat it as read-only in C++ code, using it only for calculations and not for direct modification.
- If you need to modify the value in C++, use the appropriate Unreal Engine functions to set console variable values rather than changing
BakedAnalysisTimeShiftCVar
directly. - When reading the value, consider caching it if used frequently to avoid potential performance impacts from repeatedly accessing the console variable system.
#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:23
Scope: file
Source code excerpt:
static float BakedAnalysisTimeShiftCVar = 0.0f;
FAutoConsoleVariableRef CVarBackedAnalysisTimeShift(
TEXT("au.AnalysisTimeShift"),
BakedAnalysisTimeShiftCVar,
TEXT("Shifts the timeline for baked analysis playback.\n")
TEXT("Value: The time in seconds to shift the timeline."),
ECVF_Default);
static int32 PrimeSoundOnAudioComponentSpawnCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named BakedAnalysisTimeShiftCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:21
Scope: file
Source code excerpt:
DECLARE_CYCLE_STAT(TEXT("AudioComponent Play"), STAT_AudioComp_Play, STATGROUP_Audio);
static float BakedAnalysisTimeShiftCVar = 0.0f;
FAutoConsoleVariableRef CVarBackedAnalysisTimeShift(
TEXT("au.AnalysisTimeShift"),
BakedAnalysisTimeShiftCVar,
TEXT("Shifts the timeline for baked analysis playback.\n")
TEXT("Value: The time in seconds to shift the timeline."),
ECVF_Default);
static int32 PrimeSoundOnAudioComponentSpawnCVar = 0;
FAutoConsoleVariableRef CVarPrimeSoundOnAudioComponentSpawn(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp:1663
Scope (from outer to inner):
file
function void UAudioComponent::SetPlaybackTimes
Source code excerpt:
if (PlaybackTimeData)
{
PlaybackTimeData->PlaybackTime = FMath::Max(Elem.Value - BakedAnalysisTimeShiftCVar, 0.0f);
}
}
}
bool UAudioComponent::GetCookedFFTData(const TArray<float>& FrequenciesToGet, TArray<FSoundWaveSpectralData>& OutSoundWaveSpectralData)
{