Skip to content

Music Streamer

Background streaming music player with seamless looping, crossfading, and volume attenuation.

Type: MusicNode · Category: Audio & Sound · Also found as: music

Property Type Default Description
volume number 1 Volume (0-1), before the bus and master volumes. Range 0 to 1.
pitch number 1 Playback speed / pitch (1 = normal). Range 0.1 to 3.
pan number 0.5 Stereo position: 0 left, 0.5 centre, 1 right. Range 0 to 1.
bus string "" The mixer bus it plays into (the Mixer tab; empty = Music): its fader, effects and output apply.
caption string "" Shown on the subtitle track when it starts, for players with sound captions on (e.g. “[calm music]”).
looping boolean true Start again at the end.
autoplay boolean false Start playing when the node becomes ready.
isPlaying boolean false Playing now. Runtime state: read-only, not saved.
isPaused boolean false Paused now. Runtime state: read-only, not saved.

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Connects a handler to one of this node’s events: finished (Playback (or the dialogue) ended); the tree events; custom ones.

self.node:connect("finished", function(value, source) Log.info("finished") end)
  • event MusicNodeEvent|string
  • handler fun(value: any, source: MusicNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("volume")
  • path MusicNodeProperty|string

Returns any

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("volume", 1.5)
  • path MusicNodeProperty|string
  • value any
  • y? number

Plays or resumes the background music on this MusicNode.

Scene.find_node("Music"):music_play()

Stops background music on this MusicNode.

Scene.find_node("Music"):music_stop()

Pauses background music on this MusicNode.

Scene.find_node("Music"):music_pause()

Resumes paused background music on this MusicNode.

Scene.find_node("Music"):music_resume()

MusicNode:music_fade(volume, seconds, stop_at_end)

Section titled “MusicNode:music_fade(volume, seconds, stop_at_end)”

Fades this MusicNode’s volume to volume (0..1) over seconds, starting it if it isn’t playing.

Scene.find_node("Music"):music_fade(0, 2.0, true)
  • volume number
  • seconds number
  • stop_at_end? boolean Stop when the fade reaches 0
{
"type": "MusicNode",
"name": "MusicStreamer",
"position": [
0,
0
],
"properties": {
"volume": 1,
"pitch": 1,
"pan": 0.5
}
}