MinSampleRate

MinSampleRate

#Overview

name: MinSampleRate

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

#Summary

#Usage in the C++ source code

The purpose of MinSampleRate is to define the minimum acceptable sample rate for audio processing in Unreal Engine 5. This setting is primarily used for audio compression and resampling quality control across different target platforms.

This setting variable is relied upon by multiple platform-specific modules within Unreal Engine, including:

  1. Windows target platform (WindowsTargetPlatform)
  2. Android runtime settings (AndroidRuntimeSettings)
  3. iOS runtime settings (IOSRuntimeSettings)

The value of this variable is typically set in the platform-specific settings classes, such as UWindowsTargetSettings, UAndroidRuntimeSettings, and UIOSRuntimeSettings. It is often initialized with a default value of 8000 Hz, which is considered the lowest acceptable sample rate for audio in most cases.

MinSampleRate interacts with other sample rate variables like MaxSampleRate, HighSampleRate, MedSampleRate, and LowSampleRate. These variables collectively define the range of sample rates used for audio processing and compression in the engine.

Developers should be aware that:

  1. Lowering the MinSampleRate below 8000 Hz may result in poor audio quality and is generally not recommended.
  2. This setting affects the audio compression and resampling process during content cooking for specific platforms.
  3. Changing this value may impact performance and audio quality, especially on lower-end devices.

Best practices when using this variable include:

  1. Keeping the MinSampleRate at 8000 Hz or higher unless there’s a specific reason to lower it.
  2. Considering the target platform’s audio capabilities when adjusting this value.
  3. Testing the audio quality thoroughly after making changes to ensure acceptable results across different devices.
  4. Coordinating changes to MinSampleRate with other sample rate settings to maintain a consistent audio quality across the project.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:319, 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:132

Scope (from outer to inner):

file
class        class UWindowsTargetSettings : public UObject

Source code excerpt:


	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Min"))
	float MinSampleRate;

	/** Scales all compression qualities when cooking to this platform. For example, 0.5 will halve all compression qualities, and 1.0 will leave them unchanged. */
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides")
	float CompressionQualityModifier;

	/** When set to anything beyond 0, this will ensure any SoundWaves longer than this value, in seconds, to stream directly off of the disk. */

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

Scope (from outer to inner):

file
function     UWindowsTargetSettings::UWindowsTargetSettings

Source code excerpt:

	, MedSampleRate(24000)
	, LowSampleRate(12000)
	, MinSampleRate(8000)
	, CompressionQualityModifier(1)
{
	// Default windows settings
	AudioSampleRate = 48000;
	AudioCallbackBufferFrameSize = 1024;
	AudioNumBuffersToEnqueue = 1;

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

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:


	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Min"))
	float MinSampleRate;

	// Scales all compression qualities when cooking to this platform. For example, 0.5 will halve all compression qualities, and 1.0 will leave them unchanged.
	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides")
	float CompressionQualityModifier;

	// When set to anything beyond 0, this will ensure any SoundWaves longer than this value, in seconds, to stream directly off of the disk.

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:37

Scope (from outer to inner):

file
function     UAndroidRuntimeSettings::UAndroidRuntimeSettings

Source code excerpt:

    , MedSampleRate(24000)
    , LowSampleRate(12000)
	, MinSampleRate(8000)
	, CompressionQualityModifier(1)
	, bMultiTargetFormat_ETC2(true)
	, bMultiTargetFormat_DXT(true)
	, bMultiTargetFormat_ASTC(true)
	, TextureFormatPriority_ETC2(0.2f)
	, TextureFormatPriority_DXT(0.6f)

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

Scope (from outer to inner):

file
function     void CacheAudioCookOverrides

Source code excerpt:

	RetrievedSampleRate = -1.0f;

	PlatformFile.GetFloat(*CategoryName, TEXT("MinSampleRate"), RetrievedSampleRate);
	OutOverrides.PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Min, RetrievedSampleRate);
#endif
}


static bool PlatformSupportsCompressionOverrides(const FString& PlatformName)

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

Scope (from outer to inner):

file
class        class UIOSRuntimeSettings : public UObject

Source code excerpt:


	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Min"))
	float MinSampleRate;

	// Scales all compression qualities when cooking to this platform. For example, 0.5 will halve all compression qualities, and 1.0 will leave them unchanged.
	UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides")
	float CompressionQualityModifier;

	// When set to anything beyond 0, this will ensure any SoundWaves longer than this value, in seconds, to stream directly off of the disk.

#Loc: <Workspace>/Engine/Source/Runtime/IOS/IOSRuntimeSettings/Private/IOSRuntimeSettings.cpp:22

Scope (from outer to inner):

file
function     UIOSRuntimeSettings::UIOSRuntimeSettings

Source code excerpt:

	, MedSampleRate(24000)
	, LowSampleRate(12000)
	, MinSampleRate(8000)
	, CompressionQualityModifier(1)
{
	bEnableGameCenterSupport = true;
	bEnableCloudKitSupport = false;
	bUserSwitching = false;
	bSupportsPortraitOrientation = true;