OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_LookupTable.h>
Public Member Functions | |
LookupTable () | |
LookupTable (const std::function< FloatType(size_t)> &functionToApproximate, size_t numPointsToUse) | |
void | initialise (const std::function< FloatType(size_t)> &functionToApproximate, size_t numPointsToUse) |
FloatType | getUnchecked (FloatType index) const noexcept |
FloatType | get (FloatType index) const noexcept |
FloatType | operator[] (FloatType index) const noexcept |
size_t | getNumPoints () const noexcept |
bool | isInitialised () const noexcept |
Class for efficiently approximating expensive arithmetic operations.
The approximation is based on linear interpolation between pre-calculated values. The approximated function should be passed as a callable object to the constructor along with the number of data points to be pre-calculated. The accuracy of the approximation can be increased by using more points at the cost of a larger memory footprint.
Consider using LookupTableTransform as an easy-to-use alternative.
Example:
LookupTable<float> lut ([] (size_t i) { return std::sqrt ((float) i); }, 64); auto outValue = lut[17];
Definition at line 53 of file juce_LookupTable.h.
juce::dsp::LookupTable< FloatType >::LookupTable | ( | ) |
Creates an uninitialised LookupTable object.
You need to call initialise() before using the object. Prefer using the non-default constructor instead.
Definition at line 33 of file juce_LookupTable.cpp.
juce::dsp::LookupTable< FloatType >::LookupTable | ( | const std::function< FloatType(size_t)> & | functionToApproximate, |
size_t | numPointsToUse | ||
) |
Creates and initialises a LookupTable object.
functionToApproximate | The function to be approximated. This should be a mapping from the integer range [0, numPointsToUse - 1]. |
numPointsToUse | The number of pre-calculated values stored. |
Definition at line 39 of file juce_LookupTable.cpp.
|
inlinenoexcept |
Calculates the approximated value for the given index with range checking.
This can be called with any input indices. If the provided index is out-of-range either the bottom or the top element of the LookupTable is returned.
If the index is guaranteed to be in range use the faster getUnchecked() instead.
index | The approximation is calculated for this non-integer index. |
Definition at line 124 of file juce_LookupTable.h.
|
inlinenoexcept |
Returns the size of the LookupTable, i.e., the number of pre-calculated data points.
Definition at line 139 of file juce_LookupTable.h.
Referenced by juce::dsp::LookupTable< FloatType >::get(), and juce::dsp::LookupTable< FloatType >::getUnchecked().
|
inlinenoexcept |
Calculates the approximated value for the given index without range checking.
Use this if you can guarantee that the index is non-negative and less than numPoints. Otherwise use get().
index | The approximation is calculated for this non-integer index. |
Definition at line 96 of file juce_LookupTable.h.
Referenced by juce::dsp::LookupTable< FloatType >::get(), and juce::dsp::LookupTable< FloatType >::operator[]().
void juce::dsp::LookupTable< FloatType >::initialise | ( | const std::function< FloatType(size_t)> & | functionToApproximate, |
size_t | numPointsToUse | ||
) |
Initialises or changes the parameters of a LookupTable object.
This function can be used to change what function is approximated by an already constructed LookupTable along with the number of data points used. If the function to be approximated won't ever change, prefer using the non-default constructor.
functionToApproximate | The function to be approximated. This should be a mapping from the integer range [0, numPointsToUse - 1]. |
numPointsToUse | The number of pre-calculated values stored. |
Definition at line 47 of file juce_LookupTable.cpp.
|
inlinenoexcept |
Returns true if the LookupTable is initialised and ready to be used.
Definition at line 142 of file juce_LookupTable.h.
Referenced by juce::dsp::LookupTable< FloatType >::getUnchecked().
|
inlinenoexcept |
Definition at line 136 of file juce_LookupTable.h.