Sound Functions - SmallSquareStudios/Psych-Engine-Wiki-Extra GitHub Wiki

Start Sound/Music

playMusic(sound:String, ?volume:Float = 1, ?loop:Bool = false)

sound - File name (Should be located in mods/music/ or assets/music/).

volume - Optional value, volume percent goes from 0 to 1. The default is 1.

loop - Optional value, if the music should loop indefinitely. The default is false.

Plays a music file. The same as playSound, but the volume can be change alongside the inst volume.

This is deprecated, meaning you should use playSound instead.

playSound(sound:String, ?volume:Float = 1, ?tag:String)

sound - File name (Should be located in mods/sounds/ or assets/sounds/).

volume - Optional value, volume percent goes from 0 to 1. The default is 1.

tag - Optional value, use for sound related functions such as pauseSound or setSoundVolume.

Control Sound/Music

stopSound(tag:String)

Stops the sound and removes it permanently.

tag - Sound tag.

pauseSound(tag:String)

Pauses a sound.

tag - Sound tag.

resumeSound(tag:String)

Resumes a paused sound.

tag - Sound tag.

Fading in/out

soundFadeIn(tag:String, duration:Float, ?fromValue:Float = ?0, toValue:Float = 1)

tag - Sound tag, leave this field empty if you want to do a fade in on the background music instead.

duration - The time it takes for the volume to go from fromValue to toValue.

fromValue - Optional, starting value. The default is 0.

toValue - Optional, end value. The default is 1.

soundFadeOut(tag:String, duration:Float, toValue:Float = 0)

tag - Sound tag, leave this field empty if you want to do a fade out on the background music instead.

duration - The time it takes for the volume to go from the starting volume to toValue.

toValue - End value. The default is 0.

soundFadeCancel(?tag:String)

tag - Optional, sound tag, leave this field empty if you want cancel the background music's fade in/out instead.

Getters/Setters

getSoundVolume(?tag:String)

tag - Optional, sound tag, leave this field empty if you want get the background music's volume instead.

setSoundVolume(?tag:String, value:Float)

tag - Sound tag, leave this field empty if you want change the Background music's volume instead.

value - The volume you want to set the sound to. Goes from 0 to 1.

getSoundTime(tag:String)

Gets the current sound's position in miliseconds.

tag - Sound tag.

setSoundTime(tag:String, value:Float)

Sets the current sound's position in miliseconds

tag - Sound tag. value - The position you want to set the sound to.