GNU Radio 3.6.5 C++ API

gr_pfb_decimator_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_DECIMATOR_CCF_H
00025 #define INCLUDED_GR_PFB_DECIMATOR_CCF_H
00026 
00027 #include <gr_core_api.h>
00028 #include <gr_sync_block.h>
00029 
00030 class gr_pfb_decimator_ccf;
00031 typedef boost::shared_ptr<gr_pfb_decimator_ccf> gr_pfb_decimator_ccf_sptr;
00032 GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim,
00033                                                      const std::vector<float> &taps,
00034                                                      unsigned int channel=0);
00035 
00036 class gr_fir_ccf;
00037 class gri_fft_complex;
00038 
00039 /*!
00040  * \brief Polyphase filterbank bandpass decimator with gr_complex
00041  *        input, gr_complex output and float taps
00042  *
00043  * This block takes in a signal stream and performs interger down-
00044  * sampling (decimation) with a polyphase filterbank. The first input
00045  * is the integer specifying how much to decimate by. The second
00046  * input is a vector (Python list) of floating-point taps of the
00047  * prototype filter. The third input specifies the channel to extract.
00048  * By default, the zeroth channel is used, which is the baseband
00049  * channel (first Nyquist zone).
00050  *
00051  * The <EM>channel</EM> parameter specifies which channel to use since
00052  * this class is capable of bandpass decimation. Given a complex input
00053  * stream at a sampling rate of <EM>fs</EM> and a decimation rate of
00054  * <EM>decim</EM>, the input frequency domain is split into
00055  * <EM>decim</EM> channels that represent the Nyquist zones. Using the
00056  * polyphase filterbank, we can select any one of these channels to
00057  * decimate.
00058  *
00059  * The output signal will be the basebanded and decimated signal from
00060  * that channel. This concept is very similar to the PFB channelizer
00061  * (see #gr_pfb_channelizer_ccf) where only a single channel is
00062  * extracted at a time.
00063  *
00064  * The filter's taps should be based on the sampling rate before
00065  * decimation.
00066  *
00067  * For example, using the GNU Radio's firdes utility to building
00068  * filters, we build a low-pass filter with a sampling rate of
00069  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
00070  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
00071  * attenuation to use, <EM>ATT</EM>, and the filter window
00072  * function (a Blackman-harris window in this case). The first input
00073  *  is the gain of the filter, which we specify here as unity.
00074  *
00075  *      <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB,
00076  *           attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
00077  *
00078  * The PFB decimator code takes the taps generated above and builds a
00079  * set of filters. The set contains <EM>decim</EM> number of filters
00080  * and each filter contains ceil(taps.size()/decim) number of taps.
00081  * Each tap from the filter prototype is sequentially inserted into
00082  * the next filter. When all of the input taps are used, the remaining
00083  * filters in the filterbank are filled out with 0's to make sure each
00084  * filter has the same number of taps.
00085  *
00086  * The theory behind this block can be found in Chapter 6 of
00087  * the following book.
00088  *
00089  *    <B><EM>f. harris, "Multirate Signal Processing for Communication
00090  *       Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
00091  */
00092 
00093 class GR_CORE_API gr_pfb_decimator_ccf : public gr_sync_block
00094 {
00095  private:
00096   /*!
00097    * Build the polyphase filterbank decimator.
00098    * \param decim   (unsigned integer) Specifies the decimation rate to use
00099    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
00100    * \param channel (unsigned integer) Selects the channel to return [default=0].
00101    */
00102   friend GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim,
00103                                                               const std::vector<float> &taps,
00104                                                               unsigned int channel);
00105 
00106   std::vector<gr_fir_ccf*> d_filters;
00107   std::vector< std::vector<float> > d_taps;
00108   gri_fft_complex         *d_fft;
00109   unsigned int             d_rate;
00110   unsigned int             d_chan;
00111   unsigned int             d_taps_per_filter;
00112   bool                     d_updated;
00113   gr_complex              *d_rotator;
00114 
00115   /*!
00116    * Build the polyphase filterbank decimator.
00117    * \param decim   (unsigned integer) Specifies the decimation rate to use
00118    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
00119    * \param channel (unsigned integer) Selects the channel to return [default=0].
00120    */
00121   gr_pfb_decimator_ccf (unsigned int decim,
00122                         const std::vector<float> &taps,
00123                         unsigned int channel);
00124 
00125 public:
00126   ~gr_pfb_decimator_ccf ();
00127 
00128   /*!
00129    * Resets the filterbank's filter taps with the new prototype filter
00130    * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
00131    */
00132    void set_taps (const std::vector<float> &taps);
00133 
00134   /*!
00135    * Print all of the filterbank taps to screen.
00136    */
00137   void print_taps();
00138 
00139  //void set_channel (unsigned int channel);
00140 
00141   int work (int noutput_items,
00142             gr_vector_const_void_star &input_items,
00143             gr_vector_void_star &output_items);
00144 };
00145 
00146 #endif