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