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. More...
#include <resample.h>
Public Member Functions | |
ArbitraryResample (int32 num_samples_in, BaseFloat samp_rate_hz, BaseFloat filter_cutoff_hz, const Vector< BaseFloat > &sample_points_secs, int32 num_zeros) | |
int32 | NumSamplesIn () const |
int32 | NumSamplesOut () const |
void | Resample (const MatrixBase< BaseFloat > &input, MatrixBase< BaseFloat > *output) const |
This function does the resampling. More... | |
void | Resample (const VectorBase< BaseFloat > &input, VectorBase< BaseFloat > *output) const |
This version of the Resample function processes just one vector. More... | |
Private Member Functions | |
void | SetIndexes (const Vector< BaseFloat > &sample_points) |
void | SetWeights (const Vector< BaseFloat > &sample_points) |
BaseFloat | FilterFunc (BaseFloat t) const |
Here, t is a time in seconds representing an offset from the center of the windowed filter function, and FilterFunction(t) returns the windowed filter function, described in the header as h(t) = f(t)g(t), evaluated at t. More... | |
Private Attributes | |
int32 | num_samples_in_ |
BaseFloat | samp_rate_in_ |
BaseFloat | filter_cutoff_ |
int32 | num_zeros_ |
std::vector< int32 > | first_index_ |
std::vector< Vector< BaseFloat > > | weights_ |
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.
Definition at line 95 of file resample.h.
ArbitraryResample | ( | int32 | num_samples_in, |
BaseFloat | samp_rate_hz, | ||
BaseFloat | filter_cutoff_hz, | ||
const Vector< BaseFloat > & | sample_points_secs, | ||
int32 | num_zeros | ||
) |
Definition at line 262 of file resample.cc.
References KALDI_ASSERT, ArbitraryResample::SetIndexes(), and ArbitraryResample::SetWeights().
Here, t is a time in seconds representing an offset from the center of the windowed filter function, and FilterFunction(t) returns the windowed filter function, described in the header as h(t) = f(t)g(t), evaluated at t.
Definition at line 353 of file resample.cc.
References ArbitraryResample::filter_cutoff_, M_2PI, M_PI, and ArbitraryResample::num_zeros_.
Referenced by LinearResample::GetOutputSamplingRate(), ArbitraryResample::NumSamplesOut(), and ArbitraryResample::SetWeights().
|
inline |
|
inline |
Definition at line 105 of file resample.h.
References ArbitraryResample::FilterFunc(), ArbitraryResample::Resample(), ArbitraryResample::SetIndexes(), ArbitraryResample::SetWeights(), and ArbitraryResample::weights_.
Referenced by ArbitraryResample::Resample(), and ArbitraryResample::SetWeights().
void Resample | ( | const MatrixBase< BaseFloat > & | input, |
MatrixBase< BaseFloat > * | output | ||
) | const |
This function does the resampling.
input.NumRows() and output.NumRows() should be equal and nonzero. input.NumCols() should equal NumSamplesIn() and output.NumCols() should equal NumSamplesOut().
Definition at line 280 of file resample.cc.
References MatrixBase< Real >::CopyColFromVec(), ArbitraryResample::first_index_, rnnlm::i, KALDI_ASSERT, kaldi::kNoTrans, ArbitraryResample::num_samples_in_, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), ArbitraryResample::NumSamplesOut(), and ArbitraryResample::weights_.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), ArbitraryResample::NumSamplesOut(), UnitTestArbitraryResample(), and UnitTestLinearResample().
void Resample | ( | const VectorBase< BaseFloat > & | input, |
VectorBase< BaseFloat > * | output | ||
) | const |
This version of the Resample function processes just one vector.
Definition at line 301 of file resample.cc.
References VectorBase< Real >::Dim(), ArbitraryResample::first_index_, rnnlm::i, KALDI_ASSERT, ArbitraryResample::num_samples_in_, kaldi::VecVec(), and ArbitraryResample::weights_.
Definition at line 313 of file resample.cc.
References VectorBase< Real >::Dim(), ArbitraryResample::filter_cutoff_, ArbitraryResample::first_index_, rnnlm::i, ArbitraryResample::num_samples_in_, ArbitraryResample::num_zeros_, ArbitraryResample::samp_rate_in_, and ArbitraryResample::weights_.
Referenced by ArbitraryResample::ArbitraryResample(), and ArbitraryResample::NumSamplesOut().
Definition at line 335 of file resample.cc.
References ArbitraryResample::FilterFunc(), ArbitraryResample::first_index_, rnnlm::i, rnnlm::j, ArbitraryResample::NumSamplesOut(), ArbitraryResample::samp_rate_in_, and ArbitraryResample::weights_.
Referenced by ArbitraryResample::ArbitraryResample(), and ArbitraryResample::NumSamplesOut().
|
private |
Definition at line 128 of file resample.h.
Referenced by ArbitraryResample::FilterFunc(), and ArbitraryResample::SetIndexes().
|
private |
Definition at line 131 of file resample.h.
Referenced by ArbitraryResample::Resample(), ArbitraryResample::SetIndexes(), and ArbitraryResample::SetWeights().
|
private |
Definition at line 126 of file resample.h.
Referenced by ArbitraryResample::NumSamplesIn(), ArbitraryResample::Resample(), and ArbitraryResample::SetIndexes().
|
private |
Definition at line 129 of file resample.h.
Referenced by ArbitraryResample::FilterFunc(), and ArbitraryResample::SetIndexes().
|
private |
Definition at line 127 of file resample.h.
Referenced by LinearResample::GetInputSamplingRate(), ArbitraryResample::SetIndexes(), and ArbitraryResample::SetWeights().
Definition at line 133 of file resample.h.
Referenced by ArbitraryResample::NumSamplesOut(), ArbitraryResample::Resample(), ArbitraryResample::SetIndexes(), and ArbitraryResample::SetWeights().