Show / Hide Table of Contents

Class WaveFormat

Represents a Wave file format

Inheritance
System.Object
WaveFormat
WaveFormatExtraData
Namespace: pdftron.PDF.Tools
Assembly: pdftron.PDF.Tools.dll
Syntax
public class WaveFormat : object

Constructors

WaveFormat()

Creates a new PCM 44.1Khz stereo 16 bit format

Declaration
public WaveFormat()

WaveFormat(BinaryReader)

Reads a new WaveFormat object from a stream

Declaration
public WaveFormat(BinaryReader br)
Parameters
Type Name Description
BinaryReader br

A binary reader that wraps the stream

WaveFormat(Int32, Int32)

Creates a new 16 bit wave format with the specified sample rate and channel count

Declaration
public WaveFormat(int sampleRate, int channels)
Parameters
Type Name Description
System.Int32 sampleRate

Sample Rate

System.Int32 channels

Number of channels

WaveFormat(Int32, Int32, Int32)

Creates a new PCM format with the specified sample rate, bit depth and channels

Declaration
public WaveFormat(int rate, int bits, int channels)
Parameters
Type Name Description
System.Int32 rate
System.Int32 bits
System.Int32 channels

Fields

averageBytesPerSecond

for buffer estimation

Declaration
protected int averageBytesPerSecond
Field Value
Type Description
System.Int32

bitsPerSample

number of bits per sample of mono data

Declaration
protected short bitsPerSample
Field Value
Type Description
System.Int16

blockAlign

block size of data

Declaration
protected short blockAlign
Field Value
Type Description
System.Int16

channels

number of channels

Declaration
protected short channels
Field Value
Type Description
System.Int16

extraSize

number of following bytes

Declaration
protected short extraSize
Field Value
Type Description
System.Int16

sampleRate

sample rate

Declaration
protected int sampleRate
Field Value
Type Description
System.Int32

waveFormatTag

format type

Declaration
protected WaveFormatEncoding waveFormatTag
Field Value
Type Description
WaveFormatEncoding

Properties

AverageBytesPerSecond

Returns the average number of bytes used per second

Declaration
public int AverageBytesPerSecond { get; }
Property Value
Type Description
System.Int32

BitsPerSample

Returns the number of bits per sample (usually 16 or 32, sometimes 24 or 8) Can be 0 for some codecs

Declaration
public int BitsPerSample { get; }
Property Value
Type Description
System.Int32

BlockAlign

Returns the block alignment

Declaration
public virtual int BlockAlign { get; }
Property Value
Type Description
System.Int32

Channels

Returns the number of channels (1=mono,2=stereo etc)

Declaration
public int Channels { get; }
Property Value
Type Description
System.Int32

Encoding

Returns the encoding type used

Declaration
public WaveFormatEncoding Encoding { get; }
Property Value
Type Description
WaveFormatEncoding

ExtraSize

Returns the number of extra bytes used by this waveformat. Often 0, except for compressed formats which store extra data after the WAVEFORMATEX header

Declaration
public int ExtraSize { get; }
Property Value
Type Description
System.Int32

SampleRate

Returns the sample rate (samples per second)

Declaration
public int SampleRate { get; }
Property Value
Type Description
System.Int32

Methods

ConvertLatencyToByteSize(Int32)

Gets the size of a wave buffer equivalent to the latency in milliseconds.

Declaration
public int ConvertLatencyToByteSize(int milliseconds)
Parameters
Type Name Description
System.Int32 milliseconds

The milliseconds.

Returns
Type Description
System.Int32

CreateALawFormat(Int32, Int32)

Creates an A-law wave format

Declaration
public static WaveFormat CreateALawFormat(int sampleRate, int channels)
Parameters
Type Name Description
System.Int32 sampleRate

Sample Rate

System.Int32 channels

Number of Channels

Returns
Type Description
WaveFormat

Wave Format

CreateCustomFormat(WaveFormatEncoding, Int32, Int32, Int32, Int32, Int32)

Creates a WaveFormat with custom members

Declaration
public static WaveFormat CreateCustomFormat(WaveFormatEncoding tag, int sampleRate, int channels, int averageBytesPerSecond, int blockAlign, int bitsPerSample)
Parameters
Type Name Description
WaveFormatEncoding tag

The encoding

System.Int32 sampleRate

Sample Rate

System.Int32 channels

Number of channels

System.Int32 averageBytesPerSecond

Average Bytes Per Second

System.Int32 blockAlign

Block Align

System.Int32 bitsPerSample

Bits Per Sample

Returns
Type Description
WaveFormat

CreateIeeeFloatWaveFormat(Int32, Int32)

Creates a new 32 bit IEEE floating point wave format

Declaration
public static WaveFormat CreateIeeeFloatWaveFormat(int sampleRate, int channels)
Parameters
Type Name Description
System.Int32 sampleRate

sample rate

System.Int32 channels

number of channels

Returns
Type Description
WaveFormat

CreateMuLawFormat(Int32, Int32)

Creates a Mu-law wave format

Declaration
public static WaveFormat CreateMuLawFormat(int sampleRate, int channels)
Parameters
Type Name Description
System.Int32 sampleRate

Sample Rate

System.Int32 channels

Number of Channels

Returns
Type Description
WaveFormat

Wave Format

Equals(Object)

Compares with another WaveFormat object

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

Object to compare to

Returns
Type Description
System.Boolean

True if the objects are the same

FromFormatChunk(BinaryReader, Int32)

Reads in a WaveFormat (with extra data) from a fmt chunk (chunk identifier and length should already have been read)

Declaration
public static WaveFormat FromFormatChunk(BinaryReader br, int formatChunkLength)
Parameters
Type Name Description
BinaryReader br

Binary reader

System.Int32 formatChunkLength

Format chunk length

Returns
Type Description
WaveFormat

A WaveFormatExtraData

GetHashCode()

Provides a Hashcode for this WaveFormat

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

A hashcode

Serialize(BinaryWriter)

Writes this WaveFormat object to a stream

Declaration
public virtual void Serialize(BinaryWriter writer)
Parameters
Type Name Description
BinaryWriter writer

the output stream

ToString()

Reports this WaveFormat as a string

Declaration
public override string ToString()
Returns
Type Description
System.String

String describing the wave format

In This Article
Back to top Generated by DocFX