GNU Radio Manual and C++ API Reference 3.10.5.1
The Free & Open Software Radio Ecosystem
rational_resampler.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2005,2012,2018 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef RATIONAL_RESAMPLER_H
12#define RATIONAL_RESAMPLER_H
13
14#include <gnuradio/block.h>
15#include <gnuradio/filter/api.h>
16
17
18namespace gr {
19namespace filter {
20
21/*!
22 * \brief Rational Resampling Polyphase FIR filter with IN_T
23 * input, OUT_T output and TAP_T taps.
24 * \ingroup resamplers_blk
25 *
26 * Make a rational resampling FIR filter. If the input signal is
27 * at rate fs, then the output signal will be at a rate of \p
28 * interpolation * fs / \p decimation.
29 *
30 * The interpolation and decimation rates should be kept as
31 * small as possible, and generally should be relatively prime
32 * to help reduce complexity in memory and computation.
33 *
34 * The set of \p taps supplied to this filterbank should be
35 * designed around the resampling amount and must avoid aliasing
36 * (when interpolation/decimation < 1) and images (when
37 * interpolation/decimation > 1).
38 *
39 * As with any filter, the behavior of the filter taps (or
40 * coefficients) is determined by the highest sampling rate that
41 * the filter will ever see. In the case of a resampler that
42 * increases the sampling rate, the highest sampling rate observed
43 * is \p interpolation since in the filterbank, the number of
44 * filter arms is equal to \p interpolation. When the resampler
45 * decreases the sampling rate (decimation > interpolation), then
46 * the highest rate is the input sample rate of the original
47 * signal. We must create a filter based around this value to
48 * reduce any aliasing that may occur from out-of-band signals.
49 *
50 * Another way to think about how to create the filter taps is
51 * that the filter is effectively applied after interpolation and
52 * before decimation. And yet another way to think of it is that
53 * the taps should be a LPF that is at least as narrow as the
54 * narrower of the required anti-image postfilter or anti-alias
55 * prefilter.
56 */
57template <class IN_T, class OUT_T, class TAP_T>
58class FILTER_API rational_resampler : virtual public block
59{
60public:
61 typedef std::shared_ptr<rational_resampler<IN_T, OUT_T, TAP_T>> sptr;
62
63 /*!
64 * Make a rational resampling FIR filter.
65 *
66 * \param interpolation The integer interpolation rate of the filter
67 * \param decimation The integer decimation rate of the filter
68 * \param taps The filter taps to control images and aliases
69 * \param fractional_bw The fractional bandwidth of the filter (0 to 0.5)
70 */
71 static sptr make(unsigned interpolation,
72 unsigned decimation,
73 const std::vector<TAP_T>& taps = std::vector<TAP_T>(),
74 float fractional_bw = 0.0);
75
76 virtual unsigned interpolation() const = 0;
77 virtual unsigned decimation() const = 0;
78
79 virtual void set_taps(const std::vector<TAP_T>& taps) = 0;
80 virtual std::vector<TAP_T> taps() const = 0;
81};
88
89} /* namespace filter */
90} /* namespace gr */
91
92#endif /* RATIONAL_RESAMPLER_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Rational Resampling Polyphase FIR filter with IN_T input, OUT_T output and TAP_T taps.
Definition: rational_resampler.h:59
std::shared_ptr< rational_resampler< IN_T, OUT_T, TAP_T > > sptr
Definition: rational_resampler.h:61
virtual void set_taps(const std::vector< TAP_T > &taps)=0
virtual std::vector< TAP_T > taps() const =0
virtual unsigned interpolation() const =0
virtual unsigned decimation() const =0
static sptr make(unsigned interpolation, unsigned decimation, const std::vector< TAP_T > &taps=std::vector< TAP_T >(), float fractional_bw=0.0)
#define FILTER_API
Definition: gr-filter/include/gnuradio/filter/api.h:18
static constexpr float taps[NSTEPS+1][NTAPS]
Definition: interpolator_taps.h:9
rational_resampler< gr_complex, gr_complex, gr_complex > rational_resampler_ccc
Definition: rational_resampler.h:82
rational_resampler< float, gr_complex, gr_complex > rational_resampler_fcc
Definition: rational_resampler.h:84
rational_resampler< float, float, float > rational_resampler_fff
Definition: rational_resampler.h:85
rational_resampler< float, std::int16_t, float > rational_resampler_fsf
Definition: rational_resampler.h:86
rational_resampler< std::int16_t, gr_complex, gr_complex > rational_resampler_scc
Definition: rational_resampler.h:87
rational_resampler< gr_complex, gr_complex, float > rational_resampler_ccf
Definition: rational_resampler.h:83
GNU Radio logging wrapper.
Definition: basic_block.h:29