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
Name | Type | Default |
---|---|---|
base_music_player | AudioStreamPlayer | new() |
current_music_player | AudioStreamPlayer | |
base_sound_player | AudioStreamPlayer | new() |
Methods
Returns | Method |
---|---|
void | clear_game_state ( _clear_flag : int = 0 ) |
void | load_game_state ( load_flag : int = 0 ) |
void | pause ( ) |
void | resume ( ) |
void | update_music ( path : String = "" , volume : float = 0.0 , audio_bus : String = "" , fade_time : float = 0.0 , loop : bool = true ) |
bool | has_music ( ) |
void | play_sound ( path : String, volume : float = 0.0 , audio_bus : String = "" , loop : bool = false ) |
void | stop_all_sounds ( ) |
void | interpolate_volume_linearly ( value : float, node : Node ) |
bool | is_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:
Key | Value Type | Value |
---|---|---|
path | String | The path to the audio resource file. |
volume | float | The volume of the audio resource that will be set to the base_music_player . |
audio_bus | String | The audio bus name that the base_music_player will use. |
loop | bool | Whether 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:
Key | Value Type | Value |
---|---|---|
path | String | The path to the audio resource file. |
volume | float | The volume of the audio resource that will be set to base_sound_player . |
audio_bus | String | The audio bus name that the base_sound_player will use. |
loop | bool | Whether the audio resource will loop or not once it finishes playing. |
Property Descriptions
Audio player base duplicated to play background music. Background music is long audio.
Reference to the last used music player.
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.
Pauses playing audio.
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.
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
.