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

The Media Foundation Resampler Transform. More...

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

Public Member Functions

 MediaFoundationResampler (IWaveProvider sourceProvider, WaveFormat outputFormat)
 Creates the Media Foundation Resampler, allowing modifying of sample rate, bit depth and channel count.
 
 MediaFoundationResampler (IWaveProvider sourceProvider, int outputSampleRate)
 Creates a resampler with a specified target output sample rate.
 
- Public Member Functions inherited from NAudio.MediaFoundation.MediaFoundationTransform
 MediaFoundationTransform (IWaveProvider sourceProvider, WaveFormat outputFormat)
 Constructs a new MediaFoundationTransform wrapper Will read one second at a time.
 
void Dispose ()
 Disposes this Media Foundation Transform.
 
int Read (byte[] buffer, int offset, int count)
 Reads data from the input buffer and processes it using the transform, returning the number of bytes written to the output buffer.
 
void Reposition ()
 Repositions the object for streaming if it is initialized for streaming, by ending the stream and draining, clearing the output buffer, and reinitializing the transform for streaming.
 

Protected Member Functions

override IMFTransform CreateTransform ()
 Creates and configures a resampler transform for media format conversion.
 
override void Dispose (bool disposing)
 Releases the unmanaged resources used by the component and optionally releases the managed resources.
 
- Protected Member Functions inherited from NAudio.MediaFoundation.MediaFoundationTransform
IMFTransform CreateTransform ()
 Creates and returns a new IMFTransform object.
 

Properties

int ResamplerQuality [get, set]
 Gets or sets the Resampler quality. n.b. set the quality before starting to resample. 1 is lowest quality (linear interpolation) and 60 is best quality.
 
- Properties inherited from NAudio.MediaFoundation.MediaFoundationTransform
WaveFormat WaveFormat [get]
 The output WaveFormat of this Media Foundation Transform.
 
- Properties inherited from NAudio.Wave.IWaveProvider

Private Member Functions

void FreeComObject (object comObject)
 Releases the specified COM object from memory.
 
object CreateResamplerComObject ()
 Creates and returns a resampler COM object based on the platform.
 
object CreateResamplerComObjectUsingActivator ()
 Creates a resampler COM object using the Activator.
 

Static Private Member Functions

static bool IsPcmOrIeeeFloat (WaveFormat waveFormat)
 Checks if the given WaveFormat is PCM or IEEE Float and returns a boolean value.
 
static WaveFormat CreateOutputFormat (WaveFormat inputFormat, int outputSampleRate)
 Creates a new WaveFormat for the output based on the input WaveFormat and the specified output sample rate.
 

Private Attributes

int resamplerQuality
 
IMFActivate activate
 

Static Private Attributes

static readonly Guid ResamplerClsid = new Guid("f447b69e-1884-4a7e-8055-346f74d6edb3")
 
static readonly Guid IMFTransformIid = new Guid("bf94c121-5b05-4e6f-8000-ba598961414d")
 

Additional Inherited Members

- Protected Attributes inherited from NAudio.MediaFoundation.MediaFoundationTransform
readonly IWaveProvider sourceProvider
 The Source Provider.
 
readonly WaveFormat outputWaveFormat
 The Output WaveFormat.
 

Detailed Description

The Media Foundation Resampler Transform.

Constructor & Destructor Documentation

◆ MediaFoundationResampler() [1/2]

NAudio.Wave.MediaFoundationResampler.MediaFoundationResampler ( IWaveProvider sourceProvider,
WaveFormat outputFormat )
inline

Creates the Media Foundation Resampler, allowing modifying of sample rate, bit depth and channel count.

Parameters
sourceProviderSource provider, must be PCM
outputFormatOutput format, must also be PCM
Here is the call graph for this function:

◆ MediaFoundationResampler() [2/2]

NAudio.Wave.MediaFoundationResampler.MediaFoundationResampler ( IWaveProvider sourceProvider,
int outputSampleRate )
inline

Creates a resampler with a specified target output sample rate.

Parameters
sourceProviderSource provider
outputSampleRateOutput sample rate

Member Function Documentation

◆ CreateOutputFormat()

static WaveFormat NAudio.Wave.MediaFoundationResampler.CreateOutputFormat ( WaveFormat inputFormat,
int outputSampleRate )
inlinestaticprivate

Creates a new WaveFormat for the output based on the input WaveFormat and the specified output sample rate.

Parameters
inputFormatThe input WaveFormat to be used as a basis for creating the output format.
outputSampleRateThe sample rate of the output WaveFormat.
Returns
A new WaveFormat for the output based on the input WaveFormat and the specified output sample rate.
Exceptions
ArgumentExceptionThrown when the inputFormat.Encoding is neither WaveFormatEncoding.Pcm nor WaveFormatEncoding.IeeeFloat.

This method creates a new WaveFormat for the output based on the input WaveFormat and the specified output sample rate. If the inputFormat.Encoding is WaveFormatEncoding.Pcm, a new WaveFormat is created with the specified output sample rate, inputFormat.BitsPerSample, and inputFormat.Channels. If the inputFormat.Encoding is WaveFormatEncoding.IeeeFloat, a new WaveFormat is created with the specified output sample rate and inputFormat.Channels using WaveFormat.CreateIeeeFloatWaveFormat method. If the inputFormat.Encoding is neither WaveFormatEncoding.Pcm nor WaveFormatEncoding.IeeeFloat, an ArgumentException is thrown with the message "Can only resample PCM or IEEE float".

Here is the call graph for this function:

◆ CreateResamplerComObject()

object NAudio.Wave.MediaFoundationResampler.CreateResamplerComObject ( )
inlineprivate

Creates and returns a resampler COM object based on the platform.

Returns
A resampler COM object based on the platform. Returns an instance of ResamplerMediaComObject for non-UWP platforms and uses CreateResamplerComObjectUsingActivator for UWP platforms.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateResamplerComObjectUsingActivator()

object NAudio.Wave.MediaFoundationResampler.CreateResamplerComObjectUsingActivator ( )
inlineprivate

Creates a resampler COM object using the Activator.

Returns
The resampler COM object created using the Activator, or null if no matching object is found.

This method enumerates the audio effect transforms using MediaFoundationApi.EnumerateTransforms and searches for the resampler using the ResamplerClsid. If a matching resampler is found, it activates the object using the activator and returns the created COM object.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateTransform()

override IMFTransform NAudio.Wave.MediaFoundationResampler.CreateTransform ( )
inlineprotected

Creates and configures a resampler transform for media format conversion.

Returns
The configured resampler transform for media format conversion.

This method creates a resampler transform for media format conversion. It sets the input and output media formats, configures quality settings, and returns the configured resampler transform.

Here is the call graph for this function:

◆ Dispose()

override void NAudio.Wave.MediaFoundationResampler.Dispose ( bool disposing)
inlineprotectedvirtual

Releases the unmanaged resources used by the component and optionally releases the managed resources.

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

This method releases the unmanaged resources used by the component and optionally releases the managed resources. If disposing is true, this method invokes the ShutdownObject method on the activate object to release its resources and sets the activate object to null.

Reimplemented from NAudio.MediaFoundation.MediaFoundationTransform.

Here is the call graph for this function:

◆ FreeComObject()

void NAudio.Wave.MediaFoundationResampler.FreeComObject ( object comObject)
inlineprivate

Releases the specified COM object from memory.

Parameters
comObjectThe COM object to be released from memory.
Exceptions
NullReferenceExceptionThrown when the comObject is null.

This method releases the specified COM object from memory by calling the Marshal.ReleaseComObject method. Additionally, if the activate object is not null, it calls the activate.ShutdownObject method to perform any necessary cleanup.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPcmOrIeeeFloat()

static bool NAudio.Wave.MediaFoundationResampler.IsPcmOrIeeeFloat ( WaveFormat waveFormat)
inlinestaticprivate

Checks if the given WaveFormat is PCM or IEEE Float and returns a boolean value.

Parameters
waveFormatThe WaveFormat to be checked.
Returns
True if the WaveFormat is PCM or IEEE Float, otherwise False.
Here is the caller graph for this function:

Member Data Documentation

◆ activate

IMFActivate NAudio.Wave.MediaFoundationResampler.activate
private

◆ IMFTransformIid

readonly Guid NAudio.Wave.MediaFoundationResampler.IMFTransformIid = new Guid("bf94c121-5b05-4e6f-8000-ba598961414d")
staticprivate

◆ ResamplerClsid

readonly Guid NAudio.Wave.MediaFoundationResampler.ResamplerClsid = new Guid("f447b69e-1884-4a7e-8055-346f74d6edb3")
staticprivate

◆ resamplerQuality

int NAudio.Wave.MediaFoundationResampler.resamplerQuality
private

Property Documentation

◆ ResamplerQuality

int NAudio.Wave.MediaFoundationResampler.ResamplerQuality
getset

Gets or sets the Resampler quality. n.b. set the quality before starting to resample. 1 is lowest quality (linear interpolation) and 60 is best quality.


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