MaxSampleRate
MaxSampleRate
#Overview
name: MaxSampleRate
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 13
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MaxSampleRate is to define the maximum allowed sample rate for audio processing in various Unreal Engine subsystems and plugins. It is primarily used in audio-related modules and settings to establish an upper limit for audio quality and processing.
MaxSampleRate is utilized in several Unreal Engine subsystems, plugins, and modules:
- ElectraPlayer: A media plugin for adaptive streaming.
- Metasound: A node-based audio system.
- Windows Target Platform: Platform-specific settings for Windows.
- Android Runtime Settings: Platform-specific settings for Android.
- iOS Runtime Settings: Platform-specific settings for iOS.
- Audio Compression Settings: Used in audio cooking and compression.
The value of this variable is set in different places depending on the context:
- In ElectraPlayer, it’s hardcoded to 48000 Hz.
- In Metasound, it’s retrieved from the operator settings.
- For platform-specific settings (Windows, Android, iOS), it’s set in the constructor of the respective settings classes and can be modified through project settings.
MaxSampleRate often interacts with other sample rate variables like HighSampleRate, MedSampleRate, LowSampleRate, and MinSampleRate. It’s used as an upper bound for clamping sample rate values in audio processing operations.
Developers must be aware that:
- MaxSampleRate affects audio quality and performance.
- Different platforms may have different default values.
- Changing this value can impact audio processing, compression, and playback.
Best practices when using this variable include:
- Consider the target platform’s capabilities when setting the value.
- Balance audio quality with performance requirements.
- Ensure that other sample rate settings (High, Med, Low) are properly scaled relative to MaxSampleRate.
- Test thoroughly after modifying this value to ensure audio quality and performance meet expectations across all target platforms.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:315, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]
- INI Section:
/Script/WindowsTargetPlatform.WindowsTargetSettings
- Raw value:
48000.000000
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Media/ElectraPlayer/Source/ElectraPlayerRuntime/Private/Runtime/Player/AdaptiveStreamingPlayerRenderers.cpp:78
Scope (from outer to inner):
file
namespace Electra
class class FAdaptiveStreamingWrappedRenderer : public IAdaptiveStreamingWrappedRenderer
Source code excerpt:
private:
const int32 MaxSampleRate = 48000;
const int32 NumInterpolationSamplesAt48kHz = 60;
const double MinPlaybackSpeed = 0.8;
const double MaxPlaybackSpeed = 1.5;
const double MinResampleSpeed = 0.98;
const double MaxResampleSpeed = 1.02;
#Loc: <Workspace>/Engine/Plugins/Media/ElectraPlayer/Source/ElectraPlayerRuntime/Private/Runtime/Player/AdaptiveStreamingPlayerRenderers.cpp:327
Scope (from outer to inner):
file
namespace Electra
function UEMediaError FAdaptiveStreamingWrappedRenderer::CreateBufferPool
Source code excerpt:
// Get maximum number of samples we may produce when slowing down the most.
int32 NumTempoSamples = AudioVars.TempoChanger->GetNominalOutputSampleNum(MaxSampleRate, MinPlaybackSpeed);
int32 NumResampleSamples = (int32)(SamplesPerBlock / MinPlaybackSpeed + 0.5);
AudioVars.MaxOutputSampleBlockSize = Utils::Max(Utils::Max(NumTempoSamples, NumResampleSamples), SamplesPerBlock);
AudioVars.AudioBufferSize = AudioVars.MaxOutputSampleBlockSize * MaxChannels * sizeof(float);
Parameters.Set(RenderOptionKeys::MaxBufferSize, FVariantValue(AudioVars.AudioBufferSize));
AudioVars.TempoChanger->SetMaxOutputSamples(AudioVars.MaxOutputSampleBlockSize);
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundStandardNodes/Private/MetasoundBitcrusherNode.cpp:41
Scope (from outer to inner):
file
namespace Metasound
class class FBitcrusherOperator : public TExecutableOperator<FBitcrusherOperator>
function FBitcrusherOperator
Source code excerpt:
, CrushedSampleRate(InCrushedSampleRate)
, CrushedBitDepth(InCrushedBitDepth)
, MaxSampleRate(InParams.OperatorSettings.GetSampleRate())
{
Reset(InParams);
}
static const FNodeClassMetadata& GetNodeInfo()
{
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundStandardNodes/Private/MetasoundBitcrusherNode.cpp:144
Scope (from outer to inner):
file
namespace Metasound
class class FBitcrusherOperator : public TExecutableOperator<FBitcrusherOperator>
function void Reset
Source code excerpt:
Bitcrusher.Init(InParams.OperatorSettings.GetSampleRate(), 1);
const float CurSampleRate = FMath::Clamp(*CrushedSampleRate, 1.0f, MaxSampleRate);
const float CurBitDepth = FMath::Clamp(*CrushedBitDepth, 1.0f, Bitcrusher.GetMaxBitDepth());
Bitcrusher.SetSampleRateCrush(CurSampleRate);
Bitcrusher.SetBitDepthCrush(CurBitDepth);
PrevSampleRate = CurSampleRate;
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundStandardNodes/Private/MetasoundBitcrusherNode.cpp:162
Scope (from outer to inner):
file
namespace Metasound
class class FBitcrusherOperator : public TExecutableOperator<FBitcrusherOperator>
function void Execute
Source code excerpt:
}
const float CurrSampleRate = FMath::Clamp(*CrushedSampleRate, 1.0f, MaxSampleRate);
if (!FMath::IsNearlyEqual(PrevSampleRate, CurrSampleRate))
{
Bitcrusher.SetSampleRateCrush(CurrSampleRate);
PrevSampleRate = CurrSampleRate;
}
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundStandardNodes/Private/MetasoundBitcrusherNode.cpp:197
Scope (from outer to inner):
file
namespace Metasound
class class FBitcrusherOperator : public TExecutableOperator<FBitcrusherOperator>
Source code excerpt:
float PrevSampleRate;
float PrevBitDepth;
const float MaxSampleRate;
};
// Node Class
class FBitcrusherNode : public FNodeFacade
{
#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Classes/WindowsTargetSettings.h:120
Scope (from outer to inner):
file
class class UWindowsTargetSettings : public UObject
Source code excerpt:
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Max"))
float MaxSampleRate;
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "High"))
float HighSampleRate;
UPROPERTY(GlobalConfig, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Medium"))
float MedSampleRate;
#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Private/WindowsTargetPlatformClasses.cpp:8
Scope (from outer to inner):
file
function UWindowsTargetSettings::UWindowsTargetSettings
Source code excerpt:
: Super(ObjectInitializer)
, CacheSizeKB(65536)
, MaxSampleRate(48000)
, HighSampleRate(32000)
, MedSampleRate(24000)
, LowSampleRate(12000)
, MinSampleRate(8000)
, CompressionQualityModifier(1)
{
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:620
Scope (from outer to inner):
file
class class UAndroidRuntimeSettings : public UObject
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Max"))
float MaxSampleRate;
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "High"))
float HighSampleRate;
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Medium"))
float MedSampleRate;
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:33
Scope (from outer to inner):
file
function UAndroidRuntimeSettings::UAndroidRuntimeSettings
Source code excerpt:
, AudioNumBuffersToEnqueue(4)
, CacheSizeKB(65536)
, MaxSampleRate(48000)
, HighSampleRate(32000)
, MedSampleRate(24000)
, LowSampleRate(12000)
, MinSampleRate(8000)
, CompressionQualityModifier(1)
, bMultiTargetFormat_ETC2(true)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioCompressionSettingsUtils.cpp:213
Scope (from outer to inner):
file
function void CacheAudioCookOverrides
Source code excerpt:
float RetrievedSampleRate = -1.0f;
PlatformFile.GetFloat(*CategoryName, TEXT("MaxSampleRate"), RetrievedSampleRate);
OutOverrides.PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Max, RetrievedSampleRate);
RetrievedSampleRate = -1.0f;
PlatformFile.GetFloat(*CategoryName, TEXT("HighSampleRate"), RetrievedSampleRate);
OutOverrides.PlatformSampleRates.Add(ESoundwaveSampleRateSettings::High, RetrievedSampleRate);
#Loc: <Workspace>/Engine/Source/Runtime/IOS/IOSRuntimeSettings/Classes/IOSRuntimeSettings.h:567
Scope (from outer to inner):
file
class class UIOSRuntimeSettings : public UObject
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Max"))
float MaxSampleRate;
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "High"))
float HighSampleRate;
UPROPERTY(config, EditAnywhere, Category = "Audio|CookOverrides|ResamplingQuality", meta = (DisplayName = "Medium"))
float MedSampleRate;
#Loc: <Workspace>/Engine/Source/Runtime/IOS/IOSRuntimeSettings/Private/IOSRuntimeSettings.cpp:18
Scope (from outer to inner):
file
function UIOSRuntimeSettings::UIOSRuntimeSettings
Source code excerpt:
: Super(ObjectInitializer)
, CacheSizeKB(65536)
, MaxSampleRate(48000)
, HighSampleRate(32000)
, MedSampleRate(24000)
, LowSampleRate(12000)
, MinSampleRate(8000)
, CompressionQualityModifier(1)
{