Audio¶
The Audio class enables loading and playing sound effects (SE) or background
music (BGM) tracks.
Synopsis¶
Constructor¶
Static Methods¶
Audio.bgm_play(path[, options])Audio.bgm_playing()Audio.bgm_stop()Audio.bgm_pause()Audio.bgm_resume()
Instance Methods¶
Constructor¶
Audio(path, [streaming])¶
Loads an audio resource from the specified path as a sound effect.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | The path to the audio asset. |
streaming |
bool |
No | If true, the file is streamed from disk rather than fully loaded into memory. Default is false. |
Static Methods¶
Audio.bgm_play(path[, options])¶
Loads and plays an audio file as background music. BGM tracks are automatically streamed.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | Path to the music file. |
options |
table |
No | Advanced playback modifiers (see Play Options). |
Audio.bgm_playing()¶
Checks whether background music is currently active.
- Returns:
bool:trueif background music is playing,falseotherwise.
Audio.bgm_stop()¶
Stops the currently playing background music.
Audio.bgm_pause()¶
Pauses the currently playing background music.
Audio.bgm_resume()¶
Resumes the currently paused background music.
Instance Methods¶
audio.play([options])¶
Plays a previously loaded sound effect.
Play Options Table¶
| Field | Type | Default | Description |
|---|---|---|---|
loops |
int |
0 |
Additional loops to play (-1 for infinite). |
pan |
float |
0.0 |
Stereo panning (-1.0 Left, 0.0 Center, 1.0 Right). |
pitch |
float |
1.0 |
Playback pitch modifier. |
position |
int |
0 |
Starting position in milliseconds. |
volume |
float |
1.0 |
Playback volume multiplier. |