Teek::SDL2::Sound Class
A short audio sample loaded from a WAV file.
Sound wraps SDL2_mixer’s Mix_Chunk for fire-and-forget playback of sound effects. The audio mixer is initialized automatically on first use.
Inherits: Object
Instance Methods ↑
initialize(path)
Load a sound effect from a file. Initializes the audio mixer automatically.
Parameters
pathString— path to a WAV, OGG, or other supported audio file
play(volume: nil, loops: 0, fade_ms: 0)
Play the sound on the next available channel.
Parameters
volumeInteger, nil— playback volume (0–128, nil = current)loopsInteger— 0 = play once, N = play N extra times, -1 = loop foreverfade_msInteger— fade-in duration in milliseconds (0 = no fade)
Returns Integer — channel number used (pass to SDL2.halt to stop)