Audio

This contains the source code documentation of the class subsystem_Audio.

subsystem_Audio

Inherits: DialogicSubsystem

Subsystem for managing background music and one-shot sound effects.

Description

This subsystem has many different helper methods for managing audio in your timeline. For instance, you can listen to music changes via music_started.

Properties


Methods

ReturnsMethod
voidclear_game_state ( _clear_flag: int = 0 )
voidload_game_state ( load_flag: int = 0 )
voidpause ( )
voidresume ( )
voidupdate_music ( path: String = "", volume: float = 0.0, audio_bus: String = "", fade_time: float = 0.0, loop: bool = true )
boolhas_music ( )
voidplay_sound ( path: String, volume: float = 0.0, audio_bus: String = "", loop: bool = false )
voidstop_all_sounds ( )
voidinterpolate_volume_linearly ( value: float, node: Node )
boolis_music_playing_resource ( resource_path: String )

Signals

signal music_started ( info: Dictionary )

Whenever a new background music is started, this signal is emitted and contains a dictionary with the following keys:

KeyValue TypeValue
pathStringThe path to the audio resource file.
volumefloatThe volume of the audio resource that will be set to the base_music_player.
audio_busStringThe audio bus name that the base_music_player will use.
loopboolWhether the audio resource will loop or not once it finishes playing.

signal sound_started ( info: Dictionary )

Whenever a new sound effect is set, this signal is emitted and contains a dictionary with the following keys:

KeyValue TypeValue
pathStringThe path to the audio resource file.
volumefloatThe volume of the audio resource that will be set to base_sound_player.
audio_busStringThe audio bus name that the base_sound_player will use.
loopboolWhether the audio resource will loop or not once it finishes playing.

Property Descriptions

var base_music_player = new()

Audio player base duplicated to play background music. Background music is long audio.


var current_music_player

Reference to the last used music player.


var base_sound_player = new()

Audio player base, that will be duplicated to play sound effects. Sound effects are short audio.


Method Descriptions

func clear_game_state ( _clear_flag: int = 0 ) ⇒ void

Clears the state on this subsystem and stops all audio. If you want to stop sounds only, use stop_all_sounds.


func load_game_state ( load_flag: int = 0 ) ⇒ void

Loads the state on this subsystem from the current state info.


func pause ( ) ⇒ void

Pauses playing audio.


func resume ( ) ⇒ void

Resumes playing audio.


func update_music ( path: String = "", volume: float = 0.0, audio_bus: String = "", fade_time: float = 0.0, loop: bool = true ) ⇒ void

Updates the background music. Will fade out previous music.


func has_music ( ) ⇒ bool

Whether music is playing.


func play_sound ( path: String, volume: float = 0.0, audio_bus: String = "", loop: bool = false ) ⇒ void

Plays a given sound file.


func stop_all_sounds ( ) ⇒ void

Stops all audio.


func interpolate_volume_linearly ( value: float, node: Node ) ⇒ void

Converts a linear loudness value to decibel and sets that volume to the given node.


func is_music_playing_resource ( resource_path: String ) ⇒ bool

Returns whether the currently playing audio resource is the same as this event's resource_path.