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:
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: This section discusses positioning at the game object level. For information regarding positioning of listeners, refer to Setting the Listener's Positioning Information. |
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.
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 AkUInt32 in_ulListenerIndex = AK_INVALID_LISTENER_INDEX // If the listener index is valid, the // listener position is used instead of the // game object position. );
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.
The third parameter should be set to AK_INVALID_LISTENER_INDEX when the game object has a real 3D position that is independent from the listener's position. Refer to Following the Listener Position for information on when to use other values for this parameter.
|
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: 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. |
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: 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. Since Wwise 2013.1, you may conveniently switch between 2D and 3D positioning using RTPC. |
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, const AkSoundPosition * in_pPositions, AkUInt16 in_NumPositions, MultiPositionType in_eMultiPositionType ); );
|
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.
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:
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, the same occlusion and obstruction parameters apply to both positions because they are bound to the same object.
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.
The X, Y and Z axes are defined as follows in the Wwise sound engine:
Direction of the X, Y and Z Axes in the Wwise Sound Engine.
|
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::SetListenerPosition() and AK::SoundEngine::SetPosition() . |
For an example of integrating 3D positions, refer to 3D Position Example.