voice.playback.ResyncThreshold
voice.playback.ResyncThreshold
#Overview
name: voice.playback.ResyncThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If the amount of audio we have buffered is greater than this value, we drop the oldest audio we have and sync to have voice.JitterDelay worth of buffered audio.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of voice.playback.ResyncThreshold is to control the threshold for audio buffer resynchronization in the Voice over IP (VoIP) system of Unreal Engine 5.
This setting variable is primarily used in the Online Subsystem Utils plugin, specifically within the VoipListenerSynthComponent. It’s part of the audio playback system for voice communication in multiplayer games.
The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through the console. The default value is 0.3 seconds.
The associated variable ResyncThresholdCVar directly interacts with voice.playback.ResyncThreshold. They share the same value, with ResyncThresholdCVar being the actual float variable used in the code.
Developers must be aware that this variable affects the quality and responsiveness of voice playback. If set too low, it may cause frequent resyncs, potentially leading to choppy audio. If set too high, it may result in increased latency.
Best practices when using this variable include:
- Testing different values to find the optimal balance between audio quality and latency for your specific use case.
- Considering network conditions and adjusting the value accordingly.
- Providing a way for users to adjust this value if voice quality issues are common in your game.
Regarding the associated variable ResyncThresholdCVar:
The purpose of ResyncThresholdCVar is to store the actual float value used in the code for the resync threshold.
It’s used within the VoipListenerSynthComponent, specifically in the ForceResync function. This function calculates the number of samples to skip based on the current latency and the desired latency (JitterDelay).
The value of ResyncThresholdCVar is set by the console variable voice.playback.ResyncThreshold.
ResyncThresholdCVar interacts directly with the audio buffer system, determining when to drop old audio data to maintain synchronization.
Developers should be aware that modifying ResyncThresholdCVar directly in the code won’t have any effect, as its value is controlled by the console variable.
Best practices for ResyncThresholdCVar include:
- Avoid modifying it directly in the code. Instead, use the console variable to change its value.
- When debugging voice issues, monitor this variable to understand when and why resyncs are occurring.
- Consider logging or exposing the actual resync events in your game’s debugging tools to help identify voice quality issues.
#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:43
Scope: file
Source code excerpt:
static float ResyncThresholdCVar = 0.3f;
FAutoConsoleVariableRef CVarResyncThreshold(
TEXT("voice.playback.ResyncThreshold"),
ResyncThresholdCVar,
TEXT("If the amount of audio we have buffered is greater than this value, we drop the oldest audio we have and sync to have voice.JitterDelay worth of buffered audio.\n"),
ECVF_Default);
#Associated Variable and Callsites
This variable is associated with another variable named ResyncThresholdCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/VoipListenerSynthComponent.cpp:41
Scope: file
Source code excerpt:
ECVF_Default);
static float ResyncThresholdCVar = 0.3f;
FAutoConsoleVariableRef CVarResyncThreshold(
TEXT("voice.playback.ResyncThreshold"),
ResyncThresholdCVar,
TEXT("If the amount of audio we have buffered is greater than this value, we drop the oldest audio we have and sync to have voice.JitterDelay worth of buffered audio.\n"),
ECVF_Default);
bool UVoipListenerSynthComponent::Init(int32& SampleRate)
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/VoipListenerSynthComponent.cpp:195
Scope (from outer to inner):
file
function void UVoipListenerSynthComponent::ForceResync
Source code excerpt:
const int32 TargetLatencyInSamples = FMath::FloorToInt(JitterDelayInSeconds * NumChannels * MySampleRate);
const int32 CurrentLatencyInSamples = PacketBuffer->GetNumBufferedSamples();
const int32 ResyncThresholdInSamples = FMath::FloorToInt(ResyncThresholdCVar * NumChannels * MySampleRate);
int32 AmountToSkip = CurrentLatencyInSamples - TargetLatencyInSamples;
if (AmountToSkip > ResyncThresholdInSamples)
{
PacketBuffer->DropOldestAudio(AmountToSkip);