PopochiuAudioCue

Inherits: Resource

Description

Used to play audio files with extra properties.

You can set the pitch (with random values), volume, and audio bus, as well as specify whether it loops, and whether it is 2D positioned.


Properties

Type Name Default
AudioStream audio
Variant bus "Master"
Variant can_play_simultaneous true
Variant is_2d false
Variant loop false
Variant max_distance 2000
Variant pitch 0.0
Variant rnd_pitch Vector2.ZERO
Variant rnd_volume Vector2.ZERO
Variant volume 0.0

Methods

Return Type Method
void change_stream_pitch(pitch = 0.0)
void change_stream_volume(volume = 0.0)
void fade(duration = 1.0, wait_to_end = false, from = -80.0, to = INF, position_2d = Vector2.ZERO)
float get_cue_playback_position()
float get_pitch_scale()
Dictionary get_values()
bool is_playing()
Callable queue_fade(duration = 1.0, wait_to_end = false, from = -80.0, to = INF, position_2d = Vector2.ZERO)
Callable queue_stop(fade_duration = 0.0)
void set_loop(value: bool)
void set_values(values: Dictionary)
void stop(fade_duration = 0.0)

Property Descriptions

audio

@export var audio : AudioStream

The audio file to play.


bus

@export var bus = "Master"

The audio bus in which the audio file will be played.


can_play_simultaneous

@export var can_play_simultaneous = true

Whether the audio can be played simultaneously with other instances of itself. Especially useful for audio cues set in a loop (where loop is true).


is_2d

@export var is_2d = false

Whether this audio cue uses a 2D position.


loop

@export var loop = false
  • Setter: set_loop

Whether the audio file will loop when played.


max_distance

@export var max_distance = 2000

Maximum distance from which the audio file is still hearable. This only works if is_2d is true.


pitch

@export var pitch = 0.0

The pitch value (in semitones) to use when playing the audio file.


rnd_pitch

@export var rnd_pitch = Vector2.ZERO

The range of values to use for randomly changing the pitch of the audio file when played.


rnd_volume

@export var rnd_volume = Vector2.ZERO

The range of values to use to randomly changing the volume of the audio file when played.


volume

@export var volume = 0.0

The volume to use when playing the audio file.


Method Descriptions

change_stream_pitch

func change_stream_pitch(pitch = 0.0) -> void

Changes the AudioStreamPlayer.pitch_scale of the AudioStreamPlayer playing the audio file associated with this audio cue to pitch. If the audio was played with a 2D position, then AudioStreamPlayer2D.pitch_scale will be affected.


change_stream_volume

func change_stream_volume(volume = 0.0) -> void

Changes the AudioStreamPlayer.volume_db of the AudioStreamPlayer playing the audio file associated with this audio cue to volume. If the audio was played with a 2D position, then AudioStreamPlayer2D.volume_db will be affected.


fade

func fade(duration = 1.0, wait_to_end = false, from = -80.0, to = INF, position_2d = Vector2.ZERO) -> void

Plays this audio cue with a fade that lasts duration seconds. If wait_to_end is set to true, the function will wait for the audio to finish. You can specify the starting volume with from and the target volume with to, as well as the position_2d of the AudioStreamPlayer or AudioStreamPlayer2D that will play the audio file.


get_cue_playback_position

func get_cue_playback_position() -> float

Returns the playback position of this audio cue.


get_pitch_scale

func get_pitch_scale() -> float

Returns the value of AudioStreamPlayer.pitch_scale to be applied to the AudioStreamPlayer playing the audio file associated with this audio cue. If the audio was played with a 2D position, then AudioStreamPlayer2D.volume_db will be affected.


get_values

func get_values() -> Dictionary

Returns the properties of this audio cue as a Dictionary. This is used by TabAudio when changing the script of the audio cue to one of the types: AudioCueSound or AudioCueMusic.


is_playing

func is_playing() -> bool

Returns true if playing.


queue_fade

func queue_fade(duration = 1.0, wait_to_end = false, from = -80.0, to = INF, position_2d = Vector2.ZERO) -> Callable

Plays this audio cue with a fade that lasts duration seconds. If wait_to_end is set to true, the function will wait for the audio to finish. You can specify the starting volume with from and the target volume with to, as well as the position_2d of the AudioStreamPlayer or AudioStreamPlayer2D that will play the audio file.

This method is intended to be used inside a queue() of instructions.


queue_stop

func queue_stop(fade_duration = 0.0) -> Callable

Stops the audio cue, with an optional fade effect lasting fade_duration seconds.

This method is intended to be used inside a queue() of instructions.


set_loop

func set_loop(value: bool) -> void

set_values

func set_values(values: Dictionary) -> void

Maps values to the properties of this audio cue. This is used by TabAudio when changing the script of the audio cue to one of the types: AudioCueSound or AudioCueMusic.


stop

func stop(fade_duration = 0.0) -> void

Stops the audio cue, with an optional fade effect lasting fade_duration seconds.