arduino-audio-tools
|
Base class for resampling algorithms using a buffer of float values. More...
#include <ResampleStreamT.h>
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< float > | values |
Buffer holding the last 4 values for interpolation. | |
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.
|
inline |
Adds a new value to the buffer, discarding the oldest.
value | The new sample value to add. |
|
inline |
Gets the next interpolated value.
newValue | Reference to store the interpolated value. |
|
inline |
Sets the step size for interpolation.
step | The new step size. |
|
protectedpure virtual |
Interpolation function to be implemented by derived classes.
y | Pointer to the buffer of 4 values. |
xf | The fractional index for interpolation. |
Implemented in LinearInterpolator, BSplineInterpolator, LagrangeInterpolator, HermiteInterpolator, and ParabolicInterpolator.
|
protectedpure virtual |
Implemented in LinearInterpolator, BSplineInterpolator, LagrangeInterpolator, HermiteInterpolator, and ParabolicInterpolator.