GNU Radio 3.6.5 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2009,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_PFB_ARB_RESAMPLER_CCF_IMPL_H 00025 #define INCLUDED_PFB_ARB_RESAMPLER_CCF_IMPL_H 00026 00027 #include <filter/pfb_arb_resampler_ccf.h> 00028 #include <filter/fir_filter.h> 00029 #include <gruel/thread.h> 00030 00031 namespace gr { 00032 namespace filter { 00033 00034 class FILTER_API pfb_arb_resampler_ccf_impl : public pfb_arb_resampler_ccf 00035 { 00036 private: 00037 std::vector<kernel::fir_filter_ccf*> d_filters; 00038 std::vector<kernel::fir_filter_ccf*> d_diff_filters; 00039 std::vector< std::vector<float> > d_taps; 00040 std::vector< std::vector<float> > d_dtaps; 00041 unsigned int d_int_rate; // the number of filters (interpolation rate) 00042 unsigned int d_dec_rate; // the stride through the filters (decimation rate) 00043 float d_flt_rate; // residual rate for the linear interpolation 00044 float d_acc; 00045 unsigned int d_last_filter; 00046 int d_start_index; 00047 unsigned int d_taps_per_filter; 00048 bool d_updated; 00049 gruel::mutex d_mutex; // mutex to protect set/work access 00050 00051 void create_diff_taps(const std::vector<float> &newtaps, 00052 std::vector<float> &difftaps); 00053 00054 /*! 00055 * Resets the filterbank's filter taps with the new prototype filter 00056 * \param newtaps (vector of floats) The prototype filter to populate the filterbank. 00057 * The taps should be generated at the interpolated sampling rate. 00058 * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. 00059 * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. 00060 */ 00061 void create_taps(const std::vector<float> &newtaps, 00062 std::vector< std::vector<float> > &ourtaps, 00063 std::vector<kernel::fir_filter_ccf*> &ourfilter); 00064 00065 public: 00066 pfb_arb_resampler_ccf_impl(float rate, 00067 const std::vector<float> &taps, 00068 unsigned int filter_size); 00069 00070 ~pfb_arb_resampler_ccf_impl(); 00071 00072 void set_taps(const std::vector<float> &taps); 00073 std::vector<std::vector<float> > taps() const; 00074 void print_taps(); 00075 void set_rate(float rate); 00076 00077 void set_phase(float ph); 00078 float phase() const; 00079 00080 int general_work(int noutput_items, 00081 gr_vector_int &ninput_items, 00082 gr_vector_const_void_star &input_items, 00083 gr_vector_void_star &output_items); 00084 }; 00085 00086 } /* namespace filter */ 00087 } /* namespace gr */ 00088 00089 #endif /* INCLUDED_PFB_ARB_RESAMPLER_CCF_IMPL_H */