SpatialAudioParams
Spatial audio parameters.
export class SpatialAudioParams {
speaker_azimuth?: number;
speaker_elevation?: number;
speaker_distance?: number;
speaker_orientation?: number;
enable_blur?: boolean;
enable_air_absorb?: boolean;
speaker_attenuation?: number;
enable_doppler?: boolean;
}
Properties
- speaker_azimuth
- The horizontal angle of the remote user or media player relative to the local user. Value range: [0,360] degrees. Where:
- 0: (default) 0 degrees, directly in front on the horizontal plane.
- 90: 90 degrees, directly to the left.
- 180: 180 degrees, directly behind.
- 270: 270 degrees, directly to the right.
- 360: 360 degrees, same as 0 degrees.
- speaker_elevation
- The elevation angle of the remote user or media player relative to the local user. Value range: [-90,90] degrees. Where:
- 0: (default) 0 degrees, no vertical rotation.
- -90: -90 degrees, rotated 90 degrees downward.
- 90: 90 degrees, rotated 90 degrees upward.
- speaker_distance
- The distance of the remote user or media player relative to the local user. Value range: [1,50] meters. Default is 1 meter.
- speaker_orientation
- The orientation of the remote user or media player relative to the local user. Value range: [0,180] degrees. Where:
- 0: (default) 0 degrees, both source and listener face the same direction.
- 180: 180 degrees, source and listener face each other.
- enable_blur
- Whether to enable sound blur processing:
- true: Enable blur.
- false: (default) Disable blur.
- enable_air_absorb
- Whether to enable air absorption, simulating the attenuation of sound timbre as it travels through air: at certain distances, high frequencies attenuate faster than low frequencies.
- true: (default) Enable air absorption. Make sure
speaker_attenuationis not0, otherwise this setting has no effect. - false: Disable air absorption.
- true: (default) Enable air absorption. Make sure
- speaker_attenuation
- Sound attenuation coefficient for the remote user or media player, value range [0,1]. Where:
- 0: Broadcast mode, volume and timbre do not attenuate with distance; the local user hears no change regardless of distance.
- (0,0.5): Weak attenuation mode; volume and timbre (requires
enable_air_absorb) attenuate slightly, allowing sound to travel farther than in real environments. - 0.5: (default) Simulates real-world volume attenuation, equivalent to not setting
speaker_attenuation. - (0.5,1]: Strong attenuation mode; volume and timbre (requires
enable_air_absorb) attenuate rapidly.
- enable_doppler
-
Note:Whether to enable Doppler effect: when there is relative movement between the sound source and the receiver, the pitch heard by the receiver changes.
- This parameter is suitable for scenarios with fast-moving sound sources (e.g., racing games). It is not recommended for typical audio/video interaction scenarios (voice chat, co-hosting, online KTV).
- When enabled, it is recommended to set a regular update interval (e.g., 30 ms) and continuously call updatePlayerPositionInfo, updateSelfPosition, and updateRemotePosition to update the relative distance between the source and receiver. The Doppler effect may not work as expected or may cause jitter if: the update interval is too long, the updates are irregular, or packet loss/delay causes distance info loss.
- true: Enable Doppler effect.
- false: (default) Disable Doppler effect.