Ambient Sounds in Levels

Overview

This Tutorial explains how to setup Ambient Sounds in CRYENGINE.

Ambient Sounds in Levels

CRYENGINE offers two Audio Entities; AudioAreaAmbience and AudioAreaEntity. Both can be used to setup Ambient Sounds in a Level, but they do need to be attached to a Shape in a Level to define the Area in which the Sound will play in.

These Entities are used to set multiple attributes that allow you to define a Play and StopTrigger, an Environment as well as the Radius around the Shape where your Ambience will start to fade in.

To make use of the AudioAreaAmbience or the AudioAreaEntity in a Level a new Shape must first be created. The Shapes that can be used with the AudioAreaAmbience and AudioAreaEntity can be found in the RollupBar. Under Object Type select either AreaBox, AreaSphere or Shape.

For this Tutorial we are going to place an Area Shape in a Level. To do this go to the RollupBar and from the Objects menu select Area, then select Shape from the Object Type menu (screenshot below).

After Shape has been selected click in the Level to create points which will become the corners of your Shape.

When you have chosen the position of your last point of your Shape, double-click - this completes your created Shape.

Then go to the Properties of the Entity (in the RollupBar) and specify a height and name for the Shape.

Using the AudioAreaAmbience

The AudioAreaAmbience Entity is the main Entity that permits the implementation of Ambiences in a Level. It is used when you are setting up Ambiences without the need to access their information in Flowgraph for advanced implementation methods.

In order to connect the AudioAreaAmbience, select the previously created Shape, then click the Pick button in Shape Parameters and select the AudioAreaAmbience Entity in your Level.

The AudioAreaAmbiance Entity will now be linked to the Shape.

For the PlayTrigger option select the ATL Trigger for your Ambient Sound. For the Rtpc option setup the ATL RTPC that is controlling the volume of the Ambience.

For a full reference of the properties for the AudioAreaAmbience Entity please refer to Audio Entities and Flownodes - AudioAreaAmbience.

You can choose/use any name you like for the ATL RTPC that is set as the RTPC in the Entity properties of the AudioAreaAmbience and AudioAreaEntity. In CRYENGINE we use the name "area_fade_distance".

If your character is moving towards the Area in a Level, then the PlayTrigger will be called as soon as the character enters into the maximum distance as defined by the RtpcDistance value in the Entity properties.

When moving closer to the shape the RtpcDistance value is increasing and moves closer to 1, this therefore increases the volume of the Ambience and in accordance to the setup in your Audio Middleware.

As long as your character is within the Area Shape the RtpcDistance equals 1 and therefore your Ambience will play without attenuation.


The distance that is output by the AudioAreaAmbience and AudioAreaEntity is always scaled in the range of 0 to 1 from the maximum range you are setting in RTPC Distance. Therefore, the range of the RTPC used by your Middleware needs to be only 0 to 1.

To learn how to create the corresponding setup for this in Wwise please refer to the tutorial Wwise and Ambiences.

Using the AudioAreaEntity

The AudioAreaEntity works in a similar way to the AudioAreaAmbience, but needs manual setup via Flowgraph to trigger the ATL Controls.

This extra step gives you access to multiple parameters and more advanced setup possibilities than with the AudioAreaAmbience.

When looking at the properties of the AudioAreaEntity you will notice that it does not contain an RtpcDistance, but includes a FadeDistance parameter. This value behaves the same as in the AudioAreaAmbience, but is named differently as it can be connected to any Object via Flowgraph and not only an ATL RTPC.

You will also notice that there are no Play and Stop Triggers in the Entity properties, this is because they are setup manually in Flowgraph - this is explained in the next step.

For a full reference of the properties for the AudioAreaEntity please refer to Audio Entities and Flownodes - AudioAreaEntity.

In order to setup an AudioAreaEntity in a Level first follow the same steps as with the AudioAreaAmbience i.e. by placing the Entity in your Level and connecting it to an Area.

Now open the Flowgraph and while the Entity is selected in the Editor right click in Flowgraph and select "Add Selected Entity" from the popup selection.

Best Practice

It is useful to contain all Audio functionality inside one Flowgraph. It's also good practice to place a Flowgraph Entity in your Audio Layer per Level and create all Flowgraph specific Audio inside of it.

For this add the Flowgraph Entity which can be found under Entity/Default in the Rollupbar and create a Flowgraph on the Entity which all your Audio Objects will use.

The AudioAreaEntity Flowgraph node does not have any Playback functionality itself - it outputs triggers when the character is entering or leaving the connected Area or by it's outer values as defined by the EventDistance. It also sends out a value that can be used to control any ATL RTPC via the Audio:Rtpc node.

Therefore, in order to enable the playback of an Ambience for your Area with the AudioAreaEntity you have to add an Audio:Trigger and an Audio:RTPC node to the Flowgraph.

After adding both nodes to the Flowgraph right-click on them and select the "Assign Selected Entity" command from the popup selection. Now both the Audio:Trigger and the Audio:RTPC will only be set on their assigned Entity which in this case is the AudioAreaEntity.

After creating the Flowgraph setup it should look like the example below:

NOTE: That you don't need to specify a StopTrigger as CRYENGINE automatically stops the playing ATL Trigger if no Stop Event is assigned.

In the case of the Ambience setup the StopTrigger is called when leaving the maximum RtpcDistance/FadeDistance and the Ambience is completely attenuated.

When in the Editor, Ambiences that are setup with the AudioAreaEntity will not play by default as they are triggering the ATL Controls in Flowgraph.

In order to preview the AudioAreaEntity when not in-game you have to enable the AI/Physics button so that the Flowgraph is calculated.

Working with Shape Priorities & Shape Nesting

When you are using multiple Shapes in a Level you can setup Shape Priorities in order to define how the Audio behaves when transitioning from one Shape to another.

You can set the Priority per Shape in the Object properties that can be found in the RollupBar.

If you are transitioning from one shape to another, then the Shape with the higher priority will override the RtpcDistance/FadeDistance that is set on the AudioAreaAmbience/AudioAreaEntity of the Shape with the lower priority.

Example

Shape A has a Priority of 20 and a FadeDistance of 10, whereas Shape B has a Priority of 40 and a FadeDistance of 5. Shape B is nested in Shape A, both have the same GroupId.

  • When the player approaches Shape A, then 10 m before the edge of the Shape the Sound starts to fade in.
  • When the player approaches Shape B, then 5 m before the edge of the Shape the Sound starts to fade in.
  • When the player enters Shape B the Sound of Shape A fades out within 5 m.
Easier Shape Selection

With Helpers enabled and pressing the Spacebar on your keyboard will show the Pivots of all Entities in your Level. This feature also allows you to select Areas more easily when they are nested together.

Using Sound Obstruction on Area Shapes

The sides of an Area Shape and an Area box can be flagged for obstruction by enabling the DisplaySoundInfo checkbox.

Obstructed sides are displayed in red and do not calculate the Ambience updates for that segment.

Non obstructed sides are displayed green and do calculate Ambience updates for that segment.

This feature can be used to define doorways and windows as well as offering greater flexibility in complex shape in shape setups.

Result

You now have learned how to setup Ambient Sounds with the AudioAreaAmbience and AudioAreaEntity in CRYENGINE.

To learn how to create a setup in Wwise for this read the tutorial Wwise and Ambiences.