AudioNumSourceWorkers

AudioNumSourceWorkers

#Overview

name: AudioNumSourceWorkers

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of AudioNumSourceWorkers is to control the number of worker threads used for computing source audio in Unreal Engine’s audio system. This setting is used to optimize audio processing performance by distributing the workload across multiple threads.

AudioNumSourceWorkers is primarily used in the audio subsystem of Unreal Engine. It is referenced in platform-specific settings classes for various target platforms, including Windows, Mac, Android, and iOS. This indicates that the variable is used to configure audio processing across different platforms.

The value of this variable is typically set in the platform-specific settings classes. For example, in the WindowsTargetSettings class, it is initialized to 4 by default. However, the actual value can be configured through the engine’s configuration files or the project settings in the Unreal Editor.

This variable interacts with the overall audio system, particularly with the source audio computation. It’s closely related to other audio settings like AudioCallbackBufferFrameSize and AudioNumBuffersToEnqueue, which are often configured alongside AudioNumSourceWorkers.

Developers should be aware that:

  1. The number of source workers is clamped to a minimum of 0.
  2. The actual number of workers used will not exceed the maximum number of audio sources.
  3. Audio sources will be evenly divided among the workers.

Best practices when using this variable include:

  1. Adjusting the value based on the target hardware capabilities. More powerful systems may benefit from a higher number of workers.
  2. Testing different values to find the optimal balance between performance and CPU usage for your specific game audio requirements.
  3. Considering the complexity of your audio sources when setting this value. Games with many complex audio sources might benefit from more workers.
  4. Remembering that setting this too high could potentially lead to diminishing returns or even performance degradation if it causes excessive thread overhead.
  5. Coordinating this setting with other audio-related settings for optimal performance across different target platforms.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:306, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/Mac/MacTargetPlatform/Classes/MacTargetSettings.h:145

Scope (from outer to inner):

file
class        class UMacTargetSettings : public UObject

Source code excerpt:

	/** The number of workers to use to compute source audio. Will only use up to the max number of sources. Will evenly divide sources to each source worker. */
	UPROPERTY(config, EditAnywhere, Category = "Audio", meta = (ClampMin = "0", UIMin = "0", DisplayName = "Number of Source Workers"))
	int32 AudioNumSourceWorkers;

	/** Which of the currently enabled spatialization plugins to use. */
	UPROPERTY(config, EditAnywhere, Category = "Audio")
	FString SpatializationPlugin;

	/** Which of the currently enabled source data override plugins to use. */

#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Classes/WindowsTargetSettings.h:82

Scope (from outer to inner):

file
class        class UWindowsTargetSettings : public UObject

Source code excerpt:

	/** The number of workers to use to compute source audio. Will only use up to the max number of sources. Will evenly divide sources to each source worker. */
	UPROPERTY(config, EditAnywhere, Category = "Audio", meta = (ClampMin = "0", UIMin = "0", DisplayName = "Number of Source Workers"))
	int32 AudioNumSourceWorkers;

	/** Which of the currently enabled spatialization plugins to use. */
	UPROPERTY(config, EditAnywhere, Category = "Audio")
	FString SpatializationPlugin;

	/** Which of the currently enabled source data override plugins to use. */

#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Private/WindowsTargetPlatformClasses.cpp:19

Scope (from outer to inner):

file
function     UWindowsTargetSettings::UWindowsTargetSettings

Source code excerpt:

	AudioCallbackBufferFrameSize = 1024;
	AudioNumBuffersToEnqueue = 1;
	AudioNumSourceWorkers = 4;
}

static bool FilterShaderPlatform_D3D12(const FString& InShaderPlatform)
{
	return InShaderPlatform == TEXT("PCD3D_SM6") || InShaderPlatform == TEXT("PCD3D_SM5") || InShaderPlatform == TEXT("PCD3D_ES31");
}

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:580

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	/** The number of workers to use to compute source audio. Will only use up to the max number of sources. Will evenly divide sources to each source worker. */
	UPROPERTY(config, EditAnywhere, Category = "Audio", meta = (ClampMin = "0", UIMin = "0", DisplayName = "Number of Source Workers"))
	int32 AudioNumSourceWorkers;

	/** Which of the currently enabled spatialization plugins to use. */
	UPROPERTY(config, EditAnywhere, Category = "Audio")
	FString SpatializationPlugin;

	/** Which of the currently enabled source data override plugins to use. */

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:947

Scope (from outer to inner):

file
function     FAudioPlatformSettings FAudioPlatformSettings::GetPlatformSettings

Source code excerpt:

	}

	if (GConfig->GetString(PlatformSettingsConfigFile, TEXT("AudioNumSourceWorkers"), TempString, GEngineIni))
	{
		Settings.NumSourceWorkers = FMath::Max(FCString::Atoi(*TempString), 0);
	}

	return Settings;
}

#Loc: <Workspace>/Engine/Source/Runtime/IOS/IOSRuntimeSettings/Classes/IOSRuntimeSettings.h:523

Scope (from outer to inner):

file
class        class UIOSRuntimeSettings : public UObject

Source code excerpt:

	/** The number of workers to use to compute source audio. Will only use up to the max number of sources. Will evenly divide sources to each source worker. */
	UPROPERTY(config, EditAnywhere, Category = "Audio", meta = (ClampMin = "0", UIMin = "0", DisplayName = "Number of Source Workers"))
	int32 AudioNumSourceWorkers;

	/** Which of the currently enabled spatialization plugins to use. */
	UPROPERTY(config, EditAnywhere, Category = "Audio")
	FString SpatializationPlugin;

	/** Which of the currently enabled source data override plugins to use. */