Documentation ¶
Overview ¶
Package sound manages music and sound effects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // If enabled is false, all sound functions are no-ops. Enabled bool // Root folder on disk where sound and music files should live. SoundRoot = filepath.Join("rtp", "sfx") MusicRoot = filepath.Join("rtp", "music") )
Package globals.
var ( // Supported file extensions, in preference order. SupportedSoundExtensions = []string{ ".wav", ".ogg", ".mp3", } )
SDL engine globals.
Functions ¶
func LoadMusic ¶
LoadMusic loads filename from the MusicRoot into the global music cache. If the music is already loaded, does nothing.
func LoadSound ¶
LoadSound loads filename from the SoundRoot into the global SFX cache. If the sound is already loaded, does nothing.
func PlaySound ¶
func PlaySound(filename string)
PlaySound plays the named sound. It will de-duplicate if the same sound is already playing.
func PreloadAll ¶
func PreloadAll()
PreloadAll looks in the SoundRoot and MusicRoot folders and preloads all supported files into the caches.
func ResolveFilename ¶
ResolveFilename resolves the filename to a sound file on disk.
Ogg has been found more reliable than MP3 for cross-platform distribution. A doodad might request a "sound.mp3" but the filename on disk is actually "sound.ogg" and this function will return the latter, if "sound.mp3" does not exist.
If the exact filename does exist, it is returned; otherwise a preference order of WAV > OGG > MP3 will be tried and returned if those versions exist.
Returns the full path on disk (e.g. "rtp/sfx/sound.ogg")
Types ¶
This section is empty.