Gksound: Difference between revisions

From Vendetta Lua
Jump to navigationJump to search
No edit summary
m added GeSHi
Line 45: Line 45:
When loading raw files, be sure to specify valid channel size and count.
When loading raw files, be sure to specify valid channel size and count.
<br><br>
<br><br>
'''Arguments:'''
'''Arguments:'''<source lang="lua">
table:
table:
{
{
   soundname = "soundeffect",
   soundname = "soundeffect",
   filename = "filename",
   filename = "filename",
Line 56: Line 56:
   biasdist = 3000, -- optional, defaults to 3000, attenuates to 0 volume when this far from the listener when played as a 3D sound.
   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.
   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, -- optiona, 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 over and over forever until it is stopped, which you can't stop right now, heh, so use at your own risk.
   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>
<br><br>
'''Returns:'''
'''Returns:'''
Line 63: Line 64:
<br><br>
<br><br>
'''Example:'''
'''Example:'''
gksound.GKLoadSound{soundname='fart',filename='sound/warp_1.ogg'}
<source lang="lua">gksound.GKLoadSound{soundname='fart',filename='sound/warp_1.ogg'}</source>
<br><br>
<br><br>


Line 81: Line 82:
<br><br>
<br><br>
'''Example:'''<br>
'''Example:'''<br>
GKPlaySound("explosion", 0.5) -> nil
<source lang="lua">GKPlaySound("explosion", 0.5) -> nil -- play explosion sound effect at half volume</source>
play explosion sound effect at half volume
<br><br>
<br><br>



Revision as of 23:22, 23 September 2007

Functions ot control audio playback. Audio files read from disk must be in ogg vorbis format.

Functions

GKPlaylist

Definition:
GKPlaylist(string playlist) -> nil

Description:
Play playlist file as background music.

Arguments:
playlist filename playlist file

Returns:

Example:


GKPlayMusic

Definition:
GKPlayMusic(string audiofile) -> nil

Description:
Playback the provided file as background music in a loop

Arguments:
audiofile filename of an audiofile

Returns:

Example:


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",
 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>


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: