voice.MicNoiseGateThreshold
voice.MicNoiseGateThreshold
#Overview
name: voice.MicNoiseGateThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Our threshold, in linear amplitude, for our noise gate on input. Similar to voice.SilenceDetectionThreshold, except that audio quieter than our noise gate threshold will still output silence.\nValue: Number of seconds of audio we buffer.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of voice.MicNoiseGateThreshold is to set a threshold for the noise gate on voice input in Unreal Engine’s voice communication system. It determines the minimum amplitude level at which audio input is considered valid and not filtered out as background noise.
This setting variable is primarily used in the voice communication system of Unreal Engine. Based on the callsites, it’s utilized in the Voice module, specifically in the Windows voice capture implementation.
The value of this variable is set in the Engine’s VoiceConfig.cpp file with a default value of 0.08f. It’s exposed as a console variable, allowing for runtime modification.
The variable interacts with other voice-related settings, such as SilenceDetectionThreshold and MicNoiseGateAttackTime. While SilenceDetectionThreshold determines when voice input is considered silence, MicNoiseGateThreshold filters out low-amplitude noise even when voice is detected.
Developers must be aware that this variable affects the sensitivity of voice input. Setting it too low might allow unwanted background noise, while setting it too high could cut off softer speech.
Best practices when using this variable include:
- Adjusting it in conjunction with SilenceDetectionThreshold for optimal voice detection.
- Testing with various microphones and environmental conditions to find a suitable value.
- Providing user-facing options to adjust this value for different audio setups.
Regarding the associated variable MicNoiseGateThresholdCvar:
The purpose of MicNoiseGateThresholdCvar is to serve as the actual storage for the voice.MicNoiseGateThreshold value. It’s a static float variable that holds the current noise gate threshold value.
This variable is used in the Engine module, specifically in the VoiceConfig system. It’s directly accessed by the UVOIPStatics::GetVoiceNoiseGateLevel() function, which likely provides an interface for other parts of the engine to retrieve the current noise gate level.
The value of MicNoiseGateThresholdCvar is set initially to 0.08f and can be modified through the console variable system.
It interacts directly with the voice.MicNoiseGateThreshold console variable, serving as its backing store.
Developers should be aware that modifying MicNoiseGateThresholdCvar directly won’t update the console variable. Always use the console variable system to ensure consistency.
Best practices include:
- Avoid direct modification of MicNoiseGateThresholdCvar; use the console variable instead.
- When retrieving the value, consider using UVOIPStatics::GetVoiceNoiseGateLevel() for consistency across the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VoiceConfig.cpp:50
Scope: file
Source code excerpt:
static float MicNoiseGateThresholdCvar = 0.08f;
FAutoConsoleVariableRef CVarMicNoiseGateThreshold(
TEXT("voice.MicNoiseGateThreshold"),
MicNoiseGateThresholdCvar,
TEXT("Our threshold, in linear amplitude, for our noise gate on input. Similar to voice.SilenceDetectionThreshold, except that audio quieter than our noise gate threshold will still output silence.\n")
TEXT("Value: Number of seconds of audio we buffer."),
ECVF_Default);
static float MicNoiseGateAttackTimeCvar = 0.05f;
#Loc: <Workspace>/Engine/Source/Runtime/Online/Voice/Private/Windows/VoiceCaptureWindows.cpp:438
Scope (from outer to inner):
file
function void FVoiceCaptureWindows::ProcessData
Source code excerpt:
const float MicSilenceThreshold = SilenceDetectionThresholdCVar->GetFloat();
static IConsoleVariable* NoiseGateThresholdCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("voice.MicNoiseGateThreshold"));
check(NoiseGateThresholdCVar);
const float MicNoiseGateThreshold = NoiseGateThresholdCVar->GetFloat();
static IConsoleVariable* NoiseGateAttackTimeCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("voice.MicNoiseAttackTime"));
check(NoiseGateAttackTimeCVar);
const float MicNoiseGateAttackTime = NoiseGateAttackTimeCVar->GetFloat();
#Associated Variable and Callsites
This variable is associated with another variable named MicNoiseGateThresholdCvar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VoiceConfig.cpp:48
Scope: file
Source code excerpt:
ECVF_Default);
static float MicNoiseGateThresholdCvar = 0.08f;
FAutoConsoleVariableRef CVarMicNoiseGateThreshold(
TEXT("voice.MicNoiseGateThreshold"),
MicNoiseGateThresholdCvar,
TEXT("Our threshold, in linear amplitude, for our noise gate on input. Similar to voice.SilenceDetectionThreshold, except that audio quieter than our noise gate threshold will still output silence.\n")
TEXT("Value: Number of seconds of audio we buffer."),
ECVF_Default);
static float MicNoiseGateAttackTimeCvar = 0.05f;
FAutoConsoleVariableRef CVarMicNoiseGateAttackTime(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VoiceConfig.cpp:198
Scope (from outer to inner):
file
function float UVOIPStatics::GetVoiceNoiseGateLevel
Source code excerpt:
float UVOIPStatics::GetVoiceNoiseGateLevel()
{
return MicNoiseGateThresholdCvar;
}
int32 UVOIPStatics::GetNumBufferedPackets()
{
// Evaluate number of packets as the total number of samples we'll need to buffer divided by
// the number of samples per buffer, plus an arbitrary amount of packets to compensate for jitter.