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