JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::LagrangeInterpolator Class Reference

Interpolator for resampling a stream of floats using 4-point lagrange interpolation. More...

#include <juce_LagrangeInterpolator.h>

Collaboration diagram for juce::LagrangeInterpolator:

Public Member Functions

 LagrangeInterpolator () noexcept
 
 ~LagrangeInterpolator () noexcept
 
int process (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce) noexcept
 Resamples a stream of samples. More...
 
int process (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, int available, int wrapAround) noexcept
 Resamples a stream of samples. More...
 
int processAdding (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, float gain) noexcept
 Resamples a stream of samples, adding the results to the output data with a gain. More...
 
int processAdding (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, int available, int wrapAround, float gain) noexcept
 Resamples a stream of samples, adding the results to the output data with a gain. More...
 
void reset () noexcept
 Resets the state of the interpolator. More...
 

Private Attributes

float lastInputSamples [5]
 
double subSamplePos
 

Detailed Description

Interpolator for resampling a stream of floats using 4-point lagrange interpolation.

Note that the resampler is stateful, so when there's a break in the continuity of the input stream you're feeding it, you should call reset() before feeding it any new data. And like with any other stateful filter, if you're resampling multiple channels, make sure each one uses its own LagrangeInterpolator object.

See also
CatmullRomInterpolator

{Audio}

Constructor & Destructor Documentation

◆ LagrangeInterpolator()

juce::LagrangeInterpolator::LagrangeInterpolator ( )
noexcept

◆ ~LagrangeInterpolator()

juce::LagrangeInterpolator::~LagrangeInterpolator ( )
noexcept

Member Function Documentation

◆ process() [1/2]

int juce::LagrangeInterpolator::process ( double  speedRatio,
const float inputSamples,
float outputSamples,
int  numOutputSamplesToProduce 
)
noexcept

Resamples a stream of samples.

Parameters
speedRatiothe number of input samples to use for each output sample
inputSamplesthe source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
outputSamplesthe buffer to write the results into
numOutputSamplesToProducethe number of output samples that should be created
Returns
the actual number of input samples that were used

◆ process() [2/2]

int juce::LagrangeInterpolator::process ( double  speedRatio,
const float inputSamples,
float outputSamples,
int  numOutputSamplesToProduce,
int  available,
int  wrapAround 
)
noexcept

Resamples a stream of samples.

Parameters
speedRatiothe number of input samples to use for each output sample
inputSamplesthe source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
outputSamplesthe buffer to write the results into
numOutputSamplesToProducethe number of output samples that should be created
availablethe number of available input samples. If it needs more samples than available, it either wraps back for wrapAround samples, or it feeds zeroes
wrapAroundif the stream exceeds available samples, it wraps back for wrapAround samples. If wrapAround is set to 0, it will feed zeroes.
Returns
the actual number of input samples that were used

◆ processAdding() [1/2]

int juce::LagrangeInterpolator::processAdding ( double  speedRatio,
const float inputSamples,
float outputSamples,
int  numOutputSamplesToProduce,
float  gain 
)
noexcept

Resamples a stream of samples, adding the results to the output data with a gain.

Parameters
speedRatiothe number of input samples to use for each output sample
inputSamplesthe source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
outputSamplesthe buffer to write the results to - the result values will be added to any pre-existing data in this buffer after being multiplied by the gain factor
numOutputSamplesToProducethe number of output samples that should be created
gaina gain factor to multiply the resulting samples by before adding them to the destination buffer
Returns
the actual number of input samples that were used

◆ processAdding() [2/2]

int juce::LagrangeInterpolator::processAdding ( double  speedRatio,
const float inputSamples,
float outputSamples,
int  numOutputSamplesToProduce,
int  available,
int  wrapAround,
float  gain 
)
noexcept

Resamples a stream of samples, adding the results to the output data with a gain.

Parameters
speedRatiothe number of input samples to use for each output sample
inputSamplesthe source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
outputSamplesthe buffer to write the results to - the result values will be added to any pre-existing data in this buffer after being multiplied by the gain factor
numOutputSamplesToProducethe number of output samples that should be created
availablethe number of available input samples. If it needs more samples than available, it either wraps back for wrapAround samples, or it feeds zeroes
wrapAroundif the stream exceeds available samples, it wraps back for wrapAround samples. If wrapAround is set to 0, it will feed zeroes.
gaina gain factor to multiply the resulting samples by before adding them to the destination buffer
Returns
the actual number of input samples that were used

◆ reset()

void juce::LagrangeInterpolator::reset ( )
noexcept

Resets the state of the interpolator.

Call this when there's a break in the continuity of the input data stream.

Member Data Documentation

◆ lastInputSamples

float juce::LagrangeInterpolator::lastInputSamples[5]
private

◆ subSamplePos

double juce::LagrangeInterpolator::subSamplePos
private

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