GNU Radio 3.6.3.1 C++ API
pfb_arb_resampler_ccf_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009,2010,2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 
24 #ifndef INCLUDED_PFB_ARB_RESAMPLER_CCF_IMPL_H
25 #define INCLUDED_PFB_ARB_RESAMPLER_CCF_IMPL_H
26 
28 #include <filter/fir_filter.h>
29 #include <gruel/thread.h>
30 
31 namespace gr {
32  namespace filter {
33 
35  {
36  private:
37  std::vector<kernel::fir_filter_ccf*> d_filters;
38  std::vector<kernel::fir_filter_ccf*> d_diff_filters;
39  std::vector< std::vector<float> > d_taps;
40  std::vector< std::vector<float> > d_dtaps;
41  unsigned int d_int_rate; // the number of filters (interpolation rate)
42  unsigned int d_dec_rate; // the stride through the filters (decimation rate)
43  float d_flt_rate; // residual rate for the linear interpolation
44  float d_acc;
45  unsigned int d_last_filter;
46  int d_start_index;
47  unsigned int d_taps_per_filter;
48  bool d_updated;
49  gruel::mutex d_mutex; // mutex to protect set/work access
50 
51  void create_diff_taps(const std::vector<float> &newtaps,
52  std::vector<float> &difftaps);
53 
54  /*!
55  * Resets the filterbank's filter taps with the new prototype filter
56  * \param newtaps (vector of floats) The prototype filter to populate the filterbank.
57  * The taps should be generated at the interpolated sampling rate.
58  * \param ourtaps (vector of floats) Reference to our internal member of holding the taps.
59  * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for.
60  */
61  void create_taps(const std::vector<float> &newtaps,
62  std::vector< std::vector<float> > &ourtaps,
63  std::vector<kernel::fir_filter_ccf*> &ourfilter);
64 
65  public:
66  pfb_arb_resampler_ccf_impl(float rate,
67  const std::vector<float> &taps,
68  unsigned int filter_size);
69 
71 
72  void set_taps(const std::vector<float> &taps);
73  std::vector<std::vector<float> > taps() const;
74  void print_taps();
75  void set_rate(float rate);
76 
77  void set_phase(float ph);
78  float phase() const;
79 
80  int general_work(int noutput_items,
81  gr_vector_int &ninput_items,
82  gr_vector_const_void_star &input_items,
83  gr_vector_void_star &output_items);
84  };
85 
86  } /* namespace filter */
87 } /* namespace gr */
88 
89 #endif /* INCLUDED_PFB_ARB_RESAMPLER_CCF_IMPL_H */