Naev

Module audio

Lua bindings to interact with audio.

Functions

__gc (audio) Frees a audio.
__eq (a1, a2) Compares two audios to see if they are the same.
new (data) Creates a new audio source.
play (source) Plays a source.
pause (source) Pauses a source.
isPaused (source) Checks to see if a source is paused.
stop (source) Stops a source.
isStopped (source) Checks to see if a source is stopped.
rewind (source) Rewinds a source.
seek (source, offset[, unit="seconds"]) Seeks a source.
tell (source[, unit="seconds"]) Gets the position of a source.
setVolume (source, vol) Sets the volume of a source.
getVolume (source) Gets the volume of a source.
setLooping (source, enable) Sets a source to be looping or not.
isLooping (source) Gets the looping state of a source.
setPitch (source, pitch) Sets the pitch of a source.
getPitch (source) Gets the pitch of a source.
soundPlay (s[, pos[, vel]]) Plays a sound.


Functions

__gc (audio)
Frees a audio.

Parameters:

  • audio Audio Audio to free.
__eq (a1, a2)
Compares two audios to see if they are the same.

Parameters:

  • a1 Audio Audio 1 to compare.
  • a2 Audio Audio 2 to compare.

Returns:

    boolean true if both audios are the same.
new (data)
Creates a new audio source.

Parameters:

  • data string or File Data to load the audio from.

Returns:

    Audio New audio corresponding to the data.
play (source)
Plays a source.

Parameters:

  • source Audio Source to play.

Returns:

    boolean True on success.
pause (source)
Pauses a source.

Parameters:

  • source Audio Source to pause.

Returns:

    boolean True on success.
isPaused (source)
Checks to see if a source is paused.

Parameters:

  • source Audio Source to check to see if is paused.

Returns:

    boolean Whether or not the source is paused.
stop (source)
Stops a source.

Parameters:

  • source Audio Source to stop.
isStopped (source)
Checks to see if a source is stopped.

Parameters:

  • source Audio Source to check to see if is stopped.

Returns:

    boolean Whether or not the source is stopped.
rewind (source)
Rewinds a source.

Parameters:

  • source Audio Source to rewind.
seek (source, offset[, unit="seconds"])
Seeks a source.

Parameters:

  • source Audio Source to seek.
  • offset number Offset to seek to.
  • unit string Either "seconds" or "samples" indicating the type to seek to. (default "seconds")
tell (source[, unit="seconds"])
Gets the position of a source.

Parameters:

  • source Audio Source to get position of.
  • unit string Either "seconds" or "samples" indicating the type to report. (default "seconds")

Returns:

    number Offset of the source or -1 on error.
setVolume (source, vol)
Sets the volume of a source.

Parameters:

  • source Audio Source to set volume of.
  • vol number Volume to set the source to.
getVolume (source)
Gets the volume of a source.

Parameters:

  • source Audio Source to get volume of.

Returns:

    number Volume the source is set to.
setLooping (source, enable)
Sets a source to be looping or not.

Parameters:

  • source Audio Source to set looping state of.
  • enable boolean Whether or not the source should be set to looping.
isLooping (source)
Gets the looping state of a source.

Parameters:

  • source Audio Source to get looping state of.

Returns:

    boolean Whether or not the source is looping.
setPitch (source, pitch)
Sets the pitch of a source.

Parameters:

  • source Audio Source to set pitch of.
  • pitch number Pitch to set the source to.
getPitch (source)
Gets the pitch of a source.

Parameters:

  • source Audio Source to get pitch of.

Returns:

    number Pitch of the source.
soundPlay (s[, pos[, vel]])
Plays a sound.

by default, the sound is played at player's current position

Parameters:

  • s string Name of the sound to play
  • pos Vec2 Position of the source (optional)
  • vel Vec2 Velocity of the source (optional)

Usage:

  • audio.soundPlay( "hail" ) -- Plays the hail sound
  • audio.soundPlay( "hail", pos ) -- Plays the hail sound at position pos
  • audio.soundPlay( "hail", pos, vel ) -- Plays the hail sound at position pos with velocity vel
generated by LDoc 1.4.6 Last updated 2021-04-18 17:10:51