SoundFileclass

A sound resource.

objectResourceSoundFile
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public class Sandbox.SoundFile : Sandbox.Resource

Methods15

Showing 15 methods

protected virtual override void Finalize()PROTECTEDVIRTUALOVERRIDE

Returns:void

public static Sandbox.SoundFile FromOgg(string filename, System.Span`1<byte> data, Sandbox.SoundFile.LoadOptions options = null)PUBLICSTATIC

ParameterTypeDescription
filenamestring
dataSpan<byte>
options = nullLoadOptions
Returns:SoundFile

public System.Threading.Tasks.Task`1<short[]> GetSamplesAsync()PUBLIC

Request decompressed audio samples.

Returns:Task<short[]>

public static Sandbox.SoundFile Load(string filename)PUBLICSTATIC

Load a new sound from disk. Includes automatic caching.

ParameterTypeDescription
filenamestringThe file path to load the sound from.
Returns:SoundFileThe loaded sound file, or null if failed.

public System.Threading.Tasks.Task`1<bool> LoadAsync()PUBLIC

Returns:Task<bool>

public void Preload()PUBLIC

Returns:void

Properties11

Showing 11 properties

public int Sandbox.SoundFile.BitsPerSample { get; set; }PUBLICGETSET

Bits per each sample of this sound file.

Returns:int

public int Sandbox.SoundFile.BytesPerSample { get; set; }PUBLICGETSET

Bytes per each sample of this sound file.

Returns:int

public int Sandbox.SoundFile.Channels { get; set; }PUBLICGETSET

Number of channels this audio file has.

Returns:int

public float Sandbox.SoundFile.Duration { get; set; }PUBLICGETSET

Duration of the sound this sound file contains, in seconds.

Returns:float

public bool Sandbox.SoundFile.IsLoaded { get; set; }PUBLICGETSET

true if sound is loaded

Returns:bool

public virtual bool Sandbox.SoundFile.IsValid { get; set; }PUBLICVIRTUALGETSET

Returns:bool

public bool Sandbox.SoundFile.IsValidForPlayback { get; set; }PUBLICGETSET

Returns:bool

public System.Action Sandbox.SoundFile.OnSoundReloaded { get; set; }PUBLICGETSET

Ran when the file is reloaded/recompiled, etc.

Returns:Action

public int Sandbox.SoundFile.Rate { get; set; }PUBLICGETSET

Sample rate of this sound file, per second.

Returns:int

public int Sandbox.SoundFile.SampleFrameSize { get; set; }PUBLICGETSET

Size of one sample, typically this would be "sample size * channel count", but can vary on audio format.

Returns:int

On this page

Methodsprotected virtual override System.Void Finalize()public static Sandbox.SoundFile FromMp3(System.String filename, System.Span`1<System.Byte> data, Sandbox.SoundFile.LoadOptions options = null)public static Sandbox.SoundFile FromMp3(System.String filename, System.Span`1<System.Byte> data, System.Boolean loop)public static Sandbox.SoundFile FromMp3(System.String filename, System.Span`1<System.Byte> data, System.Int32 loopStart, System.Int32 loopEnd)public static Sandbox.SoundFile FromOgg(System.String filename, System.Span`1<System.Byte> data, Sandbox.SoundFile.LoadOptions options = null)public static Sandbox.SoundFile FromPcm(System.String filename, System.Span`1<System.Byte> data, Sandbox.SoundFile.PcmOptions options = null)public static Sandbox.SoundFile FromPcm(System.String filename, System.Span`1<System.Byte> data, System.Int32 channels, System.UInt32 rate, System.Int32 bits, System.Boolean loop)public static Sandbox.SoundFile FromPcm(System.String filename, System.Span`1<System.Byte> data, System.Int32 channels, System.UInt32 rate, System.Int32 bits, System.Int32 loopStart, System.Int32 loopEnd)public static Sandbox.SoundFile FromWav(System.String filename, System.Span`1<System.Byte> data, Sandbox.SoundFile.LoadOptions options = null)public static Sandbox.SoundFile FromWav(System.String filename, System.Span`1<System.Byte> data, System.Boolean loop)public static Sandbox.SoundFile FromWav(System.String filename, System.Span`1<System.Byte> data, System.Int32 loopStart, System.Int32 loopEnd)public System.Threading.Tasks.Task`1<System.Int16[]> GetSamplesAsync()public static Sandbox.SoundFile Load(System.String filename)public System.Threading.Tasks.Task`1<System.Boolean> LoadAsync()public System.Void Preload()Propertiespublic System.Int32 Sandbox.SoundFile.BitsPerSample { get; set; }public System.Int32 Sandbox.SoundFile.BytesPerSample { get; set; }public System.Int32 Sandbox.SoundFile.Channels { get; set; }public System.Single Sandbox.SoundFile.Duration { get; set; }public Sandbox.SoundFormat Sandbox.SoundFile.Format { get; set; }public System.Boolean Sandbox.SoundFile.IsLoaded { get; set; }public virtual System.Boolean Sandbox.SoundFile.IsValid { get; set; }public System.Boolean Sandbox.SoundFile.IsValidForPlayback { get; set; }public System.Action Sandbox.SoundFile.OnSoundReloaded { get; set; }public System.Int32 Sandbox.SoundFile.Rate { get; set; }public System.Int32 Sandbox.SoundFile.SampleFrameSize { get; set; }Metadata