Fully managed resampler, based on Cockos WDL Resampler.
More...
|
| WdlResampler () |
| Creates a new Resampler.
|
|
void | SetMode (bool interp, int filtercnt, bool sinc, int sinc_size=64, int sinc_interpsize=32) |
| Sets the mode for resampling with optional sinc interpolation and filter count.
|
|
void | SetFilterParms (float filterpos=0.693f, float filterq=0.707f) |
| Sets the filter parameters with default values for position and quality factor.
|
|
void | SetFeedMode (bool wantInputDriven) |
| Sets the feed mode for the system.
|
|
void | Reset (double fracpos=0.0) |
| Resets the history of the resampler by creating a new history array.
|
|
void | SetRates (double rate_in, double rate_out) |
| Sets the input and output rates, ensuring they are at least 1.0, and updates the internal ratio if the rates have changed.
|
|
double | GetCurrentLatency () |
| Gets the current latency in seconds.
|
|
int | ResamplePrepare (int out_samples, int nch, out WDL_ResampleSample[] inbuffer, out int inbufferOffset) |
| Prepares the resampling process and returns the number of samples required for the resampled output.
|
|
int | ResampleOut (WDL_ResampleSample[] outBuffer, int outBufferIndex, int nsamples_in, int nsamples_out, int nch) |
| Resamples the input buffer to the output buffer based on the given parameters and returns the number of samples written to the output buffer.
|
|
|
void | BuildLowPass (double filtpos) |
| Builds a lowpass filter based on the given filter position.
|
|
void | SincSample (WDL_ResampleSample[] outBuffer, int outBufferIndex, WDL_ResampleSample[] inBuffer, int inBufferIndex, double fracpos, int nch, WDL_SincFilterSample[] filter, int filterIndex, int filtsz) |
| Performs sample rate conversion using sinc interpolation.
|
|
void | SincSample1 (WDL_ResampleSample[] outBuffer, int outBufferIndex, WDL_ResampleSample[] inBuffer, int inBufferIndex, double fracpos, WDL_SincFilterSample[] filter, int filterIndex, int filtsz) |
| Performs sinc resampling on the input buffer and writes the result to the output buffer at the specified indices.
|
|
void | SincSample2 (WDL_ResampleSample[] outptr, int outBufferIndex, WDL_ResampleSample[] inBuffer, int inBufferIndex, double fracpos, WDL_SincFilterSample[] filter, int filterIndex, int filtsz) |
| Performs a sinc resampling of the input buffer and stores the result in the output buffer.
|
|
Fully managed resampler, based on Cockos WDL Resampler.
◆ WdlResampler()
NAudio.Dsp.WdlResampler.WdlResampler |
( |
| ) |
|
|
inline |
◆ BuildLowPass()
void NAudio.Dsp.WdlResampler.BuildLowPass |
( |
double | filtpos | ) |
|
|
inlineprivate |
Builds a lowpass filter based on the given filter position.
- Parameters
-
filtpos | The position of the filter. |
This method builds a lowpass filter based on the given filter position, filter size, and interpolation size. It modifies the original filter coefficients array in place. The algorithm uses Blackman-Harris window and sinc function to construct the filter coefficients.
◆ GetCurrentLatency()
double NAudio.Dsp.WdlResampler.GetCurrentLatency |
( |
| ) |
|
|
inline |
Gets the current latency in seconds.
- Returns
- The current latency in seconds.
◆ ResampleOut()
int NAudio.Dsp.WdlResampler.ResampleOut |
( |
WDL_ResampleSample[] | outBuffer, |
|
|
int | outBufferIndex, |
|
|
int | nsamples_in, |
|
|
int | nsamples_out, |
|
|
int | nch ) |
|
inline |
Resamples the input buffer to the output buffer based on the given parameters and returns the number of samples written to the output buffer.
- Parameters
-
outBuffer | The output buffer to write the resampled samples to. |
outBufferIndex | The index in the output buffer to start writing the resampled samples. |
nsamples_in | The number of input samples to be resampled. |
nsamples_out | The number of output samples to be generated. |
nch | The number of channels in the input and output buffers. |
- Returns
- The number of samples written to the output buffer.
This method resamples the input buffer to the output buffer based on the given parameters. It handles filtering, interpolation, and padding as necessary to ensure accurate resampling. The resampling process modifies the output buffer in place.
◆ ResamplePrepare()
int NAudio.Dsp.WdlResampler.ResamplePrepare |
( |
int | out_samples, |
|
|
int | nch, |
|
|
out WDL_ResampleSample[] | inbuffer, |
|
|
out int | inbufferOffset ) |
|
inline |
Prepares the resampling process and returns the number of samples required for the resampled output.
- Parameters
-
out_samples | The number of output samples. |
nch | The number of channels. |
inbuffer | The input buffer for resampling. |
inbufferOffset | The offset for the input buffer. |
- Returns
- The number of samples required for the resampled output.
This method prepares the resampling process by resizing the input buffer and calculating the number of samples required for the resampled output. It also handles the filter latency and adjusts the size of the input buffer accordingly.
◆ Reset()
void NAudio.Dsp.WdlResampler.Reset |
( |
double | fracpos = 0::0 | ) |
|
|
inline |
Resets the history of the resampler by creating a new history array.
◆ SetFeedMode()
void NAudio.Dsp.WdlResampler.SetFeedMode |
( |
bool | wantInputDriven | ) |
|
|
inline |
Sets the feed mode for the system.
- Parameters
-
wantInputDriven | A boolean value indicating whether the system should be in input-driven feed mode. |
This method sets the feed mode for the system. If wantInputDriven is true, the system will operate in input-driven feed mode; otherwise, it will operate in a different mode.
◆ SetFilterParms()
void NAudio.Dsp.WdlResampler.SetFilterParms |
( |
float | filterpos = 0::693f, |
|
|
float | filterq = 0::707f ) |
|
inline |
Sets the filter parameters with default values for position and quality factor.
- Parameters
-
filterpos | The position parameter for the filter. Default value is 0.693. |
filterq | The quality factor parameter for the filter. Default value is 0.707. |
◆ SetMode()
void NAudio.Dsp.WdlResampler.SetMode |
( |
bool | interp, |
|
|
int | filtercnt, |
|
|
bool | sinc, |
|
|
int | sinc_size = 64, |
|
|
int | sinc_interpsize = 32 ) |
|
inline |
Sets the mode for resampling with optional sinc interpolation and filter count.
- Parameters
-
interp | Specifies whether to use interpolation. |
filtercnt | The number of filters to be used. |
sinc | Specifies whether to use sinc interpolation. |
sinc_size | The size of the sinc interpolation. Default is 64. |
sinc_interpsize | The interpolation size for sinc. Default is 32. |
This method sets the mode for resampling with optional sinc interpolation and filter count. It modifies the internal state of the resampler based on the provided parameters.
◆ SetRates()
void NAudio.Dsp.WdlResampler.SetRates |
( |
double | rate_in, |
|
|
double | rate_out ) |
|
inline |
Sets the input and output rates, ensuring they are at least 1.0, and updates the internal ratio if the rates have changed.
- Parameters
-
rate_in | The input rate to be set. |
rate_out | The output rate to be set. |
If the input rate rate_in is less than 1.0, it is set to 1.0. If the output rate rate_out is less than 1.0, it is set to 1.0. If either rate_in or rate_out is different from the current input or output rates, the internal rates are updated and the ratio is recalculated as the input rate divided by the output rate.
◆ SincSample()
Performs sample rate conversion using sinc interpolation.
- Parameters
-
outBuffer | The output buffer to store the resampled samples. |
outBufferIndex | The index in the output buffer to start writing the resampled samples. |
inBuffer | The input buffer containing the original samples. |
inBufferIndex | The index in the input buffer to start reading the original samples. |
fracpos | The fractional position within the input buffer for interpolation. |
nch | The number of channels in the audio data. |
filter | The sinc filter coefficients for interpolation. |
filterIndex | The index in the filter array to start applying the filter. |
filtsz | The size of the filter. |
This method performs sample rate conversion using sinc interpolation. It applies a sinc filter to the input samples to generate the resampled output. The fractional position within the input buffer is used for interpolation, and the number of channels and filter size are taken into account during the process. The resampled samples are written to the output buffer starting from the specified index.
◆ SincSample1()
Performs sinc resampling on the input buffer and writes the result to the output buffer at the specified indices.
- Parameters
-
outBuffer | The output buffer where the resampled data will be written. |
outBufferIndex | The index in the output buffer where the resampled data will be written. |
inBuffer | The input buffer containing the original data to be resampled. |
inBufferIndex | The index in the input buffer from where the original data will be read for resampling. |
fracpos | The fractional position within the input buffer for resampling. |
filter | The sinc filter used for resampling. |
filterIndex | The index in the sinc filter array. |
filtsz | The size of the sinc filter. |
This method performs sinc resampling on the input buffer using the provided sinc filter and fractional position. It calculates the resampled value using the filter coefficients and writes the result to the output buffer at the specified index.
◆ SincSample2()
Performs a sinc resampling of the input buffer and stores the result in the output buffer.
- Parameters
-
outptr | The output buffer where the resampled data will be stored. |
outBufferIndex | The index in the output buffer where the resampled data will start. |
inBuffer | The input buffer containing the original data to be resampled. |
inBufferIndex | The index in the input buffer from where the original data will be read for resampling. |
fracpos | The fractional position within the input buffer for resampling. |
filter | The sinc filter used for resampling. |
filterIndex | The index in the filter array from where filtering will start. |
filtsz | The size of the filter array. |
This method performs a sinc resampling of the input buffer using the provided sinc filter. It calculates the resampled values based on the fractional position within the input buffer and stores the result in the output buffer starting from the specified index. The resampling process involves applying the sinc filter to the input buffer data to obtain the resampled values. The filter is applied based on the fractional position, and the resulting values are stored in the output buffer.
◆ m_feedmode
bool NAudio.Dsp.WdlResampler.m_feedmode |
|
private |
◆ m_filter_coeffs
◆ m_filter_coeffs_size
int NAudio.Dsp.WdlResampler.m_filter_coeffs_size |
|
private |
◆ m_filter_ratio
double NAudio.Dsp.WdlResampler.m_filter_ratio |
|
private |
◆ m_filtercnt
int NAudio.Dsp.WdlResampler.m_filtercnt |
|
private |
◆ m_filterpos
float NAudio.Dsp.WdlResampler.m_filterpos |
|
private |
◆ m_filterq
float NAudio.Dsp.WdlResampler.m_filterq |
|
private |
◆ m_filtlatency
int NAudio.Dsp.WdlResampler.m_filtlatency |
|
private |
◆ m_fracpos
double NAudio.Dsp.WdlResampler.m_fracpos |
|
private |
◆ m_iirfilter
◆ m_interp
bool NAudio.Dsp.WdlResampler.m_interp |
|
private |
◆ m_last_requested
int NAudio.Dsp.WdlResampler.m_last_requested |
|
private |
◆ m_lp_oversize
int NAudio.Dsp.WdlResampler.m_lp_oversize |
|
private |
◆ m_ratio
double NAudio.Dsp.WdlResampler.m_ratio |
|
private |
◆ m_rsinbuf
◆ m_samples_in_rsinbuf
int NAudio.Dsp.WdlResampler.m_samples_in_rsinbuf |
|
private |
◆ m_sincoversize
int NAudio.Dsp.WdlResampler.m_sincoversize |
|
private |
◆ m_sincsize
int NAudio.Dsp.WdlResampler.m_sincsize |
|
private |
◆ m_sratein
double NAudio.Dsp.WdlResampler.m_sratein |
|
private |
◆ m_srateout
double NAudio.Dsp.WdlResampler.m_srateout |
|
private |
◆ PI
const double NAudio.Dsp.WdlResampler.PI = 3.1415926535897932384626433832795 |
|
staticprivate |
◆ WDL_RESAMPLE_MAX_FILTERS
const int NAudio.Dsp.WdlResampler.WDL_RESAMPLE_MAX_FILTERS = 4 |
|
staticprivate |
◆ WDL_RESAMPLE_MAX_NCH
const int NAudio.Dsp.WdlResampler.WDL_RESAMPLE_MAX_NCH = 64 |
|
staticprivate |
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Core/Dsp/WdlResampler.cs