Psych Engine Logo
Psych Engine - Lua Script API

Sound Functions

Functions to play sounds and music, change their volume, time and pitch.


playSound

playSound(sound:String, ?volume:Float = 1, ?tag:String = null, ?loop:Bool = false):String

Plays a sound, set a Tag to be able to use any functions on it.
Calls function "onSoundFinished(tag)" when it finishes if "tag" isn't null.
Returns the Sound's formatted Tag if tag isn't null, otherwise returns null.

Examples:


playMusic

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

Plays a music, used for Pre/Post Song cutscenes.

Examples:


soundFadeIn

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

Tweens the volume from a Lua Sound with a specific tag doing a Fade In.

Examples:


soundFadeOut

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

Tweens the volume from a Lua Sound with a specific tag doing a Fade Out.


soundFadeCancel

soundFadeCancel(tag:String):Void

Stops the Fade In/Out of a Lua Sound with a specific tag.


stopSound

stopSound(tag:String):Void

Interrupts and clears a Lua Sound with a specific tag.


pauseSound

pauseSound(tag:String):Void

Pauses a Lua Sound with a specific tag.


resumeSound

resumeSound(tag:String):Void

Resumes a Lua Sound with a specific tag.


luaSoundExists

luaSoundExists(tag:String):Bool

Returns if a Lua Sound with a specific tag exists.


getSoundVolume

getSoundVolume(tag:String):Float

Returns a Lua Sound's volume, if missing, it returns 0.


setSoundVolume

setSoundVolume(tag:String, value:Float):Void

Sets a Lua Sound's volume.


getSoundTime

getSoundTime(tag:String):Float

Returns a Lua Sound's time position, if missing, it returns 0.


setSoundTime

setSoundTime(tag:String, value:Float):Void

Sets a Lua Sound's time position.


getSoundPitch

getSoundPitch(tag:String):Float

Returns a Lua Sound's pitch shift, if missing, it returns 1.


setSoundPitch

setSoundPitch(tag:String, value:Float, ?doPause:Bool = false):Void

Sets a Lua Sound's pitch shift.