Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / python / gnuradio / blks2impl / pfb_interpolator.py @ 3f32342f

History | View | Annotate | Download (2.4 kB)

1 a0d13b42 trondeau
#!/usr/bin/env python
2 a0d13b42 trondeau
#
3 a0d13b42 trondeau
# Copyright 2009 Free Software Foundation, Inc.
4 a0d13b42 trondeau
# 
5 a0d13b42 trondeau
# This file is part of GNU Radio
6 a0d13b42 trondeau
# 
7 a0d13b42 trondeau
# GNU Radio is free software; you can redistribute it and/or modify
8 a0d13b42 trondeau
# it under the terms of the GNU General Public License as published by
9 a0d13b42 trondeau
# the Free Software Foundation; either version 3, or (at your option)
10 a0d13b42 trondeau
# any later version.
11 a0d13b42 trondeau
# 
12 a0d13b42 trondeau
# GNU Radio is distributed in the hope that it will be useful,
13 a0d13b42 trondeau
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14 a0d13b42 trondeau
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 a0d13b42 trondeau
# GNU General Public License for more details.
16 a0d13b42 trondeau
# 
17 a0d13b42 trondeau
# You should have received a copy of the GNU General Public License
18 a0d13b42 trondeau
# along with GNU Radio; see the file COPYING.  If not, write to
19 a0d13b42 trondeau
# the Free Software Foundation, Inc., 51 Franklin Street,
20 a0d13b42 trondeau
# Boston, MA 02110-1301, USA.
21 a0d13b42 trondeau
# 
22 a0d13b42 trondeau
23 3f32342f Tom Rondeau
from gnuradio import gr, optfir
24 a0d13b42 trondeau
25 a0d13b42 trondeau
class pfb_interpolator_ccf(gr.hier_block2):
26 a0d13b42 trondeau
    '''
27 a0d13b42 trondeau
    Make a Polyphase Filter interpolator (complex in, complex out, floating-point taps)
28 a0d13b42 trondeau
29 a0d13b42 trondeau
    The block takes a single complex stream in and outputs a single complex
30 a0d13b42 trondeau
    stream out. As such, it requires no extra glue to handle the input/output
31 a0d13b42 trondeau
    streams. This block is provided to be consistent with the interface to the
32 a0d13b42 trondeau
    other PFB block.
33 a0d13b42 trondeau
    '''
34 3f32342f Tom Rondeau
    def __init__(self, interp, taps=None, atten=100):
35 a0d13b42 trondeau
        gr.hier_block2.__init__(self, "pfb_interpolator_ccf",
36 a0d13b42 trondeau
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
37 a0d13b42 trondeau
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
38 a0d13b42 trondeau
39 a0d13b42 trondeau
        self._interp = interp
40 a0d13b42 trondeau
        self._taps = taps
41 a0d13b42 trondeau
42 3f32342f Tom Rondeau
        if taps is not None:
43 3f32342f Tom Rondeau
            self._taps = taps
44 3f32342f Tom Rondeau
        else:
45 3f32342f Tom Rondeau
            # Create a filter that covers the full bandwidth of the input signal
46 3f32342f Tom Rondeau
            bw = 0.4
47 3f32342f Tom Rondeau
            tb = 0.2
48 3f32342f Tom Rondeau
            ripple = 0.1
49 3f32342f Tom Rondeau
            made = False
50 3f32342f Tom Rondeau
            while not made:
51 3f32342f Tom Rondeau
                try:
52 3f32342f Tom Rondeau
                    self._taps = optfir.low_pass(self._interp, self._interp, bw, bw+tb, ripple, atten)
53 3f32342f Tom Rondeau
                    made = True
54 3f32342f Tom Rondeau
                except RuntimeError:
55 3f32342f Tom Rondeau
                    ripple += 0.01
56 3f32342f Tom Rondeau
                    made = False
57 3f32342f Tom Rondeau
                    print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple))
58 3f32342f Tom Rondeau
59 a0d13b42 trondeau
        self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps)
60 a0d13b42 trondeau
61 a0d13b42 trondeau
        self.connect(self, self.pfb)
62 a0d13b42 trondeau
        self.connect(self.pfb, self)
63 a0d13b42 trondeau
        
64 a0d13b42 trondeau
        
65 a0d13b42 trondeau
        
66 a0d13b42 trondeau