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