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[, Either="static"]) 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.
getDuration (source[, unit="seconds"]) Gets the length of a source.
setVolume (source, vol, ignorevol) 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.
setAttenuationDistances (ref, max) Sets the attenuation distances for the audio source.
getAttenuationDistances () Gets the attenuation distances for the audio source.
setRolloff (rolloff) Sets the rollof factor.
getRolloff () Gets the rolloff factor.
setEffect (name, params) Sets effect stuff, behaves different if the first parameter is a source or not.
setGlobalEffect ([name]) Sets a global effect.
setGlobalAirAbsorption ([speed=3443[, absorption=-1]]) Allows setting the speed of sound and air absorption.
setGlobalDopplerFactor (factor) Sets the doppler effect factor.


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[, Either="static"])
Creates a new audio source.

Parameters:

  • data string or File Data to load the audio from.
  • Either string "static" to load the entire source at the start, or "stream" to load it in real time. (default "static")

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.
getDuration (source[, unit="seconds"])
Gets the length of a source.

Parameters:

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

Returns:

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

Parameters:

  • source Audio Source to set volume of.
  • vol number Volume to set the source to with 0.0 being silent and 1.0 being full volume.
  • ignorevol boolean Don't modify volume based on master.
getVolume ([source])
Gets the volume of a source.

Parameters:

  • source Audio Source to get volume of. (optional)

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
    
setAttenuationDistances (ref, max)
Sets the attenuation distances for the audio source.

Parameters:

  • ref number Reference distance.
  • max number Maximum distance.
getAttenuationDistances ()
Gets the attenuation distances for the audio source. Set to 0. if audio is disabled.

Returns:

  1. number Reference distance.
  2. number Maximum distance.
setRolloff (rolloff)
Sets the rollof factor.

Parameters:

  • rolloff number New rolloff factor.
getRolloff ()
Gets the rolloff factor.

Returns:

    number Rolloff factor or 0. if sound is disabled.
setEffect (name, params)
Sets effect stuff, behaves different if the first parameter 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" )
    
setGlobalEffect ([name])
Sets a global effect. Will overwrite whatever was set. Does not affect sources created in Lua.

Parameters:

  • name string Name of the effect to set or nil to disable. (optional)
setGlobalAirAbsorption ([speed=3443[, absorption=-1]])
Allows setting the speed of sound and air absorption.

Parameters:

  • speed number Air speed. (default 3443)
  • absorption number Air absorptuion for all sources. Has to be a value between 0 and 10. If negative, value is ignored. (default -1)
setGlobalDopplerFactor (factor)
Sets the doppler effect factor.

Defaults to 0.3 outside of the nebula and 1.0 in the nebula.

Parameters:

  • factor number Factor to set doppler effect to. Must be positive.
generated by LDoc 1.5.0 Last updated 2024-04-25 09:00:13