Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

AudioStream

Inherits: Resource < RefCounted < Object

Inherited By: AudioStreamGenerator, AudioStreamMicrophone, AudioStreamMP3, AudioStreamOggVorbis, AudioStreamPolyphonic, AudioStreamRandomizer, AudioStreamWAV

Base class for audio streams.

Description

Base class for audio streams. Audio streams are used for sound effects and music playback, and support WAV (via AudioStreamWAV) and Ogg (via AudioStreamOggVorbis) file formats.

Tutorials

Methods

int

_get_beat_count ( ) virtual const

float

_get_bpm ( ) virtual const

float

_get_length ( ) virtual const

String

_get_stream_name ( ) virtual const

AudioStreamPlayback

_instantiate_playback ( ) virtual const

bool

_is_monophonic ( ) virtual const

float

get_length ( ) const

AudioStreamPlayback

instantiate_playback ( )

bool

is_monophonic ( ) const


Method Descriptions

int _get_beat_count ( ) virtual const

Overridable method. Should return the total number of beats of this audio stream. Used by the engine to determine the position of every beat.

Ideally, the returned value should be based off the stream's sample rate (AudioStreamWAV.mix_rate, for example).


float _get_bpm ( ) virtual const

Overridable method. Should return the tempo of this audio stream, in beats per minute (BPM). Used by the engine to determine the position of every beat.

Ideally, the returned value should be based off the stream's sample rate (AudioStreamWAV.mix_rate, for example).


float _get_length ( ) virtual const

Override this method to customize the returned value of get_length. Should return the length of this audio stream, in seconds.


String _get_stream_name ( ) virtual const

Override this method to customize the name assigned to this audio stream. Unused by the engine.


AudioStreamPlayback _instantiate_playback ( ) virtual const

Override this method to customize the returned value of instantiate_playback. Should returned a new AudioStreamPlayback created when the stream is played (such as by an AudioStreamPlayer)..


bool _is_monophonic ( ) virtual const

Override this method to customize the returned value of is_monophonic. Should return true if this audio stream only supports one channel.


float get_length ( ) const

Returns the length of the audio stream in seconds.


AudioStreamPlayback instantiate_playback ( )

Returns a newly created AudioStreamPlayback intended to play this audio stream. Useful for when you want to extend _instantiate_playback but call instantiate_playback from an internally held AudioStream subresource. An example of this can be found in the source code for AudioStreamRandomPitch::instantiate_playback.


bool is_monophonic ( ) const

Returns true if this audio stream only supports one channel (monophony), or false if the audio stream supports two or more channels (polyphony).