Stores audio data loaded from WAV files.
    public class AudioStreamSample : AudioStream

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

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

Inheritance Chain

Constructors

    public AudioStreamSample()

Properties

    public byte[] Data { get; set; }

Contains the audio data in bytes.

Note: This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.

    public FormatEnum Format { get; set; }

Audio format. See FORMAT_* constants for values.

    public int LoopBegin { get; set; }

Loop start in bytes.

    public int LoopEnd { get; set; }

Loop end in bytes.

    public LoopModeEnum LoopMode { get; set; }

Loop mode. See LOOP_* constants for values.

    public int MixRate { get; set; }

The sample rate for mixing this audio.

    public bool Stereo { get; set; }

If true, audio is stereo.

Methods

    [Obsolete("GetData is deprecated. Use the Data property instead.")]
    public byte[] GetData()

Getter for Data

    [Obsolete("GetFormat is deprecated. Use the Format property instead.")]
    public FormatEnum GetFormat()

Getter for Format

    [Obsolete("GetLoopBegin is deprecated. Use the LoopBegin property instead.")]
    public int GetLoopBegin()

Getter for LoopBegin

    [Obsolete("GetLoopEnd is deprecated. Use the LoopEnd property instead.")]
    public int GetLoopEnd()

Getter for LoopEnd

    [Obsolete("GetLoopMode is deprecated. Use the LoopMode property instead.")]
    public LoopModeEnum GetLoopMode()

Getter for LoopMode

    [Obsolete("GetMixRate is deprecated. Use the MixRate property instead.")]
    public int GetMixRate()

Getter for MixRate

    [Obsolete("IsStereo is deprecated. Use the Stereo property instead.")]
    public bool IsStereo()

Getter for Stereo

    public Error SaveToWav(string path)

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

Note: A .wav extension is automatically appended to path if it is missing.

    [Obsolete("SetData is deprecated. Use the Data property instead.")]
    public void SetData(byte[] data)

Setter for Data

    [Obsolete("SetFormat is deprecated. Use the Format property instead.")]
    public void SetFormat(FormatEnum format)

Setter for Format

    [Obsolete("SetLoopBegin is deprecated. Use the LoopBegin property instead.")]
    public void SetLoopBegin(int loopBegin)

Setter for LoopBegin

    [Obsolete("SetLoopEnd is deprecated. Use the LoopEnd property instead.")]
    public void SetLoopEnd(int loopEnd)

Setter for LoopEnd

    [Obsolete("SetLoopMode is deprecated. Use the LoopMode property instead.")]
    public void SetLoopMode(LoopModeEnum loopMode)

Setter for LoopMode

    [Obsolete("SetMixRate is deprecated. Use the MixRate property instead.")]
    public void SetMixRate(int mixRate)

Setter for MixRate

    [Obsolete("SetStereo is deprecated. Use the Stereo property instead.")]
    public void SetStereo(bool stereo)

Setter for Stereo

Inner Types

FormatEnum

Name Value Description
Format8Bits    
Format16Bits    
ImaAdpcm 2 Audio is compressed using IMA ADPCM.

LoopModeEnum

Name Value Description
Disabled 0 Audio does not loop.
Forward 1 Audio loops the data between [member loop_begin] and [member loop_end] playing forward only.
PingPong 2 Audio loops the data between [member loop_begin] and [member loop_end] playing back and forth.
Backward 3 Audio loops the data between [member loop_begin] and [member loop_end] playing backward only.
Tags: