au.LinearGainScalarForFinalOutut
au.LinearGainScalarForFinalOutut
#Overview
name: au.LinearGainScalarForFinalOutut
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Linear gain scalar applied to the final float buffer to allow for hotfixable mitigation of clipping \nDefault is 1.0f \n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.LinearGainScalarForFinalOutut is to apply a linear gain scalar to the final float buffer in the audio mixer system. This variable is used to allow for hotfixable mitigation of clipping in the audio output.
This setting variable is primarily used in the Audio Mixer subsystem of Unreal Engine 5. Specifically, it’s utilized in the AudioMixerCore module, which is responsible for core audio mixing functionality.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console. Its default value is 1.0f, as specified in the source code.
The au.LinearGainScalarForFinalOutut variable interacts directly with LinearGainScalarForFinalOututCVar. They share the same value, with LinearGainScalarForFinalOututCVar being the actual storage for the value, while au.LinearGainScalarForFinalOutut is the console variable reference.
Developers must be aware that adjusting this variable will affect the overall volume of the audio output. It’s particularly useful for addressing clipping issues without having to modify and recompile the engine code.
Best practices when using this variable include:
- Use it sparingly and only when necessary to address clipping issues.
- Monitor audio quality when adjusting this value to ensure it doesn’t introduce distortion.
- Document any changes made to this variable in project settings or documentation.
Regarding the associated variable LinearGainScalarForFinalOututCVar:
The purpose of LinearGainScalarForFinalOututCVar is to store the actual value of the linear gain scalar used in the audio mixing process.
This variable is used directly in the AudioMixerCore module, specifically in the FOutputBuffer::MixNextBuffer() function.
The value of LinearGainScalarForFinalOututCVar is set initially to 1.0f and can be modified through the au.LinearGainScalarForFinalOutut console variable.
LinearGainScalarForFinalOututCVar interacts with the audio rendering buffer. When its value is not nearly equal to 1.0f, it’s used to multiply the entire render buffer. It’s also used in the conversion process when the output format is not float.
Developers should be aware that this variable directly affects the audio output level and can impact performance if changed frequently.
Best practices for LinearGainScalarForFinalOututCVar include:
- Avoid changing it frequently during runtime to prevent performance issues.
- Consider the impact on all audio in the game when modifying this value.
- Use it in conjunction with proper audio mixing and mastering techniques rather than as a primary volume control.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:127
Scope: file
Source code excerpt:
static float LinearGainScalarForFinalOututCVar = 1.0f;
FAutoConsoleVariableRef LinearGainScalarForFinalOutut(
TEXT("au.LinearGainScalarForFinalOutut"),
LinearGainScalarForFinalOututCVar,
TEXT("Linear gain scalar applied to the final float buffer to allow for hotfixable mitigation of clipping \n")
TEXT("Default is 1.0f \n"),
ECVF_Default);
static int32 ExtraAudioMixerDeviceLoggingCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named LinearGainScalarForFinalOututCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:125
Scope: file
Source code excerpt:
ECVF_Default);
static float LinearGainScalarForFinalOututCVar = 1.0f;
FAutoConsoleVariableRef LinearGainScalarForFinalOutut(
TEXT("au.LinearGainScalarForFinalOutut"),
LinearGainScalarForFinalOututCVar,
TEXT("Linear gain scalar applied to the final float buffer to allow for hotfixable mitigation of clipping \n")
TEXT("Default is 1.0f \n"),
ECVF_Default);
static int32 ExtraAudioMixerDeviceLoggingCVar = 0;
FAutoConsoleVariableRef ExtraAudioMixerDeviceLogging(
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:248
Scope (from outer to inner):
file
namespace Audio
function bool FOutputBuffer::MixNextBuffer
Source code excerpt:
case EAudioMixerStreamDataFormat::Float:
{
if (!FMath::IsNearlyEqual(LinearGainScalarForFinalOututCVar, 1.0f))
{
ArrayMultiplyByConstantInPlace(RenderBuffer, LinearGainScalarForFinalOututCVar);
}
ArrayRangeClamp(RenderBuffer, -1.0f, 1.0f);
// No conversion is needed, so we push the RenderBuffer directly to the circular queue.
CircularBuffer.Push(reinterpret_cast<const uint8*>(RenderBuffer.GetData()), RenderBuffer.Num() * sizeof(float));
}
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:265
Scope (from outer to inner):
file
namespace Audio
function bool FOutputBuffer::MixNextBuffer
Source code excerpt:
check(FormattedBuffer.Num() / GetSizeForDataFormat(DataFormat) == RenderBuffer.Num());
const float ConversionScalar = LinearGainScalarForFinalOututCVar * 32767.0f;
ArrayMultiplyByConstantInPlace(RenderBuffer, ConversionScalar);
ArrayRangeClamp(RenderBuffer, -32767.0f, 32767.0f);
for (int32 i = 0; i < NumSamples; ++i)
{
BufferInt16[i] = (int16)RenderBuffer[i];