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.
Initialize
Initializes ILocalSpatialAudioEngine.
public abstract int Initialize();
- You must call this method to initialize ILocalSpatialAudioEngine before calling any other method of the ILocalSpatialAudioEngine class.
- The SDK supports creating only one ILocalSpatialAudioEngine instance per app.
Return Values
- 0: Success.
- < 0: Failure. See Error Codes for details and resolution suggestions.
Dispose
Destroys ILocalSpatialAudioEngine.
public abstract void Dispose();
This method releases all resources under ILocalSpatialAudioEngine. When the user no longer needs spatial audio, you can call this method to release the resources for other operations. After calling this method, you can no longer use any API under ILocalSpatialAudioEngine. To use spatial audio again, you need to call Initialize to create a new ILocalSpatialAudioEngine after Dispose completes.
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
attenuationto set the user's sound attenuation effect. In this case, theaudioAttenuationcoefficient set in SpatialAudioZone does not apply to the user. - false: Do not forcefully use
attenuationto 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
audioAttenuationin 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
attenuationin this method.
- If the sound source and listener are inside and outside the isolation zone respectively, the sound attenuation effect is determined by the
- true: Forcefully use
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.
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.