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();
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.
create
Creates ILocalSpatialAudioEngine.
public static synchronized ILocalSpatialAudioEngine create() { if (mInstance == null) { mInstance = new LocalSpatialAudioImpl(); } return mInstance; }
Details
Call this method before initialize.
Returns
initialize
Initializes ILocalSpatialAudioEngine.
public abstract int initialize(LocalSpatialAudioConfig config);
Details
- 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.
Returns
- 0: Success.
- < 0: Failure.
destroy
Destroys ILocalSpatialAudioEngine.
public static synchronized void destroy() { if (mInstance == null) return; mInstance.release(); mInstance = null; }
Details
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.
removeRemotePosition
Removes the spatial position of the specified remote user.
public abstract int removeRemotePosition(int uid);
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.
public abstract int updateRemotePosition(int uid, RemoteVoicePositionInfo posInfo);
Details
After successfully calling this method, the SDK calculates the spatial audio parameters based on the relative position of the local and 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.
- posInfo
- The spatial position of the remote user. See RemoteVoicePositionInfo.
Returns
- 0: Success.
- < 0: Failure.