voice.DefaultPatchGain

voice.DefaultPatchGain

#Overview

name: voice.DefaultPatchGain

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.DefaultPatchGain is to control the default gain of audio patches in the Voice over IP (VoIP) system of Unreal Engine 5. It is used to adjust the volume of voice communications in multiplayer games or applications.

This setting variable is primarily used in the Online Subsystem Utils plugin, specifically within the VoIP listener synthesis component. Based on the callsites, it’s clear that this variable is part of the audio system, particularly the VoIP audio processing pipeline.

The value of this variable is set through the Unreal Engine’s Console Variable (CVar) system. It’s initialized with a default value of 1.0f, which represents linear gain (no amplification or attenuation).

The associated variable DefaultPatchGainCVar interacts directly with voice.DefaultPatchGain. They share the same value, with DefaultPatchGainCVar being the actual storage for the gain value, while voice.DefaultPatchGain is the console-accessible name for this setting.

Developers should be aware that:

  1. This variable uses linear gain, not decibels. A value of 1.0 means no change in volume, values above 1.0 will increase volume, and values below 1.0 will decrease volume.
  2. Changes to this variable will affect all VoIP audio patches, potentially impacting the overall balance of voice chat volume in the game.

Best practices when using this variable include:

  1. Use it to fine-tune the default volume of voice chat in your game, ensuring it’s at a comfortable level relative to other audio elements.
  2. Consider exposing this setting to players through an in-game audio options menu, allowing them to adjust voice chat volume to their preference.
  3. Be cautious when setting this value significantly above 1.0, as it could lead to audio distortion or unexpectedly loud voice chat.

Regarding the associated variable DefaultPatchGainCVar:

#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:22

Scope: file

Source code excerpt:

static float DefaultPatchGainCVar = 1.0f;
FAutoConsoleVariableRef CVarDefaultPatchGain(
	TEXT("voice.DefaultPatchGain"),
	DefaultPatchGainCVar,
	TEXT("Changes the default gain of audio patches, in linear gain.\n"),
	ECVF_Default);

static int32 ShouldResyncCVar = 1;
FAutoConsoleVariableRef CVarShouldResync(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

static float DefaultPatchGainCVar = 1.0f;
FAutoConsoleVariableRef CVarDefaultPatchGain(
	TEXT("voice.DefaultPatchGain"),
	DefaultPatchGainCVar,
	TEXT("Changes the default gain of audio patches, in linear gain.\n"),
	ECVF_Default);

static int32 ShouldResyncCVar = 1;
FAutoConsoleVariableRef CVarShouldResync(
	TEXT("voice.playback.ShouldResync"),

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