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.
virtual int clearRemotePositions() = 0;
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.
virtual int initialize(const LocalSpatialAudioConfig& config) = 0;
Details
- Call this method after calling queryInterface
(AGORA_IID_LOCAL_SPATIAL_AUDIO)
. - 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.
removeRemotePosition
Removes the spatial position of the specified remote user.
virtual int removeRemotePosition(uid_t uid) = 0;
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.
virtual int updateRemotePosition(uid_t uid, const RemoteVoicePositionInfo &posInfo) = 0;
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.