Teek API Documentation

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

destroy

Free the underlying audio data. Further method calls will raise.

Returns nil

destroyed?

Whether the sound has been destroyed.

Returns Boolean

initialize(path)

Load a sound effect from a file. Initializes the audio mixer automatically.

Parameters
  • path String — 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
  • volume Integer, nil — playback volume (0–128, nil = current)
  • loops Integer — 0 = play once, N = play N extra times, -1 = loop forever
  • fade_ms Integer — fade-in duration in milliseconds (0 = no fade)

Returns Integer — channel number used (pass to SDL2.halt to stop)

volume

Current volume for this sound.

Returns Integer — 0–128

volume=(vol)

Set the volume for this sound.

Parameters
  • vol Integer — 0–128

Returns Integer