The Media Foundation Resampler Transform.
More...
|
| 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.
|
|
| 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.
|
|
|
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.
|
|
IMFTransform | CreateTransform () |
| Creates and returns a new IMFTransform object.
|
|
|
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.
|
|
WaveFormat | WaveFormat [get] |
| The output WaveFormat of this Media Foundation Transform.
|
|
|
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.
|
|
|
static readonly Guid | ResamplerClsid = new Guid("f447b69e-1884-4a7e-8055-346f74d6edb3") |
|
static readonly Guid | IMFTransformIid = new Guid("bf94c121-5b05-4e6f-8000-ba598961414d") |
|
The Media Foundation Resampler Transform.
◆ 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
-
sourceProvider | Source provider, must be PCM |
outputFormat | Output format, must also be PCM |
◆ MediaFoundationResampler() [2/2]
NAudio.Wave.MediaFoundationResampler.MediaFoundationResampler |
( |
IWaveProvider | sourceProvider, |
|
|
int | outputSampleRate ) |
|
inline |
Creates a resampler with a specified target output sample rate.
- Parameters
-
sourceProvider | Source provider |
outputSampleRate | Output sample rate |
◆ 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
-
inputFormat | The input WaveFormat to be used as a basis for creating the output format. |
outputSampleRate | The 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
-
ArgumentException | Thrown 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".
◆ 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.
◆ 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.
◆ 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.
◆ 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
-
disposing | True 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.
◆ FreeComObject()
void NAudio.Wave.MediaFoundationResampler.FreeComObject |
( |
object | comObject | ) |
|
|
inlineprivate |
Releases the specified COM object from memory.
- Parameters
-
comObject | The COM object to be released from memory. |
- Exceptions
-
NullReferenceException | Thrown 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.
◆ 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
-
waveFormat | The WaveFormat to be checked. |
- Returns
- True if the WaveFormat is PCM or IEEE Float, otherwise False.
◆ 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 |
◆ 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: