2 # Copyright 2006 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 3, 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, optfir
23 from gnuradio.blksimpl.fm_emph import fm_deemph
26 class fm_demod_cf(gr.hier_block):
28 Generalized FM demodulation block with deemphasis and audio
31 This block demodulates a band-limited, complex down-converted FM
32 channel into the the original baseband signal, optionally applying
33 deemphasis. Low pass filtering is done on the resultant signal. It
34 produces an output float strem in the range of [-1.0, +1.0].
37 @param channel_rate: incoming sample rate of the FM baseband
38 @type sample_rate: integer
39 @param deviation: maximum FM deviation (default = 5000)
40 @type deviation: float
41 @param audio_decim: input to output decimation rate
42 @type audio_decim: integer
43 @param audio_pass: audio low pass filter passband frequency
44 @type audio_pass: float
45 @param audio_stop: audio low pass filter stop frequency
46 @type audio_stop: float
47 @param gain: gain applied to audio output (default = 1.0)
49 @param tau: deemphasis time constant (default = 75e-6), specify 'None'
52 def __init__(self, fg, channel_rate, audio_decim, deviation,
53 audio_pass, audio_stop, gain=1.0, tau=75e-6):
56 # Equalizer for ~100 us delay
58 num_taps = int(channel_rate*delay)
61 print "CMA: delay =", delay, "n =", num_taps, "mu =", mu
62 CMA = gr.cma_equalizer_cc(num_taps, 1.0, mu)
64 k = channel_rate/(2*pi*deviation)
65 QUAD = gr.quadrature_demod_cf(k)
67 audio_taps = optfir.low_pass(gain, # Filter gain
68 channel_rate, # Sample rate
69 audio_pass, # Audio passband
70 audio_stop, # Audio stopband
71 0.1, # Passband ripple
72 60) # Stopband attenuation
73 LPF = gr.fir_filter_fff(audio_decim, audio_taps)
76 DEEMPH = fm_deemph(fg, channel_rate, tau)
77 fg.connect(QUAD, DEEMPH, LPF)
81 gr.hier_block.__init__(self, fg, QUAD, LPF)
83 class demod_20k0f3e_cf(fm_demod_cf):
85 NBFM demodulation block, 20 KHz channels
87 This block demodulates a complex, downconverted, narrowband FM
88 channel conforming to 20K0F3E emission standards, outputting
89 floats in the range [-1.0, +1.0].
92 @param sample_rate: incoming sample rate of the FM baseband
93 @type sample_rate: integer
94 @param audio_decim: input to output decimation rate
95 @type audio_decim: integer
97 def __init__(self, fg, channel_rate, audio_decim):
98 fm_demod_cf.__init__(self, fg, channel_rate, audio_decim,
100 3000, # Audio passband frequency
101 4000) # Audio stopband frequency
103 class demod_200kf3e_cf(fm_demod_cf):
105 WFM demodulation block, mono.
107 This block demodulates a complex, downconverted, wideband FM
108 channel conforming to 200KF3E emission standards, outputting
109 floats in the range [-1.0, +1.0].
112 @param sample_rate: incoming sample rate of the FM baseband
113 @type sample_rate: integer
114 @param audio_decim: input to output decimation rate
115 @type audio_decim: integer
117 def __init__(self, fg, channel_rate, audio_decim):
118 fm_demod_cf.__init__(self, fg, channel_rate, audio_decim,
120 15000, # Audio passband
121 16000, # Audio stopband