Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / blksimpl / wfm_rcv.py
1 #
2 # Copyright 2005 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 2, 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
23 from gnuradio.blksimpl.fm_emph import fm_deemph
24 import math
25
26 class wfm_rcv(gr.hier_block):
27     def __init__ (self, fg, quad_rate, audio_decimation):
28         """
29         Hierarchical block for demodulating a broadcast FM signal.
30         
31         The input is the downconverted complex baseband signal (gr_complex).
32         The output is the demodulated audio (float).
33         
34         @param fg: flow graph.
35         @type fg: flow graph
36         @param quad_rate: input sample rate of complex baseband input.
37         @type quad_rate: float
38         @param audio_decimation: how much to decimate quad_rate to get to audio.
39         @type audio_decimation: integer
40         """
41         volume = 20.
42
43         max_dev = 75e3
44         fm_demod_gain = quad_rate/(2*math.pi*max_dev)
45         audio_rate = quad_rate / audio_decimation
46         
47
48         # We assign to self so that outsiders can grab the demodulator 
49         # if they need to.  E.g., to plot its output.
50         #
51         # input: complex; output: float
52         self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain)
53
54         # input: float; output: float
55         self.deemph = fm_deemph (fg, audio_rate)
56         
57         # compute FIR filter taps for audio filter
58         width_of_transition_band = audio_rate / 32
59         audio_coeffs = gr.firdes.low_pass (1.0,         # gain
60                                            quad_rate,      # sampling rate
61                                            audio_rate/2 - width_of_transition_band,
62                                            width_of_transition_band,
63                                            gr.firdes.WIN_HAMMING)
64         # input: float; output: float
65         self.audio_filter = gr.fir_filter_fff (audio_decimation, audio_coeffs)
66
67         fg.connect (self.fm_demod, self.audio_filter, self.deemph)
68
69         gr.hier_block.__init__(self,
70                                fg,
71                                self.fm_demod,       # head of the pipeline
72                                self.deemph)   # tail of the pipeline