Package io.agora.spatialaudio
Class IBaseSpatialAudioEngine
java.lang.Object
io.agora.spatialaudio.IBaseSpatialAudioEngine
- Direct Known Subclasses:
ILocalSpatialAudioEngine
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intabstract intmuteAllRemoteAudioStreams(boolean mute) abstract intmuteLocalAudioStream(boolean mute) abstract intmuteRemoteAudioStream(int uid, boolean mute) abstract intsetAudioRecvRange(float range) abstract intsetDistanceUnit(float unit) abstract intsetMaxAudioRecvCount(int maxCount) abstract intsetPlayerAttenuation(int playerId, double attenuation, boolean forceSet) abstract intsetZones(SpatialAudioZone[] zones) abstract intupdatePlayerPositionInfo(int playerId, RemoteVoicePositionInfo positionInfo) abstract intupdateSelfPosition(float[] position, float[] axisForward, float[] axisRight, float[] axisUp) abstract intupdateSelfPositionEx(float[] position, float[] axisForward, float[] axisRight, float[] axisUp, RtcConnection connection)
-
Constructor Details
-
IBaseSpatialAudioEngine
public IBaseSpatialAudioEngine()
-
-
Method Details
-
setMaxAudioRecvCount
public abstract int setMaxAudioRecvCount(int maxCount) - Parameters:
maxCount- The maximum number of streams that a user can receive within a specified audio reception range. The value of this parameter should be ≤ 16, and the default value is 10.- Returns:
- - 0: Success. - < 0: Failure.
-
setAudioRecvRange
public abstract int setAudioRecvRange(float range) - Parameters:
range- The maximum audio reception range. The unit is meters. The value of this parameter must be greater than 0, and the default value is 20.- Returns:
- - 0: Success. - < 0: Failure.
-
setDistanceUnit
public abstract int setDistanceUnit(float unit) - Parameters:
unit- The number of meters that the game engine distance per unit is equal to. The value of this parameter must be greater than 0.00, and the default value is 1.00. For example, setting unit as 2.00 means the game engine distance per unit equals 2 meters.The larger the value is, the faster the sound heard by the local user attenuates when the remote user moves far away from the local user.- Returns:
- - 0: Success. - < 0: Failure.
-
updateSelfPosition
public abstract int updateSelfPosition(float[] position, float[] axisForward, float[] axisRight, float[] axisUp) - Parameters:
position- The coordinates in the world coordinate system. This parameter is an array of length 3, and the three values represent the front, right, and top coordinates in turn.axisForward- The unit vector of the x axis in the coordinate system. This parameter is an array of length 3, and the three values represent the front, right, and top coordinates in turn.axisRight- The unit vector of the y axis in the coordinate system. This parameter is an array of length 3, and the three values represent the front, right, and top coordinates in turn.axisUp- The unit vector of the z axis in the coordinate system. This parameter is an array of length 3, and the three values represent the front, right, and top coordinates in turn.- Returns:
- - 0: Success. - < 0: Failure.
-
updatePlayerPositionInfo
- Parameters:
playerId- The ID of the media player. You can get the Device ID by calling `getMediaPlayerId`.positionInfo- The spatial position of the media player. See `RemoteVoicePositionInfo`.- Returns:
- - 0: Success. - < 0: Failure.
-
muteLocalAudioStream
public abstract int muteLocalAudioStream(boolean mute) - Parameters:
mute- Whether to stop publishing the local audio stream: - `true`: Stop publishing the local audio stream. - `false`: Publish the local audio stream.- Returns:
- - 0: Success. - < 0: Failure.
-
muteAllRemoteAudioStreams
public abstract int muteAllRemoteAudioStreams(boolean mute) - Parameters:
mute- Whether to stop subscribing to the audio streams of all remote users: - `true`: Stop subscribing to the audio streams of all remote users. - `false`: Subscribe to the audio streams of all remote users.- Returns:
- - 0: Success. - < 0: Failure.
-
setZones
- Parameters:
zones- Sound insulation area settings. See `SpatialAudioZone`. When you set this parameter to `NULL`, it means clearing all sound insulation zones.- Returns:
- - 0: Success. - < 0: Failure.
-
setPlayerAttenuation
public abstract int setPlayerAttenuation(int playerId, double attenuation, boolean forceSet) - Parameters:
playerId- The ID of the media player. You can get the Device ID by calling `getMediaPlayerId`.attenuation- The sound attenuation coefficient of the remote user or media player. The value range is [0,1]. The values are as follows: - 0: Broadcast mode, where the volume and timbre are not attenuated with distance, and the volume and timbre heard by local users do not change regardless of distance. - (0,0.5): Weak attenuation mode, that is, the volume and timbre are only weakly attenuated during the propagation process, and the sound can travel farther than the real environment. - 0.5: (Default) simulates the attenuation of the volume in the real environment; the effect is equivalent to not setting the `speaker_attenuation` parameter. - (0.5,1]: Strong attenuation mode, that is, the volume and timbre attenuate rapidly during the propagation process.forceSet- Whether to force the sound attenuation effect of the media player: - `true`: Force `attenuation` to set the attenuation of the media player. At this time, the attenuation coefficient of the sound insulation are set in the `audioAttenuation` in the `SpatialAudioZone` does not take effect for the media player. - `false`: Do not force `attenuation` to set the sound attenuation effect of the media player, as shown in the following two cases. - If the sound source and listener are inside and outside the sound isolation area, the sound attenuation effect is determined by the `audioAttenuation` in `SpatialAudioZone`. - If the sound source and the listener are in the same sound insulation area or outside the same sound insulation area, the sound attenuation effect is determined by `attenuation` in this method.- Returns:
- - 0: Success. - < 0: Failure.
-
muteRemoteAudioStream
public abstract int muteRemoteAudioStream(int uid, boolean mute) -
updateSelfPositionEx
public abstract int updateSelfPositionEx(float[] position, float[] axisForward, float[] axisRight, float[] axisUp, RtcConnection connection) -
clearRemotePositions
public abstract int clearRemotePositions()- Returns:
- - 0: Success. - < 0: Failure.
-