AudioAPI reference
Class AudioClip
Namespace: MicroEngine.Audio
Assembly: MicroEngine.Audio.dll
Guide: Audio
Uncompressed audio: interleaved float samples in -1..1.
public sealed class AudioClipInheritance
Constructors
AudioClip(float[], int, int)
Wraps existing samples in a clip without copying them.
public AudioClip(float[] samples, int sampleRate = 44100, int channels = 1)Parameters
samples float[]
Interleaved samples in -1..1; the length must be a multiple of channels.
sampleRate int
Samples per second per channel; must be positive.
channels int
1 or 2.
Exceptions
sampleRate is not positive or channels is not 1 or 2.
The sample count is not a multiple of the channel count.
Fields
DefaultSampleRate
Sample rate used by the synthesizer and by default for new clips: 44100 Hz.
public const int DefaultSampleRate = 44100Field Value
Properties
Channels
1 (mono) or 2 (stereo).
public int Channels { get; }Property Value
Duration
Length of the clip in seconds.
public double Duration { get; }Property Value
Peak
The largest absolute sample value (0 for an empty clip). Computed on every read.
public float Peak { get; }Property Value
SampleRate
Samples per second per channel.
public int SampleRate { get; }Property Value
Samples
The samples, interleaved by channel (left, right, left… for stereo), each in -1..1. The array is not copied.
public float[] Samples { get; }Property Value
float[]
Methods
FromWav(ReadOnlySpan<byte>)
Decodes an uncompressed PCM WAV (8, 16 or 24-bit, mono or stereo).
public static AudioClip FromWav(ReadOnlySpan<byte> data)Parameters
data ReadOnlySpan<byte>
Returns
ToWav()
Encodes 16-bit PCM WAV bytes, the interchange format backends load from memory.
public byte[] ToWav()Returns
byte[]