Skip to content

DynamicMusicPlayer ​

Inherits: Node

Plays a Dynamic Music. It builds one AudioStreamInteractive from the parts of the music (a clip for each part; a part with layers is an AudioStreamSynchronized of the piece and its stems), sets the tempo of the pieces from the data of the parts (a copy of the stream gets the bpm, so the file needs none), and plays it. A change of state switches the clip with the rule of the music for that change (when, where the new part starts, the fade, a bridge part). The intensity (0 to 1) fades the layers in and out. A stinger plays over the music and lowers it while it plays. The AudioManager owns one and starts it when a sound source is a Dynamic Music. Needs Ogg or MP3 (a WAV has no tempo). See docs: Audio > Dynamic Music.

Variables ​

DynamicMusicmusic
Stringcurrent_state""
floatintensity0.0
AudioStreamInteractiveinteractive
AudioStreamPlayerplayer

Methods ​

boolis_playing()
intget_clip_of_part( part_name: String )
intget_current_clip()
boolstart( p_music: DynamicMusic, state_name: String = "", fade: float = 0.0, p_volume_db: float = 0.0 )
voidstop( fade: float = 0.0 )
boolset_state( state_name: String )
voidset_intensity( value: float, instant: bool = false )
boolplay_stinger( stinger_name: String )
boolplay_stinger_of( source_music: DynamicMusic, stinger_name: String )
floatget_layer_level( part_name: String, layer_index: int )

Signals ​

finished() ​

The part that was playing ended and no other follows: the music is over

state_changed( state_name: String ) ​

The state changed (the name of the new one)

Variable descriptions ​

DynamicMusic music ​

The music that plays (null when nothing does)

String current_state = "" ​

The state the music is in

float intensity = 0.0 ​

The intensity, 0 to 1

AudioStreamInteractive interactive ​

The stream that plays

AudioStreamPlayer player ​

The player of the music

Method descriptions ​

bool is_playing() ​

No description yet.

int get_clip_of_part( part_name: String ) ​

The index of the clip of a part (-1 when the part is not in the stream)

int get_current_clip() ​

The clip that plays now (-1 when none)

bool start( p_music: DynamicMusic, state_name: String = "", fade: float = 0.0, p_volume_db: float = 0.0 ) ​

Starts a music in a state (empty = its start state), fading in over fade seconds. False when nothing can be played

void stop( fade: float = 0.0 ) ​

Stops the music, fading out over fade seconds

bool set_state( state_name: String ) ​

Changes the state: the part of the new state takes over by the rule of the music for this change. A state that plays the part that plays only changes the intensity. False when the state does not exist

void set_intensity( value: float, instant: bool = false ) ​

The intensity, 0 to 1: the layers whose "from intensity" is at most this play, the others fade out

bool play_stinger( stinger_name: String ) ​

Plays a stinger of this music over it, lowering the music while it plays. False when there is no such stinger

bool play_stinger_of( source_music: DynamicMusic, stinger_name: String ) ​

Plays a stinger of any Dynamic Music (the music need not be the one that plays); the music that plays is lowered

float get_layer_level( part_name: String, layer_index: int ) ​

The level (0 to 1) a layer of a part has now (for the tests and the editor)