GNU Radio 3.5.1 C++ API
gr_pfb_interpolator_ccf.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2009 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 
00024 #ifndef INCLUDED_GR_PFB_INTERPOLATOR_CCF_H
00025 #define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H
00026 
00027 #include <gr_core_api.h>
00028 #include <gr_sync_interpolator.h>
00029 
00030 class gr_pfb_interpolator_ccf;
00031 typedef boost::shared_ptr<gr_pfb_interpolator_ccf> gr_pfb_interpolator_ccf_sptr;
00032 GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, 
00033                                                            const std::vector<float> &taps);
00034 
00035 class gr_fir_ccf;
00036 
00037 /*!
00038  * \class gr_pfb_interpolator_ccf
00039  * \brief Polyphase filterbank interpolator with gr_complex input,
00040  * gr_complex output and float taps
00041  *
00042  * \ingroup filter_blk
00043  * \ingroup pfb_blk
00044  * 
00045  * This block takes in a signal stream and performs interger up-
00046  * sampling (interpolation) with a polyphase filterbank. The first
00047  * input is the integer specifying how much to interpolate by. The
00048  * second input is a vector (Python list) of floating-point taps of
00049  * the prototype filter.
00050  *
00051  * The filter's taps should be based on the interpolation rate
00052  * specified. That is, the bandwidth specified is relative to the
00053  * bandwidth after interpolation.
00054  *
00055  * For example, using the GNU Radio's firdes utility to building
00056  * filters, we build a low-pass filter with a sampling rate of
00057  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
00058  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
00059  * attenuation to use, ATT, and the filter window function (a
00060  * Blackman-harris window in this case). The first input is the gain,
00061  * which is also specified as the interpolation rate so that the
00062  * output levels are the same as the input (this creates an overall
00063  * increase in power).
00064  *
00065  *      <B><EM>self._taps = gr.firdes.low_pass_2(interp, interp*fs, BW, TB, 
00066  *           attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
00067  *
00068  * The PFB interpolator code takes the taps generated above and builds
00069  * a set of filters. The set contains <EM>interp</EM> number of
00070  * filters and each filter contains ceil(taps.size()/interp) number of
00071  * taps. Each tap from the filter prototype is sequentially inserted
00072  * into the next filter. When all of the input taps are used, the
00073  * remaining filters in the filterbank are filled out with 0's to make
00074  * sure each filter has the same number of taps.
00075  *
00076  * The theory behind this block can be found in Chapter 7.1 of the
00077  * following book.
00078  *
00079  *    <B><EM>f. harris, "Multirate Signal Processing for Communication
00080  *       Systems</EM>," Upper Saddle River, NJ: Prentice Hall,
00081  *       Inc. 2004.</EM></B>
00082  */
00083 
00084 class GR_CORE_API gr_pfb_interpolator_ccf : public gr_sync_interpolator
00085 {
00086  private:
00087   /*!
00088    * Build the polyphase filterbank interpolator.
00089    * \param interp  (unsigned integer) Specifies the interpolation rate to use
00090    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00091    *                                        should be generated at the interpolated sampling rate.
00092    */
00093   friend GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp,
00094                                                                     const std::vector<float> &taps);
00095 
00096   std::vector<gr_fir_ccf*> d_filters;
00097   std::vector< std::vector<float> > d_taps;
00098   unsigned int             d_rate;
00099   unsigned int             d_taps_per_filter;
00100   bool                     d_updated;
00101 
00102   /*!
00103    * Construct a Polyphase filterbank interpolator
00104    * \param interp  (unsigned integer) Specifies the interpolation rate to use
00105    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00106    *                                        should be generated at the interpolated sampling rate.
00107    */
00108   gr_pfb_interpolator_ccf (unsigned int interp, 
00109                            const std::vector<float> &taps);
00110   
00111 public:
00112   ~gr_pfb_interpolator_ccf ();
00113   
00114   /*!
00115    * Resets the filterbank's filter taps with the new prototype filter
00116    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00117    *                                        should be generated at the interpolated sampling rate.
00118    */
00119   void set_taps (const std::vector<float> &taps);
00120 
00121   /*!
00122    * Print all of the filterbank taps to screen.
00123    */
00124   void print_taps();
00125   
00126   int work (int noutput_items,
00127             gr_vector_const_void_star &input_items,
00128             gr_vector_void_star &output_items);
00129 };
00130 
00131 #endif