OpenShot Audio Library | OpenShotAudio: juce::dsp::LookupTableTransform< FloatType > Class Template Reference

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
juce::dsp::LookupTableTransform< FloatType > Class Template Reference

`#include <juce_LookupTable.h>`

## Public Member Functions
| LookupTableTransform ()=default
| LookupTableTransform (const std::function< FloatType(FloatType)> &functionToApproximate, FloatType minInputValueToUse, FloatType maxInputValueToUse, size_t numPoints)
void | initialise (const std::function< FloatType(FloatType)> &functionToApproximate, FloatType minInputValueToUse, FloatType maxInputValueToUse, size_t numPoints)
FloatType | processSampleUnchecked (FloatType value) const noexcept
FloatType | processSample (FloatType value) const noexcept
FloatType | operator[] (FloatType index) const noexcept
FloatType | operator() (FloatType index) const noexcept
void | processUnchecked (const FloatType *input, FloatType *output, size_t numSamples) const noexcept
void | process (const FloatType *input, FloatType *output, size_t numSamples) const noexcept

## Static Public Member Functions
static double | calculateMaxRelativeError (const std::function< FloatType(FloatType)> &functionToApproximate, FloatType minInputValue, FloatType maxInputValue, size_t numPoints, size_t numTestPoints=0)

## Detailed Description

template<typename FloatType>
class juce::dsp::LookupTableTransform< FloatType >

Class for approximating expensive arithmetic operations.

Once initialised, this class can be used just like the function it approximates via operator().

Example:

    LookupTableTransform<float> tanhApprox ([] (float x) { return std::tanh (x); }, -5.0f, 5.0f, 64);
    auto outValue = tanhApprox (4.2f);

Note: If you try to call the function with an input outside the provided range, it will return either the first or the last recorded LookupTable value.

See also
  LookupTable

Definition at line 175 of file juce_LookupTable.h.

## Constructor & Destructor Documentation

## ◆ LookupTableTransform() [1/2]

template<typename FloatType >

juce::dsp::LookupTableTransform< FloatType >::LookupTableTransform | ( |  | ) |
| default

Creates an uninitialised LookupTableTransform object.

You need to call initialise() before using the object. Prefer using the non-default constructor instead.

See also
  initialise

## ◆ LookupTableTransform() [2/2]

template<typename FloatType >

juce::dsp::LookupTableTransform< FloatType >::LookupTableTransform | ( | const std::function< FloatType(FloatType)> & | functionToApproximate,
|  | FloatType | minInputValueToUse,
|  | FloatType | maxInputValueToUse,
|  | size_t | numPoints
| ) |  |
| inline

Creates and initialises a LookupTableTransform object.

Parameters

  functionToApproximate | The function to be approximated. This should be a mapping from a FloatType to FloatType.
  minInputValueToUse | The lowest input value used. The approximation will fail for values lower than this.
  maxInputValueToUse | The highest input value used. The approximation will fail for values higher than this.
  numPoints | The number of pre-calculated values stored.

Definition at line 199 of file juce_LookupTable.h.

## Member Function Documentation

## ◆ calculateMaxRelativeError()

template<typename FloatType >

double juce::dsp::LookupTableTransform< FloatType >::calculateMaxRelativeError | ( | const std::function< FloatType(FloatType)> & | functionToApproximate,
|  | FloatType | minInputValue,
|  | FloatType | maxInputValue,
|  | size_t | numPoints,
|  | size_t | numTestPoints = `0`
| ) |  |
| static

Calculates the maximum relative error of the approximation for the specified parameter set.

The closer the returned value is to zero the more accurate the approximation is.

This function compares the approximated output of this class to the function it approximates at a range of points and returns the maximum relative error. This can be used to determine if the approximation is suitable for the given problem. The accuracy of the approximation can generally be improved by increasing numPoints.

Parameters

  functionToApproximate | The approximated function. This should be a mapping from a FloatType to FloatType.
  minInputValue | The lowest input value used.
  maxInputValue | The highest input value used.
  numPoints | The number of pre-calculated values stored.
  numTestPoints | The number of input values used for error calculation. Higher numbers can increase the accuracy of the error calculation. If it's zero then 100 * numPoints will be used.

Definition at line 101 of file juce_LookupTable.cpp.

## ◆ initialise()

template<typename FloatType >

void juce::dsp::LookupTableTransform< FloatType >::initialise | ( | const std::function< FloatType(FloatType)> & | functionToApproximate,
|  | FloatType | minInputValueToUse,
|  | FloatType | maxInputValueToUse,
|  | size_t | numPoints
| ) |  |

Initialises or changes the parameters of a LookupTableTransform object.

Parameters

  functionToApproximate | The function to be approximated. This should be a mapping from a FloatType to FloatType.
  minInputValueToUse | The lowest input value used. The approximation will fail for values lower than this.
  maxInputValueToUse | The highest input value used. The approximation will fail for values higher than this.
  numPoints | The number of pre-calculated values stored.

Definition at line 75 of file juce_LookupTable.cpp.

Referenced by juce::dsp::LookupTableTransform< FloatType >::LookupTableTransform().

## ◆ operator()()

template<typename FloatType >

FloatType juce::dsp::LookupTableTransform< FloatType >::operator() | ( | FloatType | index | ) | const
| inlinenoexcept

See also
  processSample

Definition at line 267 of file juce_LookupTable.h.

## ◆ operator[]()

template<typename FloatType >

FloatType juce::dsp::LookupTableTransform< FloatType >::operator[] | ( | FloatType | index | ) | const
| inlinenoexcept

See also
  processSampleUnchecked

Definition at line 264 of file juce_LookupTable.h.

## ◆ process()

template<typename FloatType >

void juce::dsp::LookupTableTransform< FloatType >::process | ( | const FloatType * | input,
|  | FloatType * | output,
|  | size_t | numSamples
| ) |  | const
| inlinenoexcept

Processes an array of input values with range checking

See also
  processUnchecked

Definition at line 283 of file juce_LookupTable.h.

## ◆ processSample()

template<typename FloatType >

FloatType juce::dsp::LookupTableTransform< FloatType >::processSample | ( | FloatType | value | ) | const
| inlinenoexcept

Calculates the approximated value for the given input value with range checking.

This can be called with any input values. Out-of-range input values will be clipped to the specified input range.

If the index is guaranteed to be in range use the faster processSampleUnchecked() instead.

Parameters

  value | The approximation is calculated for this input value.

Returns
  The approximated value for the provided input value.

See also
  processSampleUnchecked, operator(), operator[]

Definition at line 254 of file juce_LookupTable.h.

Referenced by juce::dsp::LookupTableTransform< FloatType >::calculateMaxRelativeError(), juce::dsp::LookupTableTransform< FloatType >::operator()(), and juce::dsp::LookupTableTransform< FloatType >::process().

## ◆ processSampleUnchecked()

template<typename FloatType >

FloatType juce::dsp::LookupTableTransform< FloatType >::processSampleUnchecked | ( | FloatType | value | ) | const
| inlinenoexcept

Calculates the approximated value for the given input value without range checking.

Use this if you can guarantee that the input value is within the range specified in the constructor or initialise(), otherwise use processSample().

Parameters

  value | The approximation is calculated for this input value.

Returns
  The approximated value for the provided input value.

See also
  processSample, operator(), operator[]

Definition at line 234 of file juce_LookupTable.h.

Referenced by juce::dsp::LookupTableTransform< FloatType >::operator[](), and juce::dsp::LookupTableTransform< FloatType >::processUnchecked().

## ◆ processUnchecked()

template<typename FloatType >

void juce::dsp::LookupTableTransform< FloatType >::processUnchecked | ( | const FloatType * | input,
|  | FloatType * | output,
|  | size_t | numSamples
| ) |  | const
| inlinenoexcept

Processes an array of input values without range checking

See also
  process

Definition at line 273 of file juce_LookupTable.h.

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

- juce_LookupTable.h
- juce_LookupTable.cpp