Agora Gaming SDK Delivers: Spatial Audio Awareness in Xiaomi’s Battle Royale

Xiaomi’s Millet Shootout: Battle Royale is one of the most popular online games in China. In the Wilderness Mode, the game uses Agora Mobile Gaming (AMG) SDK 2.1 to enable live voice chat and true 3D positional audio that would give players a fully immersive in-game experience:

In order to achieve these realistic sound effects, the voice volume is automatically adjusted based on the relative distances between the players. So if a player is positioned next to another player in the game, the sound will be louder. The farther apart two players are, the lower the volume. To achieve the sound effects players experience in-game, Xiaomi uses Agora’s gaming SDK.

Here’s how Xiaomi incorporates Agora’s spatial audio awareness feature into Battle Royale:

Setting the Radius of the Audible Area

The first step in establishing realistic sound features is determining how the distance will determine the volume. Battle Royale game starts with 100 players joining a voice channel where each player is muted by default. The audible area is set within a radius R around the player. If an opponent walks within the area, both players are automatically unmuted and can hear each other. And so the audio experience begins!

Using Head-related Transfer Functions (HRTFs)

Head-related transfer functions, or HRTFs, are used to implement spatial awareness, which is what makes the audio experience truly 3D.HRTFs incorporate these acoustic concepts:

● Interaural time difference (ITD)

This is the time difference between the sounds reaching the left and right ears which enables a player to determine the relative horizontal distance of the low-frequency sound source.

● Interaural level difference (ILD)

The ILD is made up of the volume and frequency differences between the sounds heard by the left and the right ears. This enables the player to determine the direction of the high-frequency sound source.

● Spectral effects

The sounds from different directions are reflected differently by the outer ear structure. These are called spectral effects, which enable the player to determine the relative vertical position of the sound source.

Launch of SpaceX Falcon

The following video of the SpaceX Falcon launch provides a spatial awareness experience.

Launch of SpaceX Falcon

HRTFs process the sound effects based on the mentioned acoustic concepts and create an illusion through the headphones that the sound is coming from a specific location in the virtual space.

To implement HRTFs in Battle Royale, each player is given a unique ID and the coordinates of each player is recorded. The distance between two players is calculated based on their coordinates. As shown in the following figure, the red player is at position (0,0) and the green player is at position (-1,1).

To decide which sound effects they want, developers can take the following steps:

  1. Set the direction of the sound source based on the coordinates.
  2. Choose the volume of the sound based on the relative distance between the players. Assuming the radius of the audible area is 2,the distance between the two players is 1.4. The volume can then be set to 30% of the maximum volume.

Based on the coordinates of different players, the sound volume and delay between the left and the right audio channels can be calculated, providing spatial audio awareness for the 3D gaming experience.

Implementing with One API

The Agora Gaming SDK provides a Set Remote Voice Position API in which developers only need to specify the desired sound direction and volume to integrate HRTFs. See below;

int SetRemoteVoicePosition (uint uid, double pan, double gain);

Three parameters are used in this method:
● uid is the user ID of the remote user.
● pan sets the spatial position of the sound source with a range of [-11]. 0means that the sound source is in front, while -1 means the left, and 1 means the right.
● gain sets the volume of the remote sound effect with a range of [0.0100.0]. The default value is 100.0. The smaller the value, the lower the volume of the sound effect.

The SetRemoteVoicePosition API uses pan to set the spatial position of the sound source and gain to change the volume of each sound effect to determine the position of the sound.

The Results

Xiaomi is setting the bar for audio effects in gaming by giving players a truly realistic experience. Along with its stunning visual graphics, Millet Shootout: Battle Royale spatial audio awareness capabilities separate it from a sea of mobile games on the market. Agora’s gaming SDK was easily integrated into the game’s existing infrastructure, giving Xiaomi the ability to implement new features and take the gameplay to the next level.

To download AMG SDK 2.1 and get more information on documentation, please visit https://docs.agora.io. Other questions, please contact us.