GNU Radio 3.6.3.1 C++ API
pfb_decimator_ccf.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009,2012 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 
24 #ifndef INCLUDED_PFB_DECIMATOR_CCF_H
25 #define INCLUDED_PFB_DECIMATOR_CCF_H
26 
27 #include <filter/api.h>
28 #include <gr_sync_block.h>
29 
30 namespace gr {
31  namespace filter {
32 
33  /*!
34  * \class pfb_decimator_ccf
35  * \brief Polyphase filterbank bandpass decimator with gr_complex
36  * input, gr_complex output and float taps
37  *
38  * \ingroup filter_blk
39  * \ingroup pfb_blk
40  *
41  * This block takes in a signal stream and performs interger down-
42  * sampling (decimation) with a polyphase filterbank. The first
43  * input is the integer specifying how much to decimate by. The
44  * second input is a vector (Python list) of floating-point taps
45  * of the prototype filter. The third input specifies the channel
46  * to extract. By default, the zeroth channel is used, which is
47  * the baseband channel (first Nyquist zone).
48  *
49  * The <EM>channel</EM> parameter specifies which channel to use
50  * since this class is capable of bandpass decimation. Given a
51  * complex input stream at a sampling rate of <EM>fs</EM> and a
52  * decimation rate of <EM>decim</EM>, the input frequency domain
53  * is split into <EM>decim</EM> channels that represent the
54  * Nyquist zones. Using the polyphase filterbank, we can select
55  * any one of these channels to decimate.
56  *
57  * The output signal will be the basebanded and decimated signal
58  * from that channel. This concept is very similar to the PFB
59  * channelizer (see #gr_pfb_channelizer_ccf) where only a single
60  * channel is extracted at a time.
61  *
62  * The filter's taps should be based on the sampling rate before
63  * decimation.
64  *
65  * For example, using the GNU Radio's firdes utility to building
66  * filters, we build a low-pass filter with a sampling rate of
67  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
68  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
69  * attenuation to use, <EM>ATT</EM>, and the filter window
70  * function (a Blackman-harris window in this case). The first
71  * input is the gain of the filter, which we specify here as
72  * unity.
73  *
74  * <B><EM>self._taps = filter.firdes.low_pass_2(1, fs, BW, TB,
75  * attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
76  *
77  * The PFB decimator code takes the taps generated above and
78  * builds a set of filters. The set contains <EM>decim</EM> number
79  * of filters and each filter contains ceil(taps.size()/decim)
80  * number of taps. Each tap from the filter prototype is
81  * sequentially inserted into the next filter. When all of the
82  * input taps are used, the remaining filters in the filterbank
83  * are filled out with 0's to make sure each filter has the same
84  * number of taps.
85  *
86  * The theory behind this block can be found in Chapter 6 of
87  * the following book.
88  *
89  * <B><EM>f. harris, "Multirate Signal Processing for Communication
90  * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
91  */
92 
94  {
95  public:
96  // gr::filter::pfb_decimator_ccf::sptr
98 
99  /*!
100  * Build the polyphase filterbank decimator.
101  * \param decim (unsigned integer) Specifies the decimation rate to use
102  * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
103  * \param channel (unsigned integer) Selects the channel to return [default=0].
104  */
105  static sptr make(unsigned int decim,
106  const std::vector<float> &taps,
107  unsigned int channel);
108 
109  /*!
110  * Resets the filterbank's filter taps with the new prototype filter
111  * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
112  */
113  virtual void set_taps(const std::vector<float> &taps) = 0;
114 
115  /*!
116  * Return a vector<vector<>> of the filterbank taps
117  */
118  virtual std::vector<std::vector<float> > taps() const = 0;
119 
120  /*!
121  * Print all of the filterbank taps to screen.
122  */
123  virtual void print_taps() = 0;
124 
125  //virtual void set_channel(unsigned int channel) = 0;
126  };
127 
128  } /* namespace filter */
129 } /* namespace gr */
130 
131 #endif /* INCLUDED_PFB_DECIMATOR_CCF_H */