49template <
typename FloatType>
68 LookupTable (
const std::function<FloatType (
size_t)>& functionToApproximate,
size_t numPointsToUse);
80 void initialise (
const std::function<FloatType (
size_t)>& functionToApproximate,
size_t numPointsToUse);
96 jassert (isPositiveAndBelow (index, FloatType (
getNumPoints())));
98 auto i = truncatePositiveToUnsignedInt (index);
99 auto f = index - FloatType (i);
100 jassert (isPositiveAndBelow (f, FloatType (1)));
102 auto x0 = data.getUnchecked (
static_cast<int> (i));
103 auto x1 = data.getUnchecked (
static_cast<int> (i + 1));
105 return jmap (f, x0, x1);
121 FloatType
get (FloatType index)
const noexcept
124 index =
static_cast<FloatType
> (getGuardIndex());
136 size_t getNumPoints() const noexcept {
return static_cast<size_t> (data.size()) - 1; }
145 void prepare() noexcept;
146 static
size_t getRequiredBufferSize (
size_t numPointsToUse) noexcept {
return numPointsToUse + 1; }
147 size_t getGuardIndex() const noexcept {
return getRequiredBufferSize (
getNumPoints()) - 1; }
149 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (
LookupTable)
171template <
typename FloatType>
197 FloatType minInputValueToUse,
198 FloatType maxInputValueToUse,
201 initialise (functionToApproximate, minInputValueToUse, maxInputValueToUse, numPoints);
215 void initialise (
const std::function<FloatType (FloatType)>& functionToApproximate,
216 FloatType minInputValueToUse,
217 FloatType maxInputValueToUse,
233 jassert (value >= minInputValue && value <= maxInputValue);
234 return lookupTable[scaler * value + offset];
253 auto index = scaler * jlimit (minInputValue, maxInputValue, value) + offset;
254 jassert (isPositiveAndBelow (index, FloatType (lookupTable.getNumPoints())));
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,
313 size_t numTestPoints = 0);
316 static double calculateRelativeDifference (
double,
double)
noexcept;
321 FloatType minInputValue, maxInputValue;
322 FloatType scaler, offset;
FloatType get(FloatType index) const noexcept
FloatType operator[](FloatType index) const noexcept
FloatType getUnchecked(FloatType index) const noexcept
bool isInitialised() const noexcept
size_t getNumPoints() const noexcept
void initialise(const std::function< FloatType(size_t)> &functionToApproximate, size_t numPointsToUse)