au.BypassPlayWhenSilent

au.BypassPlayWhenSilent

#Overview

name: au.BypassPlayWhenSilent

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

  1. When set to 0 (default), the engine honors the “Play When Silent” flag for audio sources.
  2. When set to 1, it ignores the “Play When Silent” flag and stops all silent non-procedural sources.
  3. This setting does not affect procedural audio sources.

Best practices when using this variable include:

  1. Use it judiciously, as stopping silent audio sources may impact game logic that relies on these sources being active.
  2. Consider performance implications when deciding whether to keep silent sources active or not.
  3. Test thoroughly with both settings to ensure desired audio behavior in all game scenarios.

Regarding the associated variable BypassPlayWhenSilentCVar:

#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)