DefaultBaseSoundMix

DefaultBaseSoundMix

#Overview

name: DefaultBaseSoundMix

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 DefaultBaseSoundMix is to provide a default base sound mix for the audio system in Unreal Engine 5. It serves as the foundational audio configuration when no other system has specified a base sound mix.

This setting variable is primarily used by the audio subsystem of Unreal Engine. Specifically, it is utilized by the FAudioDevice class, which is responsible for managing audio playback and processing in the engine.

The value of this variable is typically set in several ways:

  1. In the project’s AudioSettings, defined in the UAudioSettings class.
  2. In the AWorldSettings class for each level.
  3. Programmatically through the SetDefaultBaseSoundMix function of FAudioDevice.

DefaultBaseSoundMix interacts with other audio-related variables, particularly:

  1. BaseSoundMix: The currently active base sound mix.
  2. SoundMixModifiers: A map of sound mixes affecting audio properties.

Developers should be aware of the following when using this variable:

  1. It provides a fallback sound mix when no other mix is specified.
  2. Changes to this variable can affect the overall audio experience of the game.
  3. It can be overridden on a per-level basis using the AWorldSettings class.

Best practices for using this variable include:

  1. Set a appropriate default in the project’s AudioSettings for consistency across the game.
  2. Use level-specific overrides sparingly and only when necessary for unique audio environments.
  3. Consider the impact on performance when changing the default base sound mix, as it affects all audio in the game.
  4. Ensure that the referenced SoundMix asset exists and is properly configured to avoid audio issues.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:249, 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/GameFramework/WorldSettings.h:762

Scope (from outer to inner):

file
class        class AWorldSettings : public AInfo, public IInterface_AssetUserData

Source code excerpt:

	/** Default Base SoundMix.																			*/
	UPROPERTY(EditAnywhere, Category=Audio)
	TObjectPtr<class USoundMix> DefaultBaseSoundMix;

#if WITH_EDITORONLY_DATA
	/** If set overrides the level settings and global project settings */
	UPROPERTY(EditAnywhere, config, Category = HLODSystem, meta=(EditConditionHides, EditCondition = "WorldPartition == nullptr"))
	TSoftClassPtr<class UHierarchicalLODSetup> HLODSetupAsset;

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

Scope (from outer to inner):

file
class        class UAudioSettings : public UDeveloperSettings

Source code excerpt:

	/** The SoundMix to use as base when no other system has specified a Base SoundMix */
	UPROPERTY(config, EditAnywhere, Category="Audio", meta=(AllowedClasses="/Script/Engine.SoundMix"))
	FSoftObjectPath DefaultBaseSoundMix;

	/** Sound class to be used for the VOIP audio component */
	UPROPERTY(config, EditAnywhere, Category="Audio", meta=(AllowedClasses="/Script/Engine.SoundClass", DisplayName = "VOIP Sound Class"))
	FSoftObjectPath VoiPSoundClass;

	/** The default submix through which all sounds are routed to. The root submix that outputs to audio hardware. */

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

Scope (from outer to inner):

file
function     FAudioDevice::FAudioDevice

Source code excerpt:

	, NextResourceID(1)
	, BaseSoundMix(nullptr)
	, DefaultBaseSoundMix(nullptr)
	, Effects(nullptr)
	, CurrentReverbEffect(nullptr)
	, PlatformAudioHeadroom(1.0f)
	, DefaultReverbSendLevel(0.0f)
	, bHRTFEnabledForAll_OnGameThread(false)
	, bHRTFDisabled_OnGameThread(false)

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

Scope (from outer to inner):

file
function     bool FAudioDevice::Init

Source code excerpt:

	DefaultReverbSendLevel = AudioSettings->DefaultReverbSendLevel_DEPRECATED;

	const FSoftObjectPath DefaultBaseSoundMixName = GetDefault<UAudioSettings>()->DefaultBaseSoundMix;
	if (DefaultBaseSoundMixName.IsValid())
	{
		DefaultBaseSoundMix = LoadObject<USoundMix>(nullptr, *DefaultBaseSoundMixName.ToString());
	}

	GetDefault<USoundGroups>()->Initialize();

	// Parses sound classes.
	InitSoundClasses();

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

Scope (from outer to inner):

file
function     void FAudioDevice::AddReferencedObjects

Source code excerpt:

void FAudioDevice::AddReferencedObjects(FReferenceCollector& Collector)
{
	Collector.AddReferencedObject(DefaultBaseSoundMix);
	Collector.AddReferencedObjects(PrevPassiveSoundMixModifiers);
	Collector.AddReferencedObjects(SoundMixModifiers);

	for (TPair<FName, FActivatedReverb>& ActivatedReverbPair : ActivatedReverbs)
	{
		Collector.AddReferencedObject(ActivatedReverbPair.Value.ReverbSettings.ReverbEffect);

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

Scope (from outer to inner):

file
function     void FAudioDevice::SetDefaultBaseSoundMix

Source code excerpt:

	if (IsInGameThread() && SoundMix == nullptr)
	{
		const FSoftObjectPath DefaultBaseSoundMixName = GetDefault<UAudioSettings>()->DefaultBaseSoundMix;
		if (DefaultBaseSoundMixName.IsValid())
		{
			SoundMix = LoadObject<USoundMix>(nullptr, *DefaultBaseSoundMixName.ToString());
		}
	}

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

Scope (from outer to inner):

file
function     void FAudioDevice::SetDefaultBaseSoundMix

Source code excerpt:

	}

	DefaultBaseSoundMix = SoundMix;
	SetBaseSoundMix(SoundMix);
}

void FAudioDevice::RemoveSoundMix(USoundMix* SoundMix)
{
	check(IsInAudioThread());

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

Scope (from outer to inner):

file
function     void FAudioDevice::RemoveSoundMix

Source code excerpt:

	{
		// Not sure if we will ever destroy the default base SoundMix
		if (SoundMix == DefaultBaseSoundMix)
		{
			DefaultBaseSoundMix = nullptr;
		}

		ClearSoundMix(SoundMix);

		// Try setting to global default if base SoundMix has been cleared
		if (BaseSoundMix == nullptr)
		{
			SetBaseSoundMix(DefaultBaseSoundMix);
		}
	}
}

void FAudioDevice::RecurseIntoSoundClasses(USoundClass* CurrentClass, FSoundClassProperties& ParentProperties)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:545

Scope (from outer to inner):

file
function     void UGameViewportClient::Init

Source code excerpt:

				if (World)
				{
					AudioDevice.GetAudioDevice()->SetDefaultBaseSoundMix(World->GetWorldSettings()->DefaultBaseSoundMix);

					// Set the world's audio device handle to use so that sounds which play in that world will use the correct audio device
					World->SetAudioDevice(AudioDevice);
				}

				// Set this audio device handle on the world context so future world's set onto the world context

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:15423

Scope (from outer to inner):

file
function     bool UEngine::LoadMap

Source code excerpt:

		if (AWorldSettings* WorldSettings = WorldContext.World()->GetWorldSettings())
		{
			AudioDevice->SetDefaultBaseSoundMix(WorldSettings->DefaultBaseSoundMix);
		}
		else
		{
			UE_LOG(LogInit, Warning, TEXT("Unable to get world settings. Can't initialize default base soundmix."));
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:7866

Scope (from outer to inner):

file
function     UWorld* FSeamlessTravelHandler::Tick

Source code excerpt:

				if (FAudioDevice* AudioDevice = LoadedWorld->GetAudioDeviceRaw())
				{
					AudioDevice->SetDefaultBaseSoundMix(LoadedWorld->GetWorldSettings()->DefaultBaseSoundMix);
				}

				// Copy cheat flags if the game info is present
				// @todo FIXMELH - see if this exists, it should not since it's created in GameMode or it's garbage info
				if (LoadedWorld->NetworkManager != nullptr)
				{

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

Scope (from outer to inner):

file
class        class FAudioDevice : public FExec
function     USoundMix* GetDefaultBaseSoundMixModifier

Source code excerpt:

	USoundMix* GetDefaultBaseSoundMixModifier()
	{
		return DefaultBaseSoundMix;
	}

	void SetSoundMixModifiers(const TMap<USoundMix*, FSoundMixState>& InSoundMixModifiers, const TArray<USoundMix*>& InPrevPassiveSoundMixModifiers, USoundMix* InDefaultBaseSoundMix)
	{
		SoundMixModifiers = ObjectPtrWrap(InSoundMixModifiers);
		PrevPassiveSoundMixModifiers = ObjectPtrWrap(InPrevPassiveSoundMixModifiers);
		DefaultBaseSoundMix = InDefaultBaseSoundMix;
	}

	ENGINE_API FDelegateHandle AddPreRenderDelegate(const FOnAudioDevicePreRender::FDelegate& InDelegate);

	ENGINE_API bool RemovePreRenderDelegate(const FDelegateHandle& InHandle);

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

Scope (from outer to inner):

file
class        class FAudioDevice : public FExec

Source code excerpt:


	/** The Base SoundMix that should be applied by default */
	TObjectPtr<USoundMix> DefaultBaseSoundMix;

	/** Map of sound mixes currently affecting audio properties */
	TMap<TObjectPtr<USoundMix>, FSoundMixState> SoundMixModifiers;

	/** Map of sound mix sound class overrides. Will override any sound class effects for any sound mixes */
	TMap<USoundMix*, FSoundMixClassOverrideMap> SoundMixClassEffectOverrides;