au.SetAudioChannelScaleCount

au.SetAudioChannelScaleCount

#Overview

name: au.SetAudioChannelScaleCount

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 au.SetAudioChannelScaleCount is to change the audio channel count by percentage in Unreal Engine 5. This setting variable is part of the audio system and is used to scale the number of audio channels dynamically.

This setting variable is primarily used in the Engine module, specifically within the AudioDevice subsystem. It’s referenced in the AudioDevice.cpp file, which is a core component of Unreal Engine’s audio system.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0f and can be changed at runtime using console commands or through code.

The au.SetAudioChannelScaleCount variable interacts directly with the AudioChannelCountScaleCVar. They share the same value, with AudioChannelCountScaleCVar being the actual float variable that stores the scaling factor.

Developers must be aware that this variable affects the overall number of audio channels in the engine. Changing this value can impact audio performance and quality. It’s important to use this setting judiciously, as increasing the channel count can lead to higher CPU usage and potential audio artifacts if the hardware can’t support the increased number of channels.

Best practices when using this variable include:

  1. Only modify it when necessary, as the default value (1.0f) is suitable for most scenarios.
  2. Test thoroughly after changing the value to ensure audio quality and performance are not negatively impacted.
  3. Consider the target hardware capabilities when adjusting this value.
  4. Use in conjunction with other audio settings for optimal results.

Regarding the associated variable AudioChannelCountScaleCVar:

The purpose of AudioChannelCountScaleCVar is to store the actual scaling factor for the audio channel count. It’s the underlying variable that au.SetAudioChannelScaleCount modifies.

This variable is used within the FAudioDevice class, specifically in the GetMaxChannels function. It’s multiplied with the MaxChannelsScale to determine the final number of audio channels.

The value of AudioChannelCountScaleCVar is set through the au.SetAudioChannelScaleCount console variable.

AudioChannelCountScaleCVar interacts with MaxChannelsScale and MaxChannels variables to determine the final channel count.

Developers should be aware that this variable directly affects the audio channel count calculation. Any changes to this variable will have an immediate impact on the audio system’s behavior.

Best practices for AudioChannelCountScaleCVar include:

  1. Avoid modifying it directly in code; instead, use the au.SetAudioChannelScaleCount console variable.
  2. Monitor its value when debugging audio-related issues.
  3. Consider its impact on different platforms and hardware configurations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:49

Scope: file

Source code excerpt:

static float AudioChannelCountScaleCVar = 1.0f;
FAutoConsoleVariableRef CVarSetAudioChannelScaleCount(
	TEXT("au.SetAudioChannelScaleCount"),
	AudioChannelCountScaleCVar,
	TEXT("Changes the audio channel count by percentage.\n"),
	ECVF_Default);

static int32 DisableStoppingVoicesCvar = 0;
FAutoConsoleVariableRef CVarDisableStoppingVoices(

#Associated Variable and Callsites

This variable is associated with another variable named AudioChannelCountScaleCVar. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:47

Scope: file

Source code excerpt:

	ECVF_Default);

static float AudioChannelCountScaleCVar = 1.0f;
FAutoConsoleVariableRef CVarSetAudioChannelScaleCount(
	TEXT("au.SetAudioChannelScaleCount"),
	AudioChannelCountScaleCVar,
	TEXT("Changes the audio channel count by percentage.\n"),
	ECVF_Default);

static int32 DisableStoppingVoicesCvar = 0;
FAutoConsoleVariableRef CVarDisableStoppingVoices(
	TEXT("au.DisableStoppingVoices"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:890

Scope (from outer to inner):

file
function     int32 FAudioDevice::GetMaxChannels

Source code excerpt:

	// Get thread-context version of channel scalar & scale by cvar scalar
	float MaxChannelScalarToApply = IsInAudioThread() ? MaxChannelsScale : MaxChannelsScale_GameThread;
	MaxChannelScalarToApply *= AudioChannelCountScaleCVar;

	// Get thread-context version of channel max.  Override by cvar if cvar is valid.
	int32 OutMaxChannels = IsInAudioThread() ? MaxChannels : MaxChannels_GameThread;
	if (AudioChannelCountCVar > 0)
	{
		OutMaxChannels = AudioChannelCountCVar;