au.BypassPlayWhenSilent
au.BypassPlayWhenSilent
#Overview
name: au.BypassPlayWhenSilent
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set to 1, ignores the Play When Silent flag for non-procedural sources.\n0: Honor the Play When Silent flag, 1: stop all silent non-procedural sources.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.BypassPlayWhenSilent is to control the behavior of non-procedural audio sources in Unreal Engine 5 when they are silent. It allows developers to decide whether to honor the “Play When Silent” flag or stop all silent non-procedural sources.
This setting variable is primarily used in the audio system of Unreal Engine. Based on the callsites, it’s referenced in the Engine module, specifically in the Audio.cpp file.
The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 and can be changed at runtime using console commands or through code.
The au.BypassPlayWhenSilent variable interacts directly with its associated variable BypassPlayWhenSilentCVar. They share the same value, with BypassPlayWhenSilentCVar being the actual int32 variable used in the code logic.
Developers must be aware that:
- When set to 0 (default), the engine honors the “Play When Silent” flag for audio sources.
- When set to 1, it ignores the “Play When Silent” flag and stops all silent non-procedural sources.
- This setting does not affect procedural audio sources.
Best practices when using this variable include:
- Use it judiciously, as stopping silent audio sources may impact game logic that relies on these sources being active.
- Consider performance implications when deciding whether to keep silent sources active or not.
- Test thoroughly with both settings to ensure desired audio behavior in all game scenarios.
Regarding the associated variable BypassPlayWhenSilentCVar:
- Its purpose is to provide a direct, typed access to the au.BypassPlayWhenSilent setting within the C++ code.
- It’s used in the Engine module, specifically in the audio system’s logic for determining if a wave instance is playing.
- Its value is set through the CVar system, mirroring au.BypassPlayWhenSilent.
- It interacts with the IsPlayWhenSilent() method of ActiveSound and the bProcedural flag of WaveData.
- Developers should be aware that this variable directly affects the IsPlaying() method of FWaveInstance, which could impact audio playback logic.
- Best practices include using this variable for runtime checks of the bypass setting, rather than accessing the CVar directly each time.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:88
Scope: file
Source code excerpt:
static int32 BypassPlayWhenSilentCVar = 0;
FAutoConsoleVariableRef CVarBypassPlayWhenSilent(
TEXT("au.BypassPlayWhenSilent"),
BypassPlayWhenSilentCVar,
TEXT("When set to 1, ignores the Play When Silent flag for non-procedural sources.\n")
TEXT("0: Honor the Play When Silent flag, 1: stop all silent non-procedural sources."),
ECVF_Default);
static float WaveInstanceMinVolumeThresholdCVar = UE_KINDA_SMALL_NUMBER;
#Associated Variable and Callsites
This variable is associated with another variable named BypassPlayWhenSilentCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:86
Scope: file
Source code excerpt:
ECVF_Default);
static int32 BypassPlayWhenSilentCVar = 0;
FAutoConsoleVariableRef CVarBypassPlayWhenSilent(
TEXT("au.BypassPlayWhenSilent"),
BypassPlayWhenSilentCVar,
TEXT("When set to 1, ignores the Play When Silent flag for non-procedural sources.\n")
TEXT("0: Honor the Play When Silent flag, 1: stop all silent non-procedural sources."),
ECVF_Default);
static float WaveInstanceMinVolumeThresholdCVar = UE_KINDA_SMALL_NUMBER;
FAutoConsoleVariableRef CVarMinVolumeThreshold(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio.cpp:924
Scope (from outer to inner):
file
function bool FWaveInstance::IsPlaying
Source code excerpt:
}
if (ActiveSound->IsPlayWhenSilent() && (!BypassPlayWhenSilentCVar || WaveData->bProcedural))
{
return true;
}
const float WaveInstanceVolume = Volume * VolumeMultiplier * GetDistanceAndOcclusionAttenuation() * GetDynamicVolume();
if (WaveInstanceVolume > WaveInstanceMinVolumeThresholdCVar)