All Bundles

Mixer

Portable sound mixing library

Operations

FadeOutChannel

Gradually fade out which channel over ms milliseconds starting from now.

function : FadeOutChannel(which:Int, ms:Int) ~ Int
Parameters
NameTypeDescription
whichIntchannel to fade out, or -1 to fade all channels out.
msIntmilliseconds of time that the fade-out effect should take to go to silence, starting now.

Return
TypeDescription
Intthe number of channels set to fade out

GetVolume

Gets the current volume

function : GetVolume(channel:Int) ~ Int
Parameters
NameTypeDescription
channelIntChannel to set mix volume for. -1 will set the volume for all allocated channels.

Return
TypeDescription
Intcurrent volume of the channel

HaltChannel

Halt channel playback, or all channels

function : HaltChannel(channel:Int) ~ Int
Parameters
NameTypeDescription
channelIntto stop playing, or -1 for all channels

Return
TypeDescription
Intalways returns zero

OpenAudio

Initialize the mixer API

function : OpenAudio(frequency:Int, format:Int, channels:Int, chunksize:Int) ~ Bool
Parameters
NameTypeDescription
frequencyIntoutput sampling frequency in samples per second (Hz). you might use MIX_DEFAULT_FREQUENCY(22050) since that is a good value for most games.
formatIntoutput sample format.
channelsIntNumber of sound channels in output. Set to 2 for stereo, 1 for mono. This has nothing to do with mixing channels.
chunksizeIntbytes used per output sample.

Return
TypeDescription
Bool0 on success, -1 on errors

Playing

Tells you if music is actively playing, or not

function : Playing(channel:Int) ~ Bool
Parameters
NameTypeDescription
channelIntmusic channel

Return
TypeDescription
Booltrue if music is playing, false otherwise

Quit

Shutdown and cleanup the mixer API

function : Quit() ~ Nil

Volume

Sets the current volume

function : Volume(channel:Int, volume:Int) ~ Int
Parameters
NameTypeDescription
channelIntChannel to set mix volume for. -1 will set the volume for all allocated channels.
volumeIntthe volume to use from 0 to 128

Return
TypeDescription
Intcurrent volume of the channel