UDN
Search public documentation:
AudioSystem
日本語訳
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
UE3 Home > Audio Home > Audio System
Audio System
Overview
Common Concepts
Audio Device
As described above, this is the main interface to the audio system. It maintains lists of loaded assets, handles listeners and manages sound sources.- Init - Initialises the hardware, allocates channels and does any other work required to hear audio.
- TearDown - shuts down the hardware and frees all resources back to the system.
- Update - Updates the listener's position, orientation and velocity.
- Exec - Process any debug commands typed into the console.
Sound Sources
Sound Sources (a.k.a. Voices) represent a single source of sound to be mixed into the final output. There are a limited number of these, defined by hardware limitations, or by a config file. Each source has a location, volume, pitch and velocity. The default number of MaxChannels is 32 for all platforms and is clamped to between 1 and 64 internally. Setting MaxChannels to 0 is a quick way of circumventing all audio system code.- Init - Finds the sound asset to play and submits to the hardware.
- Update - Updates the Volume, Pitch, Location and Velocity from the engine to the hardware.
- Play - Starts a sound source playing.
- Stop - Stops a sound source playing.
- Pause - Pauses sound playback for this source.
- IsFinished - Handles a sound ending, sending notification as needed, and the double buffering of queued buffers.
Sound Buffers
Sound Buffers are a container for wave data. The console command "ListSounds" will display all currently loaded waves and their format. Memory permitting, there can be an unlimited number of these. These generally come in two basic types: resident when the sound system completely contains all data and the engine has minimal control, and queued for when the engine needs to know when the sound has looped or when the sound is being decompressed in real time (e.g. ogg vorbis decompression on the PC).- Init - Locate the sound resource and load it if necessary.
UAudioComponent
AudioComponents are how the engine talks to the audio device. When the engine wishes to play a sound, it calls UAudioDevice::CreateComponent and sets the properties of the return structure. This structure is then attached to an actor's list of components for later management. If a location is passed in to the UAudioDevice::CreateComponent function, there will be a simple distance cull check if the sound is short, and the component may not be created. It is always important to check for a NULL return from UAudioDevice::CreateComponent as this is how running with -nosound disables audio. The most important fields in UAudioComponent are class USoundCue* SoundCue; // Sound to play with controlsBITFIELD bUseOwnerLocation:1; // Spatialise this sound to the location of the actor this is attached to.
BITFIELD bAllowSpatialization:1; // Spatialise this sound in 3d space
FVector Location; // Location to use for spatialisation if not attached
FVector ComponentLocation; // Location to use for spatialisation if attached
Sound Classes
Each sound cue can be assigned to a sound class which are defined in the package Content\Sounds\SoundClassesAndModes.upk. These specify properties and hierarchy for classes of sound cues which populate the FSoundClassProperties class. These are hierarchal in nature with some parent properties propagating down to all child nodes. The root sound class is called "Master" and is required. These hierarchy can be setup and properties changed in the sound class editor. This works in a very similar fashion to the sound cue editor. These groups can be used to apply ducking of volumes and/or pitch. UTGame has a test map "DM-SoundMode" to illustrate this; call SetSoundMode 'lowpass', 'bandpass', 'highpass', 'quick' and 'slow' on the command line to see how this works. One caveat here is that the sound class properties do not act hierarchically.Reverb Effects
These are implemented in a platform agnostic way using parameters that the target platform can use as they are needed. The parameters are defined in code in the FAudioEffectsManager::ReverbPresets table. In UnPlayer.cpp, the code acquires the reverb settings for the reverb volume the player is in and passes these to FAudioEffectsManager::SetReverbSettings for interpolation and passing to the platform specific layer. As the parameters are interpolated, there are no reverb discontinuities. Reverb volumes can be created by right clicking on the builder brush, "Add Volume" --> "Reverb Volume". FAudioEffectsManager is the base class; platform specific interfaces are derived from that.AmbientZone Effects
Reverb volumes now incorporate 'AmbientZone' settings; these are used to emulate occlusion for ambient sounds. Volume and/or low pass filter effects can be applied to outside sounds when inside, and inside sounds when outside. For example, you can place a huge outdoor ambient sound wind effect to cover the entire level, but when the player moves inside, that sound will be faded down, and sounds in the same volume as the player will be faded up. For additional documentation please see the Using Ambient Zones page.DistanceModel Attenuation
Attenuation is the ability of a sound to get fainter as the player moves away from it – the rate of fading is defined by the DistanceModel property. Please see the DistanceModel Attenution page for more information.Low Pass Filter
This is currently implemented via the attenuation sound node. There is a flag to enable and a min and max distance to use. This is actually implemented as a high shelf filter and interpolates from nothing at all at the min distance to no high frequency components at the max distance.Sound Modes
Sound modes apply changes to a set of sound classes over time. Sound groups is the deprecated name for sound classes (due to a clash with package groups) e.g. Ambient, Weapons. Set up an array of sound class effects with the sound modifications you want. For example, for cinematic dialog, up the volume on dialog and lower the volume for effects (these are not applied heirarchacally). Setting the sound mode starts fading in (over the fade in time) the mode after the initial delay, lasts for duration, and then fades back to default (over fade out time). A duration of < 0 means the mode will last until another mode is set. You should have a package called soundmodes that just has the default soundmode entry; add new sound modes to that package. New sound modes are ideally triggered via gameplay script. A picture speaking a thousand words (to abuse the metaphor) would be the SoundMode map in UDKGame. Run it and type 'setsoundmode quick', 'setsoundmode slow' or 'setsoundmode loud' at the command line. You can run in PIE and edit or create your own on the fly. The volume ducking example below is an example usage case.Volume Ducking
Volume Ducking is usually used to decrease volumes of all other sound groups besides the one that needs to be heard, most commonly dialog (but not limited to movies). The controls usually are:- Identify Sound Group that causes ducking (dialog).
- When a sound from that group is triggered, other groups decrease in volume to desired amount (fade) over x time (
FadeStartTime
= 0.3 seconds). - Amount other groups decrease in volume (
FadeAmount
= -0.4). - When sound from ducking group stops, other groups increase in volume back to normal volume (fade) over x time (
FadeStopTime
= 0.2 seconds). - May also want sound group exceptions to the ducking process (e.g. music), or a sound group called Exceptions that isn't affected.
Importing Sounds
Specs | |
Format | .Wav |
Bit Rate | 16 |
Speaker Channels | Mono, Stereo, 2.1, 4.1, 5.1 6.1, 7.1 |
Extension | 4.0 | 5.1 | 6.1 | 7.1 | ||
FrontLeft | _fl | * | * | * | * | |
FrontRight | _fr | * | * | * | * | |
FrontCenter | _fc | * | * | * | ||
LowFrequency | _lf | * | * | * | ||
SideLeft | _sl | * | * | * | * | |
SideRight | _sr | * | * | * | * | |
BackLeft | _bl | * | * | If there is no BackRight channel, this is the BackCenter channel | ||
BackRight | _br | * |
Visual Editing Tools
Sound Cue Editor
You can import audio files as sound waves and apply modifiers called audio nodes in the visual Sound Cue Editor.Sound Quality Previewer
If you right click on a SoundNodeWave asset in the Generic Browser and select Sound Quality Previewer, the engine will compress the sound at 5, 10, 15, 20, 15, 30, 35, 40, 50, and 60 compression settings. You can then click on any given quality settings and hear the sound after it has been re expanded back to 16 bit PCM. This can be used to select the best fidelity vs memory setting. Clicking OK will apply the currently selected setting to the wave.Multichannel Import/Export
In the Generic Browser... To import:- Select Import from the menu.
- Select the files "Surround_fl.wav", "Surround_fr.wav", "Surround_sl.wav", "Surround_sr.wav".
- Select the package you wish to save to and click OK to all.
- Select Export from the menu.
- Pick a location to save the files to.
Strategies
Dialog | ~1.4 |
Music | ~0.75 |
Weapons | ~1.1 |
Ambience | ~0.5 |
Optimising Sound Memory Usage
Test maps
- DM-SoundLoop - to test infinitely looping and loop with notification sounds.
- DM-SoundReverb - to test reverb and attenuation with a low pass filter.
- DM-SoundMultichannel - to test 5.1 playback.
- DM-SoundMode - to test sound modes. Available test modes are loud, quiet, quick, slow, lowpass, bandpass, highpass.
- DM-SoundInterior - to test the ambient zone functionality.
Streaming
Debug Commands
- ResetSoundState: turns off any and all debug commands.
- TestLowPassFilter: applies a low pass filter to all sources.
- IsolateDryAudio: filters out the reverb sounds leaving only unreverbed sounds.
- IsolateReverb: filters out the dry source leaving only the reverb sounds.
- SetSoundMode x: applies volume and pitch modifications from the sound group properties, and applies an EQ filter from a table defined in UnAudioEffects.cpp.
- ListSounds, ListSoundDurations, ListAudioComponents: list details of the currently loaded sounds.
- ListWaves: list the details of the currently playing sounds.
Known Issues
- TTP 60174: Audio will start over when gameplay window is moved.
- TTP 64605: -nosound does not propagate to PIE
- TTP 80463: AmbientSoundSimple actors don’t always restart in real-time preview in Editor
- TTP 92710: Sound Cues using the Delay Node don't preview correctly in generic browser or sound cue editor
- TTP 120345: AmbientSoundSimpleToggleable volume fading is broken
- TTP 122495: Looping Node doesn't work if placed after the mixer when non looping nodes are also connected
- TTP 122683: Distance Crossfade node incorrectly retriggers SoundNodeWave playback