GNU Radio 3.6.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2010,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_GR_PFB_SYNTHESIZER_CCF_H 00025 #define INCLUDED_GR_PFB_SYNTHESIZER_CCF_H 00026 00027 #include <gr_core_api.h> 00028 #include <gr_sync_interpolator.h> 00029 #include <gri_fir_filter_with_buffer_ccf.h> 00030 #include <gruel/thread.h> 00031 00032 class gr_pfb_synthesizer_ccf; 00033 typedef boost::shared_ptr<gr_pfb_synthesizer_ccf> gr_pfb_synthesizer_ccf_sptr; 00034 GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf 00035 (unsigned int numchans, const std::vector<float> &taps, bool twox=false); 00036 00037 class gri_fft_complex; 00038 00039 00040 /*! 00041 * \class gr_pfb_synthesizer_ccf 00042 * 00043 * \brief Polyphase synthesis filterbank with 00044 * gr_complex input, gr_complex output and float taps 00045 * 00046 * \ingroup filter_blk 00047 * \ingroup pfb_blk 00048 */ 00049 00050 class GR_CORE_API gr_pfb_synthesizer_ccf : public gr_sync_interpolator 00051 { 00052 private: 00053 /*! 00054 * Build the polyphase synthesis filterbank. 00055 * \param numchans (unsigned integer) Specifies the number of 00056 channels <EM>M</EM> 00057 * \param taps (vector/list of floats) The prototype filter to 00058 populate the filterbank. 00059 * \param twox (bool) use 2x oversampling or not (default is no) 00060 */ 00061 friend GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf 00062 (unsigned int numchans, const std::vector<float> &taps, bool twox); 00063 00064 bool d_updated; 00065 unsigned int d_numchans; 00066 unsigned int d_taps_per_filter; 00067 gri_fft_complex *d_fft; 00068 std::vector< gri_fir_filter_with_buffer_ccf*> d_filters; 00069 std::vector< std::vector<float> > d_taps; 00070 int d_state; 00071 std::vector<int> d_channel_map; 00072 unsigned int d_twox; 00073 gruel::mutex d_mutex; // mutex to protect set/work access 00074 00075 /*! 00076 * \brief Tap setting algorithm for critically sampled channels 00077 */ 00078 void set_taps1(const std::vector<float> &taps); 00079 00080 /*! 00081 * \brief Tap setting algorithm for 2x over-sampled channels 00082 */ 00083 void set_taps2(const std::vector<float> &taps); 00084 00085 /*! 00086 * Build the polyphase synthesis filterbank. 00087 * \param numchans (unsigned integer) Specifies the number of 00088 channels <EM>M</EM> 00089 * \param taps (vector/list of floats) The prototype filter 00090 to populate the filterbank. 00091 * \param twox (bool) use 2x oversampling or not (default is no) 00092 */ 00093 gr_pfb_synthesizer_ccf (unsigned int numchans, 00094 const std::vector<float> &taps, 00095 bool twox); 00096 00097 public: 00098 ~gr_pfb_synthesizer_ccf (); 00099 00100 /*! 00101 * Resets the filterbank's filter taps with the new prototype filter 00102 * \param taps (vector/list of floats) The prototype filter to 00103 populate the filterbank. 00104 */ 00105 void set_taps (const std::vector<float> &taps); 00106 00107 /*! 00108 * Print all of the filterbank taps to screen. 00109 */ 00110 void print_taps(); 00111 00112 /*! 00113 * Return a vector<vector<>> of the filterbank taps 00114 */ 00115 std::vector<std::vector<float> > taps() const; 00116 00117 /*! 00118 * Set the channel map. Channels are numbers as: 00119 * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2 00120 * <------------------- 0 --------------------> 00121 * freq 00122 * 00123 * So input stream 0 goes to channel 0, etc. Setting a new channel 00124 * map allows the user to specify where in frequency he/she wants 00125 * the input stream to go. This is especially useful to avoid 00126 * putting signals into the channels on the edge of the spectrum 00127 * which can either wrap around (in the case of odd number of 00128 * channels) and be affected by filter rolloff in the transmitter. 00129 * 00130 * The map must be at least the number of streams being sent to the 00131 * block. Less and the algorithm will not have enough data to 00132 * properly setup the buffers. Any more channels specified will be 00133 * ignored. 00134 */ 00135 void set_channel_map(const std::vector<int> &map); 00136 00137 /*! 00138 * Gets the current channel map. 00139 */ 00140 std::vector<int> channel_map() const; 00141 00142 int work (int noutput_items, 00143 gr_vector_const_void_star &input_items, 00144 gr_vector_void_star &output_items); 00145 }; 00146 00147 #endif