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.
| 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.
| att | Desired stopband attenuation in dB. |
| Kaiser beta parameter. |
Fully qualified name: kfr::dft_resampler<T>::kaiser_beta_from_attenuation(T)
Declared at dft/dft_resampler.hpp:153
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()
Declared at dft/dft_resampler.hpp:163
function factor() ¶
size_t factor() const noexcept Returns the resampling factor (a power of two, >= 1).
Fully qualified name: kfr::dft_resampler<T>::factor()
Declared at dft/dft_resampler.hpp:165
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()
Declared at dft/dft_resampler.hpp:167
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()
Declared at dft/dft_resampler.hpp:169
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()
Declared at dft/dft_resampler.hpp:171
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()
Declared at dft/dft_resampler.hpp:173
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()
Declared at dft/dft_resampler.hpp:175
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()
Declared at dft/dft_resampler.hpp:181
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).
| 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). |
| The computed block size (a power of two). |
Fully qualified name: kfr::dft_resampler<T>::compute_block_size(size_t, T, T)
Declared at dft/dft_resampler.hpp:196
constructor dft_resampler<T>(const dft_resampler_params &) ¶
explicit dft_resampler(const dft_resampler_params& params) Constructs the resampler from the given parameters.
| params | Resampler parameters. |
Fully qualified name: kfr::dft_resampler<T>::dft_resampler<T>(const dft_resampler_params &)
Declared at dft/dft_resampler.hpp:218
function process_frame(const T *) ¶
T* process_frame(const T* input) Processes one frame in-place and returns a pointer to the valid output.
| input | Pointer to input_block_size() input samples. |
Pointer to output_hop() valid (un-normalised) output samples. |
Fully qualified name: kfr::dft_resampler<T>::process_frame(const T *)
Declared at dft/dft_resampler.hpp:377
function process_frame(T *, const T *) ¶
void process_frame(T* output, const T* input) Processes one frame via overlap-save and writes normalised output.
| 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 *)
Declared at dft/dft_resampler.hpp:438
function process(std::span<T>, std::span<const T>) ¶
Processes an arbitrary-length input stream and writes the resampled output.
| output | Output buffer. Must be large enough to hold all frames produced (a logic check is performed per frame). |
| input | Input samples (any size). |
| Number of output samples actually written. |
Fully qualified name: kfr::dft_resampler<T>::process(std::span<T>, std::span<const T>)
Declared at dft/dft_resampler.hpp:458
Fully qualified name: kfr::dft_resampler<T>
Declared at dft/dft_resampler.hpp:120