3 * Copyright 2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
24 #ifndef INCLUDED_GR_PFB_DECIMATOR_CCF_H
25 #define INCLUDED_GR_PFB_DECIMATOR_CCF_H
27 #include <gr_sync_block.h>
29 class gr_pfb_decimator_ccf;
30 typedef boost::shared_ptr<gr_pfb_decimator_ccf> gr_pfb_decimator_ccf_sptr;
31 gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim,
32 const std::vector<float> &taps,
33 unsigned int channel=0);
36 class gri_fft_complex;
39 * \class gr_pfb_decimator_ccf
40 * \brief Polyphase filterbank bandpass decimator with gr_complex
41 * input, gr_complex output and float taps
45 * This block takes in a signal stream and performs interger down-
46 * sampling (decimation) with a polyphase filterbank. The first input
47 * is the integer specifying how much to decimate by. The second
48 * input is a vector (Python list) of floating-point taps of the
49 * prototype filter. The third input specifies the channel to extract.
50 * By default, the zeroth channel is used, which is the baseband
51 * channel (first Nyquist zone).
53 * The <EM>channel</EM> parameter specifies which channel to use since
54 * this class is capable of bandpass decimation. Given a complex input
55 * stream at a sampling rate of <EM>fs</EM> and a decimation rate of
56 * <EM>decim</EM>, the input frequency domain is split into
57 * <EM>decim</EM> channels that represent the Nyquist zones. Using the
58 * polyphase filterbank, we can select any one of these channels to
61 * The output signal will be the basebanded and decimated signal from
62 * that channel. This concept is very similar to the PFB channelizer
63 * (see #gr_pfb_channelizer_ccf) where only a single channel is
64 * extracted at a time.
66 * The filter's taps should be based on the sampling rate before
69 * For example, using the GNU Radio's firdes utility to building
70 * filters, we build a low-pass filter with a sampling rate of
71 * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition
72 * bandwidth of <EM>TB</EM>. We can also specify the out-of-band
73 * attenuation to use, <EM>ATT</EM>, and the filter window
74 * function (a Blackman-harris window in this case). The first input
75 * is the gain of the filter, which we specify here as unity.
77 * <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB,
78 * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B>
80 * The PFB decimator code takes the taps generated above and builds a
81 * set of filters. The set contains <EM>decim</EM> number of filters
82 * and each filter contains ceil(taps.size()/decim) number of taps.
83 * Each tap from the filter prototype is sequentially inserted into
84 * the next filter. When all of the input taps are used, the remaining
85 * filters in the filterbank are filled out with 0's to make sure each
86 * filter has the same number of taps.
88 * The theory behind this block can be found in Chapter 6 of
91 * <B><EM>f. harris, "Multirate Signal Processing for Communication
92 * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B>
95 class gr_pfb_decimator_ccf : public gr_sync_block
99 * Build the polyphase filterbank decimator.
100 * \param decim (unsigned integer) Specifies the decimation rate to use
101 * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
102 * \param channel (unsigned integer) Selects the channel to return [default=0].
104 friend gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim,
105 const std::vector<float> &taps,
106 unsigned int channel);
108 std::vector<gr_fir_ccf*> d_filters;
109 std::vector< std::vector<float> > d_taps;
110 gri_fft_complex *d_fft;
113 unsigned int d_taps_per_filter;
115 gr_complex *d_rotator;
118 * Build the polyphase filterbank decimator.
119 * \param decim (unsigned integer) Specifies the decimation rate to use
120 * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
121 * \param channel (unsigned integer) Selects the channel to return [default=0].
123 gr_pfb_decimator_ccf (unsigned int decim,
124 const std::vector<float> &taps,
125 unsigned int channel);
128 ~gr_pfb_decimator_ccf ();
131 * Resets the filterbank's filter taps with the new prototype filter
132 * \param taps (vector/list of floats) The prototype filter to populate the filterbank.
134 void set_taps (const std::vector<float> &taps);
137 * Print all of the filterbank taps to screen.
141 //void set_channel (unsigned int channel);
143 int work (int noutput_items,
144 gr_vector_const_void_star &input_items,
145 gr_vector_void_star &output_items);