SpatialSound QML Type
三维空间中的声音对象。更多
| 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 。音量在距离小于尺寸时保持不变,在距离大于截止距离时为零。
| 属性值 | 说明 |
|---|---|
| 对数 | 音量随距离呈对数递减。 |
| 线性 | 体积随距离线性减小。 |
| 手动衰减 | 使用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.