GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
rational_resampler_base.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 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef RATIONAL_RESAMPLER_BASE_H
24#define RATIONAL_RESAMPLER_BASE_H
25
26#include <gnuradio/block.h>
27#include <gnuradio/filter/api.h>
28
29
30namespace gr {
31namespace filter {
32
33/*!
34 * \brief Rational Resampling Polyphase FIR filter with IN_T
35 * input, OUT_T output and TAP_T taps.
36 * \ingroup resamplers_blk
37 *
38 * Make a rational resampling FIR filter. If the input signal is
39 * at rate fs, then the output signal will be at a rate of \p
40 * interpolation * fs / \p decimation.
41 *
42 * The interpolation and decimation rates should be kept as
43 * small as possible, and generally should be relatively prime
44 * to help reduce complexity in memory and computation.
45 *
46 * The set of \p taps supplied to this filterbank should be
47 * designed around the resampling amount and must avoid aliasing
48 * (when interpolation/decimation < 1) and images (when
49 * interpolation/decimation > 1).
50 *
51 * As with any filter, the behavior of the filter taps (or
52 * coefficients) is determined by the highest sampling rate that
53 * the filter will ever see. In the case of a resampler that
54 * increases the sampling rate, the highest sampling rate observed
55 * is \p interpolation since in the filterbank, the number of
56 * filter arms is equal to \p interpolation. When the resampler
57 * decreases the sampling rate (decimation > interpolation), then
58 * the highest rate is the input sample rate of the original
59 * signal. We must create a filter based around this value to
60 * reduce any aliasing that may occur from out-of-band signals.
61 *
62 * Another way to think about how to create the filter taps is
63 * that the filter is effectively applied after interpolation and
64 * before decimation. And yet another way to think of it is that
65 * the taps should be a LPF that is at least as narrow as the
66 * narrower of the required anti-image postfilter or anti-alias
67 * prefilter.
68 */
69template <class IN_T, class OUT_T, class TAP_T>
71{
72public:
73 typedef boost::shared_ptr<rational_resampler_base<IN_T, OUT_T, TAP_T>> sptr;
74
75 /*!
76 * Make a rational resampling FIR filter.
77 *
78 * \param interpolation The integer interpolation rate of the filter
79 * \param decimation The integer decimation rate of the filter
80 * \param taps The filter taps to control images and aliases
81 */
82 static sptr
83 make(unsigned interpolation, unsigned decimation, const std::vector<TAP_T>& taps);
84
85 virtual unsigned interpolation() const = 0;
86 virtual unsigned decimation() const = 0;
87
88 virtual void set_taps(const std::vector<TAP_T>& taps) = 0;
89 virtual std::vector<TAP_T> taps() const = 0;
90};
101
102} /* namespace filter */
103} /* namespace gr */
104
105#endif /* RATIONAL_RESAMPLER_BASE_H */
The abstract base class for all 'terminal' processing blocks.
Definition block.h:72
Rational Resampling Polyphase FIR filter with IN_T input, OUT_T output and TAP_T taps.
Definition rational_resampler_base.h:71
virtual unsigned interpolation() const =0
virtual unsigned decimation() const =0
virtual std::vector< TAP_T > taps() const =0
static sptr make(unsigned interpolation, unsigned decimation, const std::vector< TAP_T > &taps)
virtual void set_taps(const std::vector< TAP_T > &taps)=0
boost::shared_ptr< rational_resampler_base< IN_T, OUT_T, TAP_T > > sptr
Definition rational_resampler_base.h:73
#define FILTER_API
Definition gr-filter/include/gnuradio/filter/api.h:30
static const float taps[NSTEPS+1][NTAPS]
Definition interpolator_taps.h:9
rational_resampler_base< std::int16_t, gr_complex, gr_complex > rational_resampler_base_scc
Definition rational_resampler_base.h:100
rational_resampler_base< float, float, float > rational_resampler_base_fff
Definition rational_resampler_base.h:97
rational_resampler_base< gr_complex, gr_complex, float > rational_resampler_base_ccf
Definition rational_resampler_base.h:94
rational_resampler_base< float, std::int16_t, float > rational_resampler_base_fsf
Definition rational_resampler_base.h:98
rational_resampler_base< gr_complex, gr_complex, gr_complex > rational_resampler_base_ccc
Definition rational_resampler_base.h:92
rational_resampler_base< float, gr_complex, gr_complex > rational_resampler_base_fcc
Definition rational_resampler_base.h:96
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46