DefaultSoundClassName

DefaultSoundClassName

#Overview

name: DefaultSoundClassName

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of DefaultSoundClassName is to specify the default SoundClass that will be assigned to newly created sounds in Unreal Engine 5. This setting is crucial for the audio system, as it provides a baseline configuration for sound assets in the game.

The DefaultSoundClassName variable is primarily used by the Engine’s audio subsystem. It is defined in the UAudioSettings class, which is part of the Engine module. This setting is essential for maintaining consistency in audio behavior across the project.

The value of this variable is typically set in the project’s Audio settings, which can be accessed through the Unreal Engine editor. It is stored as an FSoftObjectPath, allowing for easy referencing of the SoundClass asset.

DefaultSoundClassName interacts with other variables in the UAudioSettings class, such as DefaultMediaSoundClassName and DefaultSoundClass. It’s also used in conjunction with the CachedSoundClass variable during editing operations.

Developers must be aware that:

  1. This variable should point to a valid SoundClass asset.
  2. If the specified SoundClass fails to load, the engine will attempt to fall back to a default located at “Engine/EngineSounds/Master”.
  3. Changes to this variable may affect all newly created sound assets in the project.

Best practices when using this variable include:

  1. Ensure the referenced SoundClass exists and is appropriate for the project’s audio needs.
  2. Consider the implications of changing this value, as it affects the default behavior of all new sound assets.
  3. Use this in conjunction with more specific SoundClasses for fine-grained audio control.
  4. Regularly verify that the DefaultSoundClassName is set correctly, especially when working in a team environment or when migrating projects.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1595, section: [/Script/Engine.AudioSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:246, section: [/Script/Engine.AudioSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/AudioSettings.h:134

Scope (from outer to inner):

file
class        class UAudioSettings : public UDeveloperSettings

Source code excerpt:

	/** The SoundClass assigned to newly created sounds */
	UPROPERTY(config, EditAnywhere, Category="Audio", meta=(AllowedClasses="/Script/Engine.SoundClass", DisplayName="Default Sound Class"))
	FSoftObjectPath DefaultSoundClassName;

	/** The SoundClass assigned to media player assets */
	UPROPERTY(config, EditAnywhere, Category = "Audio", meta = (AllowedClasses = "/Script/Engine.SoundClass", DisplayName = "Default Media Sound Class"))
	FSoftObjectPath DefaultMediaSoundClassName;

	/** The SoundConcurrency assigned to newly created sounds */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioSettings.cpp:45

Scope (from outer to inner):

file
function     void UAudioSettings::PreEditChange

Source code excerpt:

void UAudioSettings::PreEditChange(FProperty* PropertyAboutToChange)
{
	CachedSoundClass = DefaultSoundClassName;

	// Cache master submix in case user tries to set to submix that isn't a top-level submix
	CachedMasterSubmix = MasterSubmix;

	// Cache at least the first entry in case someone tries to clear the array
	CachedQualityLevels = QualityLevels;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioSettings.cpp:210

Scope (from outer to inner):

file
function     void UAudioSettings::LoadDefaultObjects

Source code excerpt:

	}

	if (UObject* SoundClassObject = DefaultSoundClassName.TryLoad())
	{
		DefaultSoundClass = CastChecked<USoundClass>(SoundClassObject);
		DefaultSoundClass->AddToRoot();
	}

#if WITH_EDITOR
	if (!DefaultSoundClass)
	{
		DefaultSoundClassName = CachedSoundClass;
		if (UObject* SoundClassObject = DefaultSoundClassName.TryLoad())
		{
			DefaultSoundClass = CastChecked<USoundClass>(SoundClassObject);
			DefaultSoundClass->AddToRoot();
		}
	}
#endif // WITH_EDITOR

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioSettings.cpp:230

Scope (from outer to inner):

file
function     void UAudioSettings::LoadDefaultObjects

Source code excerpt:

	if (!DefaultSoundClass)
	{
		UE_LOG(LogAudio, Warning, TEXT("Failed to load Default SoundClassObject from path '%s'.  Attempting to fall back to engine default."), *DefaultSoundClassName.GetAssetPathString());
		DefaultSoundClassName.SetPath(EngineSoundsDir / TEXT("Master"));
		if (UObject* SoundClassObject = DefaultSoundClassName.TryLoad())
		{
			DefaultSoundClass = CastChecked<USoundClass>(SoundClassObject);
			DefaultSoundClass->AddToRoot();
		}
	}

	if (!DefaultSoundClass)
	{
		UE_LOG(LogAudio, Error, TEXT("Failed to load Default SoundClassObject from path '%s'."), *DefaultSoundClassName.GetAssetPathString());
	}

	if (DefaultMediaSoundClass)
	{
		DefaultMediaSoundClass->RemoveFromRoot();
		DefaultMediaSoundClass = nullptr;