GNU Radio 3.6.5 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  * \brief Polyphase filterbank interpolator with gr_complex input,
00039  * gr_complex output and float taps
00040  *
00041  * This block takes in a signal stream and performs interger up-
00042  * sampling (interpolation) with a polyphase filterbank. The first
00043  * input is the integer specifying how much to interpolate by. The
00044  * second input is a vector (Python list) of floating-point taps of
00045  * the prototype filter.
00046  *
00047  * The filter's taps should be based on the interpolation rate
00048  * specified. That is, the bandwidth specified is relative to the
00049  * bandwidth after interpolation.
00050  *
00051  * For example, using the GNU Radio's firdes utility to building
00052  * filters, we build a low-pass filter with a sampling rate of
00053  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
00054  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
00055  * attenuation to use, ATT, and the filter window function (a
00056  * Blackman-harris window in this case). The first input is the gain,
00057  * which is also specified as the interpolation rate so that the
00058  * output levels are the same as the input (this creates an overall
00059  * increase in power).
00060  *
00061  *      <B><EM>self._taps = gr.firdes.low_pass_2(interp, interp*fs, BW, TB,
00062  *           attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
00063  *
00064  * The PFB interpolator code takes the taps generated above and builds
00065  * a set of filters. The set contains <EM>interp</EM> number of
00066  * filters and each filter contains ceil(taps.size()/interp) number of
00067  * taps. Each tap from the filter prototype is sequentially inserted
00068  * into the next filter. When all of the input taps are used, the
00069  * remaining filters in the filterbank are filled out with 0's to make
00070  * sure each filter has the same number of taps.
00071  *
00072  * The theory behind this block can be found in Chapter 7.1 of the
00073  * following book.
00074  *
00075  *    <B><EM>f. harris, "Multirate Signal Processing for Communication
00076  *       Systems</EM>," Upper Saddle River, NJ: Prentice Hall,
00077  *       Inc. 2004.</EM></B>
00078  */
00079 
00080 class GR_CORE_API gr_pfb_interpolator_ccf : public gr_sync_interpolator
00081 {
00082  private:
00083   /*!
00084    * Build the polyphase filterbank interpolator.
00085    * \param interp  (unsigned integer) Specifies the interpolation rate to use
00086    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00087    *                                        should be generated at the interpolated sampling rate.
00088    */
00089   friend GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp,
00090                                                                     const std::vector<float> &taps);
00091 
00092   std::vector<gr_fir_ccf*> d_filters;
00093   std::vector< std::vector<float> > d_taps;
00094   unsigned int             d_rate;
00095   unsigned int             d_taps_per_filter;
00096   bool                     d_updated;
00097 
00098   /*!
00099    * Construct a Polyphase filterbank interpolator
00100    * \param interp  (unsigned integer) Specifies the interpolation rate to use
00101    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00102    *                                        should be generated at the interpolated sampling rate.
00103    */
00104   gr_pfb_interpolator_ccf (unsigned int interp,
00105                            const std::vector<float> &taps);
00106 
00107 public:
00108   ~gr_pfb_interpolator_ccf ();
00109 
00110   /*!
00111    * Resets the filterbank's filter taps with the new prototype filter
00112    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank. The taps
00113    *                                        should be generated at the interpolated sampling rate.
00114    */
00115   void set_taps (const std::vector<float> &taps);
00116 
00117   /*!
00118    * Print all of the filterbank taps to screen.
00119    */
00120   void print_taps();
00121 
00122   int work (int noutput_items,
00123             gr_vector_const_void_star &input_items,
00124             gr_vector_void_star &output_items);
00125 };
00126 
00127 #endif