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