Module bank_sounds
Opens, tracks, and closes sound resources by file path.
Info:
- Author: Sharper Dev
Functions
| SoundsBank.loadSound (format, useStreaming, path) | Opens a WAV or OGG file unless its path is already loaded. |
| SoundsBank.getLoadedSounds () | Returns the table of loaded sound entries, keyed by file path. |
| SoundsBank.cleanup () | Closes every loaded sound and clears the cache. |
| SoundsBank.unloadSound (path) | Pauses a playing sound, closes it, and removes it from the cache. |
Functions
- SoundsBank.loadSound (format, useStreaming, path)
-
Opens a WAV or OGG file unless its path is already loaded.
This function does not return the sound handle; use getLoadedSounds to access the entry.
Parameters:
- format
string File format:
"wav"or"ogg". - useStreaming boolean Whether to open the sound in streaming mode.
- path string Path to the sound file; also used as its cache key.
Usage:
SoundsBank.loadSound("wav", false, "romfs:/sounds/effect.wav")
- format
string File format:
- SoundsBank.getLoadedSounds ()
-
Returns the table of loaded sound entries, keyed by file path.
Returns:
-
table Loaded sounds; each entry contains
format,wav_id, andpath.Usage:
local sounds = SoundsBank.getLoadedSounds()
- SoundsBank.cleanup ()
-
Closes every loaded sound and clears the cache.
Usage:
SoundsBank.cleanup() - SoundsBank.unloadSound (path)
-
Pauses a playing sound, closes it, and removes it from the cache.
Does nothing if the path is not loaded.
Parameters:
- path string Path used to load the sound.
Usage:
SoundsBank.unloadSound("sounds/background.wav")