LMMS
Loading...
Searching...
No Matches
juce::GenericInterpolator< InterpolatorTraits, memorySize > Class Template Reference

#include <juce_GenericInterpolator.h>

Public Member Functions

 GenericInterpolator () noexcept
 GenericInterpolator (GenericInterpolator &&) noexcept=default
GenericInterpolatoroperator= (GenericInterpolator &&) noexcept=default
void reset () noexcept
int process (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce) noexcept
int process (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, int numInputSamplesAvailable, int wrapAround) noexcept
int processAdding (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, float gain) noexcept
int processAdding (double speedRatio, const float *inputSamples, float *outputSamples, int numOutputSamplesToProduce, int numInputSamplesAvailable, int wrapAround, float gain) noexcept

Static Public Member Functions

static constexpr float getBaseLatency () noexcept

Private Member Functions

forcedinline void pushInterpolationSample (float newValue) noexcept
forcedinline void pushInterpolationSamples (const float *input, int numOutputSamplesToProduce) noexcept
forcedinline void pushInterpolationSamples (const float *input, int numOutputSamplesToProduce, int numInputSamplesAvailable, int wrapAround) noexcept
int interpolate (double speedRatio, const float *input, float *output, int numOutputSamplesToProduce) noexcept
int interpolate (double speedRatio, const float *input, float *output, int numOutputSamplesToProduce, int numInputSamplesAvailable, int wrap) noexcept
int interpolateAdding (double speedRatio, const float *input, float *output, int numOutputSamplesToProduce, int numInputSamplesAvailable, int wrap, float gain) noexcept
int interpolateAdding (double speedRatio, const float *input, float *output, int numOutputSamplesToProduce, float gain) noexcept

Private Attributes

float lastInputSamples [(size_t) memorySize]
double subSamplePos = 1.0
int indexBuffer = 0

Detailed Description

template<class InterpolatorTraits, int memorySize>
class juce::GenericInterpolator< InterpolatorTraits, memorySize >

An interpolator base class for resampling streams of floats.

Note that the resamplers are 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 interpolator object.

See also
LagrangeInterpolator, CatmullRomInterpolator, WindowedSincInterpolator, LinearInterpolator, ZeroOrderHoldInterpolator

@tags{Audio}

Constructor & Destructor Documentation

◆ GenericInterpolator() [1/2]

template<class InterpolatorTraits, int memorySize>
juce::GenericInterpolator< InterpolatorTraits, memorySize >::GenericInterpolator ( )
inlinenoexcept

◆ GenericInterpolator() [2/2]

template<class InterpolatorTraits, int memorySize>
juce::GenericInterpolator< InterpolatorTraits, memorySize >::GenericInterpolator ( GenericInterpolator< InterpolatorTraits, memorySize > && )
defaultnoexcept

Member Function Documentation

◆ getBaseLatency()

template<class InterpolatorTraits, int memorySize>
constexpr float juce::GenericInterpolator< InterpolatorTraits, memorySize >::getBaseLatency ( )
inlinestaticconstexprnoexcept

Returns the latency of the interpolation algorithm in isolation.

In the context of resampling the total latency of a process using the interpolator is the base latency divided by the speed ratio.

◆ interpolate() [1/2]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::interpolate ( double speedRatio,
const float * input,
float * output,
int numOutputSamplesToProduce )
inlineprivatenoexcept

◆ interpolate() [2/2]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::interpolate ( double speedRatio,
const float * input,
float * output,
int numOutputSamplesToProduce,
int numInputSamplesAvailable,
int wrap )
inlineprivatenoexcept

◆ interpolateAdding() [1/2]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::interpolateAdding ( double speedRatio,
const float * input,
float * output,
int numOutputSamplesToProduce,
float gain )
inlineprivatenoexcept

◆ interpolateAdding() [2/2]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::interpolateAdding ( double speedRatio,
const float * input,
float * output,
int numOutputSamplesToProduce,
int numInputSamplesAvailable,
int wrap,
float gain )
inlineprivatenoexcept

◆ operator=()

template<class InterpolatorTraits, int memorySize>
GenericInterpolator & juce::GenericInterpolator< InterpolatorTraits, memorySize >::operator= ( GenericInterpolator< InterpolatorTraits, memorySize > && )
defaultnoexcept

◆ process() [1/2]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::process ( double speedRatio,
const float * inputSamples,
float * outputSamples,
int numOutputSamplesToProduce )
inlinenoexcept

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]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::process ( double speedRatio,
const float * inputSamples,
float * outputSamples,
int numOutputSamplesToProduce,
int numInputSamplesAvailable,
int wrapAround )
inlinenoexcept

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
numInputSamplesAvailablethe 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]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::processAdding ( double speedRatio,
const float * inputSamples,
float * outputSamples,
int numOutputSamplesToProduce,
float gain )
inlinenoexcept

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]

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::processAdding ( double speedRatio,
const float * inputSamples,
float * outputSamples,
int numOutputSamplesToProduce,
int numInputSamplesAvailable,
int wrapAround,
float gain )
inlinenoexcept

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
numInputSamplesAvailablethe 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

◆ pushInterpolationSample()

template<class InterpolatorTraits, int memorySize>
forcedinline void juce::GenericInterpolator< InterpolatorTraits, memorySize >::pushInterpolationSample ( float newValue)
inlineprivatenoexcept

◆ pushInterpolationSamples() [1/2]

template<class InterpolatorTraits, int memorySize>
forcedinline void juce::GenericInterpolator< InterpolatorTraits, memorySize >::pushInterpolationSamples ( const float * input,
int numOutputSamplesToProduce )
inlineprivatenoexcept

◆ pushInterpolationSamples() [2/2]

template<class InterpolatorTraits, int memorySize>
forcedinline void juce::GenericInterpolator< InterpolatorTraits, memorySize >::pushInterpolationSamples ( const float * input,
int numOutputSamplesToProduce,
int numInputSamplesAvailable,
int wrapAround )
inlineprivatenoexcept

◆ reset()

template<class InterpolatorTraits, int memorySize>
void juce::GenericInterpolator< InterpolatorTraits, memorySize >::reset ( )
inlinenoexcept

Resets the state of the interpolator.

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

Member Data Documentation

◆ indexBuffer

template<class InterpolatorTraits, int memorySize>
int juce::GenericInterpolator< InterpolatorTraits, memorySize >::indexBuffer = 0
private

◆ lastInputSamples

template<class InterpolatorTraits, int memorySize>
float juce::GenericInterpolator< InterpolatorTraits, memorySize >::lastInputSamples[(size_t) memorySize]
private

◆ subSamplePos

template<class InterpolatorTraits, int memorySize>
double juce::GenericInterpolator< InterpolatorTraits, memorySize >::subSamplePos = 1.0
private

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