GNU Radio 3.6.5.1 C++ API
gr_pfb_synthesizer_ccf.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 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_GR_PFB_SYNTHESIZER_CCF_H
25 #define INCLUDED_GR_PFB_SYNTHESIZER_CCF_H
26 
27 #include <gr_core_api.h>
28 #include <gr_sync_interpolator.h>
29 #include <gri_fir_filter_with_buffer_ccf.h>
30 #include <gruel/thread.h>
31 
35  (unsigned int numchans, const std::vector<float> &taps, bool twox=false);
36 
37 class gri_fft_complex;
38 
39 
40 /*!
41  * \brief Polyphase synthesis filterbank with
42  * gr_complex input, gr_complex output and float taps
43  */
44 
46 {
47  private:
48  /*!
49  * Build the polyphase synthesis filterbank.
50  * \param numchans (unsigned integer) Specifies the number of
51  channels <EM>M</EM>
52  * \param taps (vector/list of floats) The prototype filter to
53  populate the filterbank.
54  * \param twox (bool) use 2x oversampling or not (default is no)
55  */
57  (unsigned int numchans, const std::vector<float> &taps, bool twox);
58 
59  bool d_updated;
60  unsigned int d_numchans;
61  unsigned int d_taps_per_filter;
62  gri_fft_complex *d_fft;
63  std::vector< gri_fir_filter_with_buffer_ccf*> d_filters;
64  std::vector< std::vector<float> > d_taps;
65  int d_state;
66  std::vector<int> d_channel_map;
67  unsigned int d_twox;
68  gruel::mutex d_mutex; // mutex to protect set/work access
69 
70  /*!
71  * \brief Tap setting algorithm for critically sampled channels
72  */
73  void set_taps1(const std::vector<float> &taps);
74 
75  /*!
76  * \brief Tap setting algorithm for 2x over-sampled channels
77  */
78  void set_taps2(const std::vector<float> &taps);
79 
80  /*!
81  * Build the polyphase synthesis filterbank.
82  * \param numchans (unsigned integer) Specifies the number of
83  channels <EM>M</EM>
84  * \param taps (vector/list of floats) The prototype filter
85  to populate the filterbank.
86  * \param twox (bool) use 2x oversampling or not (default is no)
87  */
88  gr_pfb_synthesizer_ccf (unsigned int numchans,
89  const std::vector<float> &taps,
90  bool twox);
91 
92 public:
94 
95  /*!
96  * Resets the filterbank's filter taps with the new prototype filter
97  * \param taps (vector/list of floats) The prototype filter to
98  populate the filterbank.
99  */
100  void set_taps (const std::vector<float> &taps);
101 
102  /*!
103  * Print all of the filterbank taps to screen.
104  */
105  void print_taps();
106 
107  /*!
108  * Return a vector<vector<>> of the filterbank taps
109  */
110  std::vector<std::vector<float> > taps() const;
111 
112  /*!
113  * Set the channel map. Channels are numbers as:
114  * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2
115  * <------------------- 0 -------------------->
116  * freq
117  *
118  * So input stream 0 goes to channel 0, etc. Setting a new channel
119  * map allows the user to specify where in frequency he/she wants
120  * the input stream to go. This is especially useful to avoid
121  * putting signals into the channels on the edge of the spectrum
122  * which can either wrap around (in the case of odd number of
123  * channels) and be affected by filter rolloff in the transmitter.
124  *
125  * The map must be at least the number of streams being sent to the
126  * block. Less and the algorithm will not have enough data to
127  * properly setup the buffers. Any more channels specified will be
128  * ignored.
129  */
130  void set_channel_map(const std::vector<int> &map);
131 
132  /*!
133  * Gets the current channel map.
134  */
135  std::vector<int> channel_map() const;
136 
137  int work (int noutput_items,
138  gr_vector_const_void_star &input_items,
139  gr_vector_void_star &output_items);
140 };
141 
142 #endif