Table of Contents

Class FileSfzSampleLoader

Namespace
NAudio.Sampler
Assembly
NAudio.Sampler.dll

Loads SFZ samples from disk, resolving relative paths against a base directory and decoding each fully into memory. WAV is read directly; other formats (FLAC, Ogg-Vorbis, Opus, …) decode through NAudio.SoundFile (libsndfile). If libsndfile is unavailable or the file cannot be decoded, the load fails gracefully (the region is skipped).

public sealed class FileSfzSampleLoader : ISfzSampleLoader
Inheritance
FileSfzSampleLoader
Implements
Inherited Members

Constructors

FileSfzSampleLoader(string)

Creates a loader rooted at the given base directory.

public FileSfzSampleLoader(string baseDirectory)

Parameters

baseDirectory string

Methods

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

Loads the sample at path (as written in the SFZ) into channel buffers: left is the left/mono channel and right is the right channel, or null for a mono sample. embeddedLoop carries loop points authored in the sample file itself (a WAV smpl chunk), or null if there are none — per the SFZ spec these are the region's default loop points and make loop_mode default to loop_continuous. Returns false if the sample cannot be found or decoded.

public 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