au.nrt.RenderFrameSize

au.nrt.RenderFrameSize

#Overview

name: au.nrt.RenderFrameSize

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of au.nrt.RenderFrameSize is to control the number of audio frames to render in a single callback for the non-realtime audio renderer in Unreal Engine 5. This setting is specifically for the audio rendering system, particularly for non-realtime audio processing scenarios.

This setting variable is primarily used in the NonRealtimeAudioRenderer module of Unreal Engine 5. It’s part of the audio subsystem, specifically designed for situations where real-time audio rendering is not required.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. The default value is 256 frames.

The au.nrt.RenderFrameSize variable interacts directly with the DefaultRenderFrameSizeCvar variable. They share the same value, with DefaultRenderFrameSizeCvar serving as the actual storage for the setting.

Developers should be aware that this variable affects the audio rendering performance and latency. A larger value will result in more frames being processed in each callback, which could potentially reduce CPU usage but increase latency. Conversely, a smaller value might provide lower latency but could increase CPU usage due to more frequent callbacks.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of the project, balancing between performance and latency requirements.
  2. Testing different values to find the optimal setting for the target platform and use case.
  3. Considering the impact on memory usage, as larger frame sizes will require more memory for audio buffers.

Regarding the associated variable DefaultRenderFrameSizeCvar:

The purpose of DefaultRenderFrameSizeCvar is to store the actual value of the au.nrt.RenderFrameSize setting. It’s an implementation detail that allows the console variable system to modify the value used by the audio renderer.

This variable is used directly in the NonRealtimeAudioRenderer module, specifically in the FMixerPlatformNonRealtime class.

The value of DefaultRenderFrameSizeCvar is set initially to 256, but can be modified through the console variable system using the “au.nrt.RenderFrameSize” command.

DefaultRenderFrameSizeCvar interacts primarily with the au.nrt.RenderFrameSize console variable. It’s also used in the OpenAudioStream function of FMixerPlatformNonRealtime, although the direct usage is commented out in the provided code snippet.

Developers should be aware that modifying DefaultRenderFrameSizeCvar directly is not recommended. Instead, they should use the console variable system to change au.nrt.RenderFrameSize, which will automatically update DefaultRenderFrameSizeCvar.

Best practices for DefaultRenderFrameSizeCvar include:

  1. Avoiding direct modification of this variable in code.
  2. Using the console variable system to change the value when needed.
  3. Considering the impact of the value on audio rendering performance and adjusting accordingly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/NonRealtimeAudioRenderer/Private/AudioMixerPlatformNonRealtime.cpp:21

Scope: file

Source code excerpt:

static int32 DefaultRenderFrameSizeCvar = 256;
FAutoConsoleVariableRef CVarDefaultRenderFrameSize(
	TEXT("au.nrt.RenderFrameSize"),
	DefaultRenderFrameSizeCvar,
	TEXT("Selects the number of frames to render in a single callback .\n")
	TEXT("n: Number of frames to render."),
	ECVF_Default);

static int32 RenderEveryTickCvar = 1;

#Associated Variable and Callsites

This variable is associated with another variable named DefaultRenderFrameSizeCvar. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/NonRealtimeAudioRenderer/Private/AudioMixerPlatformNonRealtime.cpp:19

Scope: file

Source code excerpt:

#include "AudioCompressionSettingsUtils.h"

static int32 DefaultRenderFrameSizeCvar = 256;
FAutoConsoleVariableRef CVarDefaultRenderFrameSize(
	TEXT("au.nrt.RenderFrameSize"),
	DefaultRenderFrameSizeCvar,
	TEXT("Selects the number of frames to render in a single callback .\n")
	TEXT("n: Number of frames to render."),
	ECVF_Default);

static int32 RenderEveryTickCvar = 1;
FAutoConsoleVariableRef CVarRenderEveryTick(

#Loc: <Workspace>/Engine/Source/Runtime/NonRealtimeAudioRenderer/Private/AudioMixerPlatformNonRealtime.cpp:195

Scope (from outer to inner):

file
namespace    Audio
function     bool FMixerPlatformNonRealtime::OpenAudioStream

Source code excerpt:


		OpenStreamParams = Params;
		//OpenStreamParams.NumFrames = DefaultRenderFrameSizeCvar;
		

		AudioStreamInfo.Reset();

		AudioStreamInfo.OutputDeviceIndex = OpenStreamParams.OutputDeviceIndex;
		AudioStreamInfo.NumOutputFrames = OpenStreamParams.NumFrames;