MusicVolumeControlBus
MusicVolumeControlBus
#Overview
name: MusicVolumeControlBus
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 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MusicVolumeControlBus is to control the volume of music in the game. It is a setting variable used in the audio system of Unreal Engine 5, specifically within the Lyra game project.
This setting variable is primarily used in the LyraGame module, particularly in the audio and settings subsystems. Based on the callsites, it is referenced in the LyraAudioMixEffectsSubsystem and LyraSettingsLocal classes.
The value of this variable is set in the LyraAudioSettings class, which inherits from UDeveloperSettings. It is defined as a config property, meaning its value can be set in configuration files and edited in the Unreal Editor.
MusicVolumeControlBus interacts with other audio-related variables, such as SoundFXVolumeControlBus and DialogueVolumeControlBus (implied by the code structure). It is used in conjunction with the USoundControlBus class to manage audio volume settings.
Developers must be aware that this variable is of type FSoftObjectPath, which means it’s a reference to an asset that can be loaded asynchronously. The code checks if the asset can be loaded and casts it to USoundControlBus before using it.
Best practices when using this variable include:
- Ensuring the referenced asset is a valid USoundControlBus object.
- Handling cases where the asset fails to load or cast properly.
- Using it consistently across the audio system to maintain a coherent volume control for music.
- Considering performance implications when loading the asset, especially in performance-critical sections of code.
- Keeping the audio settings well-organized and easily accessible for both developers and players to modify.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:217, section: [/Script/LyraGame.LyraAudioSettings]
- INI Section:
/Script/LyraGame.LyraAudioSettings
- Raw value:
/Game/Audio/Modulation/ControlBuses/CB_Music.CB_Music
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Audio/LyraAudioMixEffectsSubsystem.cpp:101
Scope (from outer to inner):
file
function void ULyraAudioMixEffectsSubsystem::PostInitialize
Source code excerpt:
}
if (UObject* ObjPath = LyraAudioSettings->MusicVolumeControlBus.TryLoad())
{
if (USoundControlBus* SoundControlBus = Cast<USoundControlBus>(ObjPath))
{
MusicControlBus = SoundControlBus;
}
else
#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Audio/LyraAudioSettings.h:52
Scope (from outer to inner):
file
class class ULyraAudioSettings : public UDeveloperSettings
Source code excerpt:
/** Control Bus assigned to the Music sound volume setting */
UPROPERTY(config, EditAnywhere, Category = UserMixSettings, meta = (AllowedClasses = "/Script/AudioModulation.SoundControlBus"))
FSoftObjectPath MusicVolumeControlBus;
/** Control Bus assigned to the SoundFX sound volume setting */
UPROPERTY(config, EditAnywhere, Category = UserMixSettings, meta = (AllowedClasses = "/Script/AudioModulation.SoundControlBus"))
FSoftObjectPath SoundFXVolumeControlBus;
/** Control Bus assigned to the Dialogue sound volume setting */
#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Settings/LyraSettingsLocal.cpp:1460
Scope (from outer to inner):
file
function void ULyraSettingsLocal::LoadUserControlBusMix
Source code excerpt:
}
if (UObject* ObjPath = LyraAudioSettings->MusicVolumeControlBus.TryLoad())
{
if (USoundControlBus* SoundControlBus = Cast<USoundControlBus>(ObjPath))
{
MusicControlBus = SoundControlBus;
ControlBusMap.Add(TEXT("Music"), MusicControlBus);
}