voice.SilenceDetectionThreshold

voice.SilenceDetectionThreshold

#Overview

name: voice.SilenceDetectionThreshold

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.SilenceDetectionThreshold is to set the threshold for the VOIP microphone’s silence detection algorithm in Unreal Engine’s voice communication system.

This setting variable is primarily used by the voice communication subsystem within Unreal Engine. Based on the callsites, it’s specifically utilized in the Engine module and the Voice module on Windows platforms.

The value of this variable is set through the console variable system. It can be modified in several ways:

  1. Through engine configuration files
  2. Via C++ code using the console variable interface
  3. By calling the UVOIPStatics::SetMicThreshold function

The variable interacts with other voice-related settings, particularly the MicNoiseGateThreshold, as seen in the VoiceCaptureWindows.cpp file.

Developers should be aware that this threshold directly affects the sensitivity of the silence detection in voice communication. A lower value will make the system more sensitive to detecting silence, while a higher value will require louder sounds to be considered as non-silence.

Best practices when using this variable include:

  1. Carefully tuning the value to balance between detecting actual silence and avoiding cutting off quiet speech.
  2. Testing the setting across various microphone types and environmental conditions to ensure consistent behavior.
  3. Considering the target platform and typical user setups when setting default values.
  4. Potentially allowing end-users to adjust this setting if voice detection quality varies significantly between different user environments.
  5. Monitoring and logging voice detection performance in different scenarios to fine-tune the threshold over time.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VoiceConfig.cpp:19

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<float> CVarVoiceSilenceDetectionThreshold(TEXT("voice.SilenceDetectionThreshold"),
	0.08f,
	TEXT("Threshold to be set for the VOIP microphone's silence detection algorithm.\n"),	
	ECVF_Default);

static float MicInputGainCvar = 1.0f;
FAutoConsoleVariableRef CVarMicInputGain(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VoiceConfig.cpp:222

Scope (from outer to inner):

file
function     void UVOIPStatics::SetMicThreshold

Source code excerpt:

void UVOIPStatics::SetMicThreshold(float InThreshold)
{
	static IConsoleVariable* SilenceDetectionCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("voice.SilenceDetectionThreshold"));
	check(SilenceDetectionCVar);
	SilenceDetectionCVar->Set(InThreshold, ECVF_SetByGameSetting);
}

void UVOIPStatics::SetVOIPTalkerForPlayer(const FUniqueNetIdWrapper& InPlayerId, UVOIPTalker* InTalker)
{

#Loc: <Workspace>/Engine/Source/Runtime/Online/Voice/Private/Windows/VoiceCaptureWindows.cpp:434

Scope (from outer to inner):

file
function     void FVoiceCaptureWindows::ProcessData

Source code excerpt:

			AudioBuffer += SamplesPushedToUncompressedAudioBuffer;

			static IConsoleVariable* SilenceDetectionThresholdCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("voice.SilenceDetectionThreshold"));
			check(SilenceDetectionThresholdCVar);			
			const float MicSilenceThreshold = SilenceDetectionThresholdCVar->GetFloat();

			static IConsoleVariable* NoiseGateThresholdCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("voice.MicNoiseGateThreshold"));
			check(NoiseGateThresholdCVar);
			const float MicNoiseGateThreshold = NoiseGateThresholdCVar->GetFloat();