arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseInterpolator Struct Referenceabstract

Base class for resampling algorithms using a buffer of float values. More...

#include <ResampleStreamT.h>

Inheritance diagram for BaseInterpolator:
BSplineInterpolator HermiteInterpolator LagrangeInterpolator LinearInterpolator ParabolicInterpolator

Public Member Functions

void addValue (float value)
 Adds a new value to the buffer, discarding the oldest.
 
bool begin ()
 Constructor. Initializes the buffer with four zeros.
 
bool getValue (float &newValue)
 Gets the next interpolated value.
 
 operator bool () const
 Returns true if there are more values to read.
 
void setStepSize (float step)
 Sets the step size for interpolation.
 
float valueExt (float *y, float xf)
 

Protected Member Functions

virtual float value (float *y, float xf)=0
 Interpolation function to be implemented by derived classes.
 
virtual int vectorSize ()=0
 

Protected Attributes

float step = 0
 
float step_size = 1.0f
 Step size for resampling, default is 1.0.
 
SingleBuffer< floatvalues
 Buffer holding the last 4 values for interpolation.
 

Detailed Description

Base class for resampling algorithms using a buffer of float values.

Call getValue() to get the next interpolated value until it returns false. Then provide a new value with addValue() to continue.

Derived classes must implement the value() and vectorSize() methods for interpolation. The calculation depends on n values. For example, a linear interpolation only needs the last two values, while a cubic B-spline interpolation requires the last four values. The buffer is always filled with the required number of values, so the derived class can assume that it has access to all required values for interpolation.

The buffer is initilaized with 0 values and it is re-initialized when setStepSize() is called with a different size.

Member Function Documentation

◆ addValue()

void addValue ( float  value)
inline

Adds a new value to the buffer, discarding the oldest.

Parameters
valueThe new sample value to add.

◆ begin()

bool begin ( )
inline

Constructor. Initializes the buffer with four zeros.

◆ getValue()

bool getValue ( float newValue)
inline

Gets the next interpolated value.

Parameters
newValueReference to store the interpolated value.
Returns
True if a value was produced, false if more input is needed.

◆ operator bool()

operator bool ( ) const
inline

Returns true if there are more values to read.

◆ setStepSize()

void setStepSize ( float  step)
inline

Sets the step size for interpolation.

Parameters
stepThe new step size.

◆ value()

virtual float value ( float y,
float  xf 
)
protectedpure virtual

Interpolation function to be implemented by derived classes.

Parameters
yPointer to the buffer of 4 values.
xfThe fractional index for interpolation.
Returns
Interpolated value.

Implemented in LinearInterpolator, BSplineInterpolator, LagrangeInterpolator, HermiteInterpolator, and ParabolicInterpolator.

◆ valueExt()

float valueExt ( float y,
float  xf 
)
inline

◆ vectorSize()

virtual int vectorSize ( )
protectedpure virtual

Member Data Documentation

◆ step

float step = 0
protected

◆ step_size

float step_size = 1.0f
protected

Step size for resampling, default is 1.0.

◆ values

SingleBuffer<float> values
protected

Buffer holding the last 4 values for interpolation.


The documentation for this struct was generated from the following file: