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

#include <resampler.hpp>

Public Member Functions

 ResamplerT ()=default
void prepare (double input_rate, double output_rate, std::size_t channels, std::size_t max_block_size, ResamplerQuality quality={})
 Configure the conversion.
void set_ratio (double input_rate, double output_rate)
 Update the streaming ratio without rebuilding the filter.
void reset ()
 Zero the delay lines + phase accumulator.
ResamplerProcessResult process_block_detailed (const SampleType *const *input, std::size_t in_count, SampleType *const *output, std::size_t out_capacity)
 Block API.
std::size_t process_block (const SampleType *const *input, std::size_t in_count, SampleType *const *output, std::size_t out_capacity)
ResamplerProcessResult process_block_mono_detailed (const SampleType *input, std::size_t in_count, SampleType *output, std::size_t out_capacity)
std::size_t process_block_mono (const SampleType *input, std::size_t in_count, SampleType *output, std::size_t out_capacity)
 Mono convenience wrapper around process_block.
std::size_t max_output_for (std::size_t in_count) const
 Worst-case output sample count for a given input count.
std::size_t taps_per_phase () const
 Per-phase filter length.
std::size_t phases () const
 Number of polyphase branches (L).
std::size_t prototype_length () const
 Total prototype length (= phases * taps_per_phase).
double input_rate () const
double output_rate () const
std::size_t channels () const

Constructor & Destructor Documentation

◆ ResamplerT()

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

Member Function Documentation

◆ channels()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::channels ( ) const
inline

◆ input_rate()

template<typename SampleType = float>
double pulp::signal::ResamplerT< SampleType >::input_rate ( ) const
inline

◆ max_output_for()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::max_output_for ( std::size_t in_count) const
inline

Worst-case output sample count for a given input count.

Includes a small margin for phase-accumulator state carry-over across blocks so callers can safely size output buffers from this value.

◆ output_rate()

template<typename SampleType = float>
double pulp::signal::ResamplerT< SampleType >::output_rate ( ) const
inline

◆ phases()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::phases ( ) const
inline

Number of polyphase branches (L).

◆ prepare()

template<typename SampleType = float>
void pulp::signal::ResamplerT< SampleType >::prepare ( double input_rate,
double output_rate,
std::size_t channels,
std::size_t max_block_size,
ResamplerQuality quality = {} )
inline

Configure the conversion.

input_rate and output_rate may be any positive values; the polyphase table is designed once at prepare(), and set_ratio() may be called later to nudge the streaming ratio without re-designing the filter.

max_block_size is used to pre-size the per-channel scratch vector used by process_block() so the audio thread does not allocate. Pass the worst-case host block size; an input block of that many samples may produce up to ceil(max_block * ratio) + 1 output samples. RT contract: prepare() allocates filter tables, delay lines, and scratch storage and is not audio-thread safe. After prepare(), set_ratio(), reset(), process_block*(), max_output_for(), and accessors are allocation-free for caller-provided input/output buffers.

◆ process_block()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::process_block ( const SampleType *const * input,
std::size_t in_count,
SampleType *const * output,
std::size_t out_capacity )
inline

◆ process_block_detailed()

template<typename SampleType = float>
ResamplerProcessResult pulp::signal::ResamplerT< SampleType >::process_block_detailed ( const SampleType *const * input,
std::size_t in_count,
SampleType *const * output,
std::size_t out_capacity )
inline

Block API.

Reads in_count samples from input[c] per channel and writes up to out_capacity resampled samples to output[c]. Returns the actual number of output samples produced.

Allocation-free after prepare().

◆ process_block_mono()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::process_block_mono ( const SampleType * input,
std::size_t in_count,
SampleType * output,
std::size_t out_capacity )
inline

Mono convenience wrapper around process_block.

◆ process_block_mono_detailed()

template<typename SampleType = float>
ResamplerProcessResult pulp::signal::ResamplerT< SampleType >::process_block_mono_detailed ( const SampleType * input,
std::size_t in_count,
SampleType * output,
std::size_t out_capacity )
inline

◆ prototype_length()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::prototype_length ( ) const
inline

Total prototype length (= phases * taps_per_phase).

Useful for reasoning about latency: group delay is roughly (N-1)/2 samples at the polyphase rate, i.e. (taps_per_phase - 1) / 2 at the input rate.

◆ reset()

template<typename SampleType = float>
void pulp::signal::ResamplerT< SampleType >::reset ( )
inline

Zero the delay lines + phase accumulator.

Not RT-safe to call concurrently with process_* — call from the audio thread between blocks, or while bypassed.

◆ set_ratio()

template<typename SampleType = float>
void pulp::signal::ResamplerT< SampleType >::set_ratio ( double input_rate,
double output_rate )
inline

Update the streaming ratio without rebuilding the filter.

Preserves the delay line + phase accumulator so audio continues without a click beyond a one-filter-span transition window.

◆ taps_per_phase()

template<typename SampleType = float>
std::size_t pulp::signal::ResamplerT< SampleType >::taps_per_phase ( ) const
inline

Per-phase filter length.

Useful for tests verifying the polyphase decomposition was rectangular.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/signal/include/pulp/signal/resampler.hpp