Class AudioStreamInteractive
Audio stream that can playback music interactively, combining clips and a transition table.
- Inheritance
-
AudioStreamInteractive
Remarks
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 AudioStreamInteractive.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.
Fields
CLIP_ANY
This constant describes that any clip is valid for a specific transition as either source or destination.
const CLIP_ANY = -1
Properties
clip_count
Amount of clips contained in this interactive player.
var clip_count : int = 0
Property Value
Remarks
initial_clip
Index of the initial clip, which will be played first when this stream is played.
var initial_clip : int = 0
Property Value
Remarks
Methods
add_transition(int, int, int, int, int, float, bool, int, bool)
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 AudioStreamInteractive.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 AudioStreamInteractive.AUTO_ADVANCE_RETURN_TO_HOLD to return to this clip after another is done playing.
void add_transition(int from_clip, int to_clip, int from_time, int to_time, int fade_mode, float fade_beats, bool use_filler_clip, int filler_clip, bool hold_previous)
Parameters
from_clip
intto_clip
intfrom_time
intto_time
intfade_mode
intfade_beats
floatuse_filler_clip
boolfiller_clip
inthold_previous
bool
erase_transition(int, int)
Erase a transition by providing from_clip
and to_clip
clip indices. CLIP_ANY can be used for either argument or both.
void erase_transition(int from_clip, int to_clip)
Parameters
get_clip_auto_advance(int)
Qualifiers: const
Return whether a clip has auto-advance enabled. See AudioStreamInteractive.set_clip_auto_advance.
int get_clip_auto_advance(int clip_index)
Parameters
clip_index
int
get_clip_auto_advance_next_clip(int)
Qualifiers: const
Return the clip towards which the clip referenced by clip_index
will auto-advance to.
int get_clip_auto_advance_next_clip(int clip_index)
Parameters
clip_index
int
get_clip_name(int)
Qualifiers: const
Return the name of a clip.
StringName get_clip_name(int clip_index)
Parameters
clip_index
int
get_clip_stream(int)
Qualifiers: const
Return the AudioStream associated with a clip.
AudioStream get_clip_stream(int clip_index)
Parameters
clip_index
int
get_transition_fade_beats(int, int)
Qualifiers: const
Return the time (in beats) for a transition (see AudioStreamInteractive.add_transition).
float get_transition_fade_beats(int from_clip, int to_clip)
Parameters
get_transition_fade_mode(int, int)
Qualifiers: const
Return the mode for a transition (see AudioStreamInteractive.add_transition).
int get_transition_fade_mode(int from_clip, int to_clip)
Parameters
get_transition_filler_clip(int, int)
Qualifiers: const
Return the filler clip for a transition (see AudioStreamInteractive.add_transition).
int get_transition_filler_clip(int from_clip, int to_clip)
Parameters
get_transition_from_time(int, int)
Qualifiers: const
Return the source time position for a transition (see AudioStreamInteractive.add_transition).
int get_transition_from_time(int from_clip, int to_clip)
Parameters
get_transition_list
Qualifiers: const
Return the list of transitions (from, to interleaved).
PackedInt32Array get_transition_list
get_transition_to_time(int, int)
Qualifiers: const
Return the destination time position for a transition (see AudioStreamInteractive.add_transition).
int get_transition_to_time(int from_clip, int to_clip)
Parameters
has_transition(int, int)
Qualifiers: const
Returns true
if a given transition exists (was added via AudioStreamInteractive.add_transition).
bool has_transition(int from_clip, int to_clip)
Parameters
is_transition_holding_previous(int, int)
Qualifiers: const
Return whether a transition uses the hold previous functionality (see AudioStreamInteractive.add_transition).
bool is_transition_holding_previous(int from_clip, int to_clip)
Parameters
is_transition_using_filler_clip(int, int)
Qualifiers: const
Return whether a transition uses the filler clip functionality (see AudioStreamInteractive.add_transition).
bool is_transition_using_filler_clip(int from_clip, int to_clip)
Parameters
set_clip_auto_advance(int, int)
Set whether a clip will auto-advance by changing the auto-advance mode.
void set_clip_auto_advance(int clip_index, int mode)
Parameters
set_clip_auto_advance_next_clip(int, int)
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.
void set_clip_auto_advance_next_clip(int clip_index, int auto_advance_next_clip)
Parameters
set_clip_name(int, StringName)
Set the name of the current clip (for easier identification).
void set_clip_name(int clip_index, StringName name)
Parameters
clip_index
intname
StringName
set_clip_stream(int, AudioStream)
Set the AudioStream associated with the current clip.
void set_clip_stream(int clip_index, AudioStream stream)
Parameters
clip_index
intstream
AudioStream