#include <Resample.h>
Public Types | |
enum | ResamplingMethod { SINC_BEST_QUALITY = 0, SINC_MEDIUM_QUALITY = 1, SINC_FASTEST = 2, ZERO_ORDER_HOLD = 3, LINEAR = 4 } |
Specifies the resampling method to be used. More... | |
Public Member Functions | |
Resample (int inputSize=1024, int outputSize=1024, Real resamplingRatio=1.0, ResamplingMethod resamplingMethod=SINC_BEST_QUALITY) | |
~Resample () | |
void | process (const MatrixXR &frames, MatrixXR *resampled) |
int | inputSize () const |
void | setInputSize (int size, bool callSetup=true) |
int | outputSize () const |
void | setOutputSize (int size, bool callSetup=true) |
Real | resamplingRatio () const |
void | setResamplingRatio (Real ratio, bool callSetup=true) |
ResamplingMethod | resamplingMethod () const |
void | setResamplingMethod (ResamplingMethod method, bool callSetup=true) |
This class represents an object to resample vectors of Real values. The algorithm takes as input N-point vectors of Real values and returns M-point vectors of Real values.
This algorithm changes the sampling rate of input vectors, modifying their number of samples.
The number of samples in the input and output vectors can be specified using setInputSize() and setOutputSize() respectively.
The ratio between the output and input sampling rates can be specified using setResamplingRatio(). Usually the sampling ratio will be chosen close to outputSize / inputSize.
enum ResamplingMethod |
Resample | ( | int | inputSize = 1024 , |
|
int | outputSize = 1024 , |
|||
Real | resamplingRatio = 1.0 , |
|||
ResamplingMethod | resamplingMethod = SINC_BEST_QUALITY | |||
) |
Constructs a Resampler object with the specified inputSize, outputSize, resamplingRatio and resamplingMethod settings.
inputSize | size of the input frames to be resampled, must be > 0. | |
outputSize | size of the output resampled frames, must be > 0. | |
resamplingRatio | the ratio between the output sampling rate and the input sampling rate | |
resamplingMethod | the resampling method to be used |
References setInputSize(), setOutputSize(), setResamplingMethod(), and setResamplingRatio().
~Resample | ( | ) |
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXR & | frames, | |
MatrixXR * | resampled | |||
) |
Performs the resampling of each of the rows of frames and puts the resulting resampled frames in the rows of resampled.
frames | matrix of Real values. The number of columns of frames must be equal to the inputSize. | |
resampled | pointer to a matrix of Real values for the output. The matrix should have the same number of rows as frames and outputSize columns. |
int inputSize | ( | ) | const |
Returns the input size of the algorithm.
By default it is 1024.
void setInputSize | ( | int | size, | |
bool | callSetup = true | |||
) |
Specifies the input size of the algorithm.
Referenced by Resample().
int outputSize | ( | ) | const |
Returns the output size of the algorithm.
By default it is 1024.
void setOutputSize | ( | int | size, | |
bool | callSetup = true | |||
) |
Specifies the output size of the algorithm.
Referenced by Resample().
Real resamplingRatio | ( | ) | const |
Returns the ratio between the output and input sampling rate. Note that this value is normally around outputSize / inputSize.
By default it is 1.0.
void setResamplingRatio | ( | Real | ratio, | |
bool | callSetup = true | |||
) |
Specifies the ratio between the output and input sampling rate.
Referenced by Resample().
Resample::ResamplingMethod resamplingMethod | ( | ) | const |
Returns the resampling method to be used.
By default it is SINC_BEST_QUALITY.
void setResamplingMethod | ( | ResamplingMethod | method, | |
bool | callSetup = true | |||
) |
Specifies the resampling method to be used.
Referenced by Resample().