Class WaveFileWriterRT
This class writes WAV data to a .wav file on disk
Inheritance
Namespace: pdftron.PDF.Tools
Assembly: pdftron.PDF.Tools.dll
Syntax
public class WaveFileWriterRT : Stream
Constructors
WaveFileWriterRT(Stream, WaveFormat)
WaveFileWriterRT that actually writes to a stream
Declaration
public WaveFileWriterRT(Stream outStream, WaveFormat format)
Parameters
Type | Name | Description |
---|---|---|
Stream | outStream | Stream to be written to |
WaveFormat | format | Wave format to use |
Properties
CanRead
Returns false: Cannot read from a WaveFileWriterRT
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanSeek
Returns false: Cannot seek within a WaveFileWriterRT
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanTimeout
Returns false: Cannot timeout within a WaveFileWriterRT
Declaration
public override bool CanTimeout { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanWrite
Returns true: Can write to a WaveFileWriterRT
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Filename
The wave file name or null if not applicable
Declaration
public string Filename { get; }
Property Value
Type | Description |
---|---|
System.String |
Length
Number of bytes of audio in the data chunk
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Position
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 |
---|---|
System.Int64 |
WaveFormat
WaveFormat of this wave file
Declaration
public WaveFormat WaveFormat { get; }
Property Value
Type | Description |
---|---|
WaveFormat |
Methods
CopyToAsync(Stream, Int32, CancellationToken)
CopyToAsync is not supported for a WaveFileWriterRT
Declaration
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | |
System.Int32 | bufferSize | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
CreateWaveFileAsync(StorageFile, IWaveProvider)
Creates a Wave file by reading all the data from a WaveProvider BEWARE: the WaveProvider MUST return 0 from its Read method when it is finished, or the Wave File will grow indefinitely.
Declaration
public static Task<StorageFile> CreateWaveFileAsync(StorageFile file, IWaveProvider sourceProvider)
Parameters
Type | Name | Description |
---|---|---|
Windows.Storage.StorageFile | file | |
IWaveProvider | sourceProvider | The source WaveProvider |
Returns
Type | Description |
---|---|
Task<Windows.Storage.StorageFile> |
Dispose(Boolean)
Actually performs the close,making sure the header contains the correct data
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | True if called from |
Finalize()
Finaliser - should only be called if the user forgot to close this WaveFileWriterRT
Declaration
protected void Finalize()
Flush()
Ensures data is written to disk
Declaration
public override void Flush()
FlushAsync(CancellationToken)
Ensures data is written to disk
Declaration
public override Task FlushAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Read(Byte[], Int32, Int32)
Read is not supported for a WaveFileWriterRT
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | |
System.Int32 | offset | |
System.Int32 | count |
Returns
Type | Description |
---|---|
System.Int32 |
ReadAsync(Byte[], Int32, Int32, CancellationToken)
ReadAsync is not supported for a WaveFileWriterRT
Declaration
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | |
System.Int32 | offset | |
System.Int32 | count | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<System.Int32> |
ReadByte()
ReadByte is not supported for a WaveFileWriterRT
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
System.Int32 |
Seek(Int64, SeekOrigin)
Seek is not supported for a WaveFileWriterRT
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | |
SeekOrigin | origin |
Returns
Type | Description |
---|---|
System.Int64 |
SetLength(Int64)
SetLength is not supported for WaveFileWriterRT
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value |
UpdateHeader(BinaryWriter)
Updates the header with file size information
Declaration
protected virtual void UpdateHeader(BinaryWriter writer)
Parameters
Type | Name | Description |
---|---|---|
BinaryWriter | writer |
Write(Byte[], Int32, Int32)
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 |
---|---|---|
System.Byte[] | data | the buffer containing the wave data |
System.Int32 | offset | the offset from which to start writing |
System.Int32 | count | the number of bytes to write |
WriteAsync(Byte[], Int32, Int32, CancellationToken)
Appends bytes to the WaveFile (assumes they are already in the correct format)
Declaration
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | the buffer containing the wave data |
System.Int32 | offset | the offset from which to start writing |
System.Int32 | count | the number of bytes to write |
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
Task |
WriteByte(Byte)
WriteByte is not supported for a WaveFileWriterRT
Use Write(Byte[], Int32, Int32) instead
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | value to write |
WriteSample(Single)
Writes a single sample to the Wave file
Declaration
public void WriteSample(float sample)
Parameters
Type | Name | Description |
---|---|---|
System.Single | sample | the sample to write (assumed floating point with 1.0f as max value) |
WriteSamples(Int16[], Int32, Int32)
Writes 16 bit samples to the Wave file
Declaration
public void WriteSamples(short[] samples, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int16[] | samples | The buffer containing the 16 bit samples |
System.Int32 | offset | The offset from which to start writing |
System.Int32 | count | The number of 16 bit samples to write |
WriteSamples(Single[], Int32, Int32)
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 |
---|---|---|
System.Single[] | samples | The buffer containing the floating point samples |
System.Int32 | offset | The offset from which to start writing |
System.Int32 | count | The number of floating point samples to write |