Skip to content

🔊 AUDIO#

Note

ANTIRUINS supports various audio formats for different use cases.

Audio Type#

ANTIRUINS supports the following audio types:

audio.SFX#

Used for short sound samples, one shots, etc. The sound is loaded directly in memory.
Must be a .wav file under 65k samples. Can be any sample rate between 8khz and 41 kHz, stero or mono.

audio.WAV#

Used for audio streaming. Must be a .wav file.

audio.CDDA#

Used for CDDA audio streaming. Must be a 16-bit 44100 kHz .wav file.

Note

CDDA files must be places in the music folder. You need to add them to the config.lua file.

Source#

local source = {
  loaded    = false,
  id        = 0,
  channel   = -1,
  volume    = 220, -- 0 to 254
  isPlaying = false,
  type      = audio.SFX,
}

function audio.load(filename, type)
Loads a .wav file. Returns a source.
Type must be audio.SFX, audio.WAV, or audio.CDDA.


function audio.play(source, volume, loop)
Plays a source.
OPTIONAL: If volume is set, it will override the source volume.
OPTIONAL: If loop is true, the audio will loop.


function audio.setVolume(source, volume)
Sets the volume of a playing source.


function audio.free(source)
Frees the memory of a loaded source.


function audio.isPlaying(source)
Returns true if the source is currently playing.


function audio.pause(source)
Pauses the playback of a source.


function audio.stop(source)
Stops the playback of a source.


function audio.setPan(source, pan)
Sets the pan. 128 is center, 0 is full left, 255 is full right.
Only works on SFX type sound.