ShowSoundClassHierarchy

ShowSoundClassHierarchy

#Overview

name: ShowSoundClassHierarchy

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowSoundClassHierarchy is to display a hierarchical representation of sound classes in Unreal Engine’s audio system. This function is part of the audio subsystem and is used for debugging and analysis purposes.

The Unreal Engine audio module relies on this functionality, specifically within the FAudioDevice class. It’s primarily used in the Engine’s runtime, as evidenced by its location in the Engine/Source/Runtime/Engine directory.

The value of this variable is not set directly, but rather it’s a function that is called to display the sound class hierarchy. It’s invoked through the HandleShowSoundClassHierarchyCommand function, which is likely triggered by a console command or debugging tool.

This function interacts with the USoundClass objects, which represent different categories of sounds in the engine. It recursively traverses the sound class hierarchy, displaying information about each class and its children.

Developers should be aware that this function is primarily a debugging tool. It’s not meant to be used in regular gameplay code, but rather for inspecting and understanding the structure of sound classes in their project.

Best practices when using this function include:

  1. Use it during development and debugging phases, not in shipping builds.
  2. Be aware that it may have a performance impact if called frequently, especially with large sound class hierarchies.
  3. Utilize it in conjunction with other audio debugging tools to get a comprehensive view of the audio system.
  4. Remember that it provides a snapshot of the current state of sound classes, which may change during runtime.

This function is particularly useful for audio designers and programmers working on complex sound systems within Unreal Engine projects.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:1188

Scope (from outer to inner):

file
function     bool FAudioDevice::HandleShowSoundClassHierarchyCommand

Source code excerpt:


bool FAudioDevice::HandleShowSoundClassHierarchyCommand(const TCHAR* Cmd, FOutputDevice& Ar)
{
	FAudioThreadSuspendContext AudioThreadSuspend;

	ShowSoundClassHierarchy(Ar);
	return true;
}

bool FAudioDevice::HandleListWavesCommand(const TCHAR* Cmd, FOutputDevice& Ar)
{
	FAudioThreadSuspendContext AudioThreadSuspend;

	TArray<FWaveInstance*> WaveInstances;
	int32 FirstActiveIndex = GetSortedActiveWaveInstances(WaveInstances, ESortedActiveWaveGetType::QueryOnly);

	for (int32 InstanceIndex = FirstActiveIndex; InstanceIndex < WaveInstances.Num(); InstanceIndex++)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:1331

Scope (from outer to inner):

file
function     void FAudioDevice::ShowSoundClassHierarchy

Source code excerpt:


	Ar.Logf(TEXT("%d total sounds in %d classes"), TotalSounds, AudioClassInfos.Num());
	return true;
}

void FAudioDevice::ShowSoundClassHierarchy(FOutputDevice& Ar, USoundClass* InSoundClass, int32 Indent ) const
{
	TArray<USoundClass*> SoundClassesToShow;
	if (InSoundClass)
	{
		SoundClassesToShow.Add(InSoundClass);
	}
	else
	{
		for (TMap<USoundClass*, FSoundClassProperties>::TConstIterator It(SoundClasses); It; ++It)
		{
			USoundClass* SoundClass = It.Key();

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:1365

Scope (from outer to inner):

file
function     void FAudioDevice::ShowSoundClassHierarchy

Source code excerpt:

		}
		for (int32 i = 0; i < SoundClass->ChildClasses.Num(); ++i)
		{
			if (SoundClass->ChildClasses[i])
			{
				ShowSoundClassHierarchy(Ar, SoundClass->ChildClasses[i], Indent+1);
			}
		}
	}
}

bool FAudioDevice::HandleDumpSoundInfoCommand(const TCHAR* Cmd, FOutputDevice& Ar)
{
	using namespace AudioDeviceUtils;

	FAudioThreadSuspendContext AudioThreadSuspend;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:2259

Scope (from outer to inner):

file
function     bool FAudioDevice::Exec

Source code excerpt:

	}
	else if (ParseAudioExecCmd(&Cmd, TEXT("ListSoundClasses")))
	{
		return HandleListSoundClassesCommand(Cmd, Ar);
	}
	else if (ParseAudioExecCmd(&Cmd, TEXT("ShowSoundClassHierarchy")))
	{
		return HandleShowSoundClassHierarchyCommand(Cmd, Ar);
	}
	else if (ParseAudioExecCmd(&Cmd, TEXT("ListSoundClassVolumes")))
	{
		return HandleListSoundClassVolumesCommand(Cmd, Ar);
	}
	else if (ParseAudioExecCmd(&Cmd, TEXT("ListAudioComponents")))
	{
		return HandleListAudioComponentsCommand(Cmd, Ar);
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/AudioDevice.h:502

Scope (from outer to inner):

file
class        class FAudioDevice : public FExec

Source code excerpt:

	void HandleAudioSoloCommon(const TCHAR* Cmd, FOutputDevice& Ar, FToggleSoloPtr Funct);

	/**
	* Lists a summary of loaded sound collated by class
	*/
	void ShowSoundClassHierarchy(FOutputDevice& Ar, USoundClass* SoundClass = nullptr, int32 Indent = 0) const;

	/**
	* Gets a summary of loaded sound collated by class
	*/
	void GetSoundClassInfo(TMap<FName, FAudioClassInfo>& AudioClassInfos);
#endif

	void UpdateAudioPluginSettingsObjectCache();

public: