Class MacAudioConverter
Provides the platform's resampler.
Has almost the same strengths as the Windows Media Resampler (excluding changing the input provider's audio format details on the fly),
and even provides more options compared to that one, allowing to select resampling algorithm, quality and dithering.
public sealed class MacAudioConverter : IWaveProvider, IDisposable
- Inheritance
-
MacAudioConverter
- Implements
- Inherited Members
- Extension Methods
Constructors
MacAudioConverter(IWaveProvider, WaveFormat)
Initializes a new instance of the MacAudioConverter class, providing the source wave provider to resample, as well as the desired format to convert the data of the provider into.
public MacAudioConverter(IWaveProvider providerToResample, WaveFormat outputFormat)
Parameters
providerToResampleIWaveProviderThe IWaveProvider whose data are subject to be resampled.
outputFormatWaveFormatThe audio format to output results as.
Properties
Complexity
Gets/sets the algorithm to use for resampling data.
public AudioConverterSampleRateComplexity Complexity { get; set; }
Property Value
Exceptions
- ObjectDisposedException
The native converter object has been disposed of.
- AudioConverterException
This property is not supported for this audio converter object.
Dithering
Gets/sets the dithering algorithm to apply to the audio converter.
The constant None can be used to disable dithering.
This is only supported in macOS.
public AudioConverterDitheringAlgorithm Dithering { get; set; }
Property Value
Exceptions
- ObjectDisposedException
The native converter object has been disposed of.
- AudioConverterException
This property is not supported for this audio converter object.
DitheringBitLength
The pre-specified dithering algorithm is applied to the bit length denoted by the value of this property.
This is only supported in macOS.
public uint DitheringBitLength { get; set; }
Property Value
Exceptions
- ObjectDisposedException
The native converter object has been disposed of.
- AudioConverterException
This property is not supported for this audio converter object.
Quality
Gets/sets the quality of the audio converter.
public AudioConverterQuality Quality { get; set; }
Property Value
Exceptions
- ObjectDisposedException
The native converter object has been disposed of.
- AudioConverterException
This property is not supported for this audio converter object.
WaveFormat
Provides the audio format under which the current resampler produces results as.
public WaveFormat WaveFormat { get; }
Property Value
Methods
Dispose()
Releases any resources used by this MacAudioConverter instance.
Thread-safe.
public void Dispose()
Read(Span<byte>)
Reads data out from the source provider, passing them through this configured resampler.
public int Read(Span<byte> buffer)
Parameters
Returns
- int
Number of bytes actually read into
buffer, 0 if end of stream.
Reset()
Resets the buffer state of the audio converter object, if there is reported a discontinuity in the source provider.
public void Reset()
Exceptions
- ObjectDisposedException
The native converter object has been disposed of.
SetChannelMap(int[])
Allows to assign a custom channel mapping matrix to
map an input channel to an output channel.
The array is arranged as follows:
Each element in the array is an output channel.
The first element is the first channel, the second the second channel, and goes on.
Each of these elements do contain an index to an index of a channel of the
source IWaveProvider format.
An example (Stereo input to four channel output, the stereo input is copied to the last two channels):
int[] chMap = [ 0, 1, 0, 1 ];
theConverter.SetChannelMap(chMap);
public void SetChannelMap(int[] channelMap)
Parameters
channelMapint[]The array that contains the channel map to assign. The length of this array must be the value of the Channels property.
Remarks
You may also set any element to a value of -1.
This special value means that no input channel is to be
mapped to the output.
Exceptions
- ArgumentNullException
channelMapis null.- AudioConverterException
If
channelMapis invalid for the current object or it cannot be set.- ArgumentException
channelMapmust have a length equal to the output format number of channels.