switch source package format to 3.0 quilt
[debian/gnuradio] / usrp2 / host / apps / gen_2tone.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2007 Free Software Foundation, Inc.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18
19 from gnuradio import gr, eng_notation
20 from gnuradio.eng_option import eng_option
21 from optparse import OptionParser
22 import sys
23
24 master_clock = 100e6
25
26 class my_top_block(gr.top_block):
27
28     def __init__(self):
29         gr.top_block.__init__(self)
30
31         parser = OptionParser(option_class=eng_option)
32         parser.add_option("-f", "--freq1", type="eng_float", default=1e6,
33                           help="set waveform frequency to FREQ [default=%default]")
34         parser.add_option("-g", "--freq2", type="eng_float", default=1e6,
35                           help="set waveform frequency to FREQ [default=%default]")
36         parser.add_option ("-a", "--amplitude1", type="eng_float", default=16e3,
37                            help="set waveform amplitude to AMPLITUDE [default=%default]", metavar="AMPL")
38         parser.add_option ("-b", "--amplitude2", type="eng_float", default=16e3,
39                            help="set waveform amplitude to AMPLITUDE [default=%default]", metavar="AMPL")
40
41         parser.add_option("-i", "--interp", type="int", default=32,
42                           help="assume fgpa interpolation rate is INTERP [default=%default]")
43
44         (options, args) = parser.parse_args ()
45         if len(args) != 0:
46             parser.print_help()
47             raise SystemExit, 1
48
49         
50         src0 = gr.sig_source_c(master_clock/options.interp,
51                                gr.GR_SIN_WAVE,
52                                options.freq1,
53                                options.amplitude1)
54         src1 = gr.sig_source_c(master_clock/options.interp,
55                                gr.GR_SIN_WAVE,
56                                options.freq2,
57                                options.amplitude2)
58
59         adder = gr.add_cc()
60
61         
62         c2s = gr.complex_to_interleaved_short()
63
64         stdout_sink = gr.file_descriptor_sink(gr.sizeof_short, 1)
65
66         self.connect(src0, (adder,0))
67         self.connect(src1, (adder,1))
68         self.connect(adder, c2s, stdout_sink)
69
70         
71 if __name__ == '__main__':
72     try:
73         my_top_block().run()
74     except KeyboardInterrupt:
75         pass