Updated license from GPL version 2 or later to GPL version 3 or later.
[debian/gnuradio] / gr-atsc / src / python / interp.py
1 #!/usr/bin/env /usr/bin/python
2 #
3 # Copyright 2004 Free Software Foundation, Inc.
4
5 # This file is part of GNU Radio
6
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
21
22 # This module starts the atsc processing chain taking the captured
23 # off-air signal created with:
24 #
25 #  usrp_rx_cfile.py -R <side with tuner, a or b>
26 #                   -d 10     set decimation to get signal at 6.4e6 rate
27 #                   -f <center of tv signal channel freq>
28 #                   -g <appropriate gain for best signal / noise>
29
30 # All this module does is multiply the sample rate by 3, from 6.4e6 to
31 # 19.2e6 complex samples / sec, then lowpass filter with a cutoff of 3.2MHz
32 # and a transition band width of .5MHz.  Center of the tv channels is
33 # then at 0 with edges at -3.2MHz and 3.2MHz.
34
35 from gnuradio import gr
36 import sys
37
38 def graph (args):
39
40     nargs = len (args)
41     if nargs == 1:
42         infile = args[0]
43     else:
44         sys.stderr.write('usage: interp.py input_file\n')
45         sys.exit (1)
46
47     sampling_freq = 6400000
48
49     fg = gr.flow_graph ()
50
51     src0 = gr.file_source (gr.sizeof_gr_complex,infile)
52     src1 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)
53     src2 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)
54
55     interlv = gr.interleave(gr.sizeof_gr_complex)
56
57     lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING )
58     lp = gr.fir_filter_ccf ( 1, lp_coeffs )
59
60     file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")
61
62     fg.connect( src0, (interlv, 0) )
63     fg.connect( src1, (interlv, 1) )
64     fg.connect( src2, (interlv, 2) )
65     fg.connect( interlv, lp, file )
66
67     fg.start()
68     raw_input ('Head End: Press Enter to stop')
69     fg.stop()
70
71 if __name__ == '__main__':
72     graph (sys.argv[1:])
73
74