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