Represents a Wave file format.
More...
|
| WaveFormat () |
| Creates a new PCM 44.1Khz stereo 16 bit format.
|
|
| WaveFormat (int sampleRate, int channels) |
| Creates a new 16 bit wave format with the specified sample rate and channel count.
|
|
int | ConvertLatencyToByteSize (int milliseconds) |
| Converts the given latency in milliseconds to the corresponding byte size based on the average bytes per second.
|
|
| WaveFormat (int rate, int bits, int channels) |
| Creates a new PCM format with the specified sample rate, bit depth and channels.
|
|
| WaveFormat (BinaryReader br) |
| Reads a new WaveFormat object from a stream.
|
|
override string | ToString () |
| Returns a string representation of the WaveFormat object.
|
|
override bool | Equals (object obj) |
| Determines whether the current WaveFormat object is equal to another object.
|
|
override int | GetHashCode () |
| Computes the hash code for the WaveFormat instance.
|
|
virtual void | Serialize (BinaryWriter writer) |
| Serializes the wave format data and writes it to the specified BinaryWriter.
|
|
|
WaveFormatEncoding | Encoding [get] |
| Returns the encoding type used.
|
|
int | Channels [get] |
| Returns the number of channels (1=mono,2=stereo etc)
|
|
int | SampleRate [get] |
| Returns the sample rate (samples per second)
|
|
int | AverageBytesPerSecond [get] |
| Returns the average number of bytes used per second.
|
|
virtual int | BlockAlign [get] |
| Returns the block alignment.
|
|
int | BitsPerSample [get] |
| Returns the number of bits per sample (usually 16 or 32, sometimes 24 or 8) Can be 0 for some codecs.
|
|
int | ExtraSize [get] |
| Returns the number of extra bytes used by this waveformat. Often 0, except for compressed formats which store extra data after the WAVEFORMATEX header.
|
|
|
void | ReadWaveFormat (BinaryReader br, int formatChunkLength) |
| Reads the wave format information from the provided BinaryReader.
|
|
Represents a Wave file format.
◆ WaveFormat() [1/4]
NAudio.Wave.WaveFormat.WaveFormat |
( |
| ) |
|
|
inline |
Creates a new PCM 44.1Khz stereo 16 bit format.
◆ WaveFormat() [2/4]
NAudio.Wave.WaveFormat.WaveFormat |
( |
int | sampleRate, |
|
|
int | channels ) |
|
inline |
Creates a new 16 bit wave format with the specified sample rate and channel count.
- Parameters
-
sampleRate | Sample Rate |
channels | Number of channels |
◆ WaveFormat() [3/4]
NAudio.Wave.WaveFormat.WaveFormat |
( |
int | rate, |
|
|
int | bits, |
|
|
int | channels ) |
|
inline |
Creates a new PCM format with the specified sample rate, bit depth and channels.
◆ WaveFormat() [4/4]
NAudio.Wave.WaveFormat.WaveFormat |
( |
BinaryReader | br | ) |
|
|
inline |
Reads a new WaveFormat object from a stream.
- Parameters
-
br | A binary reader that wraps the stream |
◆ ConvertLatencyToByteSize()
int NAudio.Wave.WaveFormat.ConvertLatencyToByteSize |
( |
int | milliseconds | ) |
|
|
inline |
Converts the given latency in milliseconds to the corresponding byte size based on the average bytes per second.
- Parameters
-
milliseconds | The latency in milliseconds to be converted. |
- Returns
- The byte size calculated based on the average bytes per second and the given latency.
This method calculates the byte size by multiplying the average bytes per second by the given latency in milliseconds and then rounding it to the nearest block align if necessary. If the calculated byte size is not already aligned to the block size, it is adjusted to the next block-aligned value.
◆ CreateALawFormat()
static WaveFormat NAudio.Wave.WaveFormat.CreateALawFormat |
( |
int | sampleRate, |
|
|
int | channels ) |
|
inlinestatic |
Creates a new WaveFormat with A-Law encoding.
- Parameters
-
sampleRate | The sample rate of the audio. |
channels | The number of channels in the audio. |
- Returns
- A new WaveFormat with A-Law encoding, sample rate, channels, and other parameters set accordingly.
◆ CreateCustomFormat()
static WaveFormat NAudio.Wave.WaveFormat.CreateCustomFormat |
( |
WaveFormatEncoding | tag, |
|
|
int | sampleRate, |
|
|
int | channels, |
|
|
int | averageBytesPerSecond, |
|
|
int | blockAlign, |
|
|
int | bitsPerSample ) |
|
inlinestatic |
Creates a custom WaveFormat with the specified parameters.
- Parameters
-
tag | The encoding format of the WaveFormat. |
sampleRate | The sample rate of the WaveFormat. |
channels | The number of channels in the WaveFormat. |
averageBytesPerSecond | The average bytes per second for the WaveFormat. |
blockAlign | The block alignment for the WaveFormat. |
bitsPerSample | The number of bits per sample in the WaveFormat. |
- Returns
- A custom WaveFormat with the specified parameters.
◆ CreateIeeeFloatWaveFormat()
static WaveFormat NAudio.Wave.WaveFormat.CreateIeeeFloatWaveFormat |
( |
int | sampleRate, |
|
|
int | channels ) |
|
inlinestatic |
Creates a new IEEE float wave format with the specified sample rate and number of channels.
- Parameters
-
sampleRate | The sample rate of the wave format. |
channels | The number of channels in the wave format. |
- Returns
- A new WaveFormat object representing the IEEE float wave format with the specified parameters.
◆ CreateMuLawFormat()
static WaveFormat NAudio.Wave.WaveFormat.CreateMuLawFormat |
( |
int | sampleRate, |
|
|
int | channels ) |
|
inlinestatic |
Creates a new WaveFormat with MuLaw encoding.
- Parameters
-
sampleRate | The sample rate of the audio. |
channels | The number of channels in the audio. |
- Returns
- A new WaveFormat with MuLaw encoding, based on the specified sampleRate and channels .
◆ Equals()
override bool NAudio.Wave.WaveFormat.Equals |
( |
object | obj | ) |
|
|
inline |
Determines whether the current WaveFormat object is equal to another object.
- Parameters
-
obj | The object to compare with the current WaveFormat object. |
- Returns
- true if the specified object is equal to the current object; otherwise, false.
◆ FromFormatChunk()
static WaveFormat NAudio.Wave.WaveFormat.FromFormatChunk |
( |
BinaryReader | br, |
|
|
int | formatChunkLength ) |
|
inlinestatic |
Reads the wave format and extra data from the specified binary reader and returns the WaveFormatExtraData.
- Parameters
-
br | The BinaryReader used to read the wave format and extra data. |
formatChunkLength | The length of the format chunk. |
- Returns
- The WaveFormatExtraData containing the wave format and extra data.
This method reads the wave format from the specified BinaryReader using the formatChunkLength to determine the length of the format chunk. It then reads the extra data from the same BinaryReader. The WaveFormatExtraData object containing the wave format and extra data is returned.
◆ GetHashCode()
override int NAudio.Wave.WaveFormat.GetHashCode |
( |
| ) |
|
|
inline |
Computes the hash code for the WaveFormat instance.
- Returns
- The computed hash code.
◆ MarshalFromPtr()
static WaveFormat NAudio.Wave.WaveFormat.MarshalFromPtr |
( |
IntPtr | pointer | ) |
|
|
inlinestatic |
Marshals a WaveFormat structure from the specified pointer.
- Parameters
-
pointer | A pointer to the WaveFormat structure. |
- Returns
- The WaveFormat structure marshaled from the specified pointer .
This method marshals a WaveFormat structure from the specified pointer . It first marshals the WaveFormat structure using Marshal.PtrToStructure method. Then, based on the wave format encoding, it may further marshal the structure to a more specific type, such as WaveFormatExtensible, AdpcmWaveFormat, Gsm610WaveFormat, or WaveFormatExtraData. If the wave format encoding is PCM, the extra size is set to 0 to avoid reading corrupt data. If the wave format encoding is Extensible, Adpcm, or Gsm610, the structure is further marshaled to the specific type. If the wave format encoding is not recognized and the extra size is greater than 0, the structure is marshaled to WaveFormatExtraData. The marshaled WaveFormat structure is then returned.
◆ MarshalToPtr()
static IntPtr NAudio.Wave.WaveFormat.MarshalToPtr |
( |
WaveFormat | format | ) |
|
|
inlinestatic |
Marshals the WaveFormat structure to a pointer.
- Parameters
-
format | The WaveFormat structure to be marshaled. |
- Returns
- A pointer to the marshaled WaveFormat structure.
This method allocates memory for the WaveFormat structure, marshals the structure to the allocated memory, and returns a pointer to the marshaled structure. The allocated memory must be released using Marshal.FreeHGlobal when it is no longer needed to prevent memory leaks.
◆ ReadWaveFormat()
void NAudio.Wave.WaveFormat.ReadWaveFormat |
( |
BinaryReader | br, |
|
|
int | formatChunkLength ) |
|
inlineprivate |
Reads the wave format information from the provided BinaryReader.
- Parameters
-
br | The BinaryReader to read the wave format from. |
formatChunkLength | The length of the format chunk. |
- Exceptions
-
InvalidDataException | Thrown when the formatChunkLength is less than 16, indicating an invalid WaveFormat structure. |
This method reads the wave format information from the provided BinaryReader, including the wave format tag, number of channels, sample rate, average bytes per second, block align, and bits per sample. If the formatChunkLength is greater than 16, it also reads the extra size and checks for format chunk mismatch.
◆ Serialize()
virtual void NAudio.Wave.WaveFormat.Serialize |
( |
BinaryWriter | writer | ) |
|
|
inlinevirtual |
Serializes the wave format data and writes it to the specified BinaryWriter.
- Parameters
-
writer | The BinaryWriter to which the wave format data will be written. |
This method serializes the wave format data including encoding, channels, sample rate, average bytes per second, block align, bits per sample, and extra size, and writes it to the specified BinaryWriter.
Reimplemented in NAudio.Wave.Gsm610WaveFormat, NAudio.Wave.TrueSpeechWaveFormat, and NAudio.Wave.WaveFormatExtraData.
◆ ToString()
override string NAudio.Wave.WaveFormat.ToString |
( |
| ) |
|
|
inline |
Returns a string representation of the WaveFormat object.
- Returns
- A string representing the wave format, including the number of bits per sample, the sample rate in Hertz, and the number of channels.
This method returns a string representation of the WaveFormat object based on the wave format tag. If the wave format tag is PCM or Extensible, it returns a string with the number of bits per sample, the sample rate in Hertz, and the number of channels. If the wave format tag is IEEEFloat, it returns a string with the number of bits per sample, the sample rate in Hertz, and the number of channels. If the wave format tag is neither PCM, Extensible, nor IEEEFloat, it returns the wave format tag as a string.
◆ averageBytesPerSecond
int NAudio.Wave.WaveFormat.averageBytesPerSecond |
|
protected |
◆ bitsPerSample
short NAudio.Wave.WaveFormat.bitsPerSample |
|
protected |
number of bits per sample of mono data
◆ blockAlign
short NAudio.Wave.WaveFormat.blockAlign |
|
protected |
◆ channels
short NAudio.Wave.WaveFormat.channels |
|
protected |
◆ extraSize
short NAudio.Wave.WaveFormat.extraSize |
|
protected |
number of following bytes
◆ sampleRate
int NAudio.Wave.WaveFormat.sampleRate |
|
protected |
◆ waveFormatTag
◆ AverageBytesPerSecond
int NAudio.Wave.WaveFormat.AverageBytesPerSecond |
|
get |
Returns the average number of bytes used per second.
◆ BitsPerSample
int NAudio.Wave.WaveFormat.BitsPerSample |
|
get |
Returns the number of bits per sample (usually 16 or 32, sometimes 24 or 8) Can be 0 for some codecs.
◆ BlockAlign
virtual int NAudio.Wave.WaveFormat.BlockAlign |
|
get |
Returns the block alignment.
◆ Channels
int NAudio.Wave.WaveFormat.Channels |
|
get |
Returns the number of channels (1=mono,2=stereo etc)
◆ Encoding
Returns the encoding type used.
◆ ExtraSize
int NAudio.Wave.WaveFormat.ExtraSize |
|
get |
Returns the number of extra bytes used by this waveformat. Often 0, except for compressed formats which store extra data after the WAVEFORMATEX header.
◆ SampleRate
int NAudio.Wave.WaveFormat.SampleRate |
|
get |
Returns the sample rate (samples per second)
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Core/Wave/WaveFormats/WaveFormat.cs