GNU Radio 3.6.5.1 C++ API
gr_pfb_interpolator_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_INTERPOLATOR_CCF_H
25 #define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H
26 
27 #include <gr_core_api.h>
28 #include <gr_sync_interpolator.h>
29 
33  const std::vector<float> &taps);
34 
35 class gr_fir_ccf;
36 
37 /*!
38  * \brief Polyphase filterbank interpolator with gr_complex input,
39  * gr_complex output and float taps
40  *
41  * This block takes in a signal stream and performs interger up-
42  * sampling (interpolation) with a polyphase filterbank. The first
43  * input is the integer specifying how much to interpolate by. The
44  * second input is a vector (Python list) of floating-point taps of
45  * the prototype filter.
46  *
47  * The filter's taps should be based on the interpolation rate
48  * specified. That is, the bandwidth specified is relative to the
49  * bandwidth after interpolation.
50  *
51  * For example, using the GNU Radio's firdes utility to building
52  * filters, we build a low-pass filter with a sampling rate of
53  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
54  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
55  * attenuation to use, ATT, and the filter window function (a
56  * Blackman-harris window in this case). The first input is the gain,
57  * which is also specified as the interpolation rate so that the
58  * output levels are the same as the input (this creates an overall
59  * increase in power).
60  *
61  * <B><EM>self._taps = gr.firdes.low_pass_2(interp, interp*fs, BW, TB,
62  * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
63  *
64  * The PFB interpolator code takes the taps generated above and builds
65  * a set of filters. The set contains <EM>interp</EM> number of
66  * filters and each filter contains ceil(taps.size()/interp) number of
67  * taps. Each tap from the filter prototype is sequentially inserted
68  * into the next filter. When all of the input taps are used, the
69  * remaining filters in the filterbank are filled out with 0's to make
70  * sure each filter has the same number of taps.
71  *
72  * The theory behind this block can be found in Chapter 7.1 of the
73  * following book.
74  *
75  * <B><EM>f. harris, "Multirate Signal Processing for Communication
76  * Systems</EM>," Upper Saddle River, NJ: Prentice Hall,
77  * Inc. 2004.</EM></B>
78  */
79 
81 {
82  private:
83  /*!
84  * Build the polyphase filterbank interpolator.
85  * \param interp (unsigned integer) Specifies the interpolation rate to use
86  * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps
87  * should be generated at the interpolated sampling rate.
88  */
90  const std::vector<float> &taps);
91 
92  std::vector<gr_fir_ccf*> d_filters;
93  std::vector< std::vector<float> > d_taps;
94  unsigned int d_rate;
95  unsigned int d_taps_per_filter;
96  bool d_updated;
97 
98  /*!
99  * Construct a Polyphase filterbank interpolator
100  * \param interp (unsigned integer) Specifies the interpolation rate to use
101  * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps
102  * should be generated at the interpolated sampling rate.
103  */
104  gr_pfb_interpolator_ccf (unsigned int interp,
105  const std::vector<float> &taps);
106 
107 public:
109 
110  /*!
111  * Resets the filterbank's filter taps with the new prototype filter
112  * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps
113  * should be generated at the interpolated sampling rate.
114  */
115  void set_taps (const std::vector<float> &taps);
116 
117  /*!
118  * Print all of the filterbank taps to screen.
119  */
120  void print_taps();
121 
122  int work (int noutput_items,
123  gr_vector_const_void_star &input_items,
124  gr_vector_void_star &output_items);
125 };
126 
127 #endif