au.AudioParameterComponent.SetParamOnlyOnValueChange
au.AudioParameterComponent.SetParamOnlyOnValueChange
#Overview
name: au.AudioParameterComponent.SetParamOnlyOnValueChange
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Only sets parameters when the underlying value has changed.\n0: Disable, 1: Enable (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.AudioParameterComponent.SetParamOnlyOnValueChange is to control the behavior of setting audio parameters in the AudioParameterComponent. It determines whether parameters should be set only when their underlying values have changed or if they should be set regardless of value changes.
This setting variable is primarily used in the Audio Gameplay plugin of Unreal Engine 5. Specifically, it’s utilized within the AudioParameterComponent, which is part of the audio system responsible for managing and updating audio parameters.
The value of this variable is set through a console variable system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime using console commands.
The associated variable bSetParamOnlyOnValueChange interacts directly with this console variable. They share the same value, and bSetParamOnlyOnValueChange is used in the actual implementation to control the parameter setting behavior.
Developers must be aware that when this variable is enabled (set to 1), the AudioParameterComponent will only update parameters when their values have actually changed. This can potentially optimize performance by reducing unnecessary parameter updates.
Best practices when using this variable include:
- Leave it enabled (default value of 1) unless there’s a specific reason to disable it, as it can help optimize performance.
- Be aware that disabling it might lead to more frequent parameter updates, which could impact performance in audio-heavy scenes.
- Use it in conjunction with profiling tools to determine the optimal setting for your specific use case.
Regarding the associated variable bSetParamOnlyOnValueChange:
The purpose of bSetParamOnlyOnValueChange is to provide a direct, code-level access to the behavior controlled by the console variable.
It’s used within the AudioParameterComponent’s SetParameterInternal function to determine whether to proceed with setting a parameter or to early-out if the value hasn’t changed.
The value of this variable is set by the console variable system and is not meant to be directly modified in code.
Developers should be aware that this variable directly affects the behavior of parameter setting in the AudioParameterComponent. When it’s non-zero, the component will check if a parameter’s value has changed before updating it.
Best practices for this variable include:
- Avoid directly modifying this variable in code; instead, use the console variable to change its value.
- When debugging audio parameter issues, check the value of this variable to understand the current behavior of parameter updates.
- Consider the implications of this setting on your audio system’s responsiveness and performance when designing your audio implementation.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/AudioGameplay/Source/AudioGameplay/Private/AudioParameterComponent.cpp:11
Scope (from outer to inner):
file
namespace AudioParameterComponentConsoleVariables
Source code excerpt:
int32 bSetParamOnlyOnValueChange = 1;
FAutoConsoleVariableRef CVarSetParamOnlyOnValueChange(
TEXT("au.AudioParameterComponent.SetParamOnlyOnValueChange"),
bSetParamOnlyOnValueChange,
TEXT("Only sets parameters when the underlying value has changed.\n0: Disable, 1: Enable (default)"),
ECVF_Default);
}
namespace AudioParameterComponentUtils
#Associated Variable and Callsites
This variable is associated with another variable named bSetParamOnlyOnValueChange
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/AudioGameplay/Source/AudioGameplay/Private/AudioParameterComponent.cpp:9
Scope (from outer to inner):
file
namespace AudioParameterComponentConsoleVariables
Source code excerpt:
namespace AudioParameterComponentConsoleVariables
{
int32 bSetParamOnlyOnValueChange = 1;
FAutoConsoleVariableRef CVarSetParamOnlyOnValueChange(
TEXT("au.AudioParameterComponent.SetParamOnlyOnValueChange"),
bSetParamOnlyOnValueChange,
TEXT("Only sets parameters when the underlying value has changed.\n0: Disable, 1: Enable (default)"),
ECVF_Default);
}
namespace AudioParameterComponentUtils
{
#Loc: <Workspace>/Engine/Plugins/AudioGameplay/Source/AudioGameplay/Private/AudioParameterComponent.cpp:226
Scope (from outer to inner):
file
function void UAudioParameterComponent::SetParameterInternal
Source code excerpt:
if (FAudioParameter* CurrentParam = FAudioParameter::FindOrAddParam(Parameters, InParam.ParamName))
{
if (AudioParameterComponentConsoleVariables::bSetParamOnlyOnValueChange != 0)
{
if (StartingParamCount == Parameters.Num())
{
// Early out if we did not add a parameter and this one matches.
// We always take the type of the param (see merge below), so the utility function below
// is only going to test based on changes to the right hand side