Controls all game audio.
This is a global object that can always be accessed.
GetSoundManager:Play("audio/warp.ogg");
SoundManager | Controls all game audio. |
Member Functions | |
Play | |
PlayLooping | |
SetSpeedFactor | |
SetVolume | |
SetPan | |
SetPaused | |
SetPriority | |
IsPlaying | |
Kill | |
MuteAll | |
Related Constants | |
C_SOUND_CONSTANTS | Used with sound functions. |
C_SOUND_NONE | Sound functions return this if no sound was created. |
number Play(string fileName)
Plays a sound. Audio files are automatically cached after use for speed.
fileName | A .wav or .ogg sound file to play. |
A numerical handle to the sound created. Save it if you want to Kill it later or adjust its properties.
nil SetSpeedFactor(number soundID, number speedMod)
Allows you to adjust the speed/pitch of a sound.
local soundID = this:PlaySoundPositioned("~/audio/quack.ogg");
//randomize the pitch
GetSoundManager:SetSpeedFactor(soundID, 0.90 + (random() * 0.2) );
soundID | A valid sound handle. |
speedMod | A number indicating the speed modification, 1 is normal speed, 1.1 is faster, 0.9 is slower. |
nil SetVolume(number soundID, number volume)
soundID | A valid sound handle. |
volume | The new volume of the sound. 0 to mute, 1 for max volume. |
nil SetPan(number soundID, number pan)
soundID | A valid sound handle. |
pan | A range between -1 and 1. (0 would be normal stereo with neither speaker getting favored) |
nil SetPaused(number soundID, boolean bPaused)
soundID | A valid sound handle. |
bPaused | If true, sound will stop playing, but will remain ready to start playing again from its current position with another SetPaused command. |
You must <Kill>() this sound or set its priority to 0 once you’re done with it so it can be properly garbage collected.
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.
soundID | A valid sound handle. |
priority | A number between 0 (low) to 255 (high) priority. |
boolean IsPlaying(number soundID)
soundID | A valid sound handle. |
True if the specified sound is currently playing.
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.
bMuteActive | If true, the sound is muted. If false, sounds can be heard. |
C_SOUND_CONSTANTS | Used with sound functions. |
C_SOUND_NONE | Sound functions return this if no sound was created. |