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. |
stop (source) | Stops a source. |
setVolume (source, vol) | Sets the volume of a source. |
getVolume (source) | Gets the volume of a source. |
getVolume (source, enable) | Sets a source to be looping or not. |
setPitch (source, pitch) | Sets 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.
- stop (source)
-
Stops a source.
Parameters:
- source Audio Source to stop.
Returns:
-
boolean
True on success.
- 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.
- getVolume (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.
- 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.
- 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