voice.DefaultPatchBufferSize

voice.DefaultPatchBufferSize

#Overview

name: voice.DefaultPatchBufferSize

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 voice.DefaultPatchBufferSize is to control the amount of audio buffered for VOIP patching in the Unreal Engine’s voice communication system. This setting variable is used to determine the size of the audio buffer in samples.

This setting variable is primarily used in the Online Subsystem Utils plugin, specifically within the VoipListenerSynthComponent. It’s part of the voice communication system in Unreal Engine, which is crucial for multiplayer games or applications requiring real-time voice chat.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through the console. The default value is set to 4096 samples.

The associated variable DefaultPatchBufferSizeCVar directly interacts with voice.DefaultPatchBufferSize. They share the same value, with DefaultPatchBufferSizeCVar being the actual integer variable used in the code, while voice.DefaultPatchBufferSize is the console variable name.

Developers must be aware that changing this value affects the latency and quality of voice communication. A larger buffer size can improve audio quality but may increase latency, while a smaller buffer size can reduce latency but might lead to audio artifacts or choppy sound.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance between audio quality and latency for your specific use case.
  2. Considering the target platform and network conditions when setting this value.
  3. Providing a way for users to adjust this setting if voice quality is crucial for the application.

Regarding the associated variable DefaultPatchBufferSizeCVar:

The purpose of DefaultPatchBufferSizeCVar is to store the actual integer value used in the code for the patch buffer size. It’s directly linked to the console variable voice.DefaultPatchBufferSize.

This variable is used in the Online Subsystem Utils plugin, specifically in the VoipListenerSynthComponent.

The value of DefaultPatchBufferSizeCVar is initially set to 4096, but it can be modified through the console variable voice.DefaultPatchBufferSize.

It interacts directly with the voice.DefaultPatchBufferSize console variable and is used when connecting to the audio splitter in the ConnectToSplitter function of UVoipListenerSynthComponent.

Developers should be aware that modifying DefaultPatchBufferSizeCVar directly in the code will not affect the console variable. Changes should be made through the console variable to ensure consistency.

Best practices include using the console variable for runtime changes and only modifying the initial value of DefaultPatchBufferSizeCVar if a different default is required for all instances of the application.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/VoipListenerSynthComponent.cpp:15

Scope: file

Source code excerpt:

static int32 DefaultPatchBufferSizeCVar = 4096;
FAutoConsoleVariableRef CVarDefaultPatchBufferSize(
	TEXT("voice.DefaultPatchBufferSize"),
	DefaultPatchBufferSizeCVar,
	TEXT("Changes the amount of audio we buffer for VOIP patching, in samples.\n"),
	ECVF_Default);

static float DefaultPatchGainCVar = 1.0f;
FAutoConsoleVariableRef CVarDefaultPatchGain(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/VoipListenerSynthComponent.cpp:13

Scope: file

Source code excerpt:

#define DEBUG_NOISE 0

static int32 DefaultPatchBufferSizeCVar = 4096;
FAutoConsoleVariableRef CVarDefaultPatchBufferSize(
	TEXT("voice.DefaultPatchBufferSize"),
	DefaultPatchBufferSizeCVar,
	TEXT("Changes the amount of audio we buffer for VOIP patching, in samples.\n"),
	ECVF_Default);

static float DefaultPatchGainCVar = 1.0f;
FAutoConsoleVariableRef CVarDefaultPatchGain(
	TEXT("voice.DefaultPatchGain"),

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/VoipListenerSynthComponent.cpp:154

Scope (from outer to inner):

file
function     void UVoipListenerSynthComponent::ConnectToSplitter

Source code excerpt:

void UVoipListenerSynthComponent::ConnectToSplitter(Audio::FPatchMixerSplitter& InSplitter)
{
	ExternalSend = InSplitter.AddNewInput(DefaultPatchBufferSizeCVar, DefaultPatchGainCVar);
}

bool UVoipListenerSynthComponent::IsIdling()
{
	if (PacketBuffer.IsValid())
	{