Index · Object → RefCounted → Resource → AudioStream → AudioStreamInteractive

AudioStreamInteractive

Audio stream that can playback music interactively, combining clips and a transition table.

Class Description

This is an audio stream that can playback music interactively, combining clips and a transition table. Clips must be added first, and then the transition rules via the add_transition(). Additionally, this stream exports a property parameter to control the playback via AudioStreamPlayer, AudioStreamPlayer2D, or AudioStreamPlayer3D.

The way this is used is by filling a number of clips, then configuring the transition table. From there, clips are selected for playback and the music will smoothly go from the current to the new one while using the corresponding transition rule defined in the transition table.

Properties

var clip_count: int = 0

Amount of clips contained in this interactive player.

var initial_clip: int = 0

Index of the initial clip, which will be played first when this stream is played.

Inherited from Resource (4)

Methods

func add_transition(from_clip: int, to_clip: int, from_time: AudioStreamInteractive.TransitionFromTime, to_time: AudioStreamInteractive.TransitionToTime, fade_mode: AudioStreamInteractive.FadeMode, fade_beats: float, use_filler_clip: bool = false, filler_clip: int = -1, hold_previous: bool = false) -> void

Add a transition between two clips. Provide the indices of the source and destination clips, or use the CLIP_ANY constant to indicate that transition happens to/from any clip to this one.

* from_time indicates the moment in the current clip the transition will begin after triggered.

* to_time indicates the time in the next clip that the playback will start from.

* fade_mode indicates how the fade will happen between clips. If unsure, just use FADE_AUTOMATIC which uses the most common type of fade for each situation.

* fade_beats indicates how many beats the fade will take. Using decimals is allowed.

* use_filler_clip indicates that there will be a filler clip used between the source and destination clips.

* filler_clip the index of the filler clip.

* If hold_previous is used, then this clip will be remembered. This can be used together with AUTO_ADVANCE_RETURN_TO_HOLD to return to this clip after another is done playing.

func erase_transition(from_clip: int, to_clip: int) -> void

Erase a transition by providing from_clip and to_clip clip indices. CLIP_ANY can be used for either argument or both.

func get_clip_auto_advance(clip_index: int) -> AudioStreamInteractive.AutoAdvanceMode

Return whether a clip has auto-advance enabled. See set_clip_auto_advance().

func get_clip_auto_advance_next_clip(clip_index: int) -> int

Return the clip towards which the clip referenced by clip_index will auto-advance to.

func get_clip_name(clip_index: int) -> StringName

Return the name of a clip.

func get_clip_stream(clip_index: int) -> AudioStream

Return the AudioStream associated with a clip.

func get_transition_fade_beats(from_clip: int, to_clip: int) -> float

Return the time (in beats) for a transition (see add_transition()).

func get_transition_fade_mode(from_clip: int, to_clip: int) -> AudioStreamInteractive.FadeMode

Return the mode for a transition (see add_transition()).

func get_transition_filler_clip(from_clip: int, to_clip: int) -> int

Return the filler clip for a transition (see add_transition()).

func get_transition_from_time(from_clip: int, to_clip: int) -> AudioStreamInteractive.TransitionFromTime

Return the source time position for a transition (see add_transition()).

func get_transition_list() -> PackedInt32Array

Return the list of transitions (from, to interleaved).

func get_transition_to_time(from_clip: int, to_clip: int) -> AudioStreamInteractive.TransitionToTime

Return the destination time position for a transition (see add_transition()).

func has_transition(from_clip: int, to_clip: int) -> bool

Returns true if a given transition exists (was added via add_transition()).

func is_transition_holding_previous(from_clip: int, to_clip: int) -> bool

Return whether a transition uses the hold previous functionality (see add_transition()).

func is_transition_using_filler_clip(from_clip: int, to_clip: int) -> bool

Return whether a transition uses the filler clip functionality (see add_transition()).

func set_clip_auto_advance(clip_index: int, mode: AudioStreamInteractive.AutoAdvanceMode) -> void

Set whether a clip will auto-advance by changing the auto-advance mode.

func set_clip_auto_advance_next_clip(clip_index: int, auto_advance_next_clip: int) -> void

Set the index of the next clip towards which this clip will auto advance to when finished. If the clip being played loops, then auto-advance will be ignored.

func set_clip_name(clip_index: int, name: StringName) -> void

Set the name of the current clip (for easier identification).

func set_clip_stream(clip_index: int, stream: AudioStream) -> void

Set the AudioStream associated with the current clip.

Inherited from AudioStream (16)
func _get_bpm() -> float
func _get_length() -> float
func _get_parameter_list() -> Dictionary[]
func _has_loop() -> bool
func get_length() -> float
Inherited from Resource (18)
func _get_rid() -> RID
func _reset_state() -> void
func _set_path_cache(path: String) -> void
func _setup_local_to_scene() -> void
func copy_from_resource(resource: Resource) -> Error
func duplicate(deep: bool = false) -> Resource
func duplicate_deep(deep_subresources_mode: Resource.DeepDuplicateMode = 1) -> Resource
func emit_changed() -> void
func get_rid() -> RID
func is_built_in() -> bool
func reset_state() -> void
func set_id_for_path(path: String, id: String) -> void
func set_path_cache(path: String) -> void
func setup_local_to_scene() -> void
func take_over_path(path: String) -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from AudioStream (1)
Inherited from Resource (2)
signal changed()
Inherited from Object (2)

Enums & Constants

enum TransitionFromTime
TRANSITION_FROM_TIME_IMMEDIATE = 0

Start transition as soon as possible, don't wait for any specific time position.

TRANSITION_FROM_TIME_NEXT_BEAT = 1

Transition when the clip playback position reaches the next beat.

TRANSITION_FROM_TIME_NEXT_BAR = 2

Transition when the clip playback position reaches the next bar.

TRANSITION_FROM_TIME_END = 3

Transition when the current clip finished playing.

enum TransitionToTime
TRANSITION_TO_TIME_SAME_POSITION = 0

Transition to the same position in the destination clip. This is useful when both clips have exactly the same length and the music should fade between them.

TRANSITION_TO_TIME_START = 1

Transition to the start of the destination clip.

TRANSITION_TO_TIME_PREVIOUS_POSITION = 2

Transition to the last played position in the destination clip, if there was a previous transition from that clip. Otherwise, plays from the start of the destination clip.

enum FadeMode
FADE_DISABLED = 0

Do not use fade for the transition. This is useful when transitioning from a clip-end to clip-beginning, and each clip has their begin/end.

FADE_IN = 1

Use a fade-in in the next clip, let the current clip finish.

FADE_OUT = 2

Use a fade-out in the current clip, the next clip will start by itself.

FADE_CROSS = 3

Use a cross-fade between clips.

FADE_AUTOMATIC = 4

Use automatic fade logic depending on the transition from/to. It is recommended to use this by default.

enum AutoAdvanceMode
AUTO_ADVANCE_DISABLED = 0

Disable auto-advance (default).

AUTO_ADVANCE_ENABLED = 1

Enable auto-advance, a clip must be specified.

AUTO_ADVANCE_RETURN_TO_HOLD = 2

Enable auto-advance, but instead of specifying a clip, the playback will return to hold (see add_transition()).

const CLIP_ANY = -1

This constant describes that any clip is valid for a specific transition as either source or destination.