bResampleForDevice
bResampleForDevice
#Overview
name: bResampleForDevice
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 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bResampleForDevice is to control whether audio should be resampled for the target device during the cooking process in Unreal Engine 5. This setting is primarily used for audio optimization and platform-specific audio adjustments.
This variable is used by multiple Unreal Engine subsystems and modules, including:
- Windows Target Platform
- Android Runtime Settings
- iOS Runtime Settings
- Audio Platform Configuration
- Engine (Audio Compression and Sound Wave processing)
The value of this variable is set in platform-specific settings classes such as UWindowsTargetSettings, UAndroidRuntimeSettings, and UIOSRuntimeSettings. It can be configured through the project settings in the Unreal Engine editor.
bResampleForDevice interacts with other variables, particularly:
- PlatformSampleRates: A map of sample rates for different quality settings
- CompressionQualityModifier: Affects the overall compression quality
- SampleRateOverride: Used when resampling is enabled
Developers should be aware of the following when using this variable:
- Enabling this variable will cause audio to be resampled during the cooking process, which can affect audio quality and file size.
- It’s platform-specific, so it needs to be set for each target platform separately.
- Resampling can impact performance and storage requirements, especially for mobile platforms.
Best practices when using this variable include:
- Only enable it when necessary for specific platform requirements or optimizations.
- Carefully consider the target sample rates for each platform to balance quality and performance.
- Test the audio quality after enabling resampling to ensure it meets your game’s standards.
- Use in conjunction with other audio settings like CompressionQualityModifier for fine-tuning audio output.
- Be consistent across all audio assets in your project to maintain uniform quality.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:314, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]
- INI Section:
/Script/WindowsTargetPlatform.WindowsTargetSettings
- Raw value:
False
- Is Array:
False
#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:115
Scope (from outer to inner):
file
class class UWindowsTargetSettings : public UObject
Source code excerpt:
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides")
bool bResampleForDevice;
/** Mapping of which sample rates are used for each sample rate quality for a specific platform. */
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Max"))
float MaxSampleRate;
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:611
Scope (from outer to inner):
file
class class UAndroidRuntimeSettings : public UObject
Source code excerpt:
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"))
int32 SoundCueCookQualityIndex = INDEX_NONE;
// Mapping of which sample rates are used for each sample rate quality for a specific platform.
#Loc: <Workspace>/Engine/Source/Runtime/AudioPlatformConfiguration/Private/AudioCompressionSettings.cpp:44
Scope (from outer to inner):
file
function void FPlatformAudioCookOverrides::GetHashSuffix
Source code excerpt:
// FPlatformAudioCookOverrides
FPCU::AppendHash(OutSuffix, TEXT("R4DV"), InOverrides->bResampleForDevice);
TArray<float> Rates;
InOverrides->PlatformSampleRates.GenerateValueArray(Rates);
for (int32 i = 0; i < Rates.Num(); ++i)
{
FPCU::AppendHash(OutSuffix, *FString::Printf(TEXT("SR%d"), i), Rates[i]);
#Loc: <Workspace>/Engine/Source/Runtime/AudioPlatformConfiguration/Public/AudioCompressionSettings.h:65
Scope: file
Source code excerpt:
static AUDIOPLATFORMCONFIGURATION_API int32 GetStreamCachingVersion();
bool bResampleForDevice;
// Mapping of which sample rates are used for each sample rate quality for a specific platform.
TMap<ESoundwaveSampleRateSettings, float> PlatformSampleRates;
// 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.
float CompressionQualityModifier;
#Loc: <Workspace>/Engine/Source/Runtime/AudioPlatformConfiguration/Public/AudioCompressionSettings.h:92
Scope (from outer to inner):
file
function FPlatformAudioCookOverrides
Source code excerpt:
FPlatformAudioCookOverrides()
: bResampleForDevice(false)
, CompressionQualityModifier(1.0f)
, AutoStreamingThreshold(0.0f)
, bInlineFirstAudioChunk(false)
, LengthOfFirstAudioChunkInSecs(0.f)
{
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Max, 48000);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:151
Scope (from outer to inner):
file
function void CacheAudioCookOverrides
Source code excerpt:
}
bool bResampleForDevice = false;
if (PlatformFile->GetBool(*CategoryName, TEXT("bResampleForDevice"), bResampleForDevice))
{
OutOverrides.bResampleForDevice = bResampleForDevice;
}
float CompressionQualityModifier = 0.0f;
if (PlatformFile->GetFloat(*CategoryName, TEXT("CompressionQualityModifier"), CompressionQualityModifier))
{
OutOverrides.CompressionQualityModifier = CompressionQualityModifier;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:407
Scope (from outer to inner):
file
function float FPlatformCompressionUtilities::GetTargetSampleRateForPlatform
Source code excerpt:
float SampleRate = -1.0f;
const FPlatformAudioCookOverrides* Settings = GetCookOverrides();
if (Settings && Settings->bResampleForDevice)
{
const float* FoundSampleRate = Settings->PlatformSampleRates.Find(InSampleRateLevel);
if (FoundSampleRate)
{
SampleRate = *FoundSampleRate;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDerivedData.cpp:1639
Scope (from outer to inner):
file
function FAudioCookInputs
Source code excerpt:
#if FORCE_RESAMPLE
FPlatformAudioCookOverrides NewCompressionOverrides = FPlatformAudioCookOverrides();
NewCompressionOverrides.bResampleForDevice = true;
if (InCookOverrides == nullptr)
{
InCookOverrides = &NewCompressionOverrides;
}
#endif //FORCE_RESAMPLE
if (InCookOverrides && InCookOverrides->bResampleForDevice)
{
SampleRateOverride = InSoundWave->GetSampleRateForCompressionOverrides(InCookOverrides);
}
// without overrides, we don't know the target platform's name to be able to look up, and passing nullptr will use editor platform's settings, which could be wrong
// @todo: Pass in TargetPlatform/PlatformName maybe?
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWave.cpp:4493
Scope (from outer to inner):
file
function void USoundWave::SerializeCuePoints
Source code excerpt:
if (const FPlatformAudioCookOverrides* Overrides = FPlatformCompressionUtilities::GetCookOverrides(*CookingTarget->IniPlatformName()))
{
if (Overrides->bResampleForDevice)
{
// at this point, the ImportedSampleRate should be ready to use!
ensureMsgf(ImportedSampleRate > 0, TEXT("SerializeCuePoints: %s ImportedSampleRate not set: ImportedSampleRate = %d"), *GetName(), ImportedSampleRate);
const float TargetSampleRate = GetSampleRateForTargetPlatform(CookingTarget);
ScaleCuePointsForSampleRate(TargetSampleRate, PlatformCuePoints);
}
#Loc: <Workspace>/Engine/Source/Runtime/IOS/IOSRuntimeSettings/Classes/IOSRuntimeSettings.h:558
Scope (from outer to inner):
file
class class UIOSRuntimeSettings : public UObject
Source code excerpt:
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"))
int32 SoundCueCookQualityIndex = INDEX_NONE;
// Mapping of which sample rates are used for each sample rate quality for a specific platform.