Merge branch 'upstream' into dfsg-orig
[debian/gnuradio] / gr-atsc / src / python / interp_short.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 2, 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 #                   -s output shorts
30 #
31 # All this module does is multiply the sample rate by 3, from 6.4e6 to
32 # 19.2e6 complex samples / sec, then lowpass filter with a cutoff of 3.2MHz
33 # and a transition band width of .5MHz.  Center of the tv channels is
34 # then at 0 with edges at -3.2MHz and 3.2MHz.
35
36 from gnuradio import gr
37 import sys, os
38
39 def graph (args):
40
41     print os.getpid()
42
43     nargs = len (args)
44     if nargs == 1:
45         infile = args[0]
46     else:
47         sys.stderr.write('usage: interp.py input_file\n')
48         sys.exit (1)
49
50     tb = gr.top_block ()
51
52     srcf = gr.file_source (gr.sizeof_short,infile)
53     s2ss = gr.stream_to_streams(gr.sizeof_short,2)
54     s2f1 = gr.short_to_float()
55     s2f2 = gr.short_to_float()
56     src0 = gr.float_to_complex()
57
58
59     lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING )
60     lp = gr.interp_fir_filter_ccf ( 3, lp_coeffs )
61
62     file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")
63
64     tb.connect( srcf, s2ss )
65     tb.connect( (s2ss, 0), s2f1, (src0,0) )
66     tb.connect( (s2ss, 1), s2f2, (src0,1) )
67     tb.connect( src0, lp, file)
68
69     tb.start()
70     raw_input ('Head End: Press Enter to stop')
71     tb.stop()
72
73 if __name__ == '__main__':
74     graph (sys.argv[1:])
75
76