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.
clone (source) Clones an existing 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.
setRelative (relative) Sets whether a source is relative or not.
setPosition (source, x, y, z) Sets the position of a source.
getPosition (source) Gets the position of a source.
setVelocity (source, x, y, z) Sets the velocity of a source.
getVelocity (source) Gets the velocity 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.
setEffect (name, params) Sets effect stuff, behaves different if the first paramater is a source or not.


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.
clone (source)
Clones an existing audio source.

Parameters:

  • source Audio Audio source to clone.

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.
setRelative (relative)
Sets whether a source is relative or not.

Parameters:

  • relative boolean Whether or not to make the source relative or not.
setPosition (source, x, y, z)
Sets the position of a source.

Parameters:

  • source Audio Source to set position of.
  • x number X position.
  • y number Y position.
  • z number Z position.
getPosition (source)
Gets the position of a source.

Parameters:

  • source Audio Source to get position of.

Returns:

  1. number X position.
  2. number Y position.
  3. number Z position.
setVelocity (source, x, y, z)
Sets the velocity of a source.

Parameters:

  • source Audio Source to set velocity of.
  • x number X velocity.
  • y number Y velocity.
  • z number Z velocity.
getVelocity (source)
Gets the velocity of a source.

Parameters:

  • source Audio Source to get velocity of.

Returns:

  1. number X velocity.
  2. number Y velocity.
  3. number Z velocity.
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
setEffect (name, params)
Sets effect stuff, behaves different if the first paramater is a source or not.

Parameters:

  • name string Name of the effect.
  • params table or boolean Parameter table of the effect if not applied to the source, or whether or not to enable it on the source otherwise.

Returns:

    boolean true on success.

Usage:

  • audio.setEffect( "reverb", { type="reverb" } )
  • source:setEffect( "reverb" )
generated by LDoc 1.4.6 Last updated 2021-10-20 12:25:39