Merge r6461:6464 from jcorgan/t162-staging into trunk.
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / blks2impl / am_demod.py
1 #
2 # Copyright 2006,2007 Free Software Foundation, Inc.
3
4 # This file is part of GNU Radio
5
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
20
21
22 from gnuradio import gr, optfir
23
24 class am_demod_cf(gr.hier_block2):
25     """
26     Generalized AM demodulation block with audio filtering.
27
28     This block demodulates a band-limited, complex down-converted AM 
29     channel into the the original baseband signal, applying low pass 
30     filtering to the audio output. It produces a float stream in the
31     range [-1.0, +1.0].
32
33     @param channel_rate:  incoming sample rate of the AM baseband
34     @type sample_rate: integer
35     @param audio_decim: input to output decimation rate
36     @type audio_decim: integer
37     @param audio_pass: audio low pass filter passband frequency 
38     @type audio_pass: float
39     @param audio_stop: audio low pass filter stop frequency
40     @type audio_stop: float
41     """ 
42     def __init__(self, channel_rate, audio_decim, audio_pass, audio_stop):
43         gr.hier_block2.__init__(self, "am_demod_cf",
44                                 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
45                                 gr.io_signature(1, 1, gr.sizeof_float))      # Input signature
46
47         MAG = gr.complex_to_mag()
48         DCR = gr.add_const_ff(-1.0)
49
50         audio_taps = optfir.low_pass(0.5,          # Filter gain
51                                      channel_rate, # Sample rate
52                                      audio_pass,   # Audio passband
53                                      audio_stop,   # Audio stopband
54                                      0.1,          # Passband ripple
55                                      60)           # Stopband attenuation
56         LPF = gr.fir_filter_fff(audio_decim, audio_taps)
57
58         self.connect(self, MAG, DCR, LPF, self)
59
60 class demod_10k0a3e_cf(am_demod_cf):
61     """
62     AM demodulation block, 10 KHz channel.
63     
64     This block demodulates an AM channel conformant to 10K0A3E emission
65     standards, such as broadcast band AM transmissions.
66
67     @param channel_rate:  incoming sample rate of the AM baseband
68     @type sample_rate: integer
69     @param audio_decim: input to output decimation rate
70     @type audio_decim: integer
71     """
72     def __init__(self, channel_rate, audio_decim):
73         am_demod_cf.__init__(self, channel_rate, audio_decim, 
74                              5000, # Audio passband
75                              5500) # Audio stopband
76