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