SpatialSound QML Type
3D空间中的声音对象。更多...
| Import Statement: | import QtQuick3D.SpatialAudio |
属性
- autoPlay : bool
- directivity : real
- directivityOrder : real
- distanceCutoff : real
- distanceModel : enumeration
- loops : int
- manualAttenuation : real
- nearFieldGain : real
- occlusionIntensity : real
- size : real
- source : url
- volume : real
方法
详细说明
SpatialSound 表示三维空间中的可听对象。您可以定义其在空间中的位置和方向,设置其播放的声音,并为该对象定义音量。
该对象可以具有不同的衰减行为,主要朝一个方向或球面方向发声,并表现得仿佛被其他对象遮挡一般。
属性文档
autoPlay : bool
确定在指定音源时,声音是否应自动开始播放。
默认值为true 。
directivity : real
定义声源的方向性。值为 0 表示声音向各个方向均匀发射,而值为 1 表示声源主要向正前方发射声音。
有效值范围为 0 到 1,默认值为 0。
directivityOrder : real
定义声源指向性的阶数。阶数越高,声锥的定位越精准。
该属性的最小值和默认值为 1。
distanceCutoff : real
定义了一个距离,超过该距离后,来自声源的声音将被截断。如果听者与声源的距离超过了截断距离,则将无法再听到该声音。
distanceModel : enumeration
定义声音音量随与听众距离的变化而变化的规律。音量从size 开始逐渐降低至distanceCutoff 。当距离小于size时,音量保持恒定;当距离大于截止距离时,音量为零。
| 属性值 | 描述 |
|---|---|
| 对数 | 音量随距离呈对数递减。 |
| 线性 | 体积随距离呈线性递减。 |
| 手动衰减 | 衰减值可通过manualAttenuation 属性手动设定。 |
loops : int
确定播放器停止前声音播放的次数。设置为 SpatialSound::Infinite 可使当前声音无限循环播放。
默认值为1 。
manualAttenuation : real
当distanceModel 设置为SpatialSound 时,定义一个手动衰减因子。ManualAttenuation。
nearFieldGain : real
定义声源的近场增益。有效值范围为 0 到 1。当声源距离听众非常近时,近场增益设为 1 将使声音信号的音量提高约 20 dB。
occlusionIntensity : real
定义了物体被遮挡的程度。0 表示物体完全未被遮挡,而较大的数值则表示遮挡程度较高。
默认值为 0。
size : real
定义声源的大小。如果听者距离声源的距离小于该大小,音量将保持不变。该大小还用于遮挡计算,在遮挡计算中,较大的声源可能会被墙壁部分遮挡。
source : url
要播放的音频的源文件。
volume : real
定义该声源的整体音量。
0 到 1 之间的值会降低音量,而大于 1 的值则会提供额外的增益提升。
方法文档
void pause()
暂停当前位置的音频播放。调用play() 可继续播放。
void play()
开始播放声音。如果声音正在播放,则不执行任何操作。
void stop()
停止声音播放,并将当前位置和循环计数重置为0。调用play() 将从声音文件的开头开始播放。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.