GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pfb_channelizer_ccf.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_FILTER_PFB_CHANNELIZER_CCF_H
25 #define INCLUDED_FILTER_PFB_CHANNELIZER_CCF_H
26 
27 #include <gnuradio/filter/api.h>
28 #include <gnuradio/block.h>
29 
30 namespace gr {
31  namespace filter {
32 
33  /*!
34  * \brief Polyphase filterbank channelizer with
35  * gr_complex input, gr_complex output and float taps
36  * \ingroup channelizers_blk
37  *
38  * \details
39  * This block takes in complex inputs and channelizes it to <EM>M</EM>
40  * channels of equal bandwidth. Each of the resulting channels is
41  * decimated to the new rate that is the input sampling rate
42  * <EM>fs</EM> divided by the number of channels, <EM>M</EM>.
43  *
44  * The PFB channelizer code takes the taps generated above and builds
45  * a set of filters. The set contains <EM>M</EM> number of filters
46  * and each filter contains ceil(taps.size()/decim) number of taps.
47  * Each tap from the filter prototype is sequentially inserted into
48  * the next filter. When all of the input taps are used, the remaining
49  * filters in the filterbank are filled out with 0's to make sure each
50  * filter has the same number of taps.
51  *
52  * Each filter operates using the gr::blocks::fir_filter_XXX
53  * classs of GNU Radio, which takes the input stream at <EM>i</EM>
54  * and performs the inner product calculation to <EM>i+(n-1)</EM>
55  * where <EM>n</EM> is the number of filter taps. To efficiently
56  * handle this in the GNU Radio structure, each filter input must
57  * come from its own input stream. So the channelizer must be
58  * provided with <EM>M</EM> streams where the input stream has
59  * been deinterleaved. This is most easily done using the
60  * gr::blocks::stream_to_streams block.
61  *
62  * The output is then produced as a vector, where index <EM>i</EM>
63  * in the vector is the next sample from the <EM>i</EM>th
64  * channel. This is most easily handled by sending the output to a
65  * gr::blocks::vector_to_streams block to handle the conversion
66  * and passing <EM>M</EM> streams out.
67  *
68  * The input and output formatting is done using a hier_block2 called
69  * pfb_channelizer_ccf. This can take in a single stream and outputs
70  * <EM>M</EM> streams based on the behavior described above.
71  *
72  * The filter's taps should be based on the input sampling rate.
73  *
74  * For example, using the GNU Radio's firdes utility to building
75  * filters, we build a low-pass filter with a sampling rate of
76  * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
77  * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
78  * attenuation to use, <EM>ATT</EM>, and the filter window
79  * function (a Blackman-harris window in this case). The first input
80  * is the gain of the filter, which we specify here as unity.
81  *
82  * <B><EM>self._taps = filter.firdes.low_pass_2(1, fs, BW, TB,
83  * attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
84  *
85  * The filter output can also be overs ampled. The over sampling rate
86  * is the ratio of the the actual output sampling rate to the normal
87  * output sampling rate. It must be rationally related to the number
88  * of channels as N/i for i in [1,N], which gives an outputsample rate
89  * of [fs/N, fs] where fs is the input sample rate and N is the number
90  * of channels.
91  *
92  * For example, for 6 channels with fs = 6000 Hz, the normal rate is
93  * 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4,
94  * 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample
95  * ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2,
96  * so the output rate would be 1200 Hz.
97  *
98  * The theory behind this block can be found in Chapter 6 of
99  * the following book.
100  *
101  * <B><EM>f. harris, "Multirate Signal Processing for Communication
102  * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
103  *
104  * When dealing with oversampling, the above book is still a good
105  * reference along with this paper:
106  *
107  * <B><EM>E. Venosa, X. Chen, and fred harris, “Polyphase analysis
108  * filter bank down-converts unequal channel bandwidths with
109  * arbitrary center frequencies - design I,” in SDR’10-WinnComm,
110  * 2010.</EM></B>
111  */
112  class FILTER_API pfb_channelizer_ccf : virtual public block
113  {
114  public:
115  // gr::filter::pfb_channelizer_ccf::sptr
116  typedef boost::shared_ptr<pfb_channelizer_ccf> sptr;
117 
118  /*!
119  * Build the polyphase filterbank decimator.
120  * \param numchans (unsigned integer) Specifies the number of
121  * channels <EM>M</EM>
122  * \param taps (vector/list of floats) The prototype filter to
123  * populate the filterbank.
124  * \param oversample_rate (float) The over sampling rate is the
125  * ratio of the the actual output
126  * sampling rate to the normal
127  * output sampling rate. It must
128  * be rationally related to the
129  * number of channels as N/i for
130  * i in [1,N], which gives an
131  * outputsample rate of [fs/N,
132  * fs] where fs is the input
133  * sample rate and N is the
134  * number of channels.
135  *
136  * For example, for 6 channels
137  * with fs = 6000 Hz, the normal
138  * rateis 6000/6 = 1000
139  * Hz. Allowable oversampling
140  * rates are 6/6, 6/5, 6/4, 6/3,
141  * 6/2, and 6/1 where the output
142  * sample rate of a 6/1
143  * oversample ratio is 6000 Hz,
144  * or 6 times the normal 1000 Hz.
145  */
146  static sptr make(unsigned int numchans,
147  const std::vector<float> &taps,
148  float oversample_rate);
149 
150  /*!
151  * Resets the filterbank's filter taps with the new prototype filter
152  * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
153  */
154  virtual void set_taps(const std::vector<float> &taps) = 0;
155 
156  /*!
157  * Print all of the filterbank taps to screen.
158  */
159  virtual void print_taps() = 0;
160 
161  /*!
162  * Return a vector<vector<>> of the filterbank taps
163  */
164  virtual std::vector<std::vector<float> > taps() const = 0;
165 
166  /*!
167  * Set the channel map. Channels are numbers as:
168  * <pre>
169  * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2
170  * <------------------- 0 -------------------->
171  * freq
172  * </pre>
173  *
174  * So output stream 0 comes from channel 0, etc. Setting a new
175  * channel map allows the user to specify which channel in frequency
176  * he/she wants to got to which output stream.
177  *
178  * The map should have the same number of elements as the number
179  * of output connections from the block. The minimum value of
180  * the map is 0 (for the 0th channel) and the maximum number is
181  * N-1 where N is the number of channels.
182  *
183  * We specify M as the number of output connections made where M
184  * <= N, so only M out of N channels are driven to an output
185  * stream. The number of items in the channel map should be at
186  * least M long. If there are more channels specified, any value
187  * in the map over M-1 will be ignored. If the size of the map
188  * is less than M the behavior is unknown (we don't wish to
189  * check every entry into the work function).
190  *
191  * This means that if the channelizer is splitting the signal up
192  * into N channels but only M channels are specified in the map
193  * (where M <= N), then M output streams must be connected and
194  * the map and the channel numbers used must be less than
195  * N-1. Output channel number can be reused, too. By default,
196  * the map is [0...M-1] with M = N.
197  */
198  virtual void set_channel_map(const std::vector<int> &map) = 0;
199 
200  /*!
201  * Gets the current channel map.
202  */
203  virtual std::vector<int> channel_map() const = 0;
204  };
205 
206  } /* namespace filter */
207 } /* namespace gr */
208 
209 #endif /* INCLUDED_FILTER_PFB_CHANNELIZER_CCF_H */
Polyphase filterbank channelizer with gr_complex input, gr_complex output and float taps...
Definition: pfb_channelizer_ccf.h:112
Include this header to use the message passing features.
Definition: logger.h:131
PMT_API pmt_t map(pmt_t proc(const pmt_t &), pmt_t list)
Apply proc element-wise to the elements of list and returns a list of the results, in order.
boost::shared_ptr< pfb_channelizer_ccf > sptr
Definition: pfb_channelizer_ccf.h:116
static const float taps[NSTEPS+1][NTAPS]
Definition: interpolator_taps.h:9
#define FILTER_API
Definition: gr-filter/include/gnuradio/filter/api.h:30
The abstract base class for all 'terminal' processing blocks.A signal processing flow is constructed ...
Definition: block.h:60