JUCE: GenericInterpolator< InterpolatorTraits, memorySize > Class Template Reference

JUCE

Public Member Functions | Static Public Member Functions | List of all members
GenericInterpolator< InterpolatorTraits, memorySize > Class Template Reference
juce_audio_basics » utilities

An interpolator base class for resampling streams of floats. More...

`#include <juce_GenericInterpolator.h>`

## Public Member Functions
| GenericInterpolator () noexcept
| GenericInterpolator (GenericInterpolator &&) noexcept=default
GenericInterpolator & | operator= (GenericInterpolator &&) noexcept=default
void | reset () noexcept
| Resets the state of the interpolator. More...
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 numInputSamplesAvailable, 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 numInputSamplesAvailable, int wrapAround, float gain) noexcept
| Resamples a stream of samples, adding the results to the output data with a gain. More...

## Static Public Member Functions
static constexpr float | getBaseLatency () noexcept
| Returns the latency of the interpolation algorithm in isolation. More...

## Detailed Description

template<class InterpolatorTraits, int memorySize>
class 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

## Constructor & Destructor Documentation

## ◆ GenericInterpolator() [1/2]

template<class InterpolatorTraits , int memorySize>

GenericInterpolator< InterpolatorTraits, memorySize >::GenericInterpolator | ( |  | ) |
| noexcept

References gl::reset.

## ◆ GenericInterpolator() [2/2]

template<class InterpolatorTraits , int memorySize>

GenericInterpolator< InterpolatorTraits, memorySize >::GenericInterpolator | ( | GenericInterpolator< InterpolatorTraits, memorySize > && |  | ) |
| defaultnoexcept

## Member Function Documentation

## ◆ operator=()

template<class InterpolatorTraits , int memorySize>

GenericInterpolator & GenericInterpolator< InterpolatorTraits, memorySize >::operator= | ( | GenericInterpolator< InterpolatorTraits, memorySize > && |  | ) |
| defaultnoexcept

## ◆ getBaseLatency()

template<class InterpolatorTraits , int memorySize>

static constexpr float GenericInterpolator< InterpolatorTraits, memorySize >::getBaseLatency | ( |  | ) |
| staticconstexprnoexcept

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.

## ◆ reset()

template<class InterpolatorTraits , int memorySize>

void GenericInterpolator< InterpolatorTraits, memorySize >::reset | ( |  | ) |
| noexcept

Resets the state of the interpolator.

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

References begin(), and end().

## ◆ process() [1/2]

template<class InterpolatorTraits , int memorySize>

int GenericInterpolator< InterpolatorTraits, memorySize >::process | ( | double | speedRatio,
|  | const float * | inputSamples,
|  | float * | outputSamples,
|  | int | numOutputSamplesToProduce
| ) |  |
| noexcept

Resamples a stream of samples.

Parameters

  speedRatio | the number of input samples to use for each output sample
  inputSamples | the source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
  outputSamples | the buffer to write the results into
  numOutputSamplesToProduce | the 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 GenericInterpolator< InterpolatorTraits, memorySize >::process | ( | double | speedRatio,
|  | const float * | inputSamples,
|  | float * | outputSamples,
|  | int | numOutputSamplesToProduce,
|  | int | numInputSamplesAvailable,
|  | int | wrapAround
| ) |  |
| noexcept

Resamples a stream of samples.

Parameters

  speedRatio | the number of input samples to use for each output sample
  inputSamples | the source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
  outputSamples | the buffer to write the results into
  numOutputSamplesToProduce | the number of output samples that should be created
  numInputSamplesAvailable | the number of available input samples. If it needs more samples than available, it either wraps back for wrapAround samples, or it feeds zeroes
  wrapAround | if 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 GenericInterpolator< InterpolatorTraits, memorySize >::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

  speedRatio | the number of input samples to use for each output sample
  inputSamples | the source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
  outputSamples | the 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
  numOutputSamplesToProduce | the number of output samples that should be created
  gain | a 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 GenericInterpolator< InterpolatorTraits, memorySize >::processAdding | ( | double | speedRatio,
|  | const float * | inputSamples,
|  | float * | outputSamples,
|  | int | numOutputSamplesToProduce,
|  | int | numInputSamplesAvailable,
|  | int | wrapAround,
|  | float | gain
| ) |  |
| noexcept

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

Parameters

  speedRatio | the number of input samples to use for each output sample
  inputSamples | the source data to read from. This must contain at least (speedRatio * numOutputSamplesToProduce) samples.
  outputSamples | the 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
  numOutputSamplesToProduce | the number of output samples that should be created
  numInputSamplesAvailable | the number of available input samples. If it needs more samples than available, it either wraps back for wrapAround samples, or it feeds zeroes
  wrapAround | if the stream exceeds available samples, it wraps back for wrapAround samples. If wrapAround is set to 0, it will feed zeroes.
  gain | a 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

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

- juce_GenericInterpolator.h