Xeno-rat
Loading...
Searching...
No Matches
NAudio.Wave.ResamplerDmoStream Class Reference

Wave Stream for converting between sample rates. More...

Inheritance diagram for NAudio.Wave.ResamplerDmoStream:
Collaboration diagram for NAudio.Wave.ResamplerDmoStream:

Public Member Functions

 ResamplerDmoStream (IWaveProvider inputProvider, WaveFormat outputFormat)
 WaveStream to resample using the DMO Resampler.
 
override int Read (byte[] buffer, int offset, int count)
 Reads a specified number of bytes from the input stream and writes them to the buffer.
 
- Public Member Functions inherited from NAudio.Wave.WaveStream
override void Flush ()
 Flushes the buffer of the current stream and causes any buffered data to be written to the underlying device.
 
override long Seek (long offset, SeekOrigin origin)
 Sets the position within the current stream.
 
override void SetLength (long length)
 Throws a NotSupportedException with the message "Can't set length of a WaveFormatString".
 
override void Write (byte[] buffer, int offset, int count)
 Throws a NotSupportedException with the message "Can't write to a WaveFormatString".
 
void Skip (int seconds)
 Skips the playback to a new position in the audio file based on the specified number of seconds.
 
virtual bool HasData (int count)
 Checks if there is data available at the current position.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the T:System.Media.DmoResampler and optionally releases the managed resources.
 

Properties

override WaveFormat WaveFormat [get]
 Stream Wave Format.
 
override long Length [get]
 Stream length in bytes.
 
override long Position [get, set]
 Stream position in bytes.
 
- Properties inherited from NAudio.Wave.WaveStream
WaveFormat WaveFormat [get]
 Retrieves the WaveFormat for this stream.
 
override bool CanRead [get]
 We can read from this stream.
 
override bool CanSeek [get]
 We can seek within this stream.
 
override bool CanWrite [get]
 We can't write to this stream.
 
virtual int BlockAlign [get]
 The block alignment for this wavestream. Do not modify the Position to anything that is not a whole multiple of this value.
 
virtual TimeSpan CurrentTime [get, set]
 The current position in the stream in Time format.
 
virtual TimeSpan TotalTime [get]
 Total length in real-time of the stream (may be an estimate for compressed files)
 
- Properties inherited from NAudio.Wave.IWaveProvider

Private Member Functions

long InputToOutputPosition (long inputPosition)
 Converts the input position to the corresponding output position based on the ratio of average bytes per second between input and output formats.
 
long OutputToInputPosition (long outputPosition)
 Converts the output position to the corresponding input position based on the audio format ratios.
 

Private Attributes

readonly IWaveProvider inputProvider
 
readonly WaveStream inputStream
 
readonly WaveFormat outputFormat
 
DmoOutputDataBuffer outputBuffer
 
DmoResampler dmoResampler
 
MediaBuffer inputMediaBuffer
 
long position
 

Detailed Description

Wave Stream for converting between sample rates.

Constructor & Destructor Documentation

◆ ResamplerDmoStream()

NAudio.Wave.ResamplerDmoStream.ResamplerDmoStream ( IWaveProvider inputProvider,
WaveFormat outputFormat )
inline

WaveStream to resample using the DMO Resampler.

Parameters
inputProviderInput Stream
outputFormatDesired Output Format
Here is the call graph for this function:

Member Function Documentation

◆ Dispose()

override void NAudio.Wave.ResamplerDmoStream.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the T:System.Media.DmoResampler and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method disposes the input media buffer if it is not null and sets it to null. It disposes the output buffer. If the DMO resampler is not null, it sets it to null.

Here is the caller graph for this function:

◆ InputToOutputPosition()

long NAudio.Wave.ResamplerDmoStream.InputToOutputPosition ( long inputPosition)
inlineprivate

Converts the input position to the corresponding output position based on the ratio of average bytes per second between input and output formats.

Parameters
inputPositionThe input position to be converted.
Returns
The corresponding output position calculated based on the ratio of average bytes per second between input and output formats.

This method calculates the output position by multiplying the input position with the ratio of average bytes per second between the output format and the input provider's wave format. If the calculated output position is not aligned with the output format's block align, it is adjusted to the nearest aligned position.

Here is the caller graph for this function:

◆ OutputToInputPosition()

long NAudio.Wave.ResamplerDmoStream.OutputToInputPosition ( long outputPosition)
inlineprivate

Converts the output position to the corresponding input position based on the audio format ratios.

Parameters
outputPositionThe output position for which the corresponding input position needs to be calculated.
Returns
The input position corresponding to the given outputPosition based on the audio format ratios.

This method calculates the input position based on the ratio of average bytes per second between the output and input audio formats. It then adjusts the input position to align with the block size of the input audio format if necessary.

Here is the caller graph for this function:

◆ Read()

override int NAudio.Wave.ResamplerDmoStream.Read ( byte[] buffer,
int offset,
int count )
inline

Reads a specified number of bytes from the input stream and writes them to the buffer.

Parameters
bufferThe buffer to write the data to.
offsetThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
countThe maximum number of bytes to read.
Returns
The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.

This method reads data from the input stream and writes it to the buffer provided. It uses a DMO (DirectX Media Object) resampler to process the input data and provide output data. The method loops until the specified number of bytes have been read or until the end of the stream is reached. It modifies the position of the stream accordingly and returns the total number of bytes read into the buffer.

Implements NAudio.Wave.IWaveProvider.

Here is the call graph for this function:

Member Data Documentation

◆ dmoResampler

DmoResampler NAudio.Wave.ResamplerDmoStream.dmoResampler
private

◆ inputMediaBuffer

MediaBuffer NAudio.Wave.ResamplerDmoStream.inputMediaBuffer
private

◆ inputProvider

readonly IWaveProvider NAudio.Wave.ResamplerDmoStream.inputProvider
private

◆ inputStream

readonly WaveStream NAudio.Wave.ResamplerDmoStream.inputStream
private

◆ outputBuffer

DmoOutputDataBuffer NAudio.Wave.ResamplerDmoStream.outputBuffer
private

◆ outputFormat

readonly WaveFormat NAudio.Wave.ResamplerDmoStream.outputFormat
private

◆ position

long NAudio.Wave.ResamplerDmoStream.position
private

Property Documentation

◆ Length

override long NAudio.Wave.ResamplerDmoStream.Length
get

Stream length in bytes.

◆ Position

override long NAudio.Wave.ResamplerDmoStream.Position
getset

Stream position in bytes.

◆ WaveFormat

override WaveFormat NAudio.Wave.ResamplerDmoStream.WaveFormat
get

Stream Wave Format.

Implements NAudio.Wave.IWaveProvider.


The documentation for this class was generated from the following file: