Constructor WaveFile
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
pathstringFile system path to the .wav file to read. Must not be null or empty.
Exceptions
- ArgumentNullException
Thrown if
pathis 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
dataMemory<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
streamStreamStream containing WAV file data.
leaveOpenboolIf true, the
streamremains open after this instance is disposed; otherwise it is closed on Dispose.
Exceptions
- ArgumentNullException
Thrown if
streamis 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)