![]() |
r8brain-free-src
High-quality pro audio sample rate converter library
|
Single-block overlap-save convolution processing class. More...
#include <CDSPBlockConvolver.h>
Public Member Functions | |
CDSPBlockConvolver (CDSPFIRFilter &aFilter, const int aUpFactor, const int aDownFactor, const double PrevLatency=0.0, const bool aDoConsumeLatency=true) | |
virtual void | clear () |
virtual int | getInLenBeforeOutPos (const int ReqOutPos) const |
virtual int | getLatency () const |
virtual double | getLatencyFrac () const |
virtual int | getMaxOutLen (const int MaxInLen) const |
virtual int | process (double *ip, int l0, double *&op0) |
virtual void | clear ()=0 |
virtual int | getInLenBeforeOutPos (const int ReqOutPos) const =0 |
virtual int | getLatency () const =0 |
virtual double | getLatencyFrac () const =0 |
virtual int | getMaxOutLen (const int MaxInLen) const =0 |
virtual int | process (double *ip, int l0, double *&op0)=0 |
Single-block overlap-save convolution processing class.
Class that implements single-block overlap-save convolution processing. The length of a single FFT block used depends on the length of the filter kernel.
The rationale behind "single-block" processing is that increasing the FFT block length by 2 is more efficient than performing convolution at the same FFT block length but using two blocks.
This class also implements a built-in resampling by any whole-number factor, which simplifies the overall resampling objects topology.
r8b::CDSPBlockConvolver::CDSPBlockConvolver | ( | CDSPFIRFilter & | aFilter, |
const int | aUpFactor, | ||
const int | aDownFactor, | ||
const double | PrevLatency = 0.0 , |
||
const bool | aDoConsumeLatency = true |
||
) |
Constructor initializes internal variables and constants of *this object.
aFilter | Pre-calculated filter data. Reference to this object is inhertied by *this object, and the object will be released when *this object is destroyed. If upsampling is used, filter's gain should be equal to the upsampling factor. |
aUpFactor | The upsampling factor, positive value. E.g. value of 2 means 2x upsampling should be performed over the input data. |
aDownFactor | The downsampling factor, positive value. E.g. value of 2 means 2x downsampling should be performed over the output data. |
PrevLatency | Latency, in samples (any value >=0), which was left in the output signal by a previous process. This value is usually non-zero if the minimum-phase filters are in use. This value is always zero if the linear-phase filters are in use. |
aDoConsumeLatency | "True" if the output latency should be consumed. Does not apply to the fractional part of the latency (if such part is available). |
|
virtual |
Function clears (resets) the state of *this object and returns it to the state after construction. All input data accumulated in the internal buffer so far will be discarded.
Implements r8b::CDSPProcessor.
|
virtual |
Function returns the number of input samples required to advance to the specified output sample position (so that the next process() call passes this output position), starting at the cleared or after-construction state of *this object.
Note that the implementation of this function assumes the caller only needs to estimate an initial buffering requirement; passing a full sample length value (e.g., greater than 100000) may overflow the calculation or cause rounding errors.
ReqOutPos | The required output position. Set to 0 to obtain "input length before output start" latency. Must be a non-negative value. |
Implements r8b::CDSPProcessor.
|
virtual |
Implements r8b::CDSPProcessor.
|
virtual |
Implements r8b::CDSPProcessor.
|
virtual |
MaxInLen | The number of samples planned to process at once, at most. |
Implements r8b::CDSPProcessor.
|
virtual |
Function performs DSP processing.
ip | Input data pointer. | |
l0 | How many samples to process. | |
[out] | op0 | Output data pointer. The capacity of this buffer should be equal to the value returned by the getMaxOutLen() function for the given "l0". This buffer can be equal to "ip" only if the getMaxOutLen( l0 ) function returned a value lesser than "l0". This pointer can be incremented on function's return if latency compensation was performed by the processor. Note that on function's return, this pointer may point to some internal buffers, including the "ip" buffer, ignoring the originally passed value. |
Implements r8b::CDSPProcessor.