ILocalSpatialAudioEngine

This class calculates user positions through the SDK to implement the spatial audio effect.

This class inherits from IBaseSpatialAudioEngine. Before calling other APIs in this class, you need to call the initialize method to initialize this class.

clearRemotePositions

Removes the spatial positions of all remote users.

public abstract int clearRemotePositions();

After successfully calling this method, the local user no longer hears any remote users.

After leaving the channel, to avoid wasting resources, you can also call this method to delete the spatial positions of all remote users.

Returns

  • 0: Success.
  • < 0: Failure.

initialize

Initializes ILocalSpatialAudioEngine.

public abstract int initialize(LocalSpatialAudioConfig config);
Note:
  • Call this method after calling create.
  • Before calling other methods of the ILocalSpatialAudioEngine class, you need to call this method to initialize ILocalSpatialAudioEngine.
  • The SDK supports creating only one ILocalSpatialAudioEngine instance for an app.

Parameters

config
The configuration of ILocalSpatialAudioEngine. See LocalSpatialAudioConfig for details.

Returns

  • 0: Success.
  • < 0: Failure.

destroy

Destroys ILocalSpatialAudioEngine.

public static synchronized void destroy() {
  if (mInstance == null)
    return;
  mInstance.release();
  mInstance = null;
}

This method releases all resources under ILocalSpatialAudioEngine. When the user does not need to use the spatial audio effect, you can call this method to release resources for other operations.

After calling this method, you can no longer use any of the APIs under ILocalSpatialAudioEngine. To use the spatial audio effect again, you need to wait until the destroy method execution to complete before calling initialize to create a new ILocalSpatialAudioEngine.
Note: Call this method before the destroy method under RtcEngine.

removeRemotePosition

Removes the spatial position of the specified remote user.

public abstract int removeRemotePosition(int uid);

After successfully calling this method, the local user no longer hears the specified remote user.

After leaving the channel, to avoid wasting resources, you can also call this method to delete the spatial position of the specified remote user.

Parameters

uid
The user ID. This parameter must be the same as the user ID passed in when the user joined the channel.

Returns

  • 0: Success.
  • < 0: Failure.

updateRemotePosition

Updates the spatial position of the specified remote user.

public abstract int updateRemotePosition(int uid, RemoteVoicePositionInfo posInfo);

After successfully calling this method, the SDK calculates the spatial audio parameters based on the relative position of the local and remote user.

Note: Call this method after joinChannel [2/2].

Parameters

uid
The user ID. This parameter must be the same as the user ID passed in when the user joined the channel.
posInfo
The spatial position of the remote user. See RemoteVoicePositionInfo.

Returns

  • 0: Success.
  • < 0: Failure.