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
path
stringFile 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
StreamStream containing WAV file data.
leaveOpen
boolIf 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)