Class WavFileWriter
This class writes WAV data to a .wav file on disk.
Implements
Inherited Members
Namespace: Evergine.Common.Media
Assembly: Evergine.Common.dll
Syntax
public class WavFileWriter : Stream, IDisposable
Constructors
WavFileWriter(Stream, WavFormat)
Initializes a new instance of the WavFileWriter class that actually 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 actually writes to a stream.
Declaration
public WavFileWriter(Stream outStream, WavFormat format, bool writeWPKHeader)
Parameters
Type | Name | Description |
---|---|---|
Stream | outStream | Stream to be written to. |
WavFormat | format | Wave format to use. |
bool | writeWPKHeader | If writes wpk header. |
Properties
CanRead
Gets a value indicating whether 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 returns false: Cannot seek within a WaveFileWriter.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
CanWrite
Gets a value indicating whether can write (Returns true: 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 gets 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 WaveFileWriter
Declaration
protected ~WavFileWriter()
Flush()
Ensures 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 | Count of elements of the read operation. |
Returns
Type | Description |
---|---|
int | Bytes readed. |
Overrides
Seek(long, SeekOrigin)
Seek 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 | 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 floating point with 1.0f as 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 Wave 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. |