public class WaveFormat : ICloneable, IEquatable
Defines the format of waveform-audio data.
WaveFormat()
Initializes a new instance of the WaveFormat class with a sample rate of 44100 Hz, bits per sample of 16 bit, 2 channels and PCM as the format type.
public void WaveFormat()
WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels)
Initializes a new instance of the WaveFormat class with PCM as the format type.
public void WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels)
Parameters
sampleRate
Int32Samples per second.
bits
Int32Number of bits, used to store one sample.
channels
Int32Number of channels in the waveform-audio data.
WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels, AudioEncoding encoding)
Initializes a new instance of the WaveFormat class.
public void WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels, AudioEncoding encoding)
Parameters
sampleRate
Int32Samples per second.
bits
Int32Number of bits, used to store one sample.
channels
Int32Number of channels in the waveform-audio data.
encoding
AudioEncodingFormat type or encoding of the wave format.
WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels, AudioEncoding encoding, Int32 extraSize)
Initializes a new instance of the WaveFormat class.
public void WaveFormat(Int32 sampleRate, Int32 bits, Int32 channels, AudioEncoding encoding, Int32 extraSize)
Parameters
sampleRate
Int32Samples per second.
bits
Int32Number of bits, used to store one sample.
channels
Int32Number of channels in the waveform-audio data.
encoding
AudioEncodingFormat type or encoding of the wave format.
extraSize
Int32Size (in bytes) of extra information. This value is mainly used for marshalling.
BytesToMilliseconds(Int64 bytes)
Converts a duration in bytes to a duration in milliseconds.
public Double BytesToMilliseconds(Int64 bytes)
Parameters
bytes
Int64Duration in bytes to convert to a duration in milliseconds.
Returns
Duration in milliseconds.
Clone()
Creates a new WaveFormat object that is a copy of the current instance.
public virtual object Clone()
Returns
A copy of the current instance.
Equals(WaveFormat other)
Indicates whether the current object is equal to another object of the same type.
public virtual Boolean Equals(WaveFormat other)
Parameters
other
WaveFormatThe WaveFormat to compare with this WaveFormat.
Returns
true if the current object is equal to the other parameter; otherwise, false.
MillisecondsToBytes(Double milliseconds)
Converts a duration in milliseconds to a duration in bytes.
public Int64 MillisecondsToBytes(Double milliseconds)
Parameters
milliseconds
DoubleDuration in millisecond to convert to a duration in bytes.
Returns
Duration in bytes.
ToString()
Returns a string which describes the WaveFormat.
public String ToString()
Returns
A string which describes the WaveFormat.
UpdateProperties()
Updates the BlockAlign- and the BytesPerSecond-property.
protectedorinternal virtual void UpdateProperties()
BitsPerSample
Gets the number of bits, used to store one sample.
public virtual Int32 BitsPerSample { get; set; }
BlockAlign
Gets the block alignment, in bytes. The block alignment is the minimum atomic unit of data. For PCM data, the block alignment is the number of bytes used by a single sample, including data for both channels if the data is stereo. For example, the block alignment for 16-bit stereo PCM is 4 bytes (2 channels x 2 bytes per sample).
public virtual Int32 BlockAlign { get; set; }
BytesPerBlock
Gets the number of bytes, used to store one block. This value equals BytesPerSample multiplied with Channels.
public virtual Int32 BytesPerBlock { get; }
BytesPerSample
Gets the number of bytes, used to store one sample.
public virtual Int32 BytesPerSample { get; }
BytesPerSecond
Gets the required average data transfer rate, in bytes per second. For example, 16-bit stereo at 44.1 kHz has an average data rate of 176,400 bytes per second (2 channels — 2 bytes per sample per channel — 44,100 samples per second).
public virtual Int32 BytesPerSecond { get; set; }
Channels
Gets the number of channels in the waveform-audio data. Mono data uses one channel and stereo data uses two channels.
public virtual Int32 Channels { get; set; }
ExtraSize
Gets the size (in bytes) of extra information. This value is mainly used for marshalling.
public virtual Int32 ExtraSize { get; set; }
SampleRate
Gets the sample rate, in samples per second (hertz).
public virtual Int32 SampleRate { get; set; }
WaveFormatTag
Gets the waveform-audio format type.
public virtual AudioEncoding WaveFormatTag { get; set; }