Class WavFileWriter
This class writes WAV data to a .wav file on disk.
Namespace: Evergine.Common.Media
Assembly: Evergine.Common.dll
Syntax
public class WavFileWriter : Stream
Constructors
WavFileWriter(Stream, WavFormat)
Initializes a new instance of the WavFileWriter class that writes to a stream.
Declaration
public WavFileWriter(Stream outStream, WavFormat format)
Parameters
Type | Name | Description |
---|---|---|
Stream | outStream | Stream to be written to. |
WavFormat | format | Wave format to use. |
WavFileWriter(Stream, WavFormat, bool)
Initializes a new instance of the WavFileWriter class that writes to a stream.
Declaration
public WavFileWriter(Stream outStream, WavFormat format, bool writeWPKHeader)
Parameters
Type | Name | Description |
---|---|---|
Stream | outStream | Stream to write to. |
WavFormat | format | Wave format to use. |
bool | writeWPKHeader | Indicates whether to write the WPK header. |
Properties
CanRead
Gets a value indicating whether it can read. (Returns false: cannot read from a WaveFileWriter).
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
CanSeek
Gets a value indicating whether seeking within the WaveFileWriter is possible. Returns false as seeking is not supported.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
CanWrite
Gets a value indicating whether it can write (Returns true if it can write to a WaveFileWriter).
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Length
Gets the number of bytes of audio in the data chunk.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
long |
Overrides
Position
Gets or sets the position in the WaveFile (i.e. number of bytes written so far).
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
long |
Overrides
WaveFormat
Gets the WaveFormat of this wave file.
Declaration
public WavFormat WaveFormat { get; }
Property Value
Type | Description |
---|---|
WavFormat |
Methods
Dispose(bool)
Actually performs the close, making sure the header contains the correct data.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | True if called from |
Overrides
~WavFileWriter()
Finalizes an instance of the WavFileWriter class. Should only be called if the user forgot to close this WavFileWriter.
Declaration
protected ~WavFileWriter()
Flush()
Ensures that data is written to disk.
Declaration
public override void Flush()
Overrides
Read(byte[], int, int)
Read is not supported for a WaveFileWriter.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | Byte read buffer. |
int | offset | Offset of the read in the buffer. |
int | count | Number of elements of the read operation. |
Returns
Type | Description |
---|---|
int | Bytes read. |
Overrides
Seek(long, SeekOrigin)
Seeking is not supported for a WaveFileWriter.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
long | offset | Offset to seek. |
SeekOrigin | origin | Origin of the seek. |
Returns
Type | Description |
---|---|
long | The new position within the current stream. |
Overrides
SetLength(long)
SetLength is not supported for EvergineFileWriter.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
long | value | The new length. |
Overrides
UpdateHeader(BinaryWriter)
Updates the header with file size information.
Declaration
protected virtual void UpdateHeader(BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | writer | Binary Writer. |
Write(byte[], int, int)
Appends bytes to the WaveFile (assumes they are already in the correct format).
Declaration
public override void Write(byte[] data, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | data | The buffer containing the wave data. |
int | offset | The offset from which to start writing. |
int | count | The number of bytes to write. |
Overrides
WriteData(short[], int, int)
Writes 16-bit samples to the wave file.
Declaration
[Obsolete("Use WriteSamples instead")]
public void WriteData(short[] samples, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
short[] | samples | The buffer containing the 16-bit samples. |
int | offset | The offset from which to start writing. |
int | count | The number of 16-bit samples to write. |
WriteSample(float)
Writes a single sample to the Wave file.
Declaration
public void WriteSample(float sample)
Parameters
Type | Name | Description |
---|---|---|
float | sample | The sample to write (assumed to be a floating point with 1.0f as the max value). |
WriteSamples(short[], int, int)
Writes 16-bit samples to the wave file.
Declaration
public void WriteSamples(short[] samples, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
short[] | samples | The buffer containing the 16-bit samples. |
int | offset | The offset from which to start writing. |
int | count | The number of 16-bit samples to write. |
WriteSamples(float[], int, int)
Writes 32-bit floating point samples to the WAV file. They will be converted to the appropriate bit depth depending on the WaveFormat of the WAV file.
Declaration
public void WriteSamples(float[] samples, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
float[] | samples | The buffer containing the floating point samples. |
int | offset | The offset from which to start writing. |
int | count | The number of floating point samples to write. |