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