CoreMath::SincInterpolator
CoreMath::SincInterpolator
Reusable numerical class for band-limited Whittaker-Shannon sinc interpolation.
#include <sinc_interpolation.hpp>
Public Functions
| Name | |
|---|---|
| double | sinc(double t) Normalized sinc function: sinc(t) = sin(pit) / (pit), sinc(0) = 1. |
| double | window(double t, int a, SincWindowType window_type) Evaluate window function at offset t for kernel half-width a. |
| float | fetchSample(std::span< float const > data, int64_t index, BoundaryMode mode) Fetch sample with boundary handling. |
| float | interpolateAt(std::span< float const > data, double fractional_index, int kernel_half_width =8, SincWindowType window_type =SincWindowType::Lanczos, BoundaryMode mode =BoundaryMode::SymmetricExtension) Interpolate discrete signal at an arbitrary continuous fractional index. |
| std::vector< float > | upsample(std::span< float const > data, int upsampling_factor, int kernel_half_width =8, SincWindowType window_type =SincWindowType::Lanczos, BoundaryMode mode =BoundaryMode::SymmetricExtension) Upsample discrete signal by an integer factor U. |
| std::vector< float > | shift(std::span< float const > data, double fractional_shift, int kernel_half_width =8, SincWindowType window_type =SincWindowType::Hann, BoundaryMode mode =BoundaryMode::SymmetricExtension) Shift discrete signal by a continuous fractional sample offset. |
| std::pair< double, float > | findSubSampleExtremum(std::span< float const > data, int center_index, bool find_minimum =true, int search_radius =2, int sub_divisions =16, int kernel_half_width =8, SincWindowType window_type =SincWindowType::Hann, BoundaryMode mode =BoundaryMode::SymmetricExtension) Find sub-sample continuous extremum (peak or trough) with sub-sample precision. |
| double | findSubSampleEnergyCentroid(std::span< float const > data, int center_index, int window_half_width =6, int sub_divisions =16, int kernel_half_width =8, SincWindowType window_type =SincWindowType::Hann, BoundaryMode mode =BoundaryMode::SymmetricExtension) Compute continuous sub-sample V^2 energy centroid. |
Public Functions Documentation
function sinc
static double sinc(
double t
)Normalized sinc function: sinc(t) = sin(pit) / (pit), sinc(0) = 1.
function window
static double window(
double t,
int a,
SincWindowType window_type
)Evaluate window function at offset t for kernel half-width a.
function fetchSample
static float fetchSample(
std::span< float const > data,
int64_t index,
BoundaryMode mode
)Fetch sample with boundary handling.
function interpolateAt
static float interpolateAt(
std::span< float const > data,
double fractional_index,
int kernel_half_width =8,
SincWindowType window_type =SincWindowType::Lanczos,
BoundaryMode mode =BoundaryMode::SymmetricExtension
)Interpolate discrete signal at an arbitrary continuous fractional index.
Parameters:
- data Discrete input sample buffer
- fractional_index Real-valued continuous sample position x
- kernel_half_width Half-width of sinc kernel (default: 8)
- window_type Window function (default: Lanczos)
- mode Boundary handling mode (default: SymmetricExtension)
Return: Interpolated continuous voltage value
Precondition:
- !data.empty()
- kernel_half_width >= 1
function upsample
static std::vector< float > upsample(
std::span< float const > data,
int upsampling_factor,
int kernel_half_width =8,
SincWindowType window_type =SincWindowType::Lanczos,
BoundaryMode mode =BoundaryMode::SymmetricExtension
)Upsample discrete signal by an integer factor U.
Parameters:
- data Discrete input buffer
- upsampling_factor Integer upsampling factor
- kernel_half_width Sinc kernel half-width (default: 8)
- window_type Window function (default: Lanczos)
- mode Boundary handling mode (default: SymmetricExtension)
Return: Vector of upsampled samples
Precondition:
- !data.empty()
- upsampling_factor >= 1
- kernel_half_width >= 1
Produces an output buffer of (N - 1) * U + 1 samples.
function shift
static std::vector< float > shift(
std::span< float const > data,
double fractional_shift,
int kernel_half_width =8,
SincWindowType window_type =SincWindowType::Hann,
BoundaryMode mode =BoundaryMode::SymmetricExtension
)Shift discrete signal by a continuous fractional sample offset.
Parameters:
- data Input sample buffer
- fractional_shift Continuous shift offset in samples
- kernel_half_width Sinc kernel half-width (default: 8)
- window_type Window function (default: Hann)
- mode Boundary handling mode (default: SymmetricExtension)
Return: Vector of shifted samples (same size as input)
Precondition:
- !data.empty()
- kernel_half_width >= 1
For each index i, evaluates signal at continuous position (i - fractional_shift).
function findSubSampleExtremum
static std::pair< double, float > findSubSampleExtremum(
std::span< float const > data,
int center_index,
bool find_minimum =true,
int search_radius =2,
int sub_divisions =16,
int kernel_half_width =8,
SincWindowType window_type =SincWindowType::Hann,
BoundaryMode mode =BoundaryMode::SymmetricExtension
)Find sub-sample continuous extremum (peak or trough) with sub-sample precision.
Parameters:
- data Input sample buffer
- center_index Discrete candidate index
- find_minimum True to find trough, false to find peak
- search_radius Discrete search radius around center_index (default: 2)
- sub_divisions Sub-sample evaluation steps per sample (default: 16)
- kernel_half_width Sinc kernel half-width (default: 8)
- window_type Window function (default: Hann)
- mode Boundary handling mode (default: SymmetricExtension)
Return: Pair of {continuous_sample_position, extremum_value}
Precondition:
- !data.empty()
- center_index >= 0 && center_index < data.size()
Performs fine sub-sample search using sinc evaluation around discrete extremum.
function findSubSampleEnergyCentroid
static double findSubSampleEnergyCentroid(
std::span< float const > data,
int center_index,
int window_half_width =6,
int sub_divisions =16,
int kernel_half_width =8,
SincWindowType window_type =SincWindowType::Hann,
BoundaryMode mode =BoundaryMode::SymmetricExtension
)Compute continuous sub-sample V^2 energy centroid.
Parameters:
- data Input sample buffer
- center_index Discrete candidate index
- window_half_width Window half-width in samples (default: 6)
- sub_divisions Sub-sample evaluation steps per sample (default: 16)
- kernel_half_width Sinc kernel half-width (default: 8)
- window_type Window function (default: Hann)
- mode Boundary handling mode (default: SymmetricExtension)
Return: Continuous sample position of energy centroid
Precondition:
- !data.empty()
- center_index >= 0 && center_index < data.size()
Evaluates continuous V^2 distribution over window to compute sub-sample centroid.
Updated on 2026-11-13 at 20:25:42 +0000