Audio
Unreal Engine Documentation
This page will only provide a brief overview of audio content, and how it works within an MSquared project. As we are working with the Unreal Engine native audio solution, it is advised to read the Unreal Engine Documentation on Working With Audio.
Volume Settings
We have a number of different "volume channels" in our project, that can be used to control the volume of different channels per client:
master_volume
(Will control all volume)sfx_volume
voice_volume
music_volume
Controlling the volume settings
These can be controlled in-game via the user's settings, using the GetVolumeLevel
and SetVolumeLevel
helper functions on the J_GameUserSettings
(the settings class used in MSquared projects)

The WBP_M2Example_SettingsMenu
provides a simple example of how you can add settings to your project to control these volume levels. We have only implemented the master_volume
value here, but you could use this same approach to set the levels of sfx, voice or music if desired.

Making new Audio Respond to the Volume Settings
In order to have your game sounds affected by the audio volume sliders, you need to ensure that you have correctly set their SoundClass
.
This can be accomplished in two ways:
Setting the SoundClass on the asset itself (strongly recommended, see below).
Setting a
Sound Class Override
on an actor.
For example, if you have an AmbientSound
actor, you can make it respect the Music Volume
slider by adding the following SoundClass override:

To set up the appropriate sound classes, you can either use the existing ones, or make your own. To make sure that they map to the appropriate volume setting, you will need to link them to the appropriate SoundControlBus
: (either directly through its list of VolumeModulators, or through a submix class):
master_volume
- No sound class needed, will be applied to all soundssfx_volume
- any SoundClass withCB_M2_ClientVolumeControl_SFX
added to its list of VolumeModulators (or using a submix that has this)e.g.
SCL_M2_NonWorld_UI
orSCL_M2_World_Ambience
voice_volume
- any SoundClass withCB_M2_ClientVolumeControl_Voice
added to its list of VolumeModulatorse.g.
SCL_M2_World_Dialogue
orSCL_M2_NonWorld_Dialogue
music_volume
- any SoundClass withCB_M2_ClientVolumeControl_Music
added to its list of VolumeModulators (or using a submix that has thise.g.
SSM_M2_World_Music
) e.g.SCL_M2_World_Music
orSCL_M2_NonWorld_Music
(World/NonWorld in this case denote Diegetic (typically 3D, in the world)/Non-Diegetic (typically 2D))
Important Audio Asset Properties
MSquared has some example audio added, such as footsteps, which rely on correctly setting parameters on imported content. It is also important to be aware of the hierarchy of properties - i.e. some properties (such as Attenuation) on a SoundWave are ignored if the SoundWave is used in a MetaSoundSource.
The hierarchy is as follows:
AudioComponent
: This component is required to play any sound, and any properties set on the component will override those on any assets being played through it.SoundCue / MetaSoundSource
: These assets contain and combine SoundWaves, and will override the properties defined on any SoundWave they contain.SoundWave
: This is the "lowest-level" and most simplistic audio .uasset.
As a consequence of this, if an Attenuation property is set on a SoundWave, but the SoundWave is played inside of a MetaSoundSource with no Attenuation setting, then the outputted audio will be in 2D (i.e. with no attenuation or spatialisation).
Important properties to be aware of:
SoundClass: This property defines the "category" of a sound and to which channel of the mixer system the audio will be routed. For example, this system is used by volume sliders in the pause menu. Adjusting the UI slider will only change the volume of sounds that are being sent to the UI channel, which can be accomplished by setting the SCL_M2_NonWorld_UI SoundClass.
Attenuation: This property defines the spatial behaviour of a sound - i.e. how it behaves in 3D space. The default null value will play a sound in 2D (i.e. it will sound the same regardless of your position, orientation, etc.) Using an Attenuation asset with spatialisation will make the sound play from a world location (i.e. the location of the AudioComponent that is playing it).

Looping: This property (when true) will set a sound to repeatedly play in a continuous loop. This is useful for ambient sounds, like running water in a river. If there is a noticeable gap where a sound stops and starts, it will ruin the immersion, so a continually looping sound will better simulate the sound of a flowing river.
Note: volume multipliers in Unreal are multiplicative, so setting the volume of a SoundWave to 0.5, then adding that SoundWave to a MetaSoundSource, and setting its volume to 0.5, will result in the sound playing at a volume of 0.5 multiplied 0.5, or 0.25. This also means that a sound can be muted by setting its volume to zero at any stage.
Last updated
Was this helpful?