Imported Upstream version 3.0.4
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / blksimpl / am_demod.py
1 #
2 # Copyright 2006 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_block):
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 fg: flowgraph
34     @param channel_rate:  incoming sample rate of the AM baseband
35     @type sample_rate: integer
36     @param audio_decim: input to output decimation rate
37     @type audio_decim: integer
38     @param audio_pass: audio low pass filter passband frequency 
39     @type audio_pass: float
40     @param audio_stop: audio low pass filter stop frequency
41     @type audio_stop: float
42     """ 
43     def __init__(self, fg, channel_rate, audio_decim, audio_pass, audio_stop):
44         MAG = gr.complex_to_mag()
45         DCR = gr.add_const_ff(-1.0)
46
47         audio_taps = optfir.low_pass(0.5,          # Filter gain
48                                      channel_rate, # Sample rate
49                                      audio_pass,   # Audio passband
50                                      audio_stop,   # Audio stopband
51                                      0.1,          # Passband ripple
52                                      60)           # Stopband attenuation
53         LPF = gr.fir_filter_fff(audio_decim, audio_taps)
54
55         fg.connect(MAG, DCR, LPF)
56         gr.hier_block.__init__(self, fg, MAG, LPF)
57
58 class demod_10k0a3e_cf(am_demod_cf):
59     """
60     AM demodulation block, 10 KHz channel.
61     
62     This block demodulates an AM channel conformant to 10K0A3E emission
63     standards, such as broadcast band AM transmissions.
64
65     @param fg: flowgraph
66     @param channel_rate:  incoming sample rate of the AM baseband
67     @type sample_rate: integer
68     @param audio_decim: input to output decimation rate
69     @type audio_decim: integer
70     """
71     def __init__(self, fg, channel_rate, audio_decim):
72         am_demod_cf.__init__(self, fg, channel_rate, audio_decim, 
73                              5000, # Audio passband
74                              5500) # Audio stopband
75