32 Star 227 Fork 40

GVPI++俱乐部/Dora-SSR

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
AudioSource.mdx 5.55 KB
一键复制 编辑 原始数据 按行查看 历史
Li Jin 提交于 2025-07-07 18:11 +08:00 . Updated docs. [skip CI]
# AudioSource
**Description:**
  A record that represents an audio source.
**Class Object:** [AudioSource Class](/docs/api/Class%20Object/AudioSource).
**Inherits from:** [Node](/docs/api/Class/Node).
## AudioSource.AttenuationModel
**Type:** Enumeration.
**Description:**
  The model of the attenuation.
**Signature:**
```tl
enum AttenuationModel
"NoAttenuation"
"InverseDistance"
"LinearDistance"
"ExponentialDistance"
end
```
## volume
**Type:** Field.
**Description:**
  The volume of the audio source. The value is between 0.0 and 1.0.
**Signature:**
```tl
volume: number
```
## pan
**Type:** Field.
**Description:**
  The pan of the audio source. The value is between -1.0 and 1.0.
**Signature:**
```tl
pan: number
```
## looping
**Type:** Field.
**Description:**
  Whether the audio source is looped.
**Signature:**
```tl
looping: boolean
```
## playing
**Type:** Field.
**Description:**
  Whether the audio source is playing.
**Signature:**
```tl
playing: boolean
```
## seek
**Type:** Function.
**Description:**
  Seeks to the specified time in the audio source.
**Signature:**
```tl
seek: function(self: AudioSource, startTime: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| startTime | number | The time to seek to. |
## scheduleStop
**Type:** Function.
**Description:**
  Schedules the stop of the audio source.
**Signature:**
```tl
scheduleStop: function(self: AudioSource, timeToStop: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| timeToStop | number | The time to stop the audio source. |
## stop
**Type:** Function.
**Description:**
  Stops the audio source.
**Signature:**
```tl
stop: function(self: AudioSource, fadeTime?: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| fadeTime | number | The time to fade the audio source. Default is 0 seconds. |
## play
**Type:** Function.
**Description:**
  Plays the audio source.
**Signature:**
```tl
play: function(self: AudioSource, delayTime?: number): boolean
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| delayTime | number | [optional] The time to delay before playing the audio source. Default is 0 seconds. |
**Returns:**
| Return Type | Description |
| --- | --- |
| boolean | Whether the audio source was played successfully. |
## playBackground
**Type:** Function.
**Description:**
  Plays the audio source as a background audio.
**Signature:**
```tl
playBackground: function(self: AudioSource): boolean
```
**Returns:**
| Return Type | Description |
| --- | --- |
| boolean | Whether the audio source was played successfully. |
## play3D
**Type:** Function.
**Description:**
  Plays the audio source as a 3D audio.
**Signature:**
```tl
play3D: function(self: AudioSource, delayTime?: number): boolean
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| delayTime | number | [optional] The time to delay before playing the audio source. Default is 0 seconds. |
**Returns:**
| Return Type | Description |
| --- | --- |
| boolean | Whether the audio source was played successfully. |
## setProtected
**Type:** Function.
**Description:**
  Sets the protected state of the audio source. If the audio source is protected, it won't get stopped if we run out of voices.
**Signature:**
```tl
setProtected: function(self: AudioSource, var: boolean)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| var | boolean | The protected state to set. |
## setLoopPoint
**Type:** Function.
**Description:**
  Sets the loop point of the audio source. The audio source will loop from the specified time to the end of the audio.
**Signature:**
```tl
setLoopPoint: function(self: AudioSource, loopStartTime: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| loopStartTime | number | The time to loop the audio source. |
## setVelocity
**Type:** Function.
**Description:**
  Sets the velocity of the 3D audio source.
**Signature:**
```tl
setVelocity: function(self: AudioSource, vx: number, vy: number, vz: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| vx | number | The x-axis velocity. |
| vy | number | The y-axis velocity. |
| vz | number | The z-axis velocity. |
## setMinMaxDistance
**Type:** Function.
**Description:**
  Sets the minimum and maximum distance of the 3D audio source.
**Signature:**
```tl
setMinMaxDistance: function(self: AudioSource, min: number, max: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| min | number | The minimum distance. |
| max | number | The maximum distance. |
## setAttenuation
**Type:** Function.
**Description:**
  Sets the attenuation model of the 3D audio source.
**Signature:**
```tl
setAttenuation: function(self: AudioSource, model: AttenuationModel, factor: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| model | AttenuationModel | The model of the attenuation. |
| factor | number | The factor of the attenuation. |
## setDopplerFactor
**Type:** Function.
**Description:**
  Sets the Doppler factor of the 3D audio source.
**Signature:**
```tl
setDopplerFactor: function(self: AudioSource, factor: number)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| factor | number | The factor of the Doppler effect. |
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/ippclub/Dora-SSR.git
git@gitee.com:ippclub/Dora-SSR.git
ippclub
Dora-SSR
Dora-SSR
main

搜索帮助