Table of Contents

Class WaveSampleLoader

Namespace
NAudio.Sampler
Assembly
NAudio.Sampler.dll

Decodes an audio file (or any ISampleProvider) fully into mono/stereo float channel buffers for the sampler — the in-memory, random-access form the voice engine plays from. WAV is read directly (including any loop points authored in its smpl chunk); other formats decode through any provided ISampleProvider (e.g. NAudio.SoundFile.SoundFileReader for FLAC/Ogg). Shared by the SFZ sample loader and the single-sample instrument.

public static class WaveSampleLoader
Inheritance
WaveSampleLoader
Inherited Members

Methods

TryLoad(ISampleProvider, out float[], out float[], out int)

Reads an entire sample provider into channel buffers (left/mono and an optional right channel), decoding it fully into memory. Returns false if it yields no samples.

public static bool TryLoad(ISampleProvider source, out float[] left, out float[] right, out int sampleRate)

Parameters

source ISampleProvider
left float[]
right float[]
sampleRate int

Returns

bool

TryLoad(string, out float[], out float[], out int)

Reads a WAV file into channel buffers: left is the left/mono channel and right is the right channel, or null for a mono file. Channels beyond the first two are ignored. Returns false if the file is missing or empty.

public static bool TryLoad(string path, out float[] left, out float[] right, out int sampleRate)

Parameters

path string
left float[]
right float[]
sampleRate int

Returns

bool

TryLoad(string, out float[], out float[], out int, out SampleLoop?)

Reads a WAV file into channel buffers (see TryLoad(string, out float[], out float[], out int)), also surfacing the first loop authored in the file's smpl chunk — real sample libraries commonly put loop points in the WAV rather than in the instrument definition. embeddedLoop is null when the file has no (valid) smpl loop; malformed or truncated chunks are ignored rather than failing the load.

public static bool TryLoad(string path, out float[] left, out float[] right, out int sampleRate, out SampleLoop? embeddedLoop)

Parameters

path string
left float[]
right float[]
sampleRate int
embeddedLoop SampleLoop?

Returns

bool