4 #ifndef SP_RESAMPLING_H 5 #define SP_RESAMPLING_H 20 template <
class T1> arma::Col<T1>
upsample(
const arma::Col<T1> &x,
const int p)
22 long int N = x.size();
26 for (
long int n = 0; n < N; n++)
38 arma::Col<T1>
downsample(
const arma::Col<T1> &x,
const int q)
41 int N = int(floor(1.0 * x.size() / q));
43 for (
long int n = 0; n < N; n++)
69 resampling(
const arma::uword _P,
const arma::uword _Q,
const arma::vec _H)
88 arma::uword M = (P >
Q) ? P : Q;
89 H =
fir1(8 * M, 1.0f / M);
105 void downfir(
const arma::Col<T1> &in, arma::Col<T1> &out)
107 arma::uword sz = in.n_elem;
108 for (arma::uword n = 0; n < sz; n++)
122 void upfir(
const arma::Col<T1> &in, arma::Col<T1> &out)
124 arma::uword sz = P * in.n_elem;
125 for (arma::uword n = 0; n < sz; n++)
128 out[n] = P *
aa_filt(in[n / P]);
142 void upfirdown(
const arma::Col<T1> &in, arma::Col<T1> &out)
144 arma::uword sz = P * in.n_elem;
146 for (arma::uword n = 0; n < sz; n++)
153 out[n /
Q] = P * tmp;
resampling(const arma::uword _P, const arma::uword _Q, const arma::vec _H)
Constructor.
arma::vec K
Number of filter coefficients.
void downfir(const arma::Col< T1 > &in, arma::Col< T1 > &out)
Downsampling with anti alias filter.
void upfirdown(const arma::Col< T1 > &in, arma::Col< T1 > &out)
Resampling by a rational P/Q with anti alias filtering.
arma::Col< T1 > upsample(const arma::Col< T1 > &x, const int p)
Upsampling without anti alias filtering.
arma::uword P
Upsampling rate.
arma_inline arma::vec fir1(const arma::uword M, const double f0)
FIR lowpass design function. FIR lowpassdesign using windows method (hamming window). NB! Returns size M+1.
arma::vec H
Filter coefficients.
void upfir(const arma::Col< T1 > &in, arma::Col< T1 > &out)
Upsampling with anti alias filter.
void set_coeffs(const arma::Mat< T2 > &_b)
Sets coefficients in FIR filter. The internal state and pointers are cleared.
FIR_filt< T1, double, T1 > aa_filt
arma::uword Q
Downsampling rate.
resampling(const arma::uword _P, const arma::uword _Q)
Constructor using a fir1 filter with 8*M+1 taps and cutoff 1/M where M=max(P,Q)
arma::Col< T1 > downsample(const arma::Col< T1 > &x, const int q)
Downsampling without anti alias filtering.