AgoraLocalSpatialAudioKit

This class calculates user positions through the SDK to implement the spatial audio effect.

This class inherits from AgoraBaseSpatialAudioKit. Before calling other APIs in this class, you need to call the sharedLocalSpatialAudioWithConfig method to initialize this class.

clearRemotePositions

Removes the spatial positions of all remote users.

- (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.

sharedLocalSpatialAudioWithConfig

Initializes AgoraLocalSpatialAudioKit.

+ (instancetype _Nonnull)sharedLocalSpatialAudioWithConfig:(AgoraLocalSpatialAudioConfig* _Nonnull)config;

Details

Note:
  • Before calling other methods of the AgoraLocalSpatialAudioKit class, you need to call this method to initialize AgoraLocalSpatialAudioKit.
  • The SDK supports creating only one AgoraLocalSpatialAudioKit instance for an app.

Parameters

config
The configuration of AgoraLocalSpatialAudioKit. See AgoraLocalSpatialAudioConfig.

Returns

  • 0: Success.
  • < 0: Failure.

destroy

Destroys AgoraLocalSpatialAudioKit.

+ (void)destroy;

Details

This method releases all resources under AgoraLocalSpatialAudioKit. When the user does not need to use the spatial audio effect, you can call this method to release resources for other operations.

After calling this method, you can no longer use any of the APIs under AgoraLocalSpatialAudioKit. To use the spatial audio effect again, you need to wait until the destroy method execution to complete before calling sharedLocalSpatialAudioWithConfig to create a new AgoraLocalSpatialAudioKit.
Note: Call this method before the destroy method under AgoraRtcEngineKit.

removeRemotePosition

Removes the spatial position of the specified remote user.

- (int) removeRemotePosition:(NSUInteger)uid;

Details

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

After leaving the channel, to avoid wasting resources, you can also call this method to delete the spatial position of the specified 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.

Returns

  • 0: Success.
  • < 0: Failure.

updateRemotePosition

Updates the spatial position of the specified remote user.

- (int)updateRemotePosition:(NSUInteger)uid positionInfo:(AgoraRemoteVoicePositionInfo* _Nonnull)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.

Note: Call this method after joinChannelByToken [2/4].

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 AgoraRemoteVoicePositionInfo.

Returns

  • 0: Success.
  • < 0: Failure.