![]() |
naev 0.12.5
|
Bindings for Special effects functionality from Lua. More...
#include "nlua_audio.h"#include "AL/efx.h"#include "array.h"#include "nlua_file.h"#include "nlua_vec2.h"#include "nluadef.h"#include "nopenal.h"#include "ntracing.h"#include "sound.h"
Go to the source code of this file.
Data Structures | |
| struct | LuaAudioEfx_t |
| Handles the OpenAL effects that have been set up Lua side. More... | |
Functions | |
| static int | stream_thread (void *la_data) |
| static int | stream_loadBuffer (LuaAudio_t *la, ALuint buffer) |
| Loads a buffer. | |
| static int | audio_genSource (ALuint *source) |
| Tries to generate a single openal source, running GC if necessary. | |
| static int | audioL_tostring (lua_State *L) |
| Lua bindings to interact with audio. | |
| static int | audioL_gc (lua_State *L) |
| Frees a audio. | |
| static int | audioL_eq (lua_State *L) |
| Compares two audios to see if they are the same. | |
| static int | audioL_new (lua_State *L) |
| Creates a new audio source. | |
| static int | audioL_clone (lua_State *L) |
| Clones an existing audio source. | |
| static int | audioL_play (lua_State *L) |
| Plays a source. | |
| static int | audioL_pause (lua_State *L) |
| Pauses a source. | |
| static int | audioL_isPaused (lua_State *L) |
| Checks to see if a source is paused. | |
| static int | audioL_stop (lua_State *L) |
| Stops a source. | |
| static int | audioL_isStopped (lua_State *L) |
| Checks to see if a source is stopped. | |
| static int | audioL_rewind (lua_State *L) |
| Rewinds a source. | |
| static int | audioL_seek (lua_State *L) |
| Seeks a source. | |
| static int | audioL_tell (lua_State *L) |
| Gets the position of a source. | |
| static int | audioL_getDuration (lua_State *L) |
| Gets the length of a source. | |
| static int | audioL_setVolume (lua_State *L) |
| Sets the volume of a source. | |
| static int | audioL_getVolume (lua_State *L) |
| Gets the volume of a source. | |
| static int | audioL_setRelative (lua_State *L) |
| Sets whether a source is relative or not. | |
| static int | audioL_setPosition (lua_State *L) |
| Sets the position of a source. | |
| static int | audioL_getPosition (lua_State *L) |
| Gets the position of a source. | |
| static int | audioL_setVelocity (lua_State *L) |
| Sets the velocity of a source. | |
| static int | audioL_getVelocity (lua_State *L) |
| Gets the velocity of a source. | |
| static int | audioL_setLooping (lua_State *L) |
| Sets a source to be looping or not. | |
| static int | audioL_isLooping (lua_State *L) |
| Gets the looping state of a source. | |
| static int | audioL_setPitch (lua_State *L) |
| Sets the pitch of a source. | |
| static int | audioL_getPitch (lua_State *L) |
| Gets the pitch of a source. | |
| static int | audioL_setAttenuationDistances (lua_State *L) |
| Sets the attenuation distances for the audio source. | |
| static int | audioL_getAttenuationDistances (lua_State *L) |
| Gets the attenuation distances for the audio source. Set to 0. if audio is disabled. | |
| static int | audioL_setRolloff (lua_State *L) |
| Sets the rollof factor. | |
| static int | audioL_getRolloff (lua_State *L) |
| Gets the rolloff factor. | |
| static int | audioL_setEffect (lua_State *L) |
| Sets effect stuff, behaves different if the first parameter is a source or not. | |
| static int | audioL_setGlobalEffect (lua_State *L) |
| Sets a global effect. Will overwrite whatever was set. Does not affect sources created in Lua. | |
| static int | audioL_setGlobalAirAbsorption (lua_State *L) |
| Allows setting the speed of sound and air absorption. | |
| static int | audioL_setGlobaDopplerFactor (lua_State *L) |
| Sets the doppler effect factor. | |
| static int | audioL_soundPlay (lua_State *L) |
| Plays a sound. | |
| static int | audioL_isBool (lua_State *L, ALenum param) |
| Checks to see a boolean property of a source. | |
| static int | audioL_isState (lua_State *L, ALenum state) |
| Checks to see the state of the source. | |
| int | nlua_loadAudio (nlua_env env) |
| Loads the audio library. | |
| LuaAudio_t * | lua_toaudio (lua_State *L, int ind) |
| Gets audio at index. | |
| LuaAudio_t * | luaL_checkaudio (lua_State *L, int ind) |
| Gets audio at index or raises error if there is no audio at index. | |
| LuaAudio_t * | lua_pushaudio (lua_State *L, LuaAudio_t audio) |
| Pushes a audio on the stack. | |
| int | lua_isaudio (lua_State *L, int ind) |
| Checks to see if ind is a audio. | |
| void | audio_cleanup (LuaAudio_t *la) |
| void | audio_clone (LuaAudio_t *la, const LuaAudio_t *source) |
| static void | efx_setnum (lua_State *L, int pos, ALuint effect, const char *name, ALuint param) |
| static void | efx_setint (lua_State *L, int pos, ALuint effect, const char *name, ALuint param) |
| static void | efx_setbool (lua_State *L, int pos, ALuint effect, const char *name, ALuint param) |
| static int | audioL_setEffectGlobal (lua_State *L) |
| static LuaAudioEfx_t * | audio_getEffectByName (const char *name) |
Variables | |
| static LuaAudioEfx_t * | lua_efx = NULL |
| List of effects handled by Lua. These are persistent throughout game runtime. | |
| static const luaL_Reg | audioL_methods [] |
Bindings for Special effects functionality from Lua.
Definition in file nlua_audio.c.
| void audio_cleanup | ( | LuaAudio_t * | la | ) |
Definition at line 341 of file nlua_audio.c.
| void audio_clone | ( | LuaAudio_t * | la, |
| const LuaAudio_t * | source ) |
Definition at line 608 of file nlua_audio.c.
|
static |
Tries to generate a single openal source, running GC if necessary.
Definition at line 445 of file nlua_audio.c.
|
static |
Definition at line 1658 of file nlua_audio.c.
|
static |
Clones an existing audio source.
Lua function parameter: Audio source Audio source to clone. Lua return parameter: Audio New audio corresponding to the data.
| L | Lua State |
Lua function: clone
Definition at line 664 of file nlua_audio.c.
|
static |
Compares two audios to see if they are the same.
Lua function parameter: Audio a1 Audio 1 to compare. Lua function parameter: Audio a2 Audio 2 to compare. Lua return parameter: boolean true if both audios are the same.
| L | Lua State |
Lua function: __eq
Definition at line 433 of file nlua_audio.c.
|
static |
Frees a audio.
Lua function parameter: Audio audio Audio to free.
| L | Lua State |
Lua function: __gc
Definition at line 418 of file nlua_audio.c.
|
static |
Gets the attenuation distances for the audio source. Set to 0. if audio is disabled.
Lua return parameter: number Reference distance. Lua return parameter: number Maximum distance.
| L | Lua State |
Lua function: getAttenuationDistances
Definition at line 1352 of file nlua_audio.c.
|
static |
Gets the length of a source.
Lua function parameter: Audio source Source to get duration of. Lua function parameter:[opt="seconds"] string unit Either "seconds" or "samples" indicating the type to report. Lua return parameter: number Duration of the source or -1 on error.
| L | Lua State |
Lua function: getDuration
Definition at line 958 of file nlua_audio.c.
|
static |
Gets the pitch of a source.
Lua function parameter: Audio source Source to get pitch of. Lua return parameter: number Pitch of the source.
| L | Lua State |
Lua function: getPitch
Definition at line 1263 of file nlua_audio.c.
|
static |
Gets the position of a source.
Lua function parameter: Audio source Source to get position of. Lua return parameter: number X position. Lua return parameter: number Y position. Lua return parameter: number Z position.
| L | Lua State |
Lua function: getPosition
Definition at line 1123 of file nlua_audio.c.
|
static |
Gets the rolloff factor.
Lua return parameter: number Rolloff factor or 0. if sound is disabled.
| L | Lua State |
Lua function: getRolloff
Definition at line 1396 of file nlua_audio.c.
|
static |
Gets the velocity of a source.
Lua function parameter: Audio source Source to get velocity of. Lua return parameter: number X velocity. Lua return parameter: number Y velocity. Lua return parameter: number Z velocity.
| L | Lua State |
Lua function: getVelocity
Definition at line 1181 of file nlua_audio.c.
|
static |
Gets the volume of a source.
Lua function parameter:[opt] Audio source Source to get volume of. Lua return parameter: number Volume the source is set to.
| L | Lua State |
Lua function: getVolume
Definition at line 1054 of file nlua_audio.c.
|
static |
Checks to see a boolean property of a source.
Definition at line 235 of file nlua_audio.c.
|
static |
Gets the looping state of a source.
Lua function parameter: Audio source Source to get looping state of. Lua return parameter: boolean Whether or not the source is looping.
| L | Lua State |
Lua function: isLooping
Definition at line 1231 of file nlua_audio.c.
|
static |
Checks to see if a source is paused.
Lua function parameter: Audio source Source to check to see if is paused. Lua return parameter: boolean Whether or not the source is paused.
| L | Lua State |
Lua function: isPaused
Definition at line 737 of file nlua_audio.c.
|
static |
Checks to see the state of the source.
Definition at line 252 of file nlua_audio.c.
|
static |
Checks to see if a source is stopped.
Lua function parameter: Audio source Source to check to see if is stopped. Lua return parameter: boolean Whether or not the source is stopped.
| L | Lua State |
Lua function: isStopped
Definition at line 801 of file nlua_audio.c.
|
static |
Creates a new audio source.
Lua function parameter: string|File data Data to load the audio from. Lua function parameter:[opt="static"] string Either "static" to load the entire source at the start, or "stream" to load it in real time. Lua return parameter: Audio New audio corresponding to the data.
| L | Lua State |
Lua function: new
Definition at line 485 of file nlua_audio.c.
|
static |
Pauses a source.
Lua function parameter: Audio source Source to pause. Lua return parameter: boolean True on success.
| L | Lua State |
Lua function: pause
Definition at line 718 of file nlua_audio.c.
|
static |
Plays a source.
Lua function parameter: Audio source Source to play. Lua return parameter: boolean True on success.
| L | Lua State |
Lua function: play
Definition at line 680 of file nlua_audio.c.
|
static |
Rewinds a source.
Lua function parameter: Audio source Source to rewind.
| L | Lua State |
Lua function: rewind
Definition at line 812 of file nlua_audio.c.
|
static |
Seeks a source.
Lua function parameter: Audio source Source to seek. Lua function parameter: number offset Offset to seek to. Lua function parameter:[opt="seconds"] string unit Either "seconds" or "samples" indicating the type to seek to.
| L | Lua State |
Lua function: seek
Definition at line 845 of file nlua_audio.c.
|
static |
Sets the attenuation distances for the audio source.
Lua function parameter: number ref Reference distance. Lua function parameter: number max Maximum distance.
| L | Lua State |
Lua function: setAttenuationDistances
Definition at line 1329 of file nlua_audio.c.
|
static |
Sets effect stuff, behaves different if the first parameter is a source or not.
Lua usage parameter: audio.setEffect( "reverb", { type="reverb" } ) Lua usage parameter: source:setEffect( "reverb" )
Lua function parameter: string name Name of the effect. Lua function parameter: table|boolean params Parameter table of the effect if not applied to the source, or whether or not to enable it on the source otherwise. Lua return parameter: boolean true on success.
| L | Lua State |
Lua function: setEffect
Definition at line 1681 of file nlua_audio.c.
|
static |
Definition at line 1436 of file nlua_audio.c.
|
static |
Sets the doppler effect factor.
Defaults to 0.3 outside of the nebula and 1.0 in the nebula.
Lua function parameter: number factor Factor to set doppler effect to. Must be positive.
| L | Lua State |
Lua function: setGlobalDopplerFactor
Definition at line 1793 of file nlua_audio.c.
|
static |
Allows setting the speed of sound and air absorption.
Lua function parameter:[opt=3443] number speed Air speed. Lua function parameter:[opt=-1] number absorption Air absorptuion for all sources. Has to be a value between 0 and 10. If negative, value is ignored.
| L | Lua State |
Lua function: setGlobalAirAbsorption
Definition at line 1767 of file nlua_audio.c.
|
static |
Sets a global effect. Will overwrite whatever was set. Does not affect sources created in Lua.
Lua function parameter:[opt] string name Name of the effect to set or nil to disable.
| L | Lua State |
Lua function: setGlobalEffect
Definition at line 1724 of file nlua_audio.c.
|
static |
Sets a source to be looping or not.
Lua function parameter: Audio source Source to set looping state of. Lua function parameter: boolean enable Whether or not the source should be set to looping.
| L | Lua State |
Lua function: setLooping
Definition at line 1211 of file nlua_audio.c.
|
static |
Sets the pitch of a source.
Lua function parameter: Audio source Source to set pitch of. Lua function parameter: number pitch Pitch to set the source to.
| L | Lua State |
Lua function: setPitch
Definition at line 1243 of file nlua_audio.c.
|
static |
Sets the position of a source.
Lua function parameter: Audio source Source to set position of. Lua function parameter: number x X position. Lua function parameter: number y Y position. Lua function parameter: number z Z position.
| L | Lua State |
Lua function: setPosition
Definition at line 1096 of file nlua_audio.c.
|
static |
Sets whether a source is relative or not.
Lua function parameter: boolean relative Whether or not to make the source relative or not.
| L | Lua State |
Lua function: setRelative
Definition at line 1074 of file nlua_audio.c.
|
static |
Sets the rollof factor.
Lua function parameter: number rolloff New rolloff factor.
| L | Lua State |
Lua function: setRolloff
Definition at line 1377 of file nlua_audio.c.
|
static |
Sets the velocity of a source.
Lua function parameter: Audio source Source to set velocity of. Lua function parameter: number x X velocity. Lua function parameter: number y Y velocity. Lua function parameter: number z Z velocity.
| L | Lua State |
Lua function: setVelocity
Definition at line 1154 of file nlua_audio.c.
|
static |
Sets the volume of a source.
Lua function parameter: Audio source Source to set volume of. Lua function parameter: number vol Volume to set the source to with 0.0 being silent and 1.0 being full volume. Lua function parameter: boolean ignorevol Don't modify volume based on master.
| L | Lua State |
Lua function: setVolume
Definition at line 1026 of file nlua_audio.c.
|
static |
Plays a sound.
by default, the sound is played at player's current position
Lua usage parameter: audio.soundPlay( "hail" ) – Plays the hail sound Lua usage parameter: audio.soundPlay( "hail", pos ) – Plays the hail sound at position pos Lua usage parameter: audio.soundPlay( "hail", pos, vel ) – Plays the hail sound at position pos with velocity vel
Lua function parameter: string s Name of the sound to play Lua function parameter:[opt] Vec2 pos Position of the source Lua function parameter:[opt] Vec2 vel Velocity of the source
| L | Lua State |
Lua function: soundPlay
Definition at line 1292 of file nlua_audio.c.
|
static |
Stops a source.
Lua function parameter: Audio source Source to stop.
| L | Lua State |
Lua function: stop
Definition at line 748 of file nlua_audio.c.
|
static |
Gets the position of a source.
Lua function parameter: Audio source Source to get position of. Lua function parameter:[opt="seconds"] string unit Either "seconds" or "samples" indicating the type to report. Lua return parameter: number Offset of the source or -1 on error.
| L | Lua State |
Lua function: tell
Definition at line 899 of file nlua_audio.c.
|
static |
Lua bindings to interact with audio.
Lua module: audio
Gets a string representation of an audio file.
Lua function parameter: Audio audio Audio to get string representation of. Lua return parameter: string String representation of the audio.
| L | Lua State |
Lua function: __tostring
Definition at line 404 of file nlua_audio.c.
|
static |
Definition at line 1428 of file nlua_audio.c.
|
static |
Definition at line 1420 of file nlua_audio.c.
|
static |
Definition at line 1412 of file nlua_audio.c.
| int lua_isaudio | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a audio.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 325 of file nlua_audio.c.
| LuaAudio_t * lua_pushaudio | ( | lua_State * | L, |
| LuaAudio_t | audio ) |
Pushes a audio on the stack.
| L | Lua state to push audio into. |
| audio | Audio to push. |
Definition at line 310 of file nlua_audio.c.
| LuaAudio_t * lua_toaudio | ( | lua_State * | L, |
| int | ind ) |
Gets audio at index.
| L | Lua state to get audio from. |
| ind | Index position to find the audio. |
Definition at line 285 of file nlua_audio.c.
| LuaAudio_t * luaL_checkaudio | ( | lua_State * | L, |
| int | ind ) |
Gets audio at index or raises error if there is no audio at index.
| L | Lua state to get audio from. |
| ind | Index position to find audio. |
Definition at line 296 of file nlua_audio.c.
| int nlua_loadAudio | ( | nlua_env | env | ) |
Loads the audio library.
| env | Lua environment. |
Definition at line 272 of file nlua_audio.c.
|
static |
|
static |
Definition at line 122 of file nlua_audio.c.
|
static |
AudioLua methods.
Definition at line 84 of file nlua_audio.c.
|
static |
List of effects handled by Lua. These are persistent throughout game runtime.
Definition at line 41 of file nlua_audio.c.