File: dsb_tx.py

package info (click to toggle)
gnuradio 3.0.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 17,508 kB
  • ctags: 14,057
  • sloc: cpp: 48,308; python: 22,497; ansic: 11,514; sh: 9,013; asm: 3,202; makefile: 2,555; xml: 1,754; fortran: 927; pascal: 173
file content (51 lines) | stat: -rwxr-xr-x 1,319 bytes parent folder | download
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
#!/usr/bin/env python

from gnuradio import gr, eng_notation
from gnuradio import usrp
from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser


def build_graph (cordic_freq):

    audio_rate = 32000
    sw_interp = 4
    usrp_interp = 1000
    audio_file = "/home/eb/demo/testing-audio.dat"
    
    fg = gr.flow_graph ()

    src = gr.file_source (gr.sizeof_float, audio_file, True)
    gain = gr.multiply_const_ff (10000)

    interp = gr.interp_fir_filter_fff (sw_interp, (1, 1, 1, 1))

    f2c = gr.float_to_complex ()
    
    u = usrp.sink_c (0, usrp_interp)
    u.set_tx_freq (0, cordic_freq)

    fg.connect (src, gain)
    fg.connect (gain, interp)
    fg.connect (interp, (f2c, 0))
    fg.connect (interp, (f2c, 1))
    fg.connect (f2c, u)

    return fg

def main ():
    parser = OptionParser (option_class=eng_option)
    parser.add_option ("-c", "--cordic-freq", type="eng_float", default=10e6,
                       help="set Tx cordic frequency to FREQ", metavar="FREQ")
    (options, args) = parser.parse_args ()

    print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq))
    fg = build_graph (options.cordic_freq)
    
    fg.start ()
    raw_input ('Press Enter to quit: ')
    fg.stop ()

if __name__ == '__main__':
    main ()