Table of Contents

Class AudioStreamWav

Namespace
Godot
Assembly
GodotSharp.dll

AudioStreamWAV 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. See also AudioStreamGenerator for procedural audio generation.

[GodotClassName("AudioStreamWAV")]
public class AudioStreamWav : AudioStream, IDisposable
Inheritance
AudioStreamWav
Implements
Inherited Members

Constructors

AudioStreamWav()

public AudioStreamWav()

Properties

Data

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 byte[] Data { get; set; }

Property Value

byte[]

Format

Audio format. See AudioStreamWav.FormatEnum constants for values.

public AudioStreamWav.FormatEnum Format { get; set; }

Property Value

AudioStreamWav.FormatEnum

LoopBegin

The loop start point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.

public int LoopBegin { get; set; }

Property Value

int

LoopEnd

The loop end point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.

public int LoopEnd { get; set; }

Property Value

int

LoopMode

The loop mode. This information will be imported automatically from the WAV file if present. See AudioStreamWav.LoopModeEnum constants for values.

public AudioStreamWav.LoopModeEnum LoopMode { get; set; }

Property Value

AudioStreamWav.LoopModeEnum

MixRate

The sample rate for mixing this audio. Higher values require more storage space, but result in better quality.

In games, common sample rates in use are 11025, 16000, 22050, 32000, 44100, and 48000.

According to the Nyquist-Shannon sampling theorem, there is no quality difference to human hearing when going past 40,000 Hz (since most humans can only hear up to ~20,000 Hz, often less). If you are using lower-pitched sounds such as voices, lower sample rates such as 32000 or 22050 may be usable with no loss in quality.

public int MixRate { get; set; }

Property Value

int

Stereo

If true, audio is stereo.

public bool Stereo { get; set; }

Property Value

bool

Methods

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SaveToWav(string)

Saves the AudioStreamWAV 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.

public Error SaveToWav(string path)

Parameters

path string

Returns

Error