Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-examples / python / ofdm / fftshift.py
1 #!/usr/bin/env python
2
3 from gnuradio import gr
4
5 class my_top_block(gr.top_block):
6     def __init__(self):
7         gr.top_block.__init__(self)
8
9         length = 101
10
11         data_r = range(length)
12         data_i = range(length,2*length)
13         src_r = gr.vector_source_s(data_r, False)
14         src_i = gr.vector_source_s(data_i, False)
15         s2f_r = gr.short_to_float()
16         s2f_i = gr.short_to_float()
17         f2c = gr.float_to_complex()
18         s2v = gr.stream_to_vector(gr.sizeof_gr_complex, length)
19
20         shift = True
21         ifft = gr.fft_vcc(length, False, [], shift)
22         fft  = gr.fft_vcc(length, True, [], shift)
23         
24         v2s = gr.vector_to_stream(gr.sizeof_gr_complex, length)
25         snk_in = gr.file_sink(gr.sizeof_gr_complex, "fftshift.in")
26         snk_out = gr.file_sink(gr.sizeof_gr_complex, "fftshift.out")
27
28         self.connect(src_r, s2f_r, (f2c,0))
29         self.connect(src_i, s2f_i, (f2c,1))
30         self.connect(f2c, snk_in)
31         self.connect(f2c, s2v, ifft, fft, v2s, snk_out)
32         
33
34 def main():
35     tb = my_top_block()
36     tb.start()
37     tb.wait()
38
39 if __name__ == "__main__":
40     try:
41         main()
42     except KeyboardInterrupt:
43         pass
44