MaxChunkSizeOverrideKB

MaxChunkSizeOverrideKB

#Overview

name: MaxChunkSizeOverrideKB

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 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of MaxChunkSizeOverrideKB is to override the default maximum chunk size used when chunking audio for stream caching in Unreal Engine. This setting is primarily used for audio optimization and performance tuning.

This setting variable is utilized by multiple Unreal Engine subsystems and platforms, including:

  1. Windows target platform
  2. Android runtime settings
  3. iOS runtime settings
  4. Audio platform configuration
  5. Engine’s audio compression settings

The value of this variable is set in the project settings for each platform (Windows, Android, iOS) and can be modified through the Unreal Editor’s Project Settings menu.

MaxChunkSizeOverrideKB interacts with other audio-related variables, such as:

  1. bForceLegacyStreamChunking
  2. ZerothChunkSizeForLegacyStreamChunkingKB
  3. CacheSizeKB

Developers should be aware of the following when using this variable:

  1. The value is in kilobytes (KB).
  2. It is ignored if set to a value less than 0.
  3. It affects the audio streaming performance and memory usage.

Best practices when using this variable include:

  1. Only override the default value if there’s a specific need for optimization on the target platform.
  2. Consider the target device’s capabilities and available memory when setting this value.
  3. Test thoroughly after modifying this setting to ensure it doesn’t negatively impact audio performance or quality.
  4. Use in conjunction with other audio streaming settings for optimal results.
  5. Document any changes made to this setting and the reasons for the changes to maintain code clarity for the development team.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
class        class UWindowsTargetSettings : public UObject

Source code excerpt:

	/** This overrides the default max chunk size used when chunking audio for stream caching (ignored if < 0) */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|Stream Caching", meta = (DisplayName = "Max Chunk Size Override (KB)"))
	int32 MaxChunkSizeOverrideKB;

	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides")
	bool bResampleForDevice;

	/** Mapping of which sample rates are used for each sample rate quality for a specific platform. */

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

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	/** This overrides the default max chunk size used when chunking audio for stream caching (ignored if < 0) */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|Stream Caching", meta = (DisplayName = "Max Chunk Size Override (KB)"))
	int32 MaxChunkSizeOverrideKB;

	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides")
	bool bResampleForDevice;

	/** Quality Level to COOK SoundCues at (if set, all other levels will be stripped by the cooker). */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides", meta = (DisplayName = "Sound Cue Cook Quality"))

#Loc: <Workspace>/Engine/Source/Runtime/AudioPlatformConfiguration/Private/AudioCompressionSettings.cpp:63

Scope (from outer to inner):

file
function     void FPlatformAudioCookOverrides::GetHashSuffix

Source code excerpt:

	FPCU::AppendHash(OutSuffix, TEXT("LCF"), InOverrides->StreamCachingSettings.bForceLegacyStreamChunking);
	FPCU::AppendHash(OutSuffix, TEXT("ZCS"), InOverrides->StreamCachingSettings.ZerothChunkSizeForLegacyStreamChunkingKB);
	FPCU::AppendHash(OutSuffix, TEXT("MCSO"), InOverrides->StreamCachingSettings.MaxChunkSizeOverrideKB);
	
	OutSuffix += TEXT("END");
}

#Loc: <Workspace>/Engine/Source/Runtime/AudioPlatformConfiguration/Public/AudioCompressionSettings.h:42

Scope: file

Source code excerpt:


	// will be ignored if < 0
	int32 MaxChunkSizeOverrideKB;

	FAudioStreamCachingSettings()
		: CacheSizeKB(DefaultCacheSize)
		, bForceLegacyStreamChunking(false)
		, ZerothChunkSizeForLegacyStreamChunkingKB(256)
		, MaxChunkSizeOverrideKB(INDEX_NONE)
	{
	}
};

/************************************************************************/
/* FPlatformAudioCookOverrides                                          */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:136

Scope (from outer to inner):

file
function     void CacheAudioCookOverrides

Source code excerpt:

	if (PlatformFile->GetInt(*CategoryName, TEXT("MaxChunkSizeOverrideKB"), RetrievedChunkSizeOverride))
	{
		OutOverrides.StreamCachingSettings.MaxChunkSizeOverrideKB = RetrievedChunkSizeOverride;
	}

	bool bForceLegacyStreamChunking = false;
	if (PlatformFile->GetBool(*CategoryName, TEXT("bForceLegacyStreamChunking"), bForceLegacyStreamChunking))
	{
		OutOverrides.StreamCachingSettings.bForceLegacyStreamChunking = bForceLegacyStreamChunking;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:341

Scope (from outer to inner):

file
function     FCachedAudioStreamingManagerParams FPlatformCompressionUtilities::BuildCachedStreamingManagerParams

Source code excerpt:

	int32 MaxChunkSize = GetMaxChunkSizeForCookOverrides(GetCookOverrides());

	const int32 MaxChunkSizeOverrideBytes = CacheSettings.MaxChunkSizeOverrideKB * 1024;
	if (MaxChunkSizeOverrideBytes > 0)
	{
		MaxChunkSize = FMath::Min(MaxChunkSizeOverrideBytes, MaxChunkSize);
	}

	// Our number of elements is tweakable based on the minimum cache usage we want to support.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:379

Scope (from outer to inner):

file
function     uint32 FPlatformCompressionUtilities::GetMaxChunkSizeForCookOverrides

Source code excerpt:


	const int32 DefaultMaxChunkSizeKB = 256;
	const int32 MaxChunkSizeOverrideKB = InCompressionOverrides->StreamCachingSettings.MaxChunkSizeOverrideKB;
	int32 ChunkSizeBasedOnUtilization = 0;

	if (CacheSizeKB / DefaultMaxChunkSizeKB < MinimumNumChunks)
	{
		ChunkSizeBasedOnUtilization = (CacheSizeKB / MinimumNumChunks);
	}

	return FMath::Max(FMath::Max(DefaultMaxChunkSizeKB, MaxChunkSizeOverrideKB), ChunkSizeBasedOnUtilization) * 1024;
}

float FPlatformCompressionUtilities::GetCompressionDurationForCurrentPlatform()
{
	float Threshold = -1.0f;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDerivedData.cpp:797

Scope (from outer to inner):

file
class        class FStreamedAudioCacheDerivedDataWorker : public FNonAbandonableTask
function     void BuildStreamedAudio

Source code excerpt:


					// observe the override chunk size now that we have set the 
					const int32 MaxChunkSizeOverrideBytes = CompressionOverrides->StreamCachingSettings.MaxChunkSizeOverrideKB * 1024;
					if (MaxChunkSizeOverrideBytes > 0)
					{
						MaxChunkSizeForCurrentWave = FMath::Min(MaxChunkSizeOverrideBytes, MaxChunkSizeForCurrentWave);
					}

				}

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

Scope (from outer to inner):

file
class        class UIOSRuntimeSettings : public UObject

Source code excerpt:

	/** This overrides the default max chunk size used when chunking audio for stream caching (ignored if < 0) */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|Stream Caching", meta = (DisplayName = "Max Chunk Size Override (KB)"))
	int32 MaxChunkSizeOverrideKB;

	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides")
	bool bResampleForDevice;

	/** Quality Level to COOK SoundCues at (if set, all other levels will be stripped by the cooker). */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides", meta = (DisplayName = "Sound Cue Cook Quality"))