PopochiuAudioManager
Inherits: Node
Description
Handles playing audio using PopochiuAudioCues.
It plays sound effects and music using AudioStreamPlayer or AudioStreamPlayer2D, creating these nodes at runtime if needed. By default, it has 6 nodes for positional streams and 5 for playing non-positional streams.
The PopochiuAudioManager is loaded as a child of Popochiu when the game starts.
Properties
| Type | Name | Default |
|---|---|---|
| Variant | twelfth_root_of_two | pow(2, (1.0 / 12)) |
| Variant | volume_settings | {} |
Methods
| Return Type | Method |
|---|---|
| void | change_cue_pitch(cue_name: String, pitch = 0.0) |
| void | change_cue_volume(cue_name: String, volume = 0.0) |
| float | get_cue_playback_position(cue_name: String) |
| bool | is_playing_cue(cue_name: String) |
| void | load_sound_settings() |
| Node | play_fade_cue(cue_name = "", duration = 1.0, from = -80.0, to = INF, position_2d = Vector2.ZERO, wait_to_end = null) |
| Node | play_music_cue(cue_name: String, fade_duration = 0.0, music_position = 0.0) |
| Node | play_sound_cue(cue_name = "", position_2d = Vector2.ZERO, wait_to_end = null) |
| void | save_sound_settings() |
| void | set_bus_volume_db(bus_name: String, value: float) |
| void | stop(cue_name: String, fade_duration = 0.0) |
Constants
| Name | Value |
|---|---|
SETTINGS_PATH |
"user://audio_settings.save" |
Constant Descriptions
SETTINGS_PATH
const SETTINGS_PATH = "user://audio_settings.save"
Specifies the path where the volume configuration for the audio buses used in the game is stored.
Property Descriptions
twelfth_root_of_two
var twelfth_root_of_two = pow(2, (1.0 / 12))
Used to convert the value of the pitch set on pitch to the
corresponding value needed for the pitch_scale property of the audio stream players.
volume_settings
var volume_settings = {}
Stores the volume values for each of the audio buses used by the game.
Method Descriptions
change_cue_pitch
func change_cue_pitch(cue_name: String, pitch = 0.0) -> void
Changes the pitch_scale of the PopochiuAudioCue identified by cue_name to
the value set (in semitones) in pitch.
change_cue_volume
func change_cue_volume(cue_name: String, volume = 0.0) -> void
Changes the volume_db of the PopochiuAudioCue identified by cue_name to
the value set in volume.
get_cue_playback_position
func get_cue_playback_position(cue_name: String) -> float
Returns the playback position of the PopochiuAudioCue identified by cue_name.
is_playing_cue
func is_playing_cue(cue_name: String) -> bool
Returns true if the PopochiuAudioCue identified by cue_name is playing.
load_sound_settings
func load_sound_settings()
Loads the volume values stored at SETTINGS_PATH for all the audio buses.
play_fade_cue
func play_fade_cue(cue_name = "", duration = 1.0, from = -80.0, to = INF, position_2d = Vector2.ZERO, wait_to_end = null) -> Node
Plays the PopochiuAudioCue identified by cue_name using a fade that will last
duration seconds. Specify the starting volume with from and the target volume
with to. You can play the audio positionally with position_2d and wait for it
to finish if wait_to_end is set to true.
play_music_cue
func play_music_cue(cue_name: String, fade_duration = 0.0, music_position = 0.0) -> Node
Searches for the PopochiuAudioCue identified by cue_name among the cues that are part
of the music group and plays it. It can fade for fade_duration seconds, and you can start
playing it from a given music_position in seconds.
play_sound_cue
func play_sound_cue(cue_name = "", position_2d = Vector2.ZERO, wait_to_end = null) -> Node
Searches for the PopochiuAudioCue identified by cue_name among the cues that are NOT
part of the music group and plays it. You can set a position_2d to play it positionally.
If wait_to_end is set to true, the function will pause until the audio
finishes.
save_sound_settings
func save_sound_settings()
Saves in the file at SETTINGS_PATH the volume values of all the audio buses.
set_bus_volume_db
func set_bus_volume_db(bus_name: String, value: float) -> void
Sets value as the volume of the audio bus identified with bus_name.
stop
func stop(cue_name: String, fade_duration = 0.0) -> void
Stops the PopochiuAudioCue identified by cue_name. It can use a fade effect that will
last fade_duration seconds.