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.

abstract clearRemotePositions(): number;

Details

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.

abstract initialize(): number;

Details

Note:
  • 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.

Returns

  • 0: Success.
  • < 0: Failure.

removeRemotePosition

Removes the spatial position of the specified remote user.

abstract removeRemotePosition(uid: number): number;

Details

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

After leaving the channel, to avoid wasting computing resources, call this method to delete the spatial position information of the specified remote user. Otherwise, the user's spatial position information will be saved continuously. When the number of remote users exceeds the number of audio streams that can be received as set in setMaxAudioRecvCount, the system automatically unsubscribes from the audio stream of the user who is furthest away based on relative distance.

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.

abstract updateRemotePosition(
    uid: number,
    posInfo: RemoteVoicePositionInfo
  ): number;

Details

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 the or joinChannel method.

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.