SoundManager

Controls all game audio.

About

This is a global object that can always be accessed.

Usage

GetSoundManager:Play("audio/warp.ogg");
Summary

Member Functions

Play

number Play(string fileName)

Plays a sound.  Audio files are automatically cached after use for speed.

Parameters

fileNameA .wav or .ogg sound file to play.

Returns

A numerical handle to the sound created.  Save it if you want to Kill it later or adjust its properties.

PlayLooping

number PlayLooping(string fileName)

Like Play but the sound loops for eternity.  You must use Kill to make it stop.

Parameters

fileNameA .wav or .ogg sound file to play.

Returns

A numerical handle to the sound created.  Save it if you want to Kill it later or adjust its properties.

SetSpeedFactor

nil SetSpeedFactor(number soundID, number speedMod)

Allows you to adjust the speed/pitch of a sound.

Usage

local soundID = this:PlaySoundPositioned("~/audio/quack.ogg");
//randomize the pitch
GetSoundManager:SetSpeedFactor(soundID, 0.90 + (random() * 0.2) );

Parameters

soundIDA valid sound handle.
speedModA number indicating the speed modification, 1 is normal speed, 1.1 is faster, 0.9 is slower.

SetVolume

nil SetVolume(number soundID, number volume)

Parameters

soundIDA valid sound handle.
volumeThe new volume of the sound.  0 to mute, 1 for max volume.

SetPan

nil SetPan(number soundID, number pan)

Parameters

soundIDA valid sound handle.
panA range between -1 and 1.  (0 would be normal stereo with neither speaker getting favored)

SetPaused

nil SetPaused(number soundID, boolean bPaused)

Parameters

soundIDA valid sound handle.
bPausedIf true, sound will stop playing, but will remain ready to start playing again from its current position with another SetPaused command.

Note

You must <Kill>() this sound or set its priority to 0 once you’re done with it so it can be properly garbage collected.

SetPriority

nil SetPriority(number soundID, number priority)

A sound with a higher priority won’t be interrupted by a sound with a lower priority in cases of limited sound channels, as when using FMOD.

Parameters

soundIDA valid sound handle.
priorityA number between 0 (low) to 255 (high) priority.

IsPlaying

boolean IsPlaying(number soundID)

Parameters

soundIDA valid sound handle.

Returns

True if the specified sound is currently playing.

Kill

nil Kill(number soundID)

Stops a sound from playing.

Parameters

soundIDA valid sound handle.

MuteAll

nil MuteAll(boolean bMuteActive)

Easy way to turn the volume of ALL sounds off and on at the same time, without actually stopping the sounds.

Parameters

bMuteActiveIf true, the sound is muted.  If false, sounds can be heard.

Related Constants

Summary
C_SOUND_CONSTANTSUsed with sound functions.
C_SOUND_NONESound functions return this if no sound was created.

C_SOUND_CONSTANTS

Used with sound functions.

C_SOUND_NONE

Sound functions return this if no sound was created.