Version

menu_open

Integration Details - 3D Positions

Wwise supports both 2D and 3D sounds. 3D sounds simulate a 3D environment and can take full advantage of a 5.1 surround speaker setup. Additionally, the player's position, known as the listener, helps the auditive and visual experiences immerse the player in a credible 3D environment.

The positioning information for 3D sounds is divided into two categories:

  • Game-defined — where an object's propagation and attenuation information is decided in game while it is being played, based on settings defined by the Wwise user.
  • User-defined — where an object's spatial positioning is "pre-defined" within a standard 5.1 surround speaker setup.

For 3D game-defined positioning, the propagation and attenuation properties are defined in relation to the listener's position and orientation in game. 3D user-defined positioning, however, creates a "pre-defined" audio experience, where the sounds follow a pre-defined path around the speakers, regardless of the listener's position and orientation in-game.

Note.gif
Note: This section discusses positioning at the game object level. For information regarding positioning of listeners, refer to Setting the Listener's Positioning Information.

Setting a Game Object's Real World Position

To set the real world position of a game object, the AK::SoundEngine::SetPosition() function must be called for every game object that needs game-defined 3D positioning. You need to set the position every time the position of a game object changes.

Setting Game Object Positions

Game object positions are set using the AK::SoundEngine::SetPosition() method:

AKRESULT AK::SoundEngine::SetPosition( 
    AkGameObjectID in_GameObjectID,                             // Game object identifier
    const AkSoundPosition & in_Position                         // Position to set
);

The first parameter is the ID of the game object. Refer to Integration Details - Game Objects for more information.

The second parameter is an AkSoundPosition structure that contains vectors representing the position and orientation of the game object. Refer to X-Y-Z Coordinate System for information regarding how the X, Y, and Z axes are defined in the Wwise sound engine.

Note.gif
Note: Each 3D Position can be applied at most once per frame. That means that even if you call the AK::SoundEngine::SetPosition() function multiple times and then call the AK::SoundEngine::RenderAudio() function, only the last value will be considered.
Tip.gif
Tip: Sounds set as 2D or 3D–user defined sounds in Wwise do not require a 3D Position. If one is set, the sound will ignore it. Avoid setting useless 3D Positions to game objects that will never use 3D game-defined sounds, and you will save some precious CPU cycles.

Following the Listener Position

In order to mimic a behavior where the game object position could automatically stick to the listener position, you need to explicitly set the game object's position to the same value as the listener position at every frame, or use the tip below.

Tip.gif
Tip: Another way to simulate following the user is to use 2D or 3D user-defined positioning. Because this is defined by the Wwise user, and does not apply in all cases, you should refer to the Wwise documentation for more information. You may also conveniently switch between 2D and 3D positioning using RTPCs.

Setting Multiple Positions for a Single Game Object

Instead of using the method AK::SoundEngine::SetPosition(), which only allows a single 3D position for each game object, you can use the method: AK::SoundEngine::SetMultiplePositions(), which allows you to set multiple 3D positions for a single game object.

AKRESULT AK::SoundEngine::SetMultiplePositions( 
            AkGameObjectID in_GameObjectID,             ///< Game object identifier.
            const AkSoundPosition * in_pPositions,      ///< Array of positions to apply.
            AkUInt16 in_NumPositions,                   ///< Number of positions specified in the provided array.
            MultiPositionType in_eMultiPositionType     ///< \ref AK::SoundEngine::MultiPositionType
            );
);
Note.gif
Note: Every game object must have at least one 3D position.

The MultiPositionType should be carefully selected. The method you choose will depend on the situation and the type of effect your are trying to create.

  • If you use the MultiPositionType_MultiSources() method, the different sound volumes are added, which simulates multiple objects emitting the same sound at the same time. This method can be useful in many different situations, and works well when you have many objects that emit the exact same sound. This method may, however, cause certain issues when the sounds are too close to each other. The problem being that by adding volumes, multiple sounds will be playing exactly in phase, which increases the chance of clipping.
  • If you use the MultiPositionType_MultiDirections() method, the volume played in each speaker is the maximum in each direction. Since the volumes aren't added, the computations used by this method are a little less expensive in terms of CPU. This method can be used to simulate a variety of different situations in game, including wall openings, area sounds, as well as multiple objects emitting the same sound at the same time. If, however, the game player expects the sound to grow louder when two or more objects emitting the sound are in close proximity, then the sounds should be added using the MultiPositionType_MultiSources method.

By creating multiple positions for a single game object, you can simulate a number of different sound effects, including:

- Area sounds

You can simulate area sounds by using the MultiPositionType_MultiDirections() option combined with appropriate values for Spread and distance-based Volume Attenuation. When using this method, you need to make sure that the number of positions does not increase the volume additively. By recreating area sounds using this method, you can have a single sound coming from multiple directions with realistic attenuation.

In the following example, the black dots represent the initial position of sounds, the black circles represent the minimum distance for attenuation and spreading, and the pink circles represent the maximum radius:

AreaSound.gif

Figure: Sample of Area Sound with Multiple Positions

The blue region represents a lake in your game. The ambience sounds emanating from the lake are simulated using a sound with four positions.

When the listener is at position A, the sound of the lake should come from all directions. This can be achieved by setting an appropriately high spread value, which diffuses the sounds so that they play back in all speakers.

When the Listener is at position B, they are beyond the maximum attenuation distance. This means that they will either hear no lake sounds or they will hear only a faint sound at its maximum attenuation. Because you are using multiple positions to simulate a large lake, the sound will always comes from the appropriate direction.

When the listener is at position C, they will hear the lake from a wide angle of speakers (~180 degrees), but the sounds will be attenuated because the listener is a certain distance away from the lake. In this situation, the listener is still within the attenuation radius, so the lake sounds will not be attenuated to their maximum levels.

By using this technique, you can recreate any kind of object shape by overlapping multiple sound positions. Keep in mind, however, that with each new position added, more CPU is required to calculate the resulting volumes.

- Multiple objects emitting the same sound in the same area.

Let's say, for example, that in one of your levels, the corridors are all lit by a series of torches on the walls. These torches are all the same and will play the exact same sound. If you post a play event for each of them separately (supposing there are 20 of them), it would consume significantly more CPU and memory. Also, if the sound is being streamed, you may potentially have multiple duplicated streams, which can increase I/O access.

In this situation, using SetMultiplePositions() would greatly improve performance. It also allows you to easily control all sounds in one operation, and reduces the number of game objects that need to be registered.

When creating this scenario in game, you can use either of the two methods: MultiPositionType_MultiSources() or MultiPositionType_MultiDirections().

MultiPositionType_MultiSources() will usually be more accurate, but may be problematic if positions are too close to one another. Remember that when only one voice is played to simulate multiple sounds, Wwise adds the volumes of the different positions, which may result in the volume going over 0 dB. MultiPositionType_MultiDirections() uses a bit less CPU, and simply takes the maximum volume and plays it through each speaker. Since MultiPositionType_MultiDirections() does not add the volumes, it guarantees that there will be no clipping and, therefore, may be more suitable.

Despite there being multiple positions for a sound, there is still only one voice played by the sound engine. This means that when all sounds are out of range, only one virtual voice will be processed.

- Simulating sounds coming from openings (Sound Relocalization)

When sounds are partially obstructed and/or occluded, they may appear to come from different directions than where they are actually located. In these cases, you can position the sound in multiple locations to create the effect that you want.

For example, let's say that the direct path of a sound is blocked by a building - see the following illustration. Instead of using the real position of object A, it would sound more realistic to use the two alternate positions: A' and A''. When doing so, use SetObjectObstructionAndOcclusion() and the same occlusion and obstruction parameters will apply to all positions, or use SetMultipleObstructionAndOcclusion() and specify a unique occlusion and obstruction value for each sound position.

Buildings.gif

Figure: Relocating a sound using two alternate positions

This approach also works well when simulating environments that have been destroyed, and sounds are coming from a number of arbitrary positions. When re-localizing sounds, it is better to use the MultiPositionType_MultiDirections() method.

X-Y-Z Coordinate System

The X, Y and Z axes are defined as follows in the Wwise sound engine:

  • X: Vector that points to the right
  • Y: Vector that points up
  • Z: Vector that points forward.
PositioningAxis.gif

Direction of the X, Y and Z Axes in the Wwise Sound Engine.

Caution.gif
Caution: Be sure to pass position and orientation vectors using the correct X-Y-Z convention. If your game engine uses a different coordinate system, coordinates will need to be converted prior to passing them to methods such as AK::SoundEngine::SetPosition().

For an example of integrating 3D positions, refer to 3D Position Example.

See also:

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise