Table of Contents

Constructor WaveFile

Namespace
LMKit.Media.Audio
Assembly
LM-Kit.NET.dll

WaveFile(string)

Initializes a new WaveFile by opening the WAV file at the specified path, reading its audio header information and locating the data section.

public WaveFile(string path)

Parameters

path string

File system path to the .wav file to read. Must not be null or empty.

Exceptions

ArgumentNullException

Thrown if path is null.

FileNotFoundException

Thrown if no file exists at path.

IOException

Thrown on I/O errors while opening the file.

CorruptedAudioException

Thrown if the file’s header, chunks, or data are invalid or incomplete.

NotSupportedAudioException

Thrown if the audio format is unsupported.

WaveFile(Memory<byte>)

Initializes a new WaveFile by reading WAV data from the given in-memory buffer.

public WaveFile(Memory<byte> data)

Parameters

data Memory<byte>

A Memory<T> containing the complete contents of a WAV file (RIFF header, fmt/data chunks, etc.).

Exceptions

CorruptedAudioException

Thrown if the buffer is too small to contain a valid WAV header or chunks, or if chunk sizes are invalid.

NotSupportedAudioException

Thrown if the WAV format (bit depth, channel count, or sub-format GUID) is not supported.

WaveFile(Stream, bool)

Initializes a new WaveFile from the provided stream.

public WaveFile(Stream stream, bool leaveOpen = false)

Parameters

stream Stream

Stream containing WAV file data.

leaveOpen bool

If true, the stream remains open after this instance is disposed; otherwise it is closed on Dispose.

Exceptions

ArgumentNullException

Thrown if stream is null.

CorruptedAudioException

Thrown if the file’s header, chunks, or data are invalid or incomplete.

NotSupportedAudioException

Thrown if the audio format is unsupported.

WaveFile(IList<float>, uint)

Creates a new WaveFile instance from normalized mono float samples.

public WaveFile(IList<float> samples, uint sampleRate = 16000)

Parameters

samples IList<float>

Float samples in [-1,1].

sampleRate uint

Sample rate of these samples, in Hz.
Defaults to 16 000 (16 kHz).