2 # Copyright 2005 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
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)
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.
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.
22 from gnuradio import gr
23 from gnuradio.blksimpl.fm_emph import fm_deemph
26 class wfm_rcv(gr.hier_block):
27 def __init__ (self, fg, quad_rate, audio_decimation):
29 Hierarchical block for demodulating a broadcast FM signal.
31 The input is the downconverted complex baseband signal (gr_complex).
32 The output is the demodulated audio (float).
34 @param 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
44 fm_demod_gain = quad_rate/(2*math.pi*max_dev)
45 audio_rate = quad_rate / audio_decimation
48 # We assign to self so that outsiders can grab the demodulator
49 # if they need to. E.g., to plot its output.
51 # input: complex; output: float
52 self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain)
54 # input: float; output: float
55 self.deemph = fm_deemph (fg, audio_rate)
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)
67 fg.connect (self.fm_demod, self.audio_filter, self.deemph)
69 gr.hier_block.__init__(self,
71 self.fm_demod, # head of the pipeline
72 self.deemph) # tail of the pipeline