ILocalSpatialAudioEngine

This class implements spatial audio by calculating user coordinates through the SDK.

Before calling other APIs in this class, you need to call the Initialize method to initialize the class.

ClearRemotePositions

Deletes the spatial position information of all remote users.

public abstract int ClearRemotePositions();

After this method is successfully called, the local user will no longer hear any remote users. After leaving the channel, to avoid wasting computing resources, you can also call this method to delete the spatial position information of all remote users.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

RemoveRemotePosition

Deletes the spatial position information of a specified remote user.

public abstract int RemoveRemotePosition(uint uid);

After this method is successfully called, the local user will no longer hear the specified remote user. After leaving the channel, to avoid wasting computing resources, you need to call this method to delete the spatial position information of the specified remote user. Otherwise, the spatial position information of that user will be retained. When the number of remote users exceeds the maximum number of audio streams set by SetMaxAudioRecvCount, the SDK will automatically stop subscribing to the audio streams of the farthest users based on relative distance.

Parameters

uid
User ID. Must be the same as the ID used when the user joined the channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetRemoteAudioAttenuation

Sets the sound attenuation effect for a specified user.

public abstract int SetRemoteAudioAttenuation(uint uid, double attenuation, bool forceSet);

Parameters

uid
User ID. Must match the user ID used when joining the channel.
attenuation
Sound attenuation coefficient for the specified user, value range [0,1].
forceSet
Whether to forcefully apply the sound attenuation effect for the user:
  • true: Forcefully use attenuation to set the user's sound attenuation effect. In this case, the audioAttenuation coefficient set in SpatialAudioZone does not apply to the user.
  • false: Do not forcefully use attenuation to set the user's sound attenuation effect. There are two cases:
    • If the sound source and listener are inside and outside the isolation zone respectively, the sound attenuation effect is determined by the audioAttenuation in SpatialAudioZone.
    • If the sound source and listener are both inside the same isolation zone or both outside, the sound attenuation effect is determined by the attenuation in this method.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UpdateRemotePosition

Updates the spatial position information of a remote user.

public abstract int UpdateRemotePosition(uint uid, RemoteVoicePositionInfo posInfo);

After this method is successfully called, the SDK calculates spatial audio parameters based on the relative position between the local and remote users.

Note: You must call this method after JoinChannel [2/2].

Parameters

uid
User ID. Must be the same as the ID used when the user joined the channel.
posInfo
The spatial position information of the remote user. See RemoteVoicePositionInfo.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.