PopochiuAudioCue
Extends: Resource
Description
Property Descriptions
audio
@export var audio: AudioStream
The audio file to play.
loop
@export var loop: bool = false
- Setter:
@loop_setter
Whether the audio file will loop when played.
is_2d
@export var is_2d: bool = false
Whether this audio cue uses a 2D position.
can_play_simultaneous
@export var can_play_simultaneous: bool = true
Whether the audio can be played simultaneously with other instances of itself. Especially useful for audio cues set in a loop (where [member loop] is [code]true[/code]).
pitch
@export var pitch: float = 0
The pitch value (in semitones) to use when playing the audio file.
volume
@export var volume: float = 0
The volume to use when playing the audio file.
rnd_pitch
@export var rnd_pitch: Vector2 = "(0, 0)"
The range of values to use for randomly changing the pitch of the audio file when played.
rnd_volume
@export var rnd_volume: Vector2 = "(0, 0)"
The range of values to use to randomly changing the volume of the audio file when played.
max_distance
@export var max_distance: int = 2000
Maximum distance from which the audio file is still hearable. This only works if [member is_2d] is [code]true[/code].
bus
@export var bus: String = "Master"
The audio bus in which the audio file will be played.
Method Descriptions
fade
func fade(duration: float = 1, wait_to_end: bool = false, from: float = -80, to: float = inf, position_2d: Vector2 = "(0, 0)") -> void
Plays this audio cue with a fade that lasts [param duration] seconds. If [param wait_to_end] is set to [code]true[/code], the function will wait for the audio to finish. You can specify the starting volume with [param from] and the target volume with [param to], as well as the [param position_2d] of the [AudioStreamPlayer] or [AudioStreamPlayer2D] that will play the audio file.
queue_fade
func queue_fade(duration: float = 1, wait_to_end: bool = false, from: float = -80, to: float = inf, position_2d: Vector2 = "(0, 0)") -> Callable
Plays this audio cue with a fade that lasts [param duration] seconds. If [param wait_to_end] is set to [code]true[/code], the function will wait for the audio to finish. You can specify the starting volume with [param from] and the target volume with [param to], as well as the [param position_2d] of the [AudioStreamPlayer] or [AudioStreamPlayer2D] that will play the audio file.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]
stop
func stop(fade_duration: float = 0) -> void
Stops the audio cue, with an optional fade effect lasting [param fade_duration] seconds.
queue_stop
func queue_stop(fade_duration: float = 0) -> Callable
Stops the audio cue, with an optional fade effect lasting [param fade_duration] seconds.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]
change_stream_pitch
func change_stream_pitch(pitch: float = 0) -> void
Changes the [member AudioStreamPlayer.pitch_scale] of the [AudioStreamPlayer] playing the audio file associated with this audio cue to [param pitch]. If the audio was played with a 2D position, then [member AudioStreamPlayer2D.pitch_scale] will be affected.
change_stream_volume
func change_stream_volume(volume: float = 0) -> void
Changes the [member AudioStreamPlayer.volume_db] of the [AudioStreamPlayer] playing the audio file associated with this audio cue to [param volume]. If the audio was played with a 2D position, then [member AudioStreamPlayer2D.volume_db] will be affected.
get_pitch_scale
func get_pitch_scale() -> float
Returns the value of [member 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 [member AudioStreamPlayer2D.volume_db] will be affected.
get_cue_playback_position
func get_cue_playback_position() -> float
Returns the playback position of this audio cue.
set_values
func set_values(values: Dictionary) -> void
Maps [param 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.
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.
is_playing
func is_playing() -> bool
Returns [code]true[/code] if playing.
set_loop
func set_loop(value: bool) -> void