au.adpcm.ChanceForIntentionalChunkMiss

au.adpcm.ChanceForIntentionalChunkMiss

#Overview

name: au.adpcm.ChanceForIntentionalChunkMiss

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.adpcm.ChanceForIntentionalChunkMiss is to simulate chunk dropping in ADPCM (Adaptive Differential Pulse Code Modulation) audio decoding for debugging purposes. This setting variable is part of the audio system in Unreal Engine 5, specifically related to the ADPCM audio decoder module.

The Unreal Engine subsystem that relies on this setting variable is the AdpcmAudioDecoder module, which is responsible for decoding ADPCM-encoded audio data.

The value of this variable is set through the engine’s console variable system. It’s initialized with a default value of 0.0f and can be modified at runtime using console commands or through configuration files.

This variable interacts directly with its associated variable ChanceForIntentionalChunkMissCVar. They share the same value, with ChanceForIntentionalChunkMissCVar being the actual float variable used in the code, while au.adpcm.ChanceForIntentionalChunkMiss is the console variable name used to set its value.

Developers must be aware that setting this variable to a value greater than 0 will intentionally cause audio chunks to be dropped during decoding. This is not intended for normal operation but is specifically designed for debugging purposes. Using this in a production environment could lead to audio playback issues.

Best practices when using this variable include:

  1. Only use it during development and debugging phases.
  2. Set it back to 0 before releasing the game or application.
  3. Use it in conjunction with logging and debugging tools to track the impact of dropped chunks on audio playback.
  4. Be cautious when adjusting the value, as higher values will result in more frequent chunk dropping.

Regarding the associated variable ChanceForIntentionalChunkMissCVar:

The purpose of ChanceForIntentionalChunkMissCVar is to store the actual float value used by the ADPCM audio decoder to determine the probability of intentionally dropping an audio chunk.

This variable is used directly in the FADPCMAudioInfo::GetLoadedChunk function to decide whether to drop a chunk or not. It’s compared against a random value between 0.0f and 1.0f to make this decision.

The value of ChanceForIntentionalChunkMissCVar is set through the au.adpcm.ChanceForIntentionalChunkMiss console variable.

Developers should be aware that modifying ChanceForIntentionalChunkMissCVar directly in the code is not recommended. Instead, they should use the console variable system to adjust the value of au.adpcm.ChanceForIntentionalChunkMiss, which will automatically update ChanceForIntentionalChunkMissCVar.

Best practices for ChanceForIntentionalChunkMissCVar include:

  1. Treat it as a read-only variable in the code.
  2. Use the console variable system to modify its value indirectly.
  3. Monitor its value during debugging sessions to ensure it’s set as expected.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/AdpcmAudioDecoder/Module/Private/ADPCMAudioInfo.cpp:34

Scope: file

Source code excerpt:

static float ChanceForIntentionalChunkMissCVar = 0.0f;
FAutoConsoleVariableRef CVarChanceForIntentionalChunkMiss(
	TEXT("au.adpcm.ChanceForIntentionalChunkMiss"),
	ChanceForIntentionalChunkMissCVar,
	TEXT("If this is set > 0 we will intentionally drop chunks. Used for debugging..\n"),
	ECVF_Default);

#define WAVE_FORMAT_LPCM  1
#define WAVE_FORMAT_ADPCM 2

#Associated Variable and Callsites

This variable is associated with another variable named ChanceForIntentionalChunkMissCVar. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/AdpcmAudioDecoder/Module/Private/ADPCMAudioInfo.cpp:32

Scope: file

Source code excerpt:

	ECVF_Default);

static float ChanceForIntentionalChunkMissCVar = 0.0f;
FAutoConsoleVariableRef CVarChanceForIntentionalChunkMiss(
	TEXT("au.adpcm.ChanceForIntentionalChunkMiss"),
	ChanceForIntentionalChunkMissCVar,
	TEXT("If this is set > 0 we will intentionally drop chunks. Used for debugging..\n"),
	ECVF_Default);

#define WAVE_FORMAT_LPCM  1
#define WAVE_FORMAT_ADPCM 2

#Loc: <Workspace>/Engine/Source/Runtime/AdpcmAudioDecoder/Module/Private/ADPCMAudioInfo.cpp:1021

Scope (from outer to inner):

file
function     const uint8* FADPCMAudioInfo::GetLoadedChunk

Source code excerpt:

const uint8* FADPCMAudioInfo::GetLoadedChunk(const FSoundWaveProxyPtr& InSoundWave, uint32 ChunkIndex, uint32& OutChunkSize)
{
	if (ChunkIndex != 0 && FMath::RandRange(0.0f, 1.0f) < ChanceForIntentionalChunkMissCVar)
	{
		UE_LOG(LogAudio, Display, TEXT("Intentionally dropping a chunk here."));
		OutChunkSize = 0;
		return nullptr;
	}