kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
knf::ArbitraryResample Class Reference

Resample a signal at arbitrary (e.g. More...

#include <resample.h>

Public Member Functions

 ArbitraryResample (int32_t num_samples_in, float samp_rate_hz, float filter_cutoff_hz, const std::vector< float > &sample_points_secs, int32_t num_zeros)
 Construct the resampler.
int32_t NumSamplesIn () const
 Return the number of samples in each input signal.
int32_t NumSamplesOut () const
 Return the number of samples in each resampled output signal (equals the sample_points_secs size given to the constructor).
void Resample (const MatrixF &input, MatrixF *output) const
 Resample a batch of signals (one per row).
void Resample (const VectorF &input, VectorF *output) const
 Resample a single signal.

Detailed Description

Resample a signal at arbitrary (e.g.

log-spaced) time points.

Class ArbitraryResample allows you to resample a signal (assumed zero outside the sample region, not periodic) at arbitrary specified time values, which don't have to be linearly spaced. The low-pass filter cutoff filter_cutoff_hz should be less than half the sample rate; num_zeros should probably be at least two preferably more; higher numbers give sharper filters but will be less efficient.

Used by:
OnlinePitch resamples the NCCF from evenly spaced lags to the log-spaced lags at which pitch is measured.
See also
LinearResample

Constructor & Destructor Documentation

◆ ArbitraryResample()

knf::ArbitraryResample::ArbitraryResample ( int32_t num_samples_in,
float samp_rate_hz,
float filter_cutoff_hz,
const std::vector< float > & sample_points_secs,
int32_t num_zeros )

Construct the resampler.

Parameters
[in]num_samples_inNumber of samples in each input signal (must be > 0).
[in]samp_rate_hzSample rate of the input signal in Hz (must be > 0).
[in]filter_cutoff_hzLow-pass filter cutoff in Hz; must be > 0 and at most half of samp_rate_hz.
[in]sample_points_secsThe time points (in seconds) at which to evaluate the resampled signal; one output sample is produced per element.
[in]num_zerosFilter sharpness: the raised-cosine window spans num_zeros zeros of the sinc filter (must be > 0; 2..10 recommended).

Member Function Documentation

◆ NumSamplesIn()

int32_t knf::ArbitraryResample::NumSamplesIn ( ) const
inline

Return the number of samples in each input signal.

◆ NumSamplesOut()

int32_t knf::ArbitraryResample::NumSamplesOut ( ) const
inline

Return the number of samples in each resampled output signal (equals the sample_points_secs size given to the constructor).

◆ Resample() [1/2]

void knf::ArbitraryResample::Resample ( const MatrixF & input,
MatrixF * output ) const

Resample a batch of signals (one per row).

Parameters
[in]inputMatrix of shape (num_rows, NumSamplesIn()); each row is one input signal.
[out]outputMatrix of shape (num_rows, NumSamplesOut()); must already be resized to that shape. Each row is the resampled version of the corresponding input row.

◆ Resample() [2/2]

void knf::ArbitraryResample::Resample ( const VectorF & input,
VectorF * output ) const

Resample a single signal.

Parameters
[in]inputVector of size NumSamplesIn().
[out]outputVector of size NumSamplesOut(); must already be resized to that shape.

The documentation for this class was generated from the following file:
  • /home/runner/work/kaldi-native-fbank/kaldi-native-fbank/kaldi-native-fbank/csrc/resample.h