Skip to main content

sound

audio · 5 properties · Audio

A sound of the node's own: which file, at what volume and pitch, looping or not. audio.play_on and audio.stop_on trigger it, and autoplay starts it when the node enters the scene.

In a scene, sound is the node key that applies it. A script reaches the same properties through node.sound.get() and node.sound.set(table).

Properties

propertytypedefaultdescription
autoplayboolfalseStart playing when the node enters the scene
filestringAudio file, project-relative; required to play
loopboolfalseRestart the sound when it ends
pitchfloat1Playback speed multiplier At least 0.01.
volumefloat1Linear gain; 1 is the file's own level At least 0.

Script functions

Methods of node.sound, the handle a node carrying this component exposes. Each is also a free function on its module, taking the node as its first argument. Every handle also has get(), set(table), has() and remove().

From audio:

methodwhat it does
play_on() -> intStart the node's own sound from the top, replacing what it had going, and return the new handle.
stop_on()Silence what the node's sound started; a node carrying none is left alone.