summaryrefslogtreecommitdiff
path: root/gr-radar/src/python/fm_demod_file.py
blob: 64ec3b2a28715a19df1a616802abdf09d07611d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
#
# Copyright 2005 Free Software Foundation, Inc.
# 
# This file is part of GNU Radio
# 
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
# 

"""
Demod FM signal in data collected for radar.
Input samples are complex baseband, 250kS/sec.
"""

from gnuradio import gr, gru, blks, eng_notation
from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
import math


class my_graph(gr.flow_graph):
    def __init__(self, input_filename, repeat):
        gr.flow_graph.__init__(self)
        
        baseband_rate = 250e3
        audio_decim = 8
        audio_rate = int(baseband_rate // audio_decim) # output is at 31250 S/s

        src = gr.file_source(gr.sizeof_gr_complex, input_filename, repeat)
        guts = blks.wfm_rcv(self, baseband_rate, audio_decim)  
        sink = audio.sink(audio_rate, "plughw:0,0")
        self.connect(src, guts, sink)

def main ():
    usage = "usage: %prog [options] filename"
    parser = OptionParser (option_class=eng_option, usage=usage)
    parser.add_option ("-r", "--repeat", action="store_true", default=False)
    (options, args) = parser.parse_args ()

    if len (args) != 1:
        parser.print_help ()
        sys.exit (1)

    try:
        my_graph(args[0], options.repeat).run()
    except KeyboardInterrupt:
        pass
    

if __name__ == '__main__':
    main ()