Gksound: Difference between revisions
New page: Functions ot control audio playback. Audio files read from disk must be in ogg vorbis format. == Functions == === GKPlaylist === '''Definition:'''<br> GKPlaylist(string playlist) -> nil ... |
Atrophenus (talk | contribs) |
||
(12 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
Functions | Functions to control audio playback. Audio files read from disk must be in ogg vorbis format. | ||
== Functions == | == Functions == | ||
=== GKUnloadSound === | |||
'''Definition:'''<br> | |||
GKUnloadSound() | |||
<br><br> | |||
'''Description:''' <br> | |||
Unloads a sound when a sound is specified.<br> | |||
<br><br> | |||
'''Arguments:'''<br> | |||
'''Soundname''' | |||
<br><br> | |||
'''Returns:''' | |||
<br><br> | |||
'''Example:''' | |||
<source lang="lua">gksound.GKUnloadSound{'billboard.buzz'}</source> | |||
<br><br> | |||
=== GKLoadSound === | |||
'''Definition:'''<br> | |||
GKLoadSound() -> boolean | |||
<br><br> | |||
'''Description:''' <br> | |||
Load an audio file and assign it to a sound effect name to be played by GKPlaySound.<br> | |||
Files supported: wav, ogg, raw. | |||
When loading raw files, be sure to specify valid channel size and count. | |||
<br><br> | |||
'''Arguments:'''<source lang="lua"> | |||
table: | |||
{ | |||
soundname = "soundeffect", | |||
filename = "filename", -- must be a filepath relative to the Vendetta directory, e.g., "plugins/lies2/lies2.ogg" | |||
samplerate = 44100, -- optional, defaults to 44100 KHz | |||
preload = boolean, -- optional, defaults to true, defines whether to load immediately or load when first played | |||
stream = boolean, -- optional, defaults to false. defines whether to load entire file or stream. | |||
channels = 2, -- optional, defaults to whatever is in the file. needed for raw files. | |||
biasdist = 3000, -- optional, defaults to 3000, attenuates to 0 volume when this far from the listener when played as a 3D sound. | |||
width = 0, -- optional, defaults to 0 which means to use whatever the file specifies. Otherwise either 8 or 16. defines how big each channel is. | |||
loop = nil, -- optional, defaults to no loop. defined loop point in number of samples. the sound will play the entire sound and then loop back to the loop | |||
-- point until it is stopped, which you can't stop right now, heh, so use at your own risk. | |||
}</source> | |||
<br><br> | |||
'''Returns:''' | |||
boolean true if load succeeded, false if load failed. | |||
<br><br> | |||
'''Example:''' | |||
<source lang="lua">gksound.GKLoadSound{soundname='fart',filename='sound/warp_1.ogg'}</source> | |||
<br><br> | |||
=== GKPlaylist === | === GKPlaylist === | ||
Line 22: | Line 70: | ||
=== GKPlayMusic === | === GKPlayMusic === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
GKPlayMusic(string | GKPlayMusic(string filename, boolean loop, forceplay, number looppoint, volume) -> nil | ||
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
Line 28: | Line 76: | ||
<br><br> | <br><br> | ||
'''Arguments:'''<br> | '''Arguments:'''<br> | ||
''' | '''filename''' filename of an audiofile | ||
<br><br> | <br><br> | ||
'''Returns:''' | '''Returns:''' | ||
Line 34: | Line 82: | ||
'''Example:''' | '''Example:''' | ||
<br><br> | <br><br> | ||
=== GKPlaySound === | === GKPlaySound === | ||
Line 47: | Line 93: | ||
'''soundeffect''' name of a [[soundeffect]]<br> | '''soundeffect''' name of a [[soundeffect]]<br> | ||
'''volume''' playback volume (0-1) | '''volume''' playback volume (0-1) | ||
<br><br> | |||
'''Returns:''' | |||
<br><br> | |||
'''Example:'''<br> | |||
<source lang="lua">GKPlaySound("explosion", 0.5) -> nil -- play explosion sound effect at half volume</source> | |||
<br><br> | |||
=== GKStopMusic === | |||
'''Definition:'''<br> | |||
GKStopMusic() -> nil | |||
<br><br> | |||
'''Description:''' <br> | |||
Stop playing background music | |||
<br><br> | |||
'''Arguments:''' | |||
<br><br> | <br><br> | ||
'''Returns:''' | '''Returns:''' | ||
Line 53: | Line 114: | ||
<br><br> | <br><br> | ||
=== MuteSound === | |||
'''Definition:'''<br> | |||
MuteSound(boolean mute) -> nil | |||
<br><br> | |||
'''Description:''' <br> | |||
Set volume to level set with [[Gksound#SetSoundDuckingLevel]] | |||
<br><br> | |||
'''Arguments:'''<br> | |||
'''mute''' mute sound if true | |||
<br><br> | |||
'''Returns:''' | |||
<br><br> | |||
'''Example:''' | |||
<br><br> | |||
=== | === GetSoundDuckingLevel === | ||
'''Definition:'''<br> | '''Definition:'''<br> | ||
GetSoundDuckingLevel() -> float level | |||
<br><br> | <br><br> | ||
'''Description:''' <br> | '''Description:''' <br> | ||
Get volume level when receiving or sending voice chat | |||
<br><br> | <br><br> | ||
'''Arguments:''' | '''Arguments:''' | ||
<br><br> | |||
'''Returns:'''<br> | |||
'''level''' volume level (0-1) | |||
<br><br> | |||
'''Example:''' | |||
<br><br> | |||
=== SetSoundDuckingLevel === | |||
'''Definition:'''<br> | |||
SetSoundDuckingLevel(float level) -> nil | |||
<br><br> | |||
'''Description:''' <br> | |||
Set volume level when receiving or sending voice chat | |||
<br><br> | |||
'''Arguments:'''<br> | |||
'''level''' volume level (0-1) | |||
<br><br> | <br><br> | ||
'''Returns:''' | '''Returns:''' | ||
Line 68: | Line 160: | ||
'''Example:''' | '''Example:''' | ||
<br><br> | <br><br> | ||
[[Category:Tables]] |
Latest revision as of 00:42, 16 June 2024
Functions to control audio playback. Audio files read from disk must be in ogg vorbis format.
Functions
GKUnloadSound
Definition:
GKUnloadSound()
Description:
Unloads a sound when a sound is specified.
Arguments:
Soundname
Returns:
Example:
<source lang="lua">gksound.GKUnloadSound{'billboard.buzz'}</source>
GKLoadSound
Definition:
GKLoadSound() -> boolean
Description:
Load an audio file and assign it to a sound effect name to be played by GKPlaySound.
Files supported: wav, ogg, raw.
When loading raw files, be sure to specify valid channel size and count.
Arguments:<source lang="lua">
table:
{
soundname = "soundeffect", filename = "filename", -- must be a filepath relative to the Vendetta directory, e.g., "plugins/lies2/lies2.ogg" samplerate = 44100, -- optional, defaults to 44100 KHz preload = boolean, -- optional, defaults to true, defines whether to load immediately or load when first played stream = boolean, -- optional, defaults to false. defines whether to load entire file or stream. channels = 2, -- optional, defaults to whatever is in the file. needed for raw files. biasdist = 3000, -- optional, defaults to 3000, attenuates to 0 volume when this far from the listener when played as a 3D sound. width = 0, -- optional, defaults to 0 which means to use whatever the file specifies. Otherwise either 8 or 16. defines how big each channel is. loop = nil, -- optional, defaults to no loop. defined loop point in number of samples. the sound will play the entire sound and then loop back to the loop -- point until it is stopped, which you can't stop right now, heh, so use at your own risk.
}</source>
Returns:
boolean true if load succeeded, false if load failed.
Example:
<source lang="lua">gksound.GKLoadSound{soundname='fart',filename='sound/warp_1.ogg'}</source>
GKPlaylist
Definition:
GKPlaylist(string playlist) -> nil
Description:
Play playlist file as background music.
Arguments:
playlist filename playlist file
Returns:
Example:
GKPlayMusic
Definition:
GKPlayMusic(string filename, boolean loop, forceplay, number looppoint, volume) -> nil
Description:
Playback the provided file as background music in a loop
Arguments:
filename filename of an audiofile
Returns:
Example:
GKPlaySound
Definition:
GKPlaySound(string soundeffect, float volume) -> nil
Description:
Playback a soundeffect at the given volume
Arguments:
soundeffect name of a soundeffect
volume playback volume (0-1)
Returns:
Example:
<source lang="lua">GKPlaySound("explosion", 0.5) -> nil -- play explosion sound effect at half volume</source>
GKStopMusic
Definition:
GKStopMusic() -> nil
Description:
Stop playing background music
Arguments:
Returns:
Example:
MuteSound
Definition:
MuteSound(boolean mute) -> nil
Description:
Set volume to level set with Gksound#SetSoundDuckingLevel
Arguments:
mute mute sound if true
Returns:
Example:
GetSoundDuckingLevel
Definition:
GetSoundDuckingLevel() -> float level
Description:
Get volume level when receiving or sending voice chat
Arguments:
Returns:
level volume level (0-1)
Example:
SetSoundDuckingLevel
Definition:
SetSoundDuckingLevel(float level) -> nil
Description:
Set volume level when receiving or sending voice chat
Arguments:
level volume level (0-1)
Returns:
Example: