Skip to content

Class dft_resampler

class dft_resampler<T> dft

template <typename T>
class dft_resampler { … }

FFT-based sample-rate converter and FIR filter using overlap-save.

Performs power-of-two resampling (upsampling, downsampling, or filter-only when the factor is 1) of a real-valued signal. The lowpass anti-aliasing / anti-imaging filter is a Kaiser-windowed sinc designed from the requested stopband attenuation and transition width, pre-transformed into the frequency domain so that each frame only requires a forward real FFT, spectral shaping (gain multiplication and stopband zeroing, plus conjugate mirroring / truncation for up/downsampling), and an inverse real FFT.

Template parameters
T Sample type ( float or double ).

function kaiser_beta_from_attenuation(T)

static T kaiser_beta_from_attenuation(T att)

Computes the Kaiser window beta from a desired stopband attenuation.

Parameters
att Desired stopband attenuation in dB.
Returns
Kaiser beta parameter.

Fully qualified name: kfr::dft_resampler<T>::kaiser_beta_from_attenuation(T)

function input_block_size()

size_t input_block_size() const noexcept

Returns the input FFT block size \(N\) .

Fully qualified name: kfr::dft_resampler<T>::input_block_size()

function factor()

size_t factor() const noexcept

Returns the resampling factor (a power of two, >= 1).

Fully qualified name: kfr::dft_resampler<T>::factor()

function is_downsampling()

bool is_downsampling() const noexcept

Returns true if this resampler downsamples by factor() .

Fully qualified name: kfr::dft_resampler<T>::is_downsampling()

function filter_length()

size_t filter_length() const noexcept

Returns the designed filter length (in filter-rate samples).

Fully qualified name: kfr::dft_resampler<T>::filter_length()

function output_block_size()

size_t output_block_size() const noexcept

Returns the output FFT block size \(M\) .

Fully qualified name: kfr::dft_resampler<T>::output_block_size()

function input_hop()

size_t input_hop() const noexcept

Returns the number of new input samples consumed per frame.

Fully qualified name: kfr::dft_resampler<T>::input_hop()

function output_hop()

size_t output_hop() const noexcept

Returns the number of valid output samples produced per frame.

Fully qualified name: kfr::dft_resampler<T>::output_hop()

function reset()

void reset() noexcept

Resets the resampler to its freshly-constructed state, clearing all buffered input without changing filter parameters.

Fully qualified name: kfr::dft_resampler<T>::reset()

function compute_block_size(size_t, T, T)

static size_t compute_block_size(size_t upsample_factor, T stopband_atten_db, T transition_width)

Computes the minimal power-of-two block size required for the given filter parameters (Kaiser formula).

Parameters
upsample_factor The upsampling factor used in the transition-width scaling.
stopband_atten_db Desired stopband attenuation in dB.
transition_width Transition bandwidth normalised to the lower-rate Nyquist (0..1).
Returns
The computed block size (a power of two).

Fully qualified name: kfr::dft_resampler<T>::compute_block_size(size_t, T, T)

constructor dft_resampler<T>(const dft_resampler_params &)

explicit dft_resampler(const dft_resampler_params& params)

Constructs the resampler from the given parameters.

Parameters
params Resampler parameters.

Fully qualified name: kfr::dft_resampler<T>::dft_resampler<T>(const dft_resampler_params &)

function process_frame(const T *)

T* process_frame(const T* input)

Processes one frame in-place and returns a pointer to the valid output.

Parameters
input Pointer to input_block_size() input samples.
Returns
Pointer to output_hop() valid (un-normalised) output samples.

Fully qualified name: kfr::dft_resampler<T>::process_frame(const T *)

function process_frame(T *, const T *)

void process_frame(T* output, const T* input)

Processes one frame via overlap-save and writes normalised output.

Parameters
output Output buffer of at least output_hop() samples.
input Pointer to input_block_size() input samples.

Fully qualified name: kfr::dft_resampler<T>::process_frame(T *, const T *)

function process(std::span<T>, std::span<const T>)

size_t process(std::span<T> output, std::span<const T> input)

Processes an arbitrary-length input stream and writes the resampled output.

Parameters
output Output buffer. Must be large enough to hold all frames produced (a logic check is performed per frame).
input Input samples (any size).
Returns
Number of output samples actually written.

Fully qualified name: kfr::dft_resampler<T>::process(std::span<T>, std::span<const T>)

Fully qualified name: kfr::dft_resampler<T>

This file was generated by cxxdox, a C++ documentation generator based on MkDocs Material and libclang.