voice.DefaultPatchGain
voice.DefaultPatchGain
#Overview
name: voice.DefaultPatchGain
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Changes the default gain of audio patches, in linear gain.\n
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:
- 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.
- 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:
- 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.
- Consider exposing this setting to players through an in-game audio options menu, allowing them to adjust voice chat volume to their preference.
- 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:
- Its purpose is to store the actual gain value used by the VoIP system.
- It’s used directly in the UVoipListenerSynthComponent::ConnectToSplitter function to set the gain when creating a new audio input.
- The value is set through the CVar system and can be modified at runtime.
- Developers should treat this variable as read-only in most cases, using the voice.DefaultPatchGain CVar to modify its value instead.
#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())
{