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