![]() |
r8brain-free-src
High-quality pro audio sample rate converter library
|
Half-band upsampling class. More...
#include <CDSPHBUpsampler.h>
Public Member Functions | |
CDSPHBUpsampler (const double ReqAtten, const int SteepIndex, const bool IsThird, const double PrevLatency, 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 l, 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 |
Static Public Member Functions | |
static void | getHBFilter (const double ReqAtten, const int SteepIndex, const double *&flt, int &fltt, double &att) |
static void | getHBFilterThird (const double ReqAtten, const int SteepIndex, const double *&flt, int &fltt, double &att) |
Half-band upsampling class.
Class implements brute-force half-band 2X upsampling that uses small sparse symmetric FIR filters. It is very efficient and should be used at latter upsampling steps after initial steep 2X upsampling.
r8b::CDSPHBUpsampler::CDSPHBUpsampler | ( | const double | ReqAtten, |
const int | SteepIndex, | ||
const bool | IsThird, | ||
const double | PrevLatency, | ||
const bool | aDoConsumeLatency = true |
||
) |
Constructor initalizes the half-band upsampler.
ReqAtten | Required half-band filter attentuation. |
SteepIndex | Steepness index - 0=steepest. Corresponds to general upsampling ratio, e.g. at 4x upsampling 0 is used, at 8x upsampling 1 is used, etc. |
IsThird | "True" if 1/3 of frequency response resampling is performed. |
PrevLatency | Latency, in samples (any value >=0), which was left in the output signal by a previous process. Whole-number latency will be consumed by *this object while remaining fractional latency can be obtained via the getLatencyFrac() function. |
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.
|
static |
Function that provides filter data for various steepness indices and attenuations.
ReqAtten | Required half-band filter attentuation. | |
SteepIndex | Steepness index - 0=steepest. Corresponds to general upsampling/downsampling ratio, e.g. at 4x 0 is used, at 8x 1 is used, etc. | |
[out] | flt | Resulting pointer to filter taps. |
[out] | fltt | Resulting filter's half-length, in samples (taps). |
[out] | att | Resulting filter's attenuation (the closest found). |
|
static |
Function that provides filter data for various steepness indices and attenuations. For 1/3 resamplings.
ReqAtten | Required half-band filter attentuation. | |
SteepIndex | Steepness index - 0=steepest. Corresponds to general upsampling/downsampling ratio, e.g. at 4x 0 is used, at 8x 1 is used, etc. | |
[out] | flt | Resulting pointer to filter taps. |
[out] | fltt | Resulting filter's half-length, in samples (taps). |
[out] | att | Resulting filter's attenuation (the closest found). |
|
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.