HomeIndex

Sound Functions

soundMixVolume(name,volume) | soundMixVolume(name)
Sets or gets the mix volume for a group of sounds.
The group is a string that represents the FMOD mixer group. It will be one of "music", "effects", "voice", or "master". The volume is float from 0.0 to 1.0
soundMixVolume("effects", 0.5)
soundVolume(name,volume) | soundMixVolume(name)
Sets or gets the volume for a group of sounds.
The group is a string that represents the FMOD mixer group. It will be one of "music", "effects", "voice", or "master". The volume is float from 0.0 to 1.0
soundVolume("music", 0.0)
The different between soundVolume() and soundMixVolume() is that soundVolume() is applied after soundMixVolume() and it's value is not saved or relected in game's UI for sound volume.
It can be used to mute the music without effecting the overall game volume settings.
defineSound(path)
defines a sounds based on a FMOD sound path string
doorOpen = defineSound("event:/objects/doors/door_open")
By convention, sounds are wrapped in a macro to make them easier to identity.
SOUNDID(doorOpen) = defineSound("event:/objects/doors/door_open")
also by convention, sounds should be defined in DefineSounds.dinky
validateSound(path)
Returns true if the sound path exists in the FMOD project.
loadSoundBank(name)
Loads a FMOD sound bank.
By default, the "MasterBank.bank" is loaded. There should be no reason to load other banks.
soundParam(sound_uid,name,value)
Sets a FMOD sounds parameter for a given playing sound_uid.
stopSound(sound_uid)
Stops a playing sound given a sound_uid.
local uid = playSound(SOUNDID(rain)) breaktime(60.0) stopSound(uid)
The the sound is not playing, it will be silently ignored.
stopSound() abruptly stops the sound. In you want to fade out a sound (or music) that needs to be setup within FMOD for each sound using parameters. It is beyond the scope of this document to detail how that is done.
isSoundPlaying(sound_uid)
returns true or false if the sound is playing
stopLocalSounds()
Stops all sounds not started with GLOBAL flag.
stopAllSounds(group="master")
Stops all sounds in a given group.
stopAllSounds("music")
pauseAllSounds(group="master", state)
pauses all sounds in the group
pauseAllSounds("music", YES)
playSound(name|sound_id[,global])
plays a sound given a name or sound_id
local uid = playSound(SOUNDID(rain)) playSound(SOUNDID(bigBang)) playSound("event:/objects/doors/door_open") playSound(SOUNDID(typing),GLOBAL)
The last form is not recommended as it is slower than using defineSound() and scatters the path information about sounds throughout the source code, making them harder to change globally.
If you don't pass the global option, the sound will be local and killed when leaving the room.
playSound() returns a uid for the playing sound. If you don't need to manipulate the sound once it's playing, the return can be ignored.
playSoundVolume(sound_uid,volume)
Plays a sound at a specified volume
playSound(SOUNDID(rain), 0.5)
Sound volumes should be modified in FMOD and only use playSoundVolume() when a specific instance needs to be lower. Even in that case, using FMOD and FMOD parameters might be better and more flexible.
playSoundAt(sound_uid,point)
Plays a sounds at a location.
Sounds can have a 2D location that will be tracked by the camera as it moves.
Tracking sounds can be slightly processor expensive and should only be used for consistent environmental sounds. One shot sounds (like a bang) shouldn't use playSoundAt().
That said, there isn't much overhead for call playSoundAt() on a non-2D sound, so it can be done in anticipation of making the sound 2D in FMOD at some point.
soundListenerAt(point)
Sets the sound listener position.
This is generally handled by the engine and should not be set by the scripts unless the sound listener needs to be off-camera.