Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::LookupTableT< SampleType > Class Template Reference

Pre-computed function lookup table with linear interpolation. More...

#include <lookup_table.hpp>

Public Member Functions

 LookupTableT ()=default
 LookupTableT (int size, SampleType min_input, SampleType max_input, std::function< SampleType(SampleType)> generator)
 Construct with a generator function.
SampleType process (SampleType input) const
 Look up a value with linear interpolation.
void process (SampleType *data, int num_samples) const
 Process a buffer in-place.
SampleType operator[] (int index) const
 Direct table access (no interpolation).
int size () const
bool empty () const

Detailed Description

template<typename SampleType = float>
class pulp::signal::LookupTableT< SampleType >

Pre-computed function lookup table with linear interpolation.

RT contract: construction allocates and runs the generator. process(), operator[], and size queries allocate no memory after construction.

Maps an input range [min, max] to pre-computed output values, using linear interpolation between table entries for smooth results.

// Fast tanh approximation with 1024 entries
LookupTable tanh_table(1024, -4.0f, 4.0f, [](float x) { return std::tanh(x); });
float out = tanh_table.process(input);
// Sine wavetable
LookupTable sine(4096, 0.0f, 1.0f, [](float phase) {
return std::sin(phase * 2.0f * 3.14159265f);
});
LookupTableT< float > LookupTable
Definition lookup_table.hpp:105
@ sine
Definition lfo_sampling.hpp:54

Constructor & Destructor Documentation

◆ LookupTableT() [1/2]

template<typename SampleType = float>
pulp::signal::LookupTableT< SampleType >::LookupTableT ( )
default

◆ LookupTableT() [2/2]

template<typename SampleType = float>
pulp::signal::LookupTableT< SampleType >::LookupTableT ( int size,
SampleType min_input,
SampleType max_input,
std::function< SampleType(SampleType)> generator )
inline

Construct with a generator function.

Parameters
sizeNumber of table entries.
min_inputMinimum input value.
max_inputMaximum input value.
generatorFunction that maps input to output.

Member Function Documentation

◆ empty()

template<typename SampleType = float>
bool pulp::signal::LookupTableT< SampleType >::empty ( ) const
inline

◆ operator[]()

template<typename SampleType = float>
SampleType pulp::signal::LookupTableT< SampleType >::operator[] ( int index) const
inline

Direct table access (no interpolation).

◆ process() [1/2]

template<typename SampleType = float>
void pulp::signal::LookupTableT< SampleType >::process ( SampleType * data,
int num_samples ) const
inline

Process a buffer in-place.

◆ process() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::LookupTableT< SampleType >::process ( SampleType input) const
inline

Look up a value with linear interpolation.

◆ size()

template<typename SampleType = float>
int pulp::signal::LookupTableT< SampleType >::size ( ) const
inline

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