Class WaveFormat
The format of the wave sound.
Inherited Members
Namespace: Evergine.Common.Audio
Assembly: Evergine.Common.dll
Syntax
public class WaveFormat
Constructors
WaveFormat(bool, int, WaveFormatEncodings)
Initializes a new instance of the WaveFormat class.
Declaration
public WaveFormat(bool isMono, int sampleRate = 44100, WaveFormatEncodings encoding = WaveFormatEncodings.PCM16)
Parameters
Type | Name | Description |
---|---|---|
bool | isMono | If sound data is in mono (one channel) or stereo (two channels). |
int | sampleRate | Sample rate, in Hertz (Hz), of audio data. It must be between 8,000 Hz and 48,000 Hz. |
WaveFormatEncodings | encoding | The encoding used for the audio data samples. |
Fields
Channels
Gets the number of channels of audio wave data.
Declaration
public readonly int Channels
Field Value
Type | Description |
---|---|
int |
Encoding
Gets the encoding used for the audio data samples.
Declaration
public readonly WaveFormatEncodings Encoding
Field Value
Type | Description |
---|---|
WaveFormatEncodings |
SampleRate
Gets the sample rate, in Hertz (Hz), of audio wave data.
Declaration
public readonly int SampleRate
Field Value
Type | Description |
---|---|
int |
Properties
AverageBytesPerSecond
Gets the average number of bytes used per second.
Declaration
public int AverageBytesPerSecond { get; }
Property Value
Type | Description |
---|---|
int |
BitsPerSample
Gets the size in bits for one sample.
Declaration
public int BitsPerSample { get; }
Property Value
Type | Description |
---|---|
int |
BlockAlign
Gets the number of bytes for one sample including all channels.
Declaration
public int BlockAlign { get; }
Property Value
Type | Description |
---|---|
int |
Methods
ConvertByteSizeToDuration(int)
Gets the duration equivalent to the specified size in bytes of a wave buffer.
Declaration
public TimeSpan ConvertByteSizeToDuration(int sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
int | sizeInBytes | The size in bytes of a wave buffer. |
Returns
Type | Description |
---|---|
TimeSpan | The duration as a TimeSpan equivalent to the specified size in bytes. |
ConvertByteSizeToSampleCount(int)
Gets the size in bytes of a wave buffer equivalent to the specified number of samples.
Declaration
public int ConvertByteSizeToSampleCount(int sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
int | sizeInBytes | The size in bytes of a wave buffer. |
Returns
Type | Description |
---|---|
int | The number of samples of a wave buffer equivalent to the specified duration. |
ConvertDurationToByteSize(TimeSpan)
Gets the size in bytes of a wave buffer equivalent to the specified duration.
Declaration
public int ConvertDurationToByteSize(TimeSpan duration)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | The duration as a TimeSpan. |
Returns
Type | Description |
---|---|
int | The size of a wave buffer equivalent to the specified duration. |
ConvertDurationToSampleCount(TimeSpan)
Gets the number of samples of a wave buffer equivalent to the specified duration.
Declaration
public int ConvertDurationToSampleCount(TimeSpan duration)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | The duration as a TimeSpan. |
Returns
Type | Description |
---|---|
int | The number of samples of a wave buffer equivalent to the specified duration. |
ConvertSampleCountToByteSize(int)
Gets the size in bytes of a wave buffer equivalent to the specified number of samples.
Declaration
public int ConvertSampleCountToByteSize(int samplesCount)
Parameters
Type | Name | Description |
---|---|---|
int | samplesCount | The number of samples. |
Returns
Type | Description |
---|---|
int | The size of a wave buffer equivalent to the specified number of samples. |
ConvertSampleCountToDuration(int)
Gets the duration equivalent to the specified number of samples.
Declaration
public TimeSpan ConvertSampleCountToDuration(int samplesCount)
Parameters
Type | Name | Description |
---|---|---|
int | samplesCount | The number of samples. |
Returns
Type | Description |
---|---|
TimeSpan | The duration as a TimeSpan equivalent to the specified number of samples. |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
IsAlignedByteSize(int)
Gets a value indicating whether the specified byte size is block-aligned.
Declaration
public bool IsAlignedByteSize(int sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
int | sizeInBytes | The size in bytes of a wave buffer. |
Returns
Type | Description |
---|---|
bool |
|
IsValidSampleRate(int)
Returns a value indicating whether a sample rate value is valid.
Declaration
public static bool IsValidSampleRate(int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
int | sampleRate | The sample rate, in Hertz (Hz). |
Returns
Type | Description |
---|---|
bool |
|
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |