au.SoundWaveProxyReader.SimulateSeek

au.SoundWaveProxyReader.SimulateSeek

#Overview

name: au.SoundWaveProxyReader.SimulateSeek

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.SoundWaveProxyReader.SimulateSeek is to control the behavior of seeking in non-seekable audio formats within Unreal Engine’s audio system.

This setting variable is primarily used by the audio subsystem of Unreal Engine, specifically within the SoundWaveProxyReader functionality. It’s part of the Engine module, as evidenced by its location in the Engine/Source/Runtime/Engine directory.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.

The associated variable GSoundWaveProxyReaderSimulateSeekOnNonSeekable directly interacts with au.SoundWaveProxyReader.SimulateSeek. They share the same value, with GSoundWaveProxyReaderSimulateSeekOnNonSeekable being the actual integer variable used in the code logic.

Developers must be aware that enabling this feature (setting it to a non-zero value) can impact performance, especially when dealing with non-seekable audio formats. The code includes a warning log to notify developers when this fallback method is used.

Best practices when using this variable include:

  1. Keeping it disabled (set to 0) by default for optimal performance.
  2. Only enabling it when necessary for debugging or when working with non-seekable audio formats that require seeking functionality.
  3. Converting non-seekable audio to seekable formats when possible, as suggested by the warning log.

Regarding the associated variable GSoundWaveProxyReaderSimulateSeekOnNonSeekable:

The purpose of GSoundWaveProxyReaderSimulateSeekOnNonSeekable is to serve as the actual integer flag that determines whether seek simulation should be performed on non-seekable audio formats.

This variable is used within the Engine module, specifically in the SoundWaveProxyReader functionality of the audio system.

Its value is set through the au.SoundWaveProxyReader.SimulateSeek console variable, which it’s directly associated with.

The variable interacts with the audio decoding and playback logic, particularly in the InitializeDecoder function of FSoundWaveProxyReader.

Developers should be aware that when this variable is non-zero, it will trigger the fallback seek method for non-seekable audio, which can impact performance.

Best practices for this variable align with those of au.SoundWaveProxyReader.SimulateSeek, as they are directly linked. Developers should generally keep it at 0 unless specifically needed for non-seekable audio formats that require seeking functionality.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static int32 GSoundWaveProxyReaderSimulateSeekOnNonSeekable = 0;
FAutoConsoleVariableRef CVarSoundWaveProxyReaderSimulateSeekOnNonSeekable(
	TEXT("au.SoundWaveProxyReader.SimulateSeek"),
	GSoundWaveProxyReaderSimulateSeekOnNonSeekable,
	TEXT("If true, SoundWaves which are not of a seekable format will simulate seek calls by reading and discarding samples.\n")
	TEXT("0: Do not simulate seek, !0: Simulate seek"),
	ECVF_Default);

uint32 FSoundWaveProxyReader::ConformDecodeSize(uint32 InMaxDesiredDecodeSizeInFrames)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWaveProxyReader.cpp:20

Scope: file

Source code excerpt:

#include "Templates/UniquePtr.h"

static int32 GSoundWaveProxyReaderSimulateSeekOnNonSeekable = 0;
FAutoConsoleVariableRef CVarSoundWaveProxyReaderSimulateSeekOnNonSeekable(
	TEXT("au.SoundWaveProxyReader.SimulateSeek"),
	GSoundWaveProxyReaderSimulateSeekOnNonSeekable,
	TEXT("If true, SoundWaves which are not of a seekable format will simulate seek calls by reading and discarding samples.\n")
	TEXT("0: Do not simulate seek, !0: Simulate seek"),
	ECVF_Default);

uint32 FSoundWaveProxyReader::ConformDecodeSize(uint32 InMaxDesiredDecodeSizeInFrames)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SoundWaveProxyReader.cpp:413

Scope (from outer to inner):

file
function     bool FSoundWaveProxyReader::InitializeDecoder

Source code excerpt:

	// For non-seekable streaming waves, use a fallback method to seek
	// to the start time. 
	const bool bUseFallbackSeekMethod = (GSoundWaveProxyReaderSimulateSeekOnNonSeekable != 0) && (InStartTimeInSeconds != 0.f) && (!WaveProxy->IsSeekable());
	if (bUseFallbackSeekMethod)
	{
		if (!bFallbackSeekMethodWarningLogged)
		{
			UE_LOG(LogAudio, Warning, TEXT("Simulating seeking in wave which is not seekable (package:%s). For better performance, set wave to a seekable format"), *WaveProxy->GetPackageName().ToString());
			bFallbackSeekMethodWarningLogged = true;