49template <
typename FloatType>
99 auto f = index - FloatType (i);
121 FloatType
get (FloatType index)
const noexcept
124 index =
static_cast<FloatType
> (getGuardIndex());
145 void prepare() noexcept;
147 size_t getGuardIndex()
const noexcept {
return getRequiredBufferSize (
getNumPoints()) - 1; }
171template <
typename FloatType>
233 jassert (value >= minInputValue && value <= maxInputValue);
234 return lookupTable[scaler * value + offset];
253 auto index = scaler *
jlimit (minInputValue, maxInputValue, value) + offset;
256 return lookupTable[index];
270 void processUnchecked (
const FloatType* input, FloatType* output,
size_t numSamples)
const noexcept
272 for (
size_t i = 0; i < numSamples; ++i)
280 void process (
const FloatType* input, FloatType* output,
size_t numSamples)
const noexcept
282 for (
size_t i = 0; i < numSamples; ++i)
310 FloatType minInputValue,
311 FloatType maxInputValue,
316 static double calculateRelativeDifference (
double,
double)
noexcept;
321 FloatType minInputValue, maxInputValue;
322 FloatType scaler, offset;
Holds a resizable array of primitive or copy-by-value objects.
ElementType getUnchecked(int index) const
Returns one of the elements in the array, without checking the index passed in.
int size() const noexcept
Returns the current number of elements in the array.
Class for efficiently approximating expensive arithmetic operations.
FloatType get(FloatType index) const noexcept
Calculates the approximated value for the given index with range checking.
FloatType operator[](FloatType index) const noexcept
FloatType getUnchecked(FloatType index) const noexcept
Calculates the approximated value for the given index without range checking.
bool isInitialised() const noexcept
Returns true if the LookupTable is initialised and ready to be used.
size_t getNumPoints() const noexcept
Returns the size of the LookupTable, i.e., the number of pre-calculated data points.
void initialise(const std::function< FloatType(size_t)> &functionToApproximate, size_t numPointsToUse)
Initialises or changes the parameters of a LookupTable object.
LookupTable()
Creates an uninitialised LookupTable object.
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Remaps a normalised value (between 0 and 1) to a target range.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
unsigned int truncatePositiveToUnsignedInt(FloatType value) noexcept
Truncates a positive floating-point number to an unsigned int.