GNU Radio v3.6.2-149-ga6d285d9 C++ API
pfb_decimator_ccf.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2009,2012 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_PFB_DECIMATOR_CCF_H
00025 #define INCLUDED_PFB_DECIMATOR_CCF_H
00026 
00027 #include <filter/api.h>
00028 #include <gr_sync_block.h>
00029 
00030 namespace gr {
00031   namespace filter {
00032 
00033     /*!
00034      * \class pfb_decimator_ccf
00035      * \brief Polyphase filterbank bandpass decimator with gr_complex
00036      *        input, gr_complex output and float taps
00037      *
00038      * \ingroup filter_blk
00039      * \ingroup pfb_blk
00040      *
00041      * This block takes in a signal stream and performs interger down-
00042      * sampling (decimation) with a polyphase filterbank. The first
00043      * input is the integer specifying how much to decimate by. The
00044      * second input is a vector (Python list) of floating-point taps
00045      * of the prototype filter. The third input specifies the channel
00046      * to extract.  By default, the zeroth channel is used, which is
00047      * the baseband channel (first Nyquist zone).
00048      *
00049      * The <EM>channel</EM> parameter specifies which channel to use
00050      * since this class is capable of bandpass decimation. Given a
00051      * complex input stream at a sampling rate of <EM>fs</EM> and a
00052      * decimation rate of <EM>decim</EM>, the input frequency domain
00053      * is split into <EM>decim</EM> channels that represent the
00054      * Nyquist zones. Using the polyphase filterbank, we can select
00055      * any one of these channels to decimate.
00056      *
00057      * The output signal will be the basebanded and decimated signal
00058      * from that channel. This concept is very similar to the PFB
00059      * channelizer (see #gr_pfb_channelizer_ccf) where only a single
00060      * channel is extracted at a time.
00061      *
00062      * The filter's taps should be based on the sampling rate before
00063      * decimation.
00064      *
00065      * For example, using the GNU Radio's firdes utility to building
00066      * filters, we build a low-pass filter with a sampling rate of
00067      * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
00068      * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
00069      * attenuation to use, <EM>ATT</EM>, and the filter window
00070      * function (a Blackman-harris window in this case). The first
00071      * input is the gain of the filter, which we specify here as
00072      * unity.
00073      *
00074      *   <B><EM>self._taps = filter.firdes.low_pass_2(1, fs, BW, TB,
00075      *      attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
00076      *
00077      * The PFB decimator code takes the taps generated above and
00078      * builds a set of filters. The set contains <EM>decim</EM> number
00079      * of filters and each filter contains ceil(taps.size()/decim)
00080      * number of taps.  Each tap from the filter prototype is
00081      * sequentially inserted into the next filter. When all of the
00082      * input taps are used, the remaining filters in the filterbank
00083      * are filled out with 0's to make sure each filter has the same
00084      * 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 FILTER_API pfb_decimator_ccf : virtual public gr_sync_block
00094     {
00095     public:
00096       // gr::filter::pfb_decimator_ccf::sptr
00097       typedef boost::shared_ptr<pfb_decimator_ccf> sptr;
00098 
00099       /*!
00100        * Build the polyphase filterbank decimator.
00101        * \param decim   (unsigned integer) Specifies the decimation rate to use
00102        * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
00103        * \param channel (unsigned integer) Selects the channel to return [default=0].
00104        */
00105       static sptr make(unsigned int decim,
00106                                   const std::vector<float> &taps,
00107                                   unsigned int channel);
00108 
00109       /*!
00110        * Resets the filterbank's filter taps with the new prototype filter
00111        * \param taps    (vector/list of floats) The prototype filter to populate the filterbank.
00112        */
00113       virtual void set_taps(const std::vector<float> &taps) = 0;
00114 
00115       /*!
00116        * Return a vector<vector<>> of the filterbank taps
00117        */
00118       virtual std::vector<std::vector<float> > taps() const = 0;
00119 
00120       /*!
00121        * Print all of the filterbank taps to screen.
00122        */
00123       virtual void print_taps() = 0;
00124 
00125       //virtual void set_channel(unsigned int channel) = 0;
00126     };
00127 
00128   } /* namespace filter */
00129 } /* namespace gr */
00130 
00131 #endif /* INCLUDED_PFB_DECIMATOR_CCF_H */