3 # Copyright 2009,2010 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.
23 from gnuradio import gr, optfir
25 class pfb_channelizer_ccf(gr.hier_block2):
27 Make a Polyphase Filter channelizer (complex in, complex out, floating-point taps)
29 This simplifies the interface by allowing a single input stream to connect to this block.
30 It will then output a stream for each channel.
32 def __init__(self, numchans, taps=None, oversample_rate=1, atten=100):
33 gr.hier_block2.__init__(self, "pfb_channelizer_ccf",
34 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
35 gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature
37 self._numchans = numchans
38 self._oversample_rate = oversample_rate
43 # Create a filter that covers the full bandwidth of the input signal
50 self._taps = optfir.low_pass(1, self._numchans, bw, bw+tb, ripple, atten)
55 print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple))
57 # Build in an exit strategy; if we've come this far, it ain't working.
59 raise RuntimeError("optfir could not generate an appropriate filter.")
61 self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._numchans)
62 self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps,
63 self._oversample_rate)
64 self.v2s = gr.vector_to_streams(gr.sizeof_gr_complex, self._numchans)
66 self.connect(self, self.s2ss)
68 for i in xrange(self._numchans):
69 self.connect((self.s2ss,i), (self.pfb,i))
71 # Get independent streams from the filterbank and send them out
72 self.connect(self.pfb, self.v2s)
74 for i in xrange(self._numchans):
75 self.connect((self.v2s,i), (self,i))