subsystem_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 )
boolhas_music ( )
voidinterpolate_volume_linearly ( value: float, node: Node )
boolis_music_playing_resource ( resource_path: String )
voidload_game_state ( load_flag: int = 0 )
voidpause ( )
voidplay_sound ( path: String, volume: float = 0.0, audio_bus: String = "Master", loop: bool = false )
voidresume ( )
voidstop_all_sounds ( )
voidupdate_music ( path: String = "", volume: float = 0.0, audio_bus: String = "Master", fade_time: float = 0.0, loop: bool = true )

Signals

signal music_started ( info: Dictionary )

Whenever a new background 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 the audio player.
audio_busStringThe audio bus name that the audio 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 the audio player.
audio_busStringThe audio bus name that the audio player will use.
loopboolWhether the audio resource will loop or not once it finishes playing.
]

Property Descriptions

var base_music_player =

Audio player used to play background music. Background music is long audio.


var base_sound_player =

Audio player used 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 the all sounds. If you want to stop audio only, use stop_all_sounds.


func has_music ( ) ⇒ bool

Whether music is playing.


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.


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 play_sound ( path: String, volume: float = 0.0, audio_bus: String = "Master", loop: bool = false ) ⇒ void

Plays a given sound file.


func resume ( ) ⇒ void

Resumes playing audio.


func stop_all_sounds ( ) ⇒ void

Stops all audio.


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

Updates the background music. Will fade out previous music.