AudioStreamSample

Inherits: AudioStream < Resource < Reference < Object

Category: Core

Brief Description

Stores audio data loaded from .wav files.

Properties

PoolByteArraydata
Formatformat
intloop_begin
intloop_end
LoopModeloop_mode
intmix_rate
boolstereo

Methods

Errorsave_to_wav ( String path )

Enumerations

enum Format:

  • FORMAT_8_BITS = 0 — Audio codec 8 bit.
  • FORMAT_16_BITS = 1 — Audio codec 16 bit.
  • FORMAT_IMA_ADPCM = 2 — Audio codec IMA ADPCM.

enum LoopMode:

  • LOOP_DISABLED = 0 — Audio does not loop.
  • LOOP_FORWARD = 1 — Audio loops the data between loop_begin and loop_end playing forward only.
  • LOOP_PING_PONG = 2 — Audio loops the data between loop_begin and loop_end playing back and forth.
  • LOOP_BACKWARD = 3 — Audio loops the data between loop_begin and loop_end playing backward only.

Description

AudioStreamSample stores sound samples loaded from .wav files. To play the stored sound use an AudioStreamPlayer (for background music) or AudioStreamPlayer2D/AudioStreamPlayer3D (for positional audio). The sound can be looped.

This class can also be used to store dynamically generated PCM audio data.

Property Descriptions

Setterset_data(value)
Getterget_data()

Contains the audio data in bytes.


Setterset_format(value)
Getterget_format()

Audio format. See FORMAT_* constants for values.


  • int loop_begin
Setterset_loop_begin(value)
Getterget_loop_begin()

Loop start in bytes.


Setterset_loop_end(value)
Getterget_loop_end()

Loop end in bytes.


Setterset_loop_mode(value)
Getterget_loop_mode()

Loop mode. See LOOP_* constants for values.


Setterset_mix_rate(value)
Getterget_mix_rate()

The sample rate for mixing this audio.


Setterset_stereo(value)
Getteris_stereo()

If true, audio is stereo. Default value: false.

Method Descriptions

Saves the AudioStreamSample as a WAV file to path. Samples with IMA ADPCM format can’t be saved.

Note that a .wav extension is automatically appended to path if it is missing.