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